Skip to content

Commit

Permalink
add WCS to L2 and L3 models (#302)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
nden and pre-commit-ci[bot] authored Jan 22, 2024
1 parent 3b242ed commit 2706ac1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- Bugfix for ``meta.model_type`` not being set to match the model writing the file. [#296]

- Add ``meta.wcs`` to ``maker_utils``. [#302]

0.18.0 (2023-11-06)
===================

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ dependencies = [
'psutil >=5.7.2',
'numpy >=1.22',
'astropy >=5.3.0',
'rad >=0.18.0',
# 'rad @ git+https://github.com/spacetelescope/rad.git',
#'rad >=0.18.0',
'rad @ git+https://github.com/spacetelescope/rad.git',
'asdf-standard >=1.0.3',
]
dynamic = ['version']
Expand Down
5 changes: 5 additions & 0 deletions src/roman_datamodels/maker_utils/_datamodels.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import warnings

import gwcs
import numpy as np
from astropy import units as u

Expand Down Expand Up @@ -136,6 +137,8 @@ def mk_level2_image(*, shape=(4088, 4088), n_groups=8, filepath=None, **kwargs):
)
wfi_image["cal_logs"] = mk_cal_logs(**kwargs)

wfi_image["meta"]["wcs"] = gwcs.WCS(output_frame="icrs")

return save_node(wfi_image, filepath=filepath)


Expand Down Expand Up @@ -189,6 +192,8 @@ def mk_level3_mosaic(*, shape=(4088, 4088), n_images=2, filepath=None, **kwargs)
)
wfi_mosaic["cal_logs"] = mk_cal_logs(**kwargs)

wfi_mosaic["meta"]["wcs"] = gwcs.WCS(output_frame="icrs")

return save_node(wfi_mosaic, filepath=filepath)


Expand Down
3 changes: 3 additions & 0 deletions src/roman_datamodels/testing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gwcs
import numpy as np
from asdf.tags.core import NDArrayType
from astropy.modeling import Model
Expand Down Expand Up @@ -56,6 +57,8 @@ def _assert_value_equal(value1, value2):
assert_array_equal(value1, value2)
elif isinstance(value1, Model):
assert_model_equal(value1, value2)
elif isinstance(value1, gwcs.WCS):
return True
else:
assert value1 == value2

Expand Down
4 changes: 4 additions & 0 deletions tests/test_maker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import mock

import asdf
import gwcs
import pytest
from astropy import units as u
from astropy.time import Time
Expand Down Expand Up @@ -147,6 +148,9 @@ def mutate_value(value):
if isinstance(value, Time):
return value + 1 * u.day

if isinstance(value, gwcs.WCS):
return gwcs.WCS(output_frame="fk5")

if isinstance(value, stnode.TaggedScalarNode):
return value.__class__(mutate_value(value.__class__.__bases__[0](value)))

Expand Down

0 comments on commit 2706ac1

Please sign in to comment.