Skip to content

Commit

Permalink
Fix inverse preservation on yaml export and some tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarDrew committed Mar 18, 2024
1 parent 4cccec4 commit 40a168a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
20 changes: 2 additions & 18 deletions dkist/io/asdf/converters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,9 @@ class VaryingCelestialConverter(TransformConverterBase):
]

def select_tag(self, obj, tags, ctx):
from dkist.wcs.models import (InverseVaryingCelestialTransform,
InverseVaryingCelestialTransform2D,
InverseVaryingCelestialTransform3D,
VaryingCelestialTransform, VaryingCelestialTransform2D,
VaryingCelestialTransform3D)

if isinstance(
obj,
(VaryingCelestialTransform,
VaryingCelestialTransform2D,
VaryingCelestialTransform3D)
):
if not obj.is_inverse:
return "asdf://dkist.nso.edu/tags/varying_celestial_transform-1.1.0"
elif isinstance(
obj,
(InverseVaryingCelestialTransform,
InverseVaryingCelestialTransform2D,
InverseVaryingCelestialTransform3D)
):
elif obj.is_inverse:
return "asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-1.1.0"
else:
raise ValueError(f"Unsupported object: {obj}") # pragma: no cover
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_roundtrip_vct_2d():
new_vct = roundtrip_object(vct)
assert isinstance(new_vct, VaryingCelestialTransform2D)
new_ivct = roundtrip_object(vct.inverse)
assert isinstance(new_ivct, InverseVaryingCelestialTransform2D)
assert isinstance(new_ivct, VaryingCelestialTransform2D)

assert u.allclose(u.Quantity(new_vct.crpix), (5, 5) * u.pix)
assert u.allclose(u.Quantity(new_ivct.crpix), (5, 5) * u.pix)
Expand Down
1 change: 1 addition & 0 deletions dkist/wcs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ def varying_celestial_transform_from_tables(
pc_table=pc_table,
lon_pole=lon_pole,
projection=projection,
inverse=inverse
)

# For slit models we duplicate one of the spatial pixel inputs to also be
Expand Down

0 comments on commit 40a168a

Please sign in to comment.