Esempio n. 1
0
    def test_shift_images_tag_mean(self) -> None:

        module = ShiftImagesModule(shift_xy='fit_mean',
                                   interpolation='spline',
                                   name_in='shift6',
                                   image_in_tag='shift',
                                   image_out_tag='shift_tag_2')

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

        data = self.pipeline.get_data('shift_tag_2')
        assert np.sum(data) == pytest.approx(103.42285579230325, rel=1e-6, abs=0.)
        assert data.shape == (10, 18, 18)
Esempio n. 2
0
    def test_shift_images_tag_mean(self) -> None:

        module = ShiftImagesModule(shift_xy='fit_mean',
                                   interpolation='spline',
                                   name_in='shift4',
                                   image_in_tag='shift',
                                   image_out_tag='shift_tag_2')

        self.pipeline.add_module(module)
        self.pipeline.run_module('shift4')
        data = self.pipeline.get_data('shift_tag_2')
        assert np.allclose(data[0, 20, 31], 5.348337712000518e-05, rtol=1e-6, atol=0.)
        assert np.allclose(np.mean(data), 0.00016430318227546225, rtol=1e-6, atol=0.)
        assert data.shape == (40, 78, 78)
Esempio n. 3
0
    def test_shift_images_tag(self) -> None:

        module = ShiftImagesModule(shift_xy='fit_full',
                                   interpolation='spline',
                                   name_in='shift5',
                                   image_in_tag='shift',
                                   image_out_tag='shift_tag_1')

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

        data = self.pipeline.get_data('shift_tag_1')
        assert np.sum(data) == pytest.approx(103.76504482668594, rel=1e-6, abs=0.)
        assert data.shape == (10, 18, 18)
Esempio n. 4
0
    def test_shift_images_fft(self) -> None:

        module = ShiftImagesModule(shift_xy=(1., 2.),
                                   interpolation='fft',
                                   name_in='shift2',
                                   image_in_tag='align1',
                                   image_out_tag='shift_fft')

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

        data = self.pipeline.get_data('shift_fft')
        assert np.sum(data) == pytest.approx(104.70747423205349, rel=self.limit, abs=0.)
        assert data.shape == (10, 18, 18)
Esempio n. 5
0
    def test_shift_images_spline(self) -> None:

        module = ShiftImagesModule(shift_xy=(1., 2.),
                                   interpolation='spline',
                                   name_in='shift1',
                                   image_in_tag='align1',
                                   image_out_tag='shift')

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

        data = self.pipeline.get_data('shift')
        assert np.sum(data) == pytest.approx(104.20425101355242, rel=self.limit, abs=0.)
        assert data.shape == (10, 18, 18)
Esempio n. 6
0
    def test_shift_images_tag(self) -> None:

        module = ShiftImagesModule(shift_xy='fit_full',
                                   interpolation='spline',
                                   name_in='shift3',
                                   image_in_tag='shift',
                                   image_out_tag='shift_tag_1')

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

        data = self.pipeline.get_data('shift_tag_1')
        assert np.allclose(data[0, 39, 39], 0.023563080974545528, rtol=1e-6, atol=0.)
        assert np.allclose(np.mean(data), 0.0001643062943690491, rtol=1e-6, atol=0.)
        assert data.shape == (40, 78, 78)
Esempio n. 7
0
    def test_shift_images_fft(self) -> None:

        module = ShiftImagesModule(shift_xy=(6., 4.),
                                   interpolation='fft',
                                   name_in='shift2',
                                   image_in_tag='align1',
                                   image_out_tag='shift_fft')

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

        data = self.pipeline.get_data('shift_fft')
        assert np.allclose(data[0, 43, 45], 0.023556628129942764, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00016446205542266847, rtol=limit, atol=0.)
        assert data.shape == (40, 78, 78)
Esempio n. 8
0
    def test_shift_images_fft(self):

        shift = ShiftImagesModule(shift_xy=(6., 4.),
                                  interpolation="spline",
                                  name_in="shift2",
                                  image_in_tag="align",
                                  image_out_tag="fft")

        self.pipeline.add_module(shift)
        self.pipeline.run_module("shift2")

        data = self.pipeline.get_data("fft")
        assert np.allclose(data[0, 43, 45], 0.023556628129942764, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00016430682224782259, rtol=limit, atol=0.)
        assert data.shape == (40, 78, 78)
Esempio n. 9
0
    def test_shift_images_spline(self):

        module = ShiftImagesModule(shift_xy=(6., 4.),
                                   interpolation='spline',
                                   name_in='shift1',
                                   image_in_tag='align',
                                   image_out_tag='shift')

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

        data = self.pipeline.get_data('shift')
        assert np.allclose(data[0, 43, 45], 0.023556628129942764, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00016430682224782259, rtol=limit, atol=0.)
        assert data.shape == (40, 78, 78)
Esempio n. 10
0
    def test_waffle_center_even(self) -> None:

        module = AddLinesModule(name_in='add1',
                                image_in_tag='star_add',
                                image_out_tag='star_even',
                                lines=(0, 1, 0, 1))

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

        data = self.pipeline.get_data('star_even')
        assert np.sum(data) == pytest.approx(105.54278879805275,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 102, 102)

        module = AddLinesModule(name_in='add2',
                                image_in_tag='waffle',
                                image_out_tag='waffle_even',
                                lines=(0, 1, 0, 1))

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

        data = self.pipeline.get_data('waffle_even')
        assert np.sum(data) == pytest.approx(4.000000000000195,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (1, 102, 102)

        module = ShiftImagesModule(shift_xy=(0.5, 0.5),
                                   interpolation='spline',
                                   name_in='shift3',
                                   image_in_tag='star_even',
                                   image_out_tag='star_shift')

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

        data = self.pipeline.get_data('star_shift')
        assert np.sum(data) == pytest.approx(105.54278879805274,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 102, 102)

        module = ShiftImagesModule(shift_xy=(0.5, 0.5),
                                   interpolation='spline',
                                   name_in='shift4',
                                   image_in_tag='waffle_even',
                                   image_out_tag='waffle_shift')

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

        data = self.pipeline.get_data('waffle_shift')
        assert np.sum(data) == pytest.approx(4.000000000000194,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (1, 102, 102)

        module = WaffleCenteringModule(size=0.2,
                                       center=(50, 50),
                                       name_in='waffle_even',
                                       image_in_tag='star_shift',
                                       center_in_tag='waffle_shift',
                                       image_out_tag='center_even',
                                       radius=35.,
                                       pattern='x',
                                       sigma=0.05)

        self.pipeline.add_module(module)

        with pytest.warns(DeprecationWarning) as warning:
            self.pipeline.run_module('waffle_even')

        assert len(warning) == 1

        assert warning[0].message.args[0] == 'The \'pattern\' parameter will be deprecated in a ' \
                                             'future release. Please Use the \'angle\' ' \
                                             'parameter instead and set it to 45.0 degrees.'

        data = self.pipeline.get_data('center_even')
        assert np.sum(data) == pytest.approx(105.22695036281449,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 9, 9)

        attr = self.pipeline.get_attribute('center_even',
                                           'History: WaffleCenteringModule')
        assert attr == '[x, y] = [50.5, 50.5]'