def test_returns_set_of_headers_from_aperture_effects(self):
        apm = eo._img_aperture_mask(array_dict={
            "x": [-1.28, 1., 1., -1.28],
            "y": [-1.28, -1.28, 2., 2.]
        })
        kwargs = {
            "pixel_scale": 0.01,
            "plate_scale": 1,
            "max_segment_size": 128**2,
            "chunk_size": 64
        }
        hdrs = fm_utils.get_imaging_headers([apm], **kwargs)

        area_sum = np.sum([hdr["NAXIS1"] * hdr["NAXIS2"] for hdr in hdrs])
        assert area_sum == 228 * 328
    def test_returns_fov_objects_for_basic_input(self):
        apm = eo._img_aperture_mask(array_dict={
            "x": [-1.0, 1.0, 1.0, -1.0],
            "y": [-1.0, -1.0, 1.0, 1.0]
        })
        kwargs = {
            "pixel_scale": 0.01,
            "plate_scale": 1,
            "max_segment_size": 100**2,
            "chunk_size": 100
        }

        hdrs = fm_utils.get_imaging_headers([apm], **kwargs)
        waveset = np.linspace(1, 2, 6)
        shifts = {
            "wavelengths": np.array([1, 2]),
            "x_shifts": np.zeros(2),
            "y_shifts": np.array([0, 1]) / 3600
        }  # 0..1 arcsec shift
        fovs = fm_utils.get_imaging_fovs(headers=hdrs,
                                         waveset=waveset,
                                         shifts=shifts)

        assert len(fovs) == (len(waveset) - 1) * len(hdrs)

        if PLOTS:
            from scopesim.optics.image_plane_utils import calc_footprint
            plt.subplot(121)
            for fov in fovs:
                x, y = calc_footprint(fov.hdu.header)
                plt.fill(x * 3600, y * 3600, alpha=0.1, c="b")
                plt.title("Sky plane")
                plt.xlabel("[arcsec]")

            plt.subplot(122)
            for fov in fovs:
                x, y = calc_footprint(fov.hdu.header, "D")
                plt.fill(x, y)
                plt.title("Detector focal plane")
                plt.xlabel("[mm]")

            plt.show()
 def test_throws_error_if_not_all_keywords_are_passed(self):
     apm = eo._img_aperture_mask()
     with pytest.raises(ValueError):
         fm_utils.get_imaging_headers([apm])