corgidrp.klip_fm#
Functions#
|
_summary_ |
|
Injects a fake psf from the CT calibration object into a corgidrp Image with |
|
Calculates the noise (standard deviation of counts) of an |
|
Measures the throughput of the KLIP algorithm via injection-recovery of fake off-axis sources. |
Module Contents#
- corgidrp.klip_fm.get_closest_psf(ct_calibration, cenx, ceny, dx, dy)[source]#
_summary_ NOTE: CT excam locations have (0,0) as the bottom left corner
of the bottom left pixel
- TODO: Calculate subpixel shifts if star or PSF model aren’t
perfectly in the center of a pixel
- Parameters:
ct_calibration (corgidrp.data.CoreThroughputCalibration) – CT calibration object.
cenx (float) – x location of mask center, measured from the center of the bottom left pixel of the 1024x1024 pixel science array.
ceny (float) – y location of mask center, measured from the center of the bottom left pixel of the 1024x1024 pixel science array.
dx (float) – x separation from the mask center in pixels
dy (float) – y separation from the mask center in pixels
- Returns:
2D PSF model closest to the desired location.
- Return type:
np.array
- corgidrp.klip_fm.inject_psf(frame_in, ct_calibration, amp, sep_pix, pa_deg)[source]#
Injects a fake psf from the CT calibration object into a corgidrp Image with the desired position and amplitude.
- Parameters:
frame_in (corgidrp.data.Image) – 2D image to inject a fake signal into.
ct_calibration (corgidrp.data.CoreThroughputCalibration) – CT calibration object containing PSF samples.
amp (float) – peak pixel amplitude of psf to inject.
sep_pix (float) – separation from star in pixels to inject
pa_deg (float) – position angle to inject (counterclockise from north/up)
- Returns:
a copy of the input Image but with a fake PSF injected.
- Return type:
- corgidrp.klip_fm.measure_noise(frame, seps_pix, hw, klmode_index=None, cand_locs=[], nsigma=1, fwhm=None, small_sample_correction=False)[source]#
- Calculates the noise (standard deviation of counts) of an
annulus at a given separation from the mask or star center, scaled to a given sigma level, with optional small sample statistics correction (Mawet et al. 2014). TODO: Mask known off-axis sources.
- Parameters:
frame (corgidrp.Image) – Image containing data as well as “STARLOCX/Y” in header
seps_pix (np.array of float) – Separations (in pixels from specified center) at which to calculate the noise level.
hw (float) – halfwidth of the annulus to use for noise calculation.
klmode_index (int, optional) – If provided, returns only the noise values for the KL mode with the given index. I.e. klmode_index=0 would return only the values for the first KL mode truncation choice. If None (by default), all indices are returned.
cand_locs (list of tuples, optional) – Locations of known off-axis sources, so we can mask them. This is a list of tuples (sep_pix,pa_degrees) for each source. Defaults to [].
nsigma (float, optional) – Sigma multiplier for the noise. E.g. nsigma=5 returns a 5-sigma noise curve. Defaults to 1.
fwhm (float or array-like, optional) – PSF FWHM in pixels, used for computing the number of resolution elements at each separation when small_sample_correction is True. A scalar is broadcast to all separations; an array must match the length of seps_pix. Required when small_sample_correction is True. Defaults to None.
small_sample_correction (bool, optional) – If True, apply the small sample statistics correction from Mawet et al. (2014) using the Student’s t-distribution. This accounts for the limited number of independent resolution elements at small separations. Defaults to False.
- Returns: np.array: array of shape (number of separations, number of KL modes) containing the annular noise. If klmode_index
specified, the number of KL modes in the output array is 1.
- corgidrp.klip_fm.meas_klip_thrupt(sci_dataset_in, ref_dataset_in, psfsub_dataset, ct_calibration, klip_params, inject_snr=5, sep_spacing=3.0, n_pas=5, seps=None, pas=None, cand_locs=[], num_processes=None)[source]#
Measures the throughput of the KLIP algorithm via injection-recovery of fake off-axis sources.
- Parameters:
sci_dataset_in (corgidrp.data.Dataset) – input dataset containing science observations
ref_dataset_in (corgidrp.data.Dataset) – input dataset containing reference observations (set to None for ADI-only reductions)
psfsub_dataset (corgidrp.data.Dataset) – dataset containing PSF subtraction result
ct_calibration (corgidrp.data.CoreThroughputCalibration) – core throughput calibration object containing off-axis PSFs.
klip_params (dict) – dictionary containing the same KLIP parameters used for PSF subtraction. Must contain the keywords ‘mode’,’annuli’,’subsections’,’movement’,’numbasis’,’outdir’. See corgidrp.l3_to_l4.do_psf_subtraction() for descriptions of each of these parameters.
inject_snr (int, optional) – SNR at which to inject fake PSFs. Defaults to 5.
sep_spacing (float, optional) – multiples of the FWHM at which to space separation samples. Defaults to 3. Overridden by passing in explicit separations to the seps keyword.
n_pas (int,optional) – number of evenly spaced position angles at which to inject PSFs. Defaults to 5. Overridden by in explicit PAs to the pas keyword.
seps (np.array, optional) – Separations (in pixels from the star center) at which to inject fake PSFs. If not provided, a linear spacing of separations between the IWA & OWA will be chosen.
pas (np.array, optional) – Position angles (in degrees counterclockwise from north/up) at which to inject fake PSFs at each separation. Defaults to [0.,90.,180.,270.].
cand_locs (list of tuples, optional) – Locations of known off-axis sources, so we don’t inject a fake PSF too close to them. This is a list of tuples (sep_pix,pa_degrees) for each source. Defaults to [].
num_processes (int) – number of processes for parallelizing the PSF subtraction
- Returns:
array of shape (N,n_seps,2), where N is 1 + the number of KL mode truncation choices and n_seps is the number of separations sampled. Index 0 contains the separations sampled, and each following index contains the dimensionless KLIP throughput and FWHM in pixels measured at each separation for each KL mode truncation choice. An example for 4 KL mode truncation choices, using r1 and r2 for separations and n_seps=2:
[ [[r1,r1],[r2,r2]], [[KL_thpt_r1_KL1, FWHM_r1_KL1],[KL_thpt_r2_KL1, FWHM_r2_KL1]], [[KL_thpt_r1_KL2, FWHM_r1_KL2],[KL_thpt_r2_KL2, FWHM_r2_KL2]], [[KL_thpt_r1_KL3, FWHM_r1_KL3],[KL_thpt_r2_KL3, FWHM_r2_KL3]], [[KL_thpt_r1_KL4, FWHM_r1_KL4],[KL_thpt_r2_KL4, FWHM_r2_KL4]] ]
- Return type:
np.array