Skip to content

Commit 6277fbc

Browse files
committed
Add a distinct corrector for Roman
1 parent 369531b commit 6277fbc

4 files changed

Lines changed: 41 additions & 13 deletions

File tree

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Release Notes
77
.. 0.8.13 (unreleased)
88
===================
99
10+
0.9.0 (06-Mar-2026)
11+
====================
12+
13+
- Added ``RomanWCSCorrector`` class to support Roman WCS. [#243]
14+
15+
1016
0.8.12 (08-Oct-2025)
1117
====================
1218

tweakwcs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
from .correctors import (WCSCorrector, JWSTWCSCorrector, # noqa: F401
21-
FITSWCSCorrector, # noqa: F401
21+
RomanWCSCorrector, FITSWCSCorrector, # noqa: F401
2222
TPWCS, JWSTgWCS, FITSWCS) # noqa: F401
2323
from .matchutils import MatchCatalogs, XYXYMatch, TPMatch # noqa: F401
2424
from .imalign import fit_wcs, align_wcs # noqa: F401

tweakwcs/correctors.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727

2828
__author__ = 'Mihai Cara'
2929

30-
__all__ = ['WCSCorrector', 'JWSTWCSCorrector', 'FITSWCSCorrector']
30+
__all__ = [
31+
'FITSWCSCorrector',
32+
'JWSTWCSCorrector',
33+
'RomanWCSCorrector',
34+
'WCSCorrector',
35+
]
3136

3237
log = logging.getLogger(__name__)
3338
log.setLevel(logging.DEBUG)
@@ -565,6 +570,7 @@ class JWSTWCSCorrector(WCSCorrector):
565570
566571
"""
567572
units = 'arcsec'
573+
corrector_name = 'JWST tangent-plane linear correction. v1'
568574

569575
def __init__(self, wcs, wcsinfo, meta=None):
570576
"""
@@ -642,18 +648,19 @@ def __init__(self, wcs, wcsinfo, meta=None):
642648
self._default_tpcorr = JWSTWCSCorrector._tpcorr_init(
643649
v2_ref=v2_ref / 3600.0,
644650
v3_ref=v3_ref / 3600.0,
645-
roll_ref=roll_ref
651+
roll_ref=roll_ref,
652+
corrector_name=self.corrector_name
646653
)
647654
self._partial_tpcorr = JWSTWCSCorrector._v2v3_to_tpcorr_from_full(
648655
self._default_tpcorr
649656
)
650657

651658
self._update_transformations()
652659

653-
@staticmethod
654-
def _check_tpcorr_structure(tpcorr):
660+
@classmethod
661+
def _check_tpcorr_structure(cls, tpcorr):
655662
# implement a more sophisticated check later
656-
if tpcorr.name != 'JWST tangent-plane linear correction. v1':
663+
if tpcorr.name != cls.corrector_name:
657664
return False
658665
return True
659666

@@ -694,7 +701,7 @@ def _tpcorr_combine_affines(tpcorr, matrix, shift):
694701
tpcorr.inverse['tp_affine_inv'].translation = -np.dot(invm, t)
695702

696703
@staticmethod
697-
def _tpcorr_init(v2_ref, v3_ref, roll_ref):
704+
def _tpcorr_init(v2_ref, v3_ref, roll_ref, corrector_name="Unnamed"):
698705
s2c = SphericalToCartesian(name='s2c', wrap_lon_at=180)
699706
c2s = CartesianToSpherical(name='c2s', wrap_lon_at=180)
700707

@@ -730,13 +737,13 @@ def _tpcorr_init(v2_ref, v3_ref, roll_ref):
730737
unit_conv | s2c | rot | c2tan | affine |
731738
tan2c | rot_inv | c2s | unit_conv_inv
732739
)
733-
total_corr.name = 'JWST tangent-plane linear correction. v1'
740+
total_corr.name = corrector_name
734741

735742
inv_total_corr = (
736743
unit_conv | s2c | rot | c2tan | affine_inv |
737744
tan2c | rot_inv | c2s | unit_conv_inv
738745
)
739-
inv_total_corr.name = 'Inverse JWST tangent-plane linear correction. v1'
746+
inv_total_corr.name = f'Inverse {corrector_name}'
740747

741748
# TODO
742749
# re-enable circular inverse definitions once
@@ -859,7 +866,8 @@ def set_correction(self, matrix=[[1, 0], [0, 1]], shift=[0, 0],
859866
self._tpcorr = JWSTWCSCorrector._tpcorr_init(
860867
v2_ref=self._wcsinfo['v2_ref'] / 3600.0,
861868
v3_ref=self._wcsinfo['v3_ref'] / 3600.0,
862-
roll_ref=self._wcsinfo['roll_ref']
869+
roll_ref=self._wcsinfo['roll_ref'],
870+
corrector_name=self.corrector_name
863871
)
864872

865873
JWSTWCSCorrector._tpcorr_combine_affines(
@@ -1043,6 +1051,17 @@ def bounding_box(self):
10431051
return self._owcs.pixel_bounds
10441052

10451053

1054+
class RomanWCSCorrector(JWSTWCSCorrector):
1055+
""" A class for holding ``Roman`` ``GWCS`` information and for managing
1056+
tangent-plane corrections. The units of the tangent plane of this
1057+
corrector are ``arcsec`` and the axes are not along parallel to the
1058+
axes of the detector's coordinate system.
1059+
1060+
"""
1061+
units = 'arcsec'
1062+
corrector_name = 'Roman tangent-plane linear correction. v1'
1063+
1064+
10461065
@deprecated(since='0.8.0', alternative='WCSCorrector')
10471066
class TPWCS(WCSCorrector):
10481067
pass

tweakwcs/tests/test_multichip_jwst.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
import numpy as np
24
from astropy.io import fits
35
from astropy import table
@@ -125,10 +127,11 @@ def _match(x, y, tp_pscale, tp_units, **kwargs):
125127
return match
126128

127129

128-
def test_multichip_jwst_alignment():
130+
@pytest.mark.parametrize('corrector_cls', ['JWSTWCSCorrector', 'RomanWCSCorrector'])
131+
def test_multichip_jwst_alignment(corrector_cls):
129132
w1 = _make_gwcs_wcs('data/wfc3_uvis1.hdr')
130133

131-
imcat1 = tweakwcs.JWSTWCSCorrector(w1, {'v2_ref': 0, 'v3_ref': 0, 'roll_ref': 0})
134+
imcat1 = getattr(tweakwcs, corrector_cls)(w1, {'v2_ref': 0, 'v3_ref': 0, 'roll_ref': 0})
132135
imcat1.meta['catalog'] = table.Table.read(
133136
get_pkg_data_filename('data/wfc3_uvis1.cat'),
134137
format='ascii.csv',
@@ -141,7 +144,7 @@ def test_multichip_jwst_alignment():
141144
imcat1.meta['name'] = 'ext1'
142145

143146
w2 = _make_gwcs_wcs('data/wfc3_uvis2.hdr')
144-
imcat2 = tweakwcs.JWSTWCSCorrector(w2, {'v2_ref': 0, 'v3_ref': 0, 'roll_ref': 0})
147+
imcat2 = getattr(tweakwcs, corrector_cls)(w2, {'v2_ref': 0, 'v3_ref': 0, 'roll_ref': 0})
145148
imcat2.meta['catalog'] = table.Table.read(
146149
get_pkg_data_filename('data/wfc3_uvis2.cat'),
147150
format='ascii.csv',

0 commit comments

Comments
 (0)