Exemplo n.º 1
0
 def test_creates_single_combined_from_multiple_images(
         self, image_source, basic_fov_header):
     src = image_source + image_source
     the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                               area=1 * u.m**2)
     the_fov.extract_from(src)
     assert len(the_fov.fields) == 1
     assert isinstance(the_fov.fields[0], fits.ImageHDU)
Exemplo n.º 2
0
    def test_ignores_fields_outside_fov_boundary(self, basic_fov_header):

        src = _combined_source(dx=[200, 200, 200])
        src.fields[0]["x"] += 200

        the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                                  area=1 * u.m**2)
        the_fov.extract_from(src)

        assert len(the_fov.fields) == 0
Exemplo n.º 3
0
 def test_creates_two_fields_for_tables_and_images(self, basic_fov_header,
                                                   image_source,
                                                   table_source):
     src = image_source + table_source
     the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                               area=1 * u.m**2)
     the_fov.extract_from(src)
     assert len(the_fov.fields) == 2
     assert isinstance(the_fov.fields[0], Table)
     assert isinstance(the_fov.fields[1], fits.ImageHDU)
Exemplo n.º 4
0
    def test_views_with_only_table(self, basic_fov_header):
        src = _table_source()
        fluxes = src.photons_in_range(1 * u.um, 2 * u.um)
        phs = fluxes[src.fields[0]["ref"]] * src.fields[0]["weight"]

        the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                                  area=1 * u.m**2)
        the_fov.extract_from(src)
        view = the_fov.view()

        assert np.sum(view) == np.sum(phs).value - 4

        if PLOTS:
            plt.imshow(view.T, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()
Exemplo n.º 5
0
    def test_views_with_rotated_image(self, basic_fov_header):
        src = _image_source(angle=30)
        flux = src.photons_in_range(1 * u.um, 2 * u.um).value
        orig_sum = np.sum(src.fields[0].data) * flux

        the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                                  area=1 * u.m**2)
        the_fov.extract_from(src)
        view = the_fov.view()

        assert np.isclose(np.sum(view), orig_sum, rtol=1e-3)

        if PLOTS:
            plt.imshow(src.fields[0].data, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()

            plt.imshow(view, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()
Exemplo n.º 6
0
    def test_views_with_only_image(self, basic_fov_header):
        src = _image_source()
        flux = src.photons_in_range(1 * u.um, 2 * u.um).value
        orig_sum = np.sum(src.fields[0].data * flux)

        the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                                  area=1 * u.m**2)
        the_fov.extract_from(src)
        the_fov.view()

        assert np.isclose(np.sum(the_fov.hdu.data), orig_sum)

        if PLOTS:
            plt.imshow(src.fields[0].data, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()

            plt.imshow(the_fov.hdu.data, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()
Exemplo n.º 7
0
    def test_views_with_tables_and_images(self, basic_fov_header):
        src = _combined_source(im_angle=0,
                               weight=[1, 1, 1],
                               dx=[-2, 0, 0],
                               dy=[2, 2, 0])
        ii = src.fields[3].header["SPEC_REF"]
        flux = src.photons_in_range(1 * u.um, 2 * u.um, indexes=[ii]).value
        orig_sum = np.sum(src.fields[3].data) * flux

        the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                                  area=1 * u.m**2)
        the_fov.extract_from(src)
        view = the_fov.view()

        assert np.sum(the_fov.fields[0]["flux"]) == approx(36)
        assert np.isclose(np.sum(the_fov.fields[1].data), orig_sum)
        assert np.isclose(np.sum(view), orig_sum + 36)

        if PLOTS:
            plt.imshow(view.T, origin="lower", norm=LogNorm())
            plt.colorbar()
            plt.show()
Exemplo n.º 8
0
 def test_throws_error_if_no_wcs_in_header(self):
     with pytest.raises(ValueError):
         fov.FieldOfView(fits.Header(), (1, 2) * u.um, area=1 * u.m**2)
Exemplo n.º 9
0
 def test_initialises_with_header_and_waverange(self, basic_fov_header):
     print(dict(basic_fov_header))
     the_fov = fov.FieldOfView(basic_fov_header, (1, 2) * u.um,
                               area=1 * u.m**2)
     assert isinstance(the_fov, fov.FieldOfView)
Exemplo n.º 10
0
 def test_initialises_with_nothing_raise_error(self):
     with pytest.raises(TypeError):
         fov.FieldOfView()