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

        read1 = FitsReadingModule(name_in="read1",
                                  image_tag="star",
                                  input_dir=self.test_dir+"star")

        self.pipeline.add_module(read1)

        read2 = FitsReadingModule(name_in="read2",
                                  image_tag="sky",
                                  input_dir=self.test_dir+"sky")

        self.pipeline.add_module(read2)

        nodding = NoddingBackgroundModule(name_in="nodding",
                                          sky_in_tag="sky",
                                          science_in_tag="star",
                                          image_out_tag="nodding",
                                          mode="both")

        self.pipeline.add_module(nodding)

        self.pipeline.run()

        data = self.pipeline.get_data("star")
        assert np.allclose(data[0, 50, 50], 0.09798413502193704, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00010029494781738066, rtol=limit, atol=0.)

        data = self.pipeline.get_data("sky")
        assert np.allclose(data[0, 50, 50], -7.613171257478652e-05, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 8.937360237872607e-07, rtol=limit, atol=0.)

        data = self.pipeline.get_data("nodding")
        assert np.allclose(data[0, 50, 50], 0.09806026673451182, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 9.942251790089106e-05, rtol=limit, atol=0.)
Exemplo n.º 2
0
    def test_add_modules(self):
        pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)

        # --- Reading Modules ---
        # default location
        reading = FitsReadingModule(name_in="reading",
                                    input_dir=None,
                                    image_tag="im_arr")

        pipeline.add_module(reading)

        # no default location
        reading2 = FitsReadingModule(name_in="reading2",
                                     input_dir=self.test_dir,
                                     image_tag="im_arr2")

        pipeline.add_module(reading2)

        # --- Processing Module ---
        process = BadPixelSigmaFilterModule(image_in_tag="im_arr")

        pipeline.add_module(process)

        # --- Writing Module ---
        # default location
        write = FitsWritingModule(name_in="writing",
                                  file_name="result.fits",
                                  data_tag="im_arr")

        pipeline.add_module(write)

        # no default location
        write2 = FitsWritingModule(name_in="writing2",
                                   file_name="result.fits",
                                   data_tag="im_arr",
                                   output_dir=self.test_dir)

        pipeline.add_module(write2)

        with pytest.warns(UserWarning):
            pipeline.add_module(write2)

        pipeline.run()

        os.remove(self.test_dir+"result.fits")
        os.remove(self.test_data)

        # --- Reading Module ---
        # run_module

        pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)

        reading = FitsReadingModule(name_in="reading",
                                    input_dir=None,
                                    image_tag="im_arr")

        pipeline.add_module(reading)
        pipeline.run_module("reading")

        os.remove(self.test_data)
Exemplo n.º 3
0
    def test_run_non_valid_module_list(self):
        pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)

        # --- Reading Modules ---
        reading = FitsReadingModule(name_in="reading")

        pipeline.add_module(reading)

        # --- Processing Module ---
        process = BadPixelSigmaFilterModule(name_in="filter", image_in_tag="im_list")

        pipeline.add_module(process)

        # --- Writing Module ---
        write = FitsWritingModule(name_in="writing",
                                  file_name="result.fits",
                                  data_tag="im_list")

        pipeline.add_module(write)

        with pytest.raises(AttributeError):
            pipeline.run()

        with pytest.raises(AttributeError):
            pipeline.run_module("filter")

        with pytest.raises(AttributeError):
            pipeline.run_module("writing")

        assert pipeline.validate_pipeline_module("test") is None

        os.remove(self.test_data)
Exemplo n.º 4
0
    def create_wdir(cls, dir_in, **kwargs):

        tmp_pypeline = Pypeline(dir_in, dir_in, dir_in)

        obj = cls(tmp_pypeline)

        obj._save_kwargs(**kwargs)

        reading = FitsReadingModule(name_in="reading_mod",
                                    input_dir=dir_in,
                                    image_tag=obj._m_image_data_tag)

        obj._pypeline.add_module(reading)
        obj._pypeline.run_module("reading_mod")
        obj._prepare_data()

        return obj
