From c453bfffa22b094f2f1d8fe029e59aceec8741ab Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 12 Oct 2023 15:04:34 -0400 Subject: [PATCH 1/2] add pixel_shape to WCS converter --- gwcs/converters/tests/test_wcs.py | 4 ++++ gwcs/converters/wcs.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gwcs/converters/tests/test_wcs.py b/gwcs/converters/tests/test_wcs.py index d8738864..fa38035a 100644 --- a/gwcs/converters/tests/test_wcs.py +++ b/gwcs/converters/tests/test_wcs.py @@ -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) @@ -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): diff --git a/gwcs/converters/wcs.py b/gwcs/converters/wcs.py index c806df6d..a2f40b3f 100644 --- a/gwcs/converters/wcs.py +++ b/gwcs/converters/wcs.py @@ -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, } From 2adb0c309e2e345203a95b51a338a77a6256faab Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 12 Oct 2023 15:40:36 -0400 Subject: [PATCH 2/2] update changelog --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 0582181c..df5449fa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) -------------------