Exemplo n.º 1
0
    def test_dithering_center(self):

        pca_dither = DitheringBackgroundModule(name_in='pca_dither2',
                                               image_in_tag='dither',
                                               image_out_tag='pca_dither2',
                                               center=((25., 75.), (75., 75.),
                                                       (75., 25.), (25., 25.)),
                                               cubes=1,
                                               size=0.8,
                                               gaussian=0.1,
                                               subframe=None,
                                               pca_number=5,
                                               mask_star=0.1,
                                               bad_pixel=None,
                                               crop=True,
                                               prepare=True,
                                               pca_background=True,
                                               combine='pca')

        self.pipeline.add_module(pca_dither)
        self.pipeline.run_module('pca_dither2')

        data = self.pipeline.get_data('pca_dither2')
        assert np.allclose(data[0, 14, 14],
                           0.05302488794328089,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.0010406279782666378,
                           rtol=1e-3,
                           atol=0.)
        assert data.shape == (80, 31, 31)
Exemplo n.º 2
0
    def test_dithering_center(self) -> None:

        module = DitheringBackgroundModule(name_in='pca_dither2',
                                           image_in_tag='dither',
                                           image_out_tag='pca_dither2',
                                           center=((5, 5), (5, 15), (15, 15),
                                                   (15, 5)),
                                           cubes=1,
                                           size=0.2,
                                           gaussian=0.05,
                                           subframe=None,
                                           pca_number=1,
                                           mask_star=0.05,
                                           crop=True,
                                           prepare=True,
                                           pca_background=True,
                                           combine='pca')

        self.pipeline.add_module(module)
        self.pipeline.run_module('pca_dither2')

        data = self.pipeline.get_data('pca_dither2')
        assert np.sum(data) == pytest.approx(209.8271898501695,
                                             rel=1e-6,
                                             abs=0.)
        assert data.shape == (20, 9, 9)
