def setup_class(self): ID = 'AZP' wcs_map = os.path.join(MAPS_DIR, f"1904-66_{ID}.hdr") test_file = get_pkg_data_filename(wcs_map) header = fits.Header.fromfile(test_file, endcard=False, padding=False) self.wazp = wcs.WCS(header) self.wazp.wcs.crpix = np.array([0., 0.]) self.wazp.wcs.crval = np.array([0., 0.]) self.wazp.wcs.cdelt = np.array([1., 1.]) self.pv_kw = [kw[2] for kw in self.wazp.wcs.get_pv()] self.azp = projections.Pix2Sky_ZenithalPerspective(*self.pv_kw)
def test_Pix2Sky_ZenithalPerspective_inverse(): model = projections.Pix2Sky_ZenithalPerspective(2, 30) inverse = model.inverse assert isinstance(inverse, projections.Sky2Pix_ZenithalPerspective) assert inverse.mu == model.mu == 2 assert_allclose(inverse.gamma, model.gamma) assert_allclose(inverse.gamma, 30) x = np.linspace(0, 1, 100) y = np.linspace(0, 1, 100) a, b = model(*inverse(x, y)) assert_allclose(a, x, atol=1e-12) assert_allclose(b, y, atol=1e-12) a, b = inverse(*model(x, y)) assert_allclose(a, x, atol=1e-12) assert_allclose(b, y, atol=1e-12)
def test_validate(self): message = "Zenithal perspective projection is not defined for mu = -1" with pytest.raises(InputParameterError) as err: projections.Pix2Sky_ZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Sky2Pix_ZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Pix2Sky_SlantZenithalPerspective(-1) assert str(err.value) == message with pytest.raises(InputParameterError) as err: projections.Sky2Pix_SlantZenithalPerspective(-1) assert str(err.value) == message