Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# compute linear transformation from the tangent plane used for
# alignment to the tangent plane of this wcs:
r, t = _tp2tp(ref_tpwcs, self)
matrix = np.linalg.multi_dot([r, matrix, inv(r)]).astype(np.double)
shift = (np.dot(r, shift) - np.dot(matrix, t) + t).astype(np.double)
# if original WCS did not have tangent-plane corrections, create
# new correction and add it to the WCs pipeline:
if self._tpcorr is None:
self._tpcorr = JWSTgWCS._tpcorr_init(
v2_ref=self._wcsinfo['v2_ref'] / 3600.0,
v3_ref=self._wcsinfo['v3_ref'] / 3600.0,
roll_ref=self._wcsinfo['roll_ref']
)
JWSTgWCS._tpcorr_combine_affines(
self._tpcorr,
matrix,
_ARCSEC2RAD * np.asarray(shift)
)
self._partial_tpcorr = JWSTgWCS._v2v3_to_tpcorr_from_full(self._tpcorr)
idx_v2v3 = frms.index(self._v23name)
pipeline = deepcopy(self._wcs.pipeline)
pf, pt = pipeline[idx_v2v3]
pipeline[idx_v2v3] = (pf, deepcopy(self._tpcorr))
frm_v2v3corr = deepcopy(pf)
frm_v2v3corr.name = 'v2v3corr'
pipeline.insert(idx_v2v3 + 1, (frm_v2v3corr, pt))
self._wcs = gwcs.WCS(pipeline, name=self._owcs.name)
self._v23name = 'v2v3corr'