Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pixel_shape to WCS converter #480

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ other

- Replace ``pkg_resources`` with ``importlib.metadata``. [#478]

- Serialize and deserialize ``pixel_shape`` with asdf. [#480]

0.19.0 (2023-09-15)
-------------------

Expand Down
4 changes: 4 additions & 0 deletions gwcs/converters/tests/test_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def assert_frame_roundtrip(frame, tmpdir, version=None):

def _assert_wcs_equal(a, b):
assert a.name == b.name # nosec
assert a.pixel_shape == b.pixel_shape
assert len(a.available_frames) == len(b.available_frames) # nosec
for a_step, b_step in zip(a.pipeline, b.pipeline):
_assert_frame_equal(a_step.frame, b_step.frame)
Expand All @@ -75,10 +76,13 @@ def test_create_wcs(tmpdir):
gw1 = wcs.WCS(output_frame='icrs', input_frame='detector', forward_transform=m1)
gw2 = wcs.WCS(output_frame='icrs', forward_transform=m1)
gw3 = wcs.WCS(output_frame=icrs, input_frame=det, forward_transform=m1)
gw4 = wcs.WCS(output_frame=icrs, input_frame=det, forward_transform=m1)
gw4.pixel_shape = (100, 200)

assert_wcs_roundtrip(gw1, tmpdir)
assert_wcs_roundtrip(gw2, tmpdir)
assert_wcs_roundtrip(gw3, tmpdir)
assert_wcs_roundtrip(gw4, tmpdir)


def test_composite_frame(tmpdir):
Expand Down
8 changes: 6 additions & 2 deletions gwcs/converters/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ class WCSConverter(Converter):

def from_yaml_tree(self, node, tag, ctx):
from ..wcs import WCS
return WCS(node['steps'], name=node['name'])
gwcsobj = WCS(node['steps'], name=node['name'])
if 'pixel_shape' in node:
gwcsobj.pixel_shape = node['pixel_shape']
return gwcsobj

def to_yaml_tree(self, gwcsobj, tag, ctx):
return {
'name': gwcsobj.name,
'steps': gwcsobj.pipeline
'steps': gwcsobj.pipeline,
'pixel_shape': gwcsobj.pixel_shape,
}


Expand Down
Loading