Exemplo n.º 1
0
    def test_add_lines(self) -> None:

        module = AddLinesModule(lines=(2, 5, 0, 3),
                                name_in='add',
                                image_in_tag='read',
                                image_out_tag='add')

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

        data = self.pipeline.get_data('add')
        assert np.sum(data) == pytest.approx(105.54278879805275, rel=self.limit, abs=0.)
        assert data.shape == (10, 14, 18)
Exemplo n.º 2
0
    def test_add_lines(self):

        module = AddLinesModule(lines=(2, 5, 0, 9),
                                name_in='add',
                                image_in_tag='read',
                                image_out_tag='add')

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

        data = self.pipeline.get_data('add')
        assert np.allclose(data[0, 50, 50], 0.02851872141873229, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 8.599412485413757e-05, rtol=limit, atol=0.)
        assert data.shape == (40, 109, 107)
Exemplo n.º 3
0
    def test_waffle_center_odd(self) -> None:

        module = AddLinesModule(name_in='add',
                                image_in_tag='star',
                                image_out_tag='star_add',
                                lines=(45, 45, 45, 45))

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

        data = self.pipeline.get_data('star_add')
        assert np.sum(data) == pytest.approx(105.54278879805278,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 101, 101)

        module = WaffleCenteringModule(size=0.2,
                                       center=(50, 50),
                                       name_in='waffle',
                                       image_in_tag='star_add',
                                       center_in_tag='waffle',
                                       image_out_tag='center',
                                       radius=35.,
                                       pattern='x',
                                       sigma=0.05)

        self.pipeline.add_module(module)

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

        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')
        assert np.sum(data) == pytest.approx(104.93318507061295,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 9, 9)

        attr = self.pipeline.get_attribute('center',
                                           'History: WaffleCenteringModule')
        assert attr == '[x, y] = [50.0, 50.0]'
Exemplo n.º 4
0
    def test_wavelet_denoising_odd_size(self):

        module = AddLinesModule(name_in='add',
                                image_in_tag='images',
                                image_out_tag='images_odd',
                                lines=(1, 0, 1, 0))

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

        data = self.pipeline.get_data('images_odd')
        assert np.allclose(data[0, 10, 10], 0.05294085050174391, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.002269413609192613, rtol=limit, atol=0.)
        assert data.shape == (40, 21, 21)

        cwt_config = CwtWaveletConfiguration(wavelet='dog',
                                             wavelet_order=2,
                                             keep_mean=False,
                                             resolution=0.5)

        assert cwt_config.m_wavelet == 'dog'
        assert np.allclose(cwt_config.m_wavelet_order, 2, rtol=limit, atol=0.)
        assert not cwt_config.m_keep_mean
        assert np.allclose(cwt_config.m_resolution, 0.5, rtol=limit, atol=0.)

        module = WaveletTimeDenoisingModule(wavelet_configuration=cwt_config,
                                            name_in='wavelet_odd_1',
                                            image_in_tag='images_odd',
                                            image_out_tag='wavelet_odd_1',
                                            padding='zero',
                                            median_filter=True,
                                            threshold_function='soft')

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

        data = self.pipeline.get_data('wavelet_odd_1')
        assert np.allclose(data[0, 10, 10], 0.0529782051386938, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.0022694631406801565, rtol=limit, atol=0.)
        assert data.shape == (40, 21, 21)

        module = WaveletTimeDenoisingModule(wavelet_configuration=cwt_config,
                                            name_in='wavelet_odd_2',
                                            image_in_tag='images_odd',
                                            image_out_tag='wavelet_odd_2',
                                            padding='mirror',
                                            median_filter=True,
                                            threshold_function='soft')

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

        data = self.pipeline.get_data('wavelet_odd_2')
        assert np.allclose(data[0, 10, 10], 0.05297146283932275, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.0022694809842930034, rtol=limit, atol=0.)
        assert data.shape == (40, 21, 21)

        data = self.pipeline.get_attribute('images', 'NFRAMES', static=False)
        assert np.allclose(data, [10, 10, 10, 10], rtol=limit, atol=0.)

        data = self.pipeline.get_attribute('wavelet_odd_1', 'NFRAMES', static=False)
        assert np.allclose(data, [10, 10, 10, 10], rtol=limit, atol=0.)

        data = self.pipeline.get_attribute('wavelet_odd_2', 'NFRAMES', static=False)
        assert np.allclose(data, [10, 10, 10, 10], rtol=limit, atol=0.)
Exemplo n.º 5
0
    def test_wavelet_denoising_even_size(self) -> None:

        module = AddLinesModule(name_in='add',
                                image_in_tag='images',
                                image_out_tag='images_even',
                                lines=(1, 0, 1, 0))

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

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

        cwt_config = CwtWaveletConfiguration(wavelet='dog',
                                             wavelet_order=2,
                                             keep_mean=False,
                                             resolution=0.5)

        assert cwt_config.m_wavelet == 'dog'
        assert cwt_config.m_wavelet_order == 2
        assert not cwt_config.m_keep_mean
        assert cwt_config.m_resolution == 0.5

        module = WaveletTimeDenoisingModule(wavelet_configuration=cwt_config,
                                            name_in='wavelet_even_1',
                                            image_in_tag='images_even',
                                            image_out_tag='wavelet_even_1',
                                            padding='zero',
                                            median_filter=True,
                                            threshold_function='soft')

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

        data = self.pipeline.get_data('wavelet_even_1')
        assert np.sum(data) == pytest.approx(105.1035789572968,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 12, 12)

        module = WaveletTimeDenoisingModule(wavelet_configuration=cwt_config,
                                            name_in='wavelet_even_2',
                                            image_in_tag='images_even',
                                            image_out_tag='wavelet_even_2',
                                            padding='mirror',
                                            median_filter=True,
                                            threshold_function='soft')

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

        data = self.pipeline.get_data('wavelet_even_2')
        assert np.sum(data) == pytest.approx(105.06809820408587,
                                             rel=self.limit,
                                             abs=0.)
        assert data.shape == (10, 12, 12)

        data = self.pipeline.get_attribute('images', 'NFRAMES', static=False)
        assert data == pytest.approx([5, 5], rel=self.limit, abs=0.)

        data = self.pipeline.get_attribute('wavelet_even_1',
                                           'NFRAMES',
                                           static=False)
        assert data == pytest.approx([5, 5], rel=self.limit, abs=0.)

        data = self.pipeline.get_attribute('wavelet_even_2',
                                           'NFRAMES',
                                           static=False)
        assert data == pytest.approx([5, 5], rel=self.limit, abs=0.)
Exemplo n.º 6
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]'