def convert_angle_to_length(hmi_map, angle_or_length, working_units=u.meter):
"""
Helper for easily converting between angle and length units. If converting to length, returned
units will be `~astropy.units.cm`. If converting to angle, the returned units will be
`~astropy.units.arcsec`.
"""
observed_distance = (hmi_map.dsun - hmi_map.rsun_meters)
radian_length = [(u.radian, u.meter, lambda x: observed_distance*x, lambda x: x/observed_distance)]
converted = solarbextrapolation.utilities.decompose_ang_len(angle_or_length,
working_units=working_units,
equivalencies=radian_length)
if working_units == u.meter:
return converted.to(u.cm)
else:
return converted.to(u.arcsec)
评论列表
文章目录