| 1 |
from asdf_astropy.converters.unit.quantity import QuantityConverter |
| 2 |
|
| 3 |
|
| 4 |
class AngleConverter(QuantityConverter): |
| 5 |
tags = ("tag:astropy.org:astropy/coordinates/angle-*",) |
| 6 |
types = ( |
| 7 |
"astropy.coordinates.angles.Angle", |
| 8 |
"astropy.coordinates.angles.core.Angle", |
| 9 |
"astropy.utils.masked.core.MaskedAngle", |
| 10 |
) |
| 11 |
|
| 12 |
def from_yaml_tree(self, node, tag, ctx): |
| 13 |
from astropy.coordinates.angles import Angle |
| 14 |
|
| 15 |
return Angle(super().from_yaml_tree(node, tag, ctx)) |
| 16 |
|
| 17 |
|
| 18 |
class LatitudeConverter(QuantityConverter): |
| 19 |
tags = ("tag:astropy.org:astropy/coordinates/latitude-*",) |
| 20 |
types = ( |
| 21 |
"astropy.coordinates.angles.Latitude", |
| 22 |
"astropy.coordinates.angles.core.Latitude", |
| 23 |
"astropy.utils.masked.core.MaskedLatitude", |
| 24 |
) |
| 25 |
|
| 26 |
def from_yaml_tree(self, node, tag, ctx): |
| 27 |
from astropy.coordinates.angles import Latitude |
| 28 |
|
| 29 |
return Latitude(super().from_yaml_tree(node, tag, ctx)) |
| 30 |
|
| 31 |
|
| 32 |
class LongitudeConverter(QuantityConverter): |
| 33 |
tags = ("tag:astropy.org:astropy/coordinates/longitude-*",) |
| 34 |
types = ( |
| 35 |
"astropy.coordinates.angles.Longitude", |
| 36 |
"astropy.coordinates.angles.core.Longitude", |
| 37 |
"astropy.utils.masked.core.MaskedLongitude", |
| 38 |
) |
| 39 |
|
| 40 |
def to_yaml_tree(self, obj, tag, ctx): |
| 41 |
tree = super().to_yaml_tree(obj, tag, ctx) |
| 42 |
tree["wrap_angle"] = obj.wrap_angle |
| 43 |
return tree |
| 44 |
|
| 45 |
def from_yaml_tree(self, node, tag, ctx): |
| 46 |
from astropy.coordinates.angles import Longitude |
| 47 |
|
| 48 |
return Longitude(super().from_yaml_tree(node, tag, ctx), wrap_angle=node["wrap_angle"]) |