def test_bad_pixel_map(self): bp_map = BadPixelMapModule(name_in="bp_map", dark_in_tag="dark", flat_in_tag="flat", bp_map_out_tag="bp_map", dark_threshold=0.99, flat_threshold=-0.99) self.pipeline.add_module(bp_map) self.pipeline.run() storage = DataStorage(self.test_dir + "/PynPoint_database.hdf5") storage.open_connection() data = storage.m_data_bank["bp_map"] assert data[0, 0] == 1. assert data[30, 30] == 1. assert data[10, 10] == 0. assert data[12, 12] == 0. assert data[14, 14] == 0. assert data[20, 20] == 0. assert data[22, 22] == 0. assert data[24, 24] == 0. assert np.mean(data) == 0.9993 storage.close_connection()
def test_create_storage_without_existing_database(self): storage = DataStorage(self.test_data) storage.open_connection() storage.m_data_bank["data"] = [0, 1, 2, 5, 7] assert storage.m_data_bank["data"][2] == 2 assert storage.m_data_bank.keys() == ["data", ] storage.close_connection() os.remove(self.test_data)
def test_open_close_connection(self): storage = DataStorage(self.test_data) storage.open_connection() assert storage.m_open is True storage.open_connection() assert storage.m_open is True storage.close_connection() assert storage.m_open is False storage.close_connection() assert storage.m_open is False os.remove(self.test_data)
def test_dark_and_flat_calibration(self): dark = DarkCalibrationModule(name_in="dark", image_in_tag="images", dark_in_tag="dark", image_out_tag="dark_cal") self.pipeline.add_module(dark) flat = FlatCalibrationModule(name_in="flat", image_in_tag="dark_cal", flat_in_tag="flat", image_out_tag="flat_cal") self.pipeline.add_module(flat) self.pipeline.run() storage = DataStorage(self.test_dir + "/PynPoint_database.hdf5") storage.open_connection() data = storage.m_data_bank["dark"] assert np.allclose(data[0, 10, 10], 3.528694163309295e-05, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 7.368663496379876e-07, rtol=limit, atol=0.) data = storage.m_data_bank["flat"] assert np.allclose(data[0, 10, 10], -0.0004053528990466237, rtol=limit, atol=0.) assert np.allclose(np.mean(data), -4.056978234798532e-07, rtol=limit, atol=0.) storage.close_connection()
def test_bad_pixel_sigma_filter(self): sigma = BadPixelSigmaFilterModule(name_in="sigma", image_in_tag="images", image_out_tag="sigma", box=9, sigma=5, iterate=1) self.pipeline.add_module(sigma) self.pipeline.run() storage = DataStorage(self.test_dir + "/PynPoint_database.hdf5") storage.open_connection() data = storage.m_data_bank["sigma"] assert np.allclose(data[0, 0, 0], 0.00032486907273264834, rtol=limit, atol=0.) assert np.allclose(data[0, 10, 10], 0.025022559679385093, rtol=limit, atol=0.) assert np.allclose(data[0, 20, 20], 0.024962143884217046, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 6.721637736047109e-07, rtol=limit, atol=0.) storage.close_connection()
def test_bad_pixel_interpolation(self): interpolation = BadPixelInterpolationModule( name_in="interpolation", image_in_tag="images", bad_pixel_map_tag="bp_map", image_out_tag="interpolation", iterations=100) self.pipeline.add_module(interpolation) self.pipeline.run() storage = DataStorage(self.test_dir + "/PynPoint_database.hdf5") storage.open_connection() data = storage.m_data_bank["interpolation"] assert np.allclose(data[0, 0, 0], 0.00032486907273264834, rtol=limit, atol=0.) assert np.allclose(data[0, 10, 10], 1.0139222106683477e-05, rtol=limit, atol=0.) assert np.allclose(data[0, 20, 20], -4.686852973820094e-05, rtol=limit, atol=0.) assert np.allclose(np.mean(data), 3.0499629451215465e-07, rtol=limit, atol=0.) storage.close_connection()
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()
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()
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()