Exemplo n.º 3
0
    def test_dithering_attributes(self) -> None:

        module = DitheringBackgroundModule(name_in='pca_dither1',
                                           image_in_tag='dither',
                                           image_out_tag='pca_dither1',
                                           center=None,
                                           cubes=None,
                                           size=0.2,
                                           gaussian=0.05,
                                           subframe=0.1,
                                           pca_number=1,
                                           mask_star=0.05)

        self.pipeline.add_module(module)
        self.pipeline.run_module('pca_dither1')

        data = self.pipeline.get_data('dither_dither_crop1')
        assert np.sum(data) == pytest.approx(54.62410860562912, rel=self.limit, abs=0.)
        assert data.shape == (20, 9, 9)

        data = self.pipeline.get_data('dither_dither_star1')
        assert np.sum(data) == pytest.approx(54.873885838788595, rel=self.limit, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_mean1')
        assert np.sum(data) == pytest.approx(54.204960755115245, rel=self.limit, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_background1')
        assert np.sum(data) == pytest.approx(-0.24977723315947564, rel=self.limit, abs=0.)
        assert data.shape == (15, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_fit1')
        assert np.sum(data) == pytest.approx(-0.6816458444287745, rel=1e-5, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_res1')
        assert np.sum(data) == pytest.approx(55.63879076093719, rel=1e-6, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_mask1')
        assert np.sum(data) == pytest.approx(360.0, rel=self.limit, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('pca_dither1')
        assert np.sum(data) == pytest.approx(208.24417329569593, rel=1e-6, abs=0.)
        assert data.shape == (20, 9, 9)

        attr = self.pipeline.get_attribute('dither_dither_pca_res1', 'STAR_POSITION', static=False)
        assert np.sum(attr) == pytest.approx(40., rel=self.limit, abs=0.)
        assert attr.shape == (5, 2)
Exemplo n.º 4
0
    def test_dithering_center(self) -> None:

        module = DitheringBackgroundModule(name_in='pca_dither2',
                                           image_in_tag='dither',
                                           image_out_tag='pca_dither2',
                                           center=[(5, 5), (5, 15), (15, 15), (15, 5)],
                                           cubes=1,
                                           size=0.2,
                                           gaussian=0.05,
                                           subframe=None,
                                           pca_number=1,
                                           mask_star=0.05)

        self.pipeline.add_module(module)
        self.pipeline.run_module('pca_dither2')

        data = self.pipeline.get_data('pca_dither2')
        assert np.sum(data) == pytest.approx(208.24417332523367, rel=1e-6, abs=0.)
        assert data.shape == (20, 9, 9)
Exemplo n.º 5
0
    def test_dithering_attributes(self):

        pca_dither = DitheringBackgroundModule(name_in='pca_dither1',
                                               image_in_tag='dither',
                                               image_out_tag='pca_dither1',
                                               center=None,
                                               cubes=None,
                                               size=0.8,
                                               gaussian=0.1,
                                               subframe=0.5,
                                               pca_number=5,
                                               mask_star=0.1,
                                               crop=True,
                                               prepare=True,
                                               pca_background=True,
                                               combine='pca')

        self.pipeline.add_module(pca_dither)
        self.pipeline.run_module('pca_dither1')

        data = self.pipeline.get_data('dither_dither_crop1')
        assert np.allclose(data[0, 14, 14],
                           0.05304008435511765,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.0002606205855710527,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (80, 31, 31)

        data = self.pipeline.get_data('dither_dither_star1')
        assert np.allclose(data[0, 14, 14],
                           0.05304008435511765,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.0010414302265833978,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (20, 31, 31)

        data = self.pipeline.get_data('dither_dither_mean1')
        assert np.allclose(data[0, 14, 14],
                           0.0530465391626132,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.0010426228104479674,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (20, 31, 31)

        data = self.pipeline.get_data('dither_dither_background1')
        assert np.allclose(data[0, 14, 14],
                           -0.00010629310882411674,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           3.5070523360436835e-07,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (60, 31, 31)

        data = self.pipeline.get_data('dither_dither_pca_fit1')
        assert np.allclose(data[0, 14, 14],
                           1.5196412298279846e-05,
                           rtol=1e-5,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           1.9779802529804516e-07,
                           rtol=1e-4,
                           atol=0.)
        assert data.shape == (20, 31, 31)

        data = self.pipeline.get_data('dither_dither_pca_res1')
        assert np.allclose(data[0, 14, 14],
                           0.05302488794281937,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.0010412324285580998,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (20, 31, 31)

        data = self.pipeline.get_data('dither_dither_pca_mask1')
        assert np.allclose(data[0, 14, 14], 0., rtol=1e-6, atol=0.)
        assert np.allclose(np.mean(data),
                           0.9531737773152965,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (20, 31, 31)

        data = self.pipeline.get_data('pca_dither1')
        assert np.allclose(data[0, 14, 14],
                           0.05302488794281937,
                           rtol=1e-6,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.001040627977720779,
                           rtol=1e-6,
                           atol=0.)
        assert data.shape == (80, 31, 31)

        data = self.pipeline.get_attribute('dither_dither_pca_res1',
                                           'STAR_POSITION',
                                           static=False)
        assert np.allclose(data[0, 0], [15., 15.], rtol=1e-6, atol=0.)
        assert np.allclose(np.mean(data), 15., rtol=1e-6, atol=0.)
        assert data.shape == (20, 2)
Exemplo n.º 6
0
    def test_dithering_attributes(self) -> None:

        module = DitheringBackgroundModule(name_in='pca_dither1',
                                           image_in_tag='dither',
                                           image_out_tag='pca_dither1',
                                           center=None,
                                           cubes=None,
                                           size=0.2,
                                           gaussian=0.05,
                                           subframe=0.1,
                                           pca_number=1,
                                           mask_star=0.05,
                                           crop=True,
                                           prepare=True,
                                           pca_background=True,
                                           combine='pca')

        self.pipeline.add_module(module)
        self.pipeline.run_module('pca_dither1')

        data = self.pipeline.get_data('dither_dither_crop1')
        assert np.sum(data) == pytest.approx(54.62410860562912,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (20, 9, 9)

        data = self.pipeline.get_data('dither_dither_star1')
        assert np.sum(data) == pytest.approx(54.873885838788595,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_mean1')
        assert np.sum(data) == pytest.approx(54.204960755115245,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_background1')
        assert np.sum(data) == pytest.approx(-0.24977723315947564,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (15, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_fit1')
        assert np.sum(data) == pytest.approx(-0.01019999314121019,
                                             rel=1e-5,
                                             abs=0.)
        print(np.sum(data))
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_res1')
        assert np.sum(data) == pytest.approx(54.884085831929795,
                                             rel=1e-6,
                                             abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('dither_dither_pca_mask1')
        assert np.sum(data) == pytest.approx(360.0, rel=self.limit, abs=0.)
        assert data.shape == (5, 9, 9)

        data = self.pipeline.get_data('pca_dither1')
        assert np.sum(data) == pytest.approx(208.774670964812,
                                             rel=1e-6,
                                             abs=0.)
        assert data.shape == (20, 9, 9)

        attr = self.pipeline.get_attribute('dither_dither_pca_res1',
                                           'STAR_POSITION',
                                           static=False)
        assert np.sum(attr) == pytest.approx(51., rel=self.limit, abs=0.)
        assert attr.shape == (5, 2)