Exemplo n.º 5
0
    def test_read(self):
        read_fits = FitsReadingModule(name_in="read_fits",
                                      image_tag="im",
                                      overwrite=True)

        self.pipeline.add_module(read_fits)
        self.pipeline.run_module("read_fits")

        data = self.pipeline.get_data("im")

        assert np.allclose(data[0, 0, 0],
                           0.00032486907273264834,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           9.4518306864680034e-05,
                           rtol=limit,
                           atol=0.)
        assert data.shape == (82, 102, 100)
Exemplo n.º 6
0
    def test_remove_module(self):
        pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)

        # --- Reading Modules ---
        reading = FitsReadingModule(name_in="reading")

        pipeline.add_module(reading)

        # --- Processing Module ---
        process = BadPixelSigmaFilterModule(name_in="filter", image_in_tag="im_list")

        pipeline.add_module(process)

        assert pipeline.get_module_names() == ["reading", "filter"]

        pipeline.remove_module("reading")

        assert pipeline.get_module_names() == ["filter"]

        assert pipeline.remove_module("filter") is True

        os.remove(self.test_data)
Exemplo n.º 7
0
    def test_simple_background_subraction(self):

        read = FitsReadingModule(name_in="read",
                                 image_tag="read",
                                 input_dir=self.test_dir+"dither")

        self.pipeline.add_module(read)

        simple = SimpleBackgroundSubtractionModule(shift=20,
                                                   name_in="simple",
                                                   image_in_tag="read",
                                                   image_out_tag="simple")

        self.pipeline.add_module(simple)

        self.pipeline.run()

        data = self.pipeline.get_data("read")
        assert np.allclose(data[0, 74, 24], 0.05304008435511765, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00010033896953157959, rtol=limit, atol=0.)

        data = self.pipeline.get_data("simple")
        assert np.allclose(data[0, 74, 74], -0.05288064325101517, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 2.7755575615628916e-22, rtol=limit, atol=0.)
Exemplo n.º 8
0
    def test_fake_planet(self):

        read = FitsReadingModule(name_in="read",
                                 image_tag="read")

        self.pipeline.add_module(read)

        angle = AngleInterpolationModule(name_in="angle",
                                         data_tag="read")

        self.pipeline.add_module(angle)

        fake = FakePlanetModule(position=(0.5, 90.),
                                magnitude=5.,
                                psf_scaling=1.,
                                interpolation="spline",
                                name_in="fake",
                                image_in_tag="read",
                                psf_in_tag="read",
                                image_out_tag="fake",
                                verbose=True)

        self.pipeline.add_module(fake)

        simplex = SimplexMinimizationModule(position=(31., 49.),
                                            magnitude=5.,
                                            psf_scaling=-1.,
                                            name_in="simplex",
                                            image_in_tag="fake",
                                            psf_in_tag="read",
                                            res_out_tag="simplex_res",
                                            flux_position_tag="flux_position",
                                            merit="sum",
                                            aperture=0.05,
                                            sigma=0.027,
                                            tolerance=0.1,
                                            pca_number=2,
                                            cent_size=None,
                                            edge_size=None,
                                            extra_rot=0.)

        self.pipeline.add_module(simplex)

        pca = PcaPsfSubtractionModule(pca_numbers=(2, ),
                                      name_in="pca",
                                      images_in_tag="fake",
                                      reference_in_tag="fake",
                                      res_mean_tag="res_mean",
                                      res_median_tag=None,
                                      res_arr_out_tag=None,
                                      res_rot_mean_clip_tag=None,
                                      extra_rot=0.)

        self.pipeline.add_module(pca)

        false = FalsePositiveModule(position=(31., 49.),
                                    aperture=0.1,
                                    ignore=True,
                                    name_in="false",
                                    image_in_tag="res_mean",
                                    snr_out_tag="snr_fpf")

        self.pipeline.add_module(false)

        photometry = AperturePhotometryModule(radius=0.1,
                                              position=None,
                                              name_in="photometry",
                                              image_in_tag="read",
                                              phot_out_tag="photometry")

        self.pipeline.add_module(photometry)

        self.pipeline.run()

        storage = DataStorage(self.test_dir+"/PynPoint_database.hdf5")
        storage.open_connection()

        data = storage.m_data_bank["read"]
        assert np.allclose(data[0, 10, 10], 0.00012958496246258364, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00010029494781738066, rtol=limit, atol=0.)

        data = storage.m_data_bank["header_read/PARANG"]
        assert data[5] == 2.7777777777777777

        data = storage.m_data_bank["fake"]
        assert np.allclose(data[0, 49, 31], 0.00036532633147006946, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.0001012983225928772, rtol=limit, atol=0.)

        data = storage.m_data_bank["simplex_res"]
        assert np.allclose(data[46, 49, 31], 3.718481593648487e-05, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), -2.8892749617545238e-08, rtol=limit, atol=0.)

        data = storage.m_data_bank["flux_position"]
        assert np.allclose(data[46, 0], 31.276994533457994, rtol=limit, atol=0.)
        assert np.allclose(data[46, 1], 50.10345749706295, rtol=limit, atol=0.)
        assert np.allclose(data[46, 2], 0.5055288651354779, rtol=limit, atol=0.)
        assert np.allclose(data[46, 3], 89.6834045889695, rtol=limit, atol=0.)
        assert np.allclose(data[46, 4], 4.997674024675655, rtol=limit, atol=0.)

        data = storage.m_data_bank["res_mean"]
        assert np.allclose(data[0, 49, 31], 9.258255068620805e-05, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), -2.610863424405134e-08, rtol=limit, atol=0.)

        data = storage.m_data_bank["snr_fpf"]
        assert np.allclose(data[0, 2], 0.513710034941892, rtol=limit, atol=0.)
        assert np.allclose(data[0, 3], 93.01278750418334, rtol=limit, atol=0.)
        assert np.allclose(data[0, 4], 11.775360946367874, rtol=limit, atol=0.)
        assert np.allclose(data[0, 5], 2.9838031156970146e-08, rtol=limit, atol=0.)

        data = storage.m_data_bank["photometry"]
        assert np.allclose(data[0][0], 0.983374353660573, rtol=limit, atol=0.)
        assert np.allclose(data[39][0], 0.9841484973083519, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.9835085649488583, rtol=limit, atol=0.)

        storage.close_connection()
