def test_override(attribute, expected): """Test overriding of Transforms attributes""" overrides = stp.Transforms(m_eci2j='overridden') to_override = stp.Transforms(m_eci2j='original', m_j2fgs1='untouched', override=overrides) assert getattr(to_override, attribute) == expected
def test_override_calc_wcs(): """Test matrix override in the full calculation""" t_pars = make_t_pars() t_pars.method = stp.Methods.OPS_TR_202111 wcsinfo, vinfo, _ = stp.calc_wcs(t_pars) override = stp.Transforms( m_eci2j=np.array([[0.80583682, 0.51339893, 0.29503999], [-0.56953229, 0.8083677, 0.14891175], [-0.16204967, -0.28803339, 0.94380971]])) t_pars.override_transforms = override wcsinfo_new, vinfo_new, transforms_new = stp.calc_wcs(t_pars) assert vinfo_new != vinfo assert all( np.isclose( vinfo_new, stp.WCSRef(ra=32.50407337171124, dec=17.161233048951043, pa=352.28553015159287)))
def test_transform_serialize(calc_transforms, tmp_path): """Test serialization of Transforms""" transforms, t_pars = calc_transforms path = tmp_path / 'transforms.asdf' transforms.write_to_asdf(path) from_asdf = stp.Transforms.from_asdf(path) assert isinstance(from_asdf, stp.Transforms) assert str(transforms) == str(from_asdf) @pytest.mark.parametrize('matrix', [matrix for matrix in stp.Transforms()._fields]) def test_methods(calc_transforms, matrix): """Ensure expected calculate of the specified matrix Parameters ---------- transforms, t_pars : Transforms, TransformParameters The transforms and the parameters used to generate the transforms matrix : str The matrix to compare """ _test_methods(calc_transforms, matrix) def test_coarse_202111_fgsid(calc_coarse_202111_fgsid):