def test_reorients_a_3D_imagehdu(self, angle): hdu0 = imo._image_hdu_rect() hdu0.data = hdu0.data[None, :, :] * np.ones(5)[:, None, None] angle *= np.pi / 180 pc_matrix = { "PC1_1": np.cos(angle), "PC1_2": np.sin(angle), "PC2_1": -np.sin(angle), "PC2_2": np.cos(angle) } hdu0.header.update(pc_matrix) hdu1 = imp_utils.reorient_imagehdu(deepcopy(hdu0)) hdr0 = hdu0.header hdr1 = hdu1.header new_x = hdr0["NAXIS1"] * np.cos(abs(angle)) + \ hdr0["NAXIS2"] * np.sin(abs(angle)) new_y = hdr0["NAXIS1"] * np.sin(abs(angle)) + \ hdr0["NAXIS2"] * np.cos(abs(angle)) if PLOTS: plt.subplot(121) plt.imshow(hdu0.data[2, :, :], origin="lower") plt.subplot(122) plt.imshow(hdu1.data[2, :, :], origin="lower") plt.show() assert hdr1["NAXIS1"] == np.ceil(new_x) assert hdr1["NAXIS2"] == np.ceil(new_y)
def test_rescales_a_2D_imagehdu(self, scale_factor): hdu0 = imo._image_hdu_rect() hdu1 = imp_utils.rescale_imagehdu(deepcopy(hdu0), scale_factor / 3600) hdr0 = hdu0.header hdr1 = hdu1.header assert hdr1["NAXIS1"] == np.ceil(hdr0["NAXIS1"] / scale_factor) assert hdr1["NAXIS2"] == np.ceil(hdr0["NAXIS2"] / scale_factor)
def test_rescales_a_3D_imagehdu(self, scale_factor): hdu0 = imo._image_hdu_rect() hdu0.data = hdu0.data[None, :, :] * np.ones(5)[:, None, None] hdu1 = imp_utils.rescale_imagehdu(deepcopy(hdu0), scale_factor / 3600) hdr0 = hdu0.header hdr1 = hdu1.header assert np.sum(hdu0.data) == approx(np.sum(hdu1.data)) assert hdr1["NAXIS1"] == np.ceil(hdr0["NAXIS1"] / scale_factor) assert hdr1["NAXIS2"] == np.ceil(hdr0["NAXIS2"] / scale_factor) assert hdr1["NAXIS3"] == hdr0["NAXIS3"]
def image_hdu_rect_mm(): return _image_hdu_rect("D")
def image_hdu_rect(): return _image_hdu_rect()