def test__add_cti_serial_fast(): arr = np.array(([ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ])) arr = ac.Array2D.manual(array=arr, pixel_scales=1.0).native ccd = ac.CCDPhase(full_well_depth=1e3, well_notch_depth=0.0, well_fill_power=1.0) trap_list = [ ac.TrapInstantCapture(density=10.0, release_timescale=-1.0 / np.log(0.5)) ] clocker = ac.Clocker2D() image_via_clocker = clocker.add_cti(data=arr, serial_trap_list=trap_list, serial_ccd=ccd) clocker = ac.Clocker2D(serial_fast_pixels=(1, 3)) image_via_clocker_fast = clocker.add_cti(data=arr, serial_trap_list=trap_list, serial_ccd=ccd) assert image_via_clocker == pytest.approx(image_via_clocker_fast, 1.0e-6)
def test__array_with_offset_through_arctic(): arr = ac.Array2D.manual( array=[[1.0, 2.0], [3.0, 4.0]], pixel_scales=1.0, header=ac.Header(header_sci_obj=None, header_hdu_obj=None, readout_offsets=(3, 5)), ).native roe = ac.ROE( dwell_times=[1.0], empty_traps_between_columns=True, empty_traps_for_first_transfers=False, force_release_away_from_readout=True, use_integer_express_matrix=False, ) ccd_phase = ac.CCDPhase(full_well_depth=1e3, well_notch_depth=0.0, well_fill_power=1.0) ccd = ac.CCD(phases=[ccd_phase], fraction_of_traps_per_phase=[1.0]) traps = [ac.TrapInstantCapture(10.0, -1.0 / np.log(0.5))] image_via_arctic = cti.add_cti( image=arr, parallel_traps=traps, parallel_ccd=ccd, parallel_roe=roe, parallel_express=3, parallel_offset=3, ) clocker = ac.Clocker2D(parallel_express=3, parallel_roe=roe) image_via_clocker = clocker.add_cti(data=arr, parallel_trap_list=traps, parallel_ccd=ccd_phase) assert image_via_arctic == pytest.approx(image_via_clocker, 1.0e-4) image_via_arctic = cti.add_cti( image=arr, serial_traps=traps, serial_ccd=ccd, serial_roe=roe, serial_express=2, serial_offset=5, ) clocker = ac.Clocker2D(serial_express=2, serial_roe=roe) image_via_clocker = clocker.add_cti(data=arr, serial_trap_list=traps, serial_ccd=ccd_phase) assert image_via_arctic == pytest.approx(image_via_clocker, 1.0e-4)
def test__parallel_and_serial_checks_raise_exception(self, imaging_ci_7x7): model = af.CollectionPriorModel(cti=af.Model( ac.CTI2D, parallel_traps=[ ac.TrapInstantCapture(density=1.1), ac.TrapInstantCapture(density=1.1), ], parallel_ccd=ac.CCDPhase(), )) analysis = ac.AnalysisImagingCI( dataset_ci=imaging_ci_7x7, clocker=None, settings_cti=ac.SettingsCTI2D(parallel_total_density_range=(1.0, 2.0)), ) instance = model.instance_from_prior_medians() with pytest.raises(exc.PriorException): analysis.log_likelihood_function(instance=instance) model = af.CollectionPriorModel(cti=af.Model( ac.CTI2D, serial_traps=[ ac.TrapInstantCapture(density=1.1), ac.TrapInstantCapture(density=1.1), ], serial_ccd=ac.CCDPhase(), )) analysis = ac.AnalysisImagingCI( dataset_ci=[imaging_ci_7x7], clocker=None, settings_cti=ac.SettingsCTI2D(serial_total_density_range=(1.0, 2.0)), ) instance = model.instance_from_prior_medians() with pytest.raises(exc.PriorException): analysis.log_likelihood_function(instance=instance)
def test__add_cti_with_poisson_trap_densities(): arr = np.array(([ [1.0, 1.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], ])) arr = ac.Array2D.manual(array=arr, pixel_scales=1.0).native roe = ac.ROE( dwell_times=[1.0], empty_traps_between_columns=True, empty_traps_for_first_transfers=False, force_release_away_from_readout=True, use_integer_express_matrix=False, ) ccd = ac.CCDPhase(full_well_depth=1e3, well_notch_depth=0.0, well_fill_power=1.0) trap_list = [ ac.TrapInstantCapture(density=10.0, release_timescale=-1.0 / np.log(0.5)) ] clocker = ac.Clocker2D( parallel_poisson_traps=True, poisson_seed=1, parallel_express=3, parallel_roe=roe, serial_express=3, serial_roe=roe, ) image_via_clocker = clocker.add_cti( data=arr, parallel_trap_list=trap_list, parallel_ccd=ccd, serial_trap_list=trap_list, serial_ccd=ccd, ) assert image_via_clocker[0, 0] == pytest.approx(0.980298, 1.0e-4) assert image_via_clocker[0, 1] == pytest.approx(0.9901042, 1.0e-4) assert image_via_clocker[0, 2] == pytest.approx(0.9901981, 1.0e-4) assert (image_via_clocker[:, 3] > 0.0).all()
def test__add_cti_serial_fast__raises_exception_if_nonzero_outside_tuple(): ccd = ac.CCDPhase(full_well_depth=1e3, well_notch_depth=0.0, well_fill_power=1.0) trap_list = [ ac.TrapInstantCapture(density=10.0, release_timescale=-1.0 / np.log(0.5)) ] clocker = ac.Clocker2D(serial_fast_pixels=(1, 3)) arr = np.array(([ [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ])) arr = ac.Array2D.manual(array=arr, pixel_scales=1.0).native with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, serial_trap_list=trap_list, serial_ccd=ccd) arr = np.array(([ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], ])) arr = ac.Array2D.manual(array=arr, pixel_scales=1.0).native with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, serial_trap_list=trap_list, serial_ccd=ccd) arr = np.array(([ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 1.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ])) arr = ac.Array2D.manual(array=arr, pixel_scales=1.0).native with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, serial_trap_list=trap_list, serial_ccd=ccd)
""" clocker = ac.Clocker2D(serial_express=2) """ __CTI Model__ The CTI model used by arCTIc to add CTI to the input image in the serial direction, which contains: - 3 trap species in the parallel direction. - A simple CCD volume beta parametrization. """ serial_trap_0 = ac.TrapInstantCapture(density=0.0442, release_timescale=0.8) serial_trap_1 = ac.TrapInstantCapture(density=0.1326, release_timescale=4.0) serial_trap_2 = ac.TrapInstantCapture(density=3.9782, release_timescale=20.0) serial_ccd = ac.CCDPhase(well_fill_power=0.8, well_notch_depth=0.0, full_well_depth=84700.0) """ __Simulate__ To simulate charge injection imaging, we pass the charge injection pattern to a `SimulatorImagingCI`, which adds CTI via arCTIc and read-noise to the data. This creates instances of the `ImagingCI` class, which include the images, noise-maps and pre_cti_data images. """ simulator = ac.ci.SimulatorImagingCI(read_noise=0.001, pixel_scales=0.1) """ We now pass each charge injection pattern to the simulator. This generate the charge injection image of each exposure and before passing each image to arCTIc does the following: - Uses an input read-out electronics corner to perform all rotations of the image before / after adding CTI.
def test__raises_exception_if_no_traps_or_ccd_passed(): arr = ac.Array2D.manual( array=[[1.0, 2.0], [3.0, 4.0]], pixel_scales=1.0, header=ac.Header(header_sci_obj=None, header_hdu_obj=None, readout_offsets=(3, 5)), ).native ccd_phase = ac.CCDPhase(full_well_depth=1e3, well_notch_depth=0.0, well_fill_power=1.0) traps = [ac.TrapInstantCapture(10.0, -1.0 / np.log(0.5))] clocker = ac.Clocker2D(parallel_express=3) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, parallel_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, serial_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, parallel_trap_list=traps, serial_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, parallel_ccd=ccd_phase) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, serial_ccd=ccd_phase) with pytest.raises(exc.ClockerException): clocker.add_cti(data=arr, parallel_ccd=ccd_phase, serial_ccd=ccd_phase) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, parallel_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, serial_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, parallel_trap_list=traps, serial_trap_list=traps) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, parallel_ccd=ccd_phase) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, serial_ccd=ccd_phase) with pytest.raises(exc.ClockerException): clocker.remove_cti(data=arr, parallel_ccd=ccd_phase, serial_ccd=ccd_phase)