11from copy import deepcopy
22
33from astropy .modeling .rotations import RotationSequence3D
4+ from astropy import units
45from gwcs .wcs import WCS
56import numpy as np
67from tweakwcs .correctors import JWSTWCSCorrector
1415_RAD2ARCSEC = 3600.0 * np .rad2deg (1.0 )
1516
1617
18+ __all__ = ["adjust_wcs" , "transfer_wcs_correction" ]
19+
20+
1721def _wcsinfo_from_wcs_transform (wcs ):
1822 frames = wcs .available_frames
1923 if 'v2v3' not in frames or 'world' not in frames or frames [- 1 ] != 'world' :
@@ -70,17 +74,17 @@ def adjust_wcs(wcs, delta_ra=0.0, delta_dec=0.0, delta_roll=0.0,
7074 WCS object to be adjusted. Must be an imaging JWST WCS of a calibrated
7175 data model.
7276
73- delta_ra : float, optional
74- Additional rotation (in degrees) to be applied along the longitude
75- direction.
77+ delta_ra : float, astropy.units.Quantity, optional
78+ Additional rotation (in degrees if units not provided ) to be applied
79+ along the longitude direction.
7680
77- delta_dec : float, optional
78- Additional rotation (in degrees) to be applied along the latitude
79- direction.
81+ delta_dec : float, astropy.units.Quantity, optional
82+ Additional rotation (in degrees if units not provided ) to be applied
83+ along the latitude direction.
8084
81- delta_roll : float, optional
82- Additional rotation (in degrees) to be applied to the telescope roll
83- angle (rotation about V1 axis).
85+ delta_roll : float, astropy.units.Quantity, optional
86+ Additional rotation (in degrees if units not provided) to be applied
87+ to the telescope roll angle (rotation about V1 axis).
8488
8589 scale_factor : float, optional
8690 A multiplicative scale factor to be applied to the current scale
@@ -94,6 +98,16 @@ def adjust_wcs(wcs, delta_ra=0.0, delta_dec=0.0, delta_roll=0.0,
9498 wcs : `gwcs.WCS`
9599 Adjusted WCS object.
96100 """
101+ # convert input angles to degrees:
102+ u_deg = units .Unit ('deg' )
103+
104+ if isinstance (delta_ra , units .Quantity ):
105+ delta_ra = delta_ra .to (u_deg ).value
106+ if isinstance (delta_dec , units .Quantity ):
107+ delta_dec = delta_dec .to (u_deg ).value
108+ if isinstance (delta_roll , units .Quantity ):
109+ delta_roll = delta_roll .to (u_deg ).value
110+
97111 # find the last frame in the pipeline that starts with 'v2v3':
98112 pipeline = deepcopy (wcs .pipeline )
99113 for step in pipeline [::- 1 ]:
0 commit comments