Exemplo n.º 9
0
    def test_star_alignment(self):

        read = FitsReadingModule(name_in="read",
                                 image_tag="read")

        self.pipeline.add_module(read)

        extraction = StarExtractionModule(name_in="extract",
                                          image_in_tag="read",
                                          image_out_tag="extract",
                                          image_size=0.6,
                                          fwhm_star=0.1,
                                          position=None)

        self.pipeline.add_module(extraction)

        align = StarAlignmentModule(name_in="align",
                                    image_in_tag="extract",
                                    ref_image_in_tag=None,
                                    image_out_tag="align",
                                    accuracy=10,
                                    resize=2)

        self.pipeline.add_module(align)

        shift = ShiftImagesModule((6., 4.),
                                  name_in="shift",
                                  image_in_tag="align",
                                  image_out_tag="shift")

        self.pipeline.add_module(shift)

        center = StarCenteringModule(name_in="center",
                                     image_in_tag="shift",
                                     image_out_tag="center",
                                     mask_out_tag=None,
                                     fit_out_tag="center_fit",
                                     method="full",
                                     interpolation="spline",
                                     radius=0.1,
                                     sign="positive",
                                     guess=(6., 4., 1., 1., 1., 0.))

        self.pipeline.add_module(center)

        self.pipeline.run()

        storage = DataStorage(self.test_dir+"/PynPoint_database.hdf5")
        storage.open_connection()

        data = storage.m_data_bank["read"]
        assert np.allclose(data[0, 10, 10], 0.00012958496246258364, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 9.832838021311831e-05, rtol=limit, atol=0.)

        data = storage.m_data_bank["extract"]
        assert np.allclose(data[0, 10, 10], 0.05304008435511765, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.0020655767159466613, rtol=limit, atol=0.)

        data = storage.m_data_bank["header_extract/STAR_POSITION"]
        assert data[10, 0] ==  data[10, 1] == 75

        data = storage.m_data_bank["shift"]
        assert np.allclose(data[0, 10, 10], -4.341611534220891e-05, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.0005164420068450968, rtol=limit, atol=0.)

        data = storage.m_data_bank["center"]
        assert np.allclose(data[0, 10, 10], 4.128859892625027e-05, rtol=1e-4, atol=0.)
        assert np.allclose(np.mean(data), 0.0005163806188663894, rtol=1e-7, atol=0.)

        storage.close_connection()
Exemplo n.º 10
0
    def test_contrast_curve(self):

        read = FitsReadingModule(name_in="read", image_tag="read")

        self.pipeline.add_module(read)

        angle = AngleInterpolationModule(name_in="angle", data_tag="read")

        self.pipeline.add_module(angle)

        contrast = ContrastCurveModule(name_in="contrast",
                                       image_in_tag="read",
                                       psf_in_tag="read",
                                       pca_out_tag="pca",
                                       contrast_out_tag="limits",
                                       separation=(0.5, 0.6, 0.1),
                                       angle=(0., 360., 180.),
                                       magnitude=(7.5, 1.),
                                       sigma=5.,
                                       accuracy=1e-1,
                                       psf_scaling=1.,
                                       aperture=0.1,
                                       ignore=True,
                                       pca_number=15,
                                       norm=False,
                                       cent_size=None,
                                       edge_size=None,
                                       extra_rot=0.)

        self.pipeline.add_module(contrast)

        self.pipeline.run()

        storage = DataStorage(self.test_dir + "/PynPoint_database.hdf5")
        storage.open_connection()

        data = storage.m_data_bank["read"]
        assert np.allclose(data[0, 10, 10],
                           0.00012958496246258364,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.00010029494781738066,
                           rtol=limit,
                           atol=0.)

        data = storage.m_data_bank["header_read/PARANG"]
        assert data[5] == 2.7777777777777777

        data = storage.m_data_bank["pca"]
        assert np.allclose(data[9, 68, 49],
                           5.707647718560735e-05,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           -3.66890878538392e-08,
                           rtol=limit,
                           atol=0.)

        data = storage.m_data_bank["pca"]
        assert np.allclose(data[21, 31, 50],
                           5.4392925807364694e-05,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           -3.668908785383954e-08,
                           rtol=limit,
                           atol=0.)

        storage.close_connection()
Exemplo n.º 11
0
    def test_docs(self):
        read_science = FitsReadingModule(name_in="read_science",
                                         input_dir=self.test_dir + "adi/",
                                         image_tag="im_arr")

        self.pipeline.add_module(read_science)

        read_dark = FitsReadingModule(name_in="read_dark",
                                      input_dir=self.test_dir + "dark/",
                                      image_tag="dark_arr")

        self.pipeline.add_module(read_dark)

        read_flat = FitsReadingModule(name_in="read_flat",
                                      input_dir=self.test_dir + "flat/",
                                      image_tag="flat_arr")

        self.pipeline.add_module(read_flat)

        remove_last = RemoveLastFrameModule(name_in="last_frame",
                                            image_in_tag="im_arr",
                                            image_out_tag="im_arr_last")

        self.pipeline.add_module(remove_last)

        cutting = RemoveLinesModule(lines=(0, 0, 0, 2),
                                    name_in="cut_lines",
                                    image_in_tag="im_arr_last",
                                    image_out_tag="im_arr_cut")

        self.pipeline.add_module(cutting)

        dark_sub = DarkCalibrationModule(name_in="dark_subtraction",
                                         image_in_tag="im_arr_cut",
                                         dark_in_tag="dark_arr",
                                         image_out_tag="dark_sub_arr")

        flat_sub = FlatCalibrationModule(name_in="flat_subtraction",
                                         image_in_tag="dark_sub_arr",
                                         flat_in_tag="flat_arr",
                                         image_out_tag="flat_sub_arr")

        self.pipeline.add_module(dark_sub)
        self.pipeline.add_module(flat_sub)

        bg_subtraction = MeanBackgroundSubtractionModule(
            shift=None,
            cubes=1,
            name_in="background_subtraction",
            image_in_tag="flat_sub_arr",
            image_out_tag="bg_cleaned_arr")

        self.pipeline.add_module(bg_subtraction)

        bp_cleaning = BadPixelSigmaFilterModule(name_in="sigma_filtering",
                                                image_in_tag="bg_cleaned_arr",
                                                image_out_tag="bp_cleaned_arr")

        self.pipeline.add_module(bp_cleaning)

        extraction = StarExtractionModule(name_in="star_cutting",
                                          image_in_tag="bp_cleaned_arr",
                                          image_out_tag="im_arr_extract",
                                          image_size=0.6,
                                          fwhm_star=0.1,
                                          position=None)

        # Required for ref_image_in_tag in StarAlignmentModule, otherwise a random frame is used
        ref_extract = StarExtractionModule(name_in="star_cut_ref",
                                           image_in_tag="bp_cleaned_arr",
                                           image_out_tag="im_arr_ref",
                                           image_size=0.6,
                                           fwhm_star=0.1,
                                           position=None)

        alignment = StarAlignmentModule(name_in="star_align",
                                        image_in_tag="im_arr_extract",
                                        ref_image_in_tag="im_arr_ref",
                                        image_out_tag="im_arr_aligned",
                                        accuracy=10,
                                        resize=2)

        self.pipeline.add_module(extraction)
        self.pipeline.add_module(ref_extract)
        self.pipeline.add_module(alignment)

        angle_calc = AngleInterpolationModule(name_in="angle_calculation",
                                              data_tag="im_arr_aligned")

        self.pipeline.add_module(angle_calc)

        subset = StackAndSubsetModule(name_in="stacking_subset",
                                      image_in_tag="im_arr_aligned",
                                      image_out_tag="im_arr_stacked",
                                      random=None,
                                      stacking=4)

        self.pipeline.add_module(subset)

        psf_sub = PSFSubtractionModule(pca_number=5,
                                       name_in="PSF_subtraction",
                                       images_in_tag="im_arr_stacked",
                                       reference_in_tag="im_arr_stacked",
                                       res_mean_tag="res_mean")

        self.pipeline.add_module(psf_sub)

        writing = FitsWritingModule(name_in="Fits_writing",
                                    file_name="test.fits",
                                    data_tag="res_mean")

        self.pipeline.add_module(writing)

        self.pipeline.run()

        data = self.pipeline.get_data("im_arr")
        assert np.allclose(data[0, 61, 39],
                           -0.00022889163546536875,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("dark_arr")
        assert np.allclose(data[0, 61, 39],
                           2.368170995592123e-05,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("flat_arr")
        assert np.allclose(data[0, 61, 39],
                           0.98703416941301647,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("im_arr_last")
        assert np.allclose(data[0, 61, 39],
                           -0.00022889163546536875,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("im_arr_cut")
        assert np.allclose(data[0, 61, 39],
                           -0.00022889163546536875,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("dark_sub_arr")
        assert np.allclose(data[0, 61, 39],
                           -0.00021601281733413911,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("flat_sub_arr")
        assert np.allclose(data[0, 61, 39],
                           -0.00021647987125847178,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("bg_cleaned_arr")
        assert np.allclose(data[0, 61, 39],
                           -0.00013095662386792948,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("bp_cleaned_arr")
        assert np.allclose(data[0, 61, 39],
                           -0.00013095662386792948,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("im_arr_extract")
        assert np.allclose(data[0, 10, 10],
                           0.052958146579313935,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("im_arr_aligned")
        assert np.allclose(data[0, 10, 10],
                           1.1307471842831197e-05,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("im_arr_stacked")
        assert np.allclose(data[0, 10, 10],
                           2.5572805947810986e-05,
                           rtol=limit,
                           atol=0.)

        data = self.pipeline.get_data("res_mean")
        assert np.allclose(data[38, 22],
                           0.00018312083384477404,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           -1.598348168584834e-07,
                           rtol=limit,
                           atol=0.)
        assert data.shape == (44, 44)
Exemplo n.º 12
0
    def test_psf_subtraction_pca(self):

        read = FitsReadingModule(name_in="read",
                                 image_tag="read")

        self.pipeline.add_module(read)

        angle = AngleInterpolationModule(name_in="angle",
                                         data_tag="read")

        self.pipeline.add_module(angle)

        pca = PcaPsfSubtractionModule(pca_numbers=(5, ),
                                      name_in="pca",
                                      images_in_tag="read",
                                      reference_in_tag="read",
                                      res_mean_tag="res_mean",
                                      res_median_tag="res_median",
                                      res_arr_out_tag="res_arr",
                                      res_rot_mean_clip_tag="res_clip",
                                      basis_out_tag="basis",
                                      extra_rot=-15.,
                                      verbose=True)

        self.pipeline.add_module(pca)

        self.pipeline.run()

        data = self.pipeline.get_data("read")
        assert np.allclose(data[0, 50, 50], 0.09798413502193708, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 0.00010063896953157961, rtol=limit, atol=0.)
        assert data.shape == (80, 100, 100)

        data = self.pipeline.get_data("res_mean")
        assert np.allclose(data[0, 50, 50], 1.947810457180298e-06, rtol=limit, atol=0.)
        assert np.allclose(data[0, 59, 46], 0.00016087655925993273, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 3.184676024912574e-08, rtol=limit, atol=0.)
        assert data.shape == (1, 100, 100)

        data = self.pipeline.get_data("res_median")
        assert np.allclose(data[0, 50, 50], -2.223389676715259e-06, rtol=limit, atol=0.)
        assert np.allclose(data[0, 59, 46], 0.00015493570876347953, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 1.250907785757355e-07, rtol=limit, atol=0.)
        assert data.shape == (1, 100, 100)

        data = self.pipeline.get_data("res_clip")
        assert np.allclose(data[0, 50, 50], 2.2828813434810948e-06, rtol=limit, atol=0.)
        assert np.allclose(data[0, 59, 46], 1.0816254290076103e-05, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 2.052077475694807e-06, rtol=limit, atol=0.)
        assert data.shape == (1, 100, 100)

        data = self.pipeline.get_data("res_arr5")
        assert np.allclose(data[0, 50, 50], -0.00010775091764735749, rtol=limit, atol=0.)
        assert np.allclose(data[0, 59, 46], 0.0001732810184783699, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), 3.184676024912564e-08, rtol=limit, atol=0.)
        assert data.shape == (80, 100, 100)

        data = self.pipeline.get_data("basis")
        assert np.allclose(data[0, 50, 50], -0.005866797940467074, rtol=limit, atol=0.)
        assert np.allclose(data[0, 59, 46], 0.0010154680995154122, rtol=limit, atol=0.)
        assert np.allclose(np.mean(data), -4.708475279640416e-05, rtol=limit, atol=0.)
        assert data.shape == (5, 100, 100)
Exemplo n.º 13
0
    def test_psf_preparation(self):

        read = FitsReadingModule(name_in="read", image_tag="read")

        self.pipeline.add_module(read)

        angle = AngleInterpolationModule(name_in="angle", data_tag="read")

        self.pipeline.add_module(angle)

        prep = PSFpreparationModule(name_in="prep",
                                    image_in_tag="read",
                                    image_out_tag="prep",
                                    mask_out_tag="mask",
                                    norm=True,
                                    resize=2.,
                                    cent_size=0.1,
                                    edge_size=1.0,
                                    verbose=True)

        self.pipeline.add_module(prep)

        sdi = SDIpreparationModule(name_in="sdi",
                                   wavelength=(0.65, 0.6),
                                   width=(0.1, 0.5),
                                   image_in_tag="read",
                                   image_out_tag="sdi")

        self.pipeline.add_module(sdi)

        self.pipeline.run()

        data = self.pipeline.get_data("read")
        assert np.allclose(data[0, 25, 25],
                           2.0926464668090656e-05,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           0.00010029494781738066,
                           rtol=limit,
                           atol=0.)
        assert data.shape == (40, 100, 100)

        data = self.pipeline.get_data("prep")
        assert np.allclose(data[0, 25, 25], 0., rtol=limit, atol=0.)
        assert np.allclose(data[0, 99, 99], 0., rtol=limit, atol=0.)
        assert np.allclose(np.mean(data),
                           0.0001818623671899089,
                           rtol=limit,
                           atol=0.)
        assert data.shape == (40, 200, 200)

        data = self.pipeline.get_data("sdi")
        assert np.allclose(data[0, 25, 25],
                           -2.6648118007008814e-05,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(np.mean(data),
                           2.0042892634995876e-05,
                           rtol=limit,
                           atol=0.)
        assert data.shape == (40, 100, 100)