corgidrp.mocks#
Attributes#
Functions#
|
Parse a combined CSV (with a Section column) and extract keywords and values |
|
Create a lightweight FluxcalFactor for unit testing. |
|
Creates default L1 headers by reading values from the l1.csv documentation file. |
|
Creates default L1 trap pump headers by reading values from the l1.csv documentation file. |
|
Creates an empty primary header and an Image extension header with currently |
|
Creates an empty primary header and an Image extension header with currently |
|
Creates an empty primary header and an Image extension header with currently |
|
Creates an empty primary header and an Image extension header with currently |
|
Creates an empty primary header and an Image extension header with currently |
|
Creates an empty primary header and an Image extension header with currently |
This function creates the basic primary and extension headers that |
|
|
Create simulated noise maps for test_masterdark_from_noisemaps.py. |
|
Create simulated data specifically for test_calibrate_darks_lsq.py. |
|
Create simulated data to create a master dark. |
|
Create simulated data to check the flat division |
|
Performs raster scan of Neptune or Uranus images |
|
Create simulated data to check the flat division |
|
Turn this flat field dataset of image frames that were taken for performing the flat calibration and |
|
Create simulated data to non-linear data to test non-linearity correction. |
|
Create simulated non-linear data with cosmic rays to test CR detection. |
|
Create simulated raw data. |
|
Create simulated bad pixel map data. Code value is 4. |
|
Reads TVAC nonlinearity table from location specified by ‘filename’. |
|
Takes array of nonlinearity coefficients (from nonlin_coefs function) |
|
This function makes a SCI-sized frame with simulated noise and a fluxmap. It |
|
Create simulated data for astrometric calibration. |
|
Create simulated data not normalized for the exposure time. |
|
Generate mock pump trap data, save it to the output_directory |
|
This creates mock L1 Dataset containing frames with large gain and short exposure time, illuminated and dark frames. |
|
Generate a 2D square array with a centered gaussian surface (for mock PSF data). |
|
Create simulated data for absolute flux calibration. This is a point source with a 2D-Gaussian PSF |
|
Create simulated data for polarimetric absolute flux calibration. Two point sources to |
|
Generate simulated reference star dataset with flux calibration. |
|
Create simulated data for core throughput calibration. This is a set of |
|
Create simulated data for core throughput calibration. This is a set of |
|
Creates a mock CoreThroughputCalibration object with gaussian PSFs. |
|
Create simulated data to test the class function that does core throughput |
|
Generate a mock science and reference dataset ready for the PSF subtraction step. |
|
Create a mock coronagraphic dataset with a star and (optionally) one or more companions. |
|
Create and optionally save a mock FpamFsamCal object. |
|
Create simulated data for core throughput calibration. |
|
Generate a simulated reference star dataset for RDI or ADI+RDI processing. |
|
Creates a synthetic 2D image with Gaussian background noise, a constant background, |
|
Renames FITS files to match CGI filename convention. Extracts visit ID and filetime |
|
Creates a single dataset of synthetic observing frames. The dataset contains: |
|
Generate filename with proper format: cgi_VISITID_YYYYMMDDtHHMMSSS_l2b.fits |
|
Turns a dataset of neptune or uranus images with single planet images into the images observed through the wollaston prisms also incorporates the spatial variation of polarization on the |
|
Creates mock L2b polarimetric data with two polarized images placed on the larger |
|
Creates a mock L2b polarimetric image with two separated polarized channels (left and right), |
|
Generate mock L4 Stokes cube with Gaussian source and controlled polarization. |
|
Create a mock L4 Stokes I image from a mock L4 Stokes cube. |
|
Create a mock Image with [I, Q, U, V] planes for testing. |
|
Generate mock L3 polarimetric datasets with controlled fractional polarization |
|
Calculate the centers of the two polarized images based on the separation and alignment angle. |
|
Generate a mock L2b polarimetric dataset for polcal testing |
|
Create a mock L4 file with 1-D spectroscopy extensions. |
Module Contents#
- corgidrp.mocks.parse_csv_table(csv_file_path, section_name, key_col='Keyword', value_col='Example Value', datatype_col='Datatype')[source]#
Parse a combined CSV (with a Section column) and extract keywords and values from a specified section.
- Parameters:
csv_file_path (str) – Path to the combined CSV file.
section_name (str) – Name of the section to filter on (eg, “Primary Header (HDU 0)” or “Image Header (HDU 1)”).
key_col (str) – Column name holding the keyword (default: “Keyword”).
value_col (str) – Column name holding the example/value (default: “Example Value”).
datatype_col (str) – Column name holding the datatype (default: “Datatype”).
- Returns:
- values are coerced using the datatype column. If the section is not a header
table or required columns are missing, returns an empty dict.
- Return type:
dict
- corgidrp.mocks.make_mock_fluxcal_factor(value, err=0.0, cfam_name='3D', dpam_name='PRISM3', fsam_name='R1C2')[source]#
Create a lightweight FluxcalFactor for unit testing.
- Parameters:
value (float) – Absolute flux calibration factor to store.
err (float, optional) – Uncertainty on the calibration factor.
cfam_name (str, optional) – CFAM filter name recorded in the header.
dpam_name (str, optional) – DPAM name recorded in the header.
fsam_name (str, optional) – FSAM name recorded in the header.
- Returns:
- Calibration object referencing a dummy dataset so tests
can exercise downstream logic without building full calibration files.
- Return type:
- corgidrp.mocks.create_default_L1_headers(arrtype='SCI', vistype='CGIVST_TDD_OBS')[source]#
Creates default L1 headers by reading values from the l1.csv documentation file.
- Parameters:
arrtype (str) – Array type (“SCI” or “ENG”). Defaults to “SCI”.
vistype (str) – Visit type. Defaults to “CGIVST_TDD_OBS”.
- Returns:
prihdr (fits.Header): Primary FITS header with L1 keywords exthdr (fits.Header): Extension FITS header with L1 keywords
- Return type:
tuple
- corgidrp.mocks.create_default_L1_TrapPump_headers(arrtype='SCI')[source]#
Creates default L1 trap pump headers by reading values from the l1.csv documentation file.
- Parameters:
arrtype (str) – Array type (“SCI” or “ENG”). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS header with L1 trap pump keywords exthdr (fits.Header): Extension FITS header with L1 trap pump keywords
- Return type:
tuple
- corgidrp.mocks.create_default_L2a_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header biashdr (fits.Header): Bias FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_L2a_TrapPump_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header biashdr (fits.Header): Bias FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_L2b_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header biashdr (fits.Header): Bias FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_L2b_TrapPump_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header biashdr (fits.Header): Bias FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_L3_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_L4_headers(arrtype='SCI')[source]#
- Creates an empty primary header and an Image extension header with currently
defined keywords.
- Parameters:
arrtype (str) – Array type (SCI or ENG). Defaults to “SCI”.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header
- Return type:
tuple
- corgidrp.mocks.create_default_calibration_product_headers()[source]#
- This function creates the basic primary and extension headers that
would be used in a calibration product. Each individual calibration product should add additional headers as required.
- Returns:
prihdr (fits.Header): Primary FITS Header exthdr (fits.Header): Extension FITS Header errhdr (fits.Header): Error FITS Header dqhdr (fits.Header): Data quality FITS Header
- Return type:
tuple
- corgidrp.mocks.create_noise_maps(FPN_map, FPN_map_err, FPN_map_dq, CIC_map, CIC_map_err, CIC_map_dq, DC_map, DC_map_err, DC_map_dq)[source]#
Create simulated noise maps for test_masterdark_from_noisemaps.py.
- Parameters:
FPN_map – 2D np.array for fixed-pattern noise (FPN) data array
FPN_map_err – 2D np.array for FPN err array
FPN_map_dq – 2D np.array for FPN DQ array
CIC_map – 2D np.array for clock-induced charge (CIC) data array
CIC_map_err – 2D np.array for CIC err array
CIC_map_dq – 2D np.array for CIC DQ array
DC_map – 2D np.array for dark current data array
DC_map_err – 2D np.array for dark current err array
DC_map_dq – 2D np.array for dark current DQ array
- Returns:
corgidrp.data.DetectorNoiseMaps instance
- corgidrp.mocks.create_synthesized_master_dark_calib(detector_areas)[source]#
Create simulated data specifically for test_calibrate_darks_lsq.py.
- Parameters:
detector_areas – dict
found (a dictionary of detector geometry properties. Keys should be as)
detector.py. (in detector_areas in)
- Returns:
corgidrp.data.Dataset instances
- Return type:
dataset
The simulated dataset
- corgidrp.mocks.create_dark_calib_files(filedir=None, numfiles=10)[source]#
Create simulated data to create a master dark. Assume these have already undergone L1 processing and are L2a level products
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Defaults to 10.
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.create_simflat_dataset(filedir=None, numfiles=10)[source]#
Create simulated data to check the flat division
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Defaults to 10.
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.create_raster(mask, data, dither_sizex=None, dither_sizey=None, row_cent=None, col_cent=None, n_dith=None, mask_size=420, snr=250, planet=None, band=None, radius=None, snr_constant=None)[source]#
Performs raster scan of Neptune or Uranus images
- Parameters:
mask (int) – (Required) Mask used for the image. (Size of the HST images, 420 X 420 pixels with random values mean=1, std=0.03)
data (float) – (Required) Data in array npixels*npixels format to be raster scanned
dither_sizex (int) – (Required) Size of the dither in X axis in pixels (number of pixels across the planet (neptune=50 and uranus=65))
dither_sizey (int) – (Required) Size of the dither in X axis in pixels (number of pixels across the planet (neptune=50 and uranus=65))
row_cent (int) – (Required) X coordinate of the centroid
col_cent (int) – (Required) Y coordinate of the centroid
n_dith (int) – number of dithers required
mask_size (int) – Size of the mask in pixels (Size of the HST images, 420 X 420 pixels with random values mean=1, std=0.03)
snr (int) – Required SNR in the planet images (=250 in the HST images)
planet (str) – neptune or uranus
band (str) – 1 or 4
radius (int) – radius of the planet in pixels (radius=54 for neptune, radius=90)
snr_constant (int) – constant for snr reference (4.95 for band1 and 9.66 for band4)
Returns
dither_stack_norm (np.array) – stacked dithers of the planet images
cent (np.array) – centroid of images
- corgidrp.mocks.create_onsky_rasterscans(dataset, filedir=None, planet=None, band=None, im_size=420, d=None, n_dith=3, radius=None, snr=250, snr_constant=None, flat_map=None, raster_radius=40, raster_subexps=1)[source]#
Create simulated data to check the flat division
- Parameters:
dataset (corgidrp.data.Dataset) – dataset of HST images of neptune and uranus
filedir (str) – Full path to directory to save the raster scanned images.
planet (str) – neptune or uranus
band (str) – 1 or 4
im_size (int) – x-dimension of the planet image (in pixels= 420 for the HST images)
d (int) – number of pixels across the planet (neptune=50 and uranus=65)
n_dith (int) – Number of dithers required (Default is 3)
radius (int) – radius of the planet in pixels (radius=54 for neptune, radius=90 in HST images)
snr (int) – SNR required for the planet image (default is 250 for the HST images)
snr_constant (int) – constant for snr reference (4.95 for band1 and 9.66 for band4)
flat_map (np.array) – a user specified flat map. Must have shape (im_size, im_size). Default: None; assumes each pixel drawn from a normal distribution with 3% rms scatter
raster_radius (float) – radius of circular raster done to smear out image during observation, in pixels
raster_subexps (int) – number of subexposures that consist of a singular raster. Currently just duplicates images and does not simulate partial rasters
- Returns:
The simulated dataset of raster scanned images of planets uranus or neptune
- Return type:
- corgidrp.mocks.create_flatfield_dummy(filedir=None, numfiles=2)[source]#
Turn this flat field dataset of image frames that were taken for performing the flat calibration and to make one master flat image
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Defaults to 1 to create the dummy flat can be changed to any number
- Returns:
a set of flat field images
- Return type:
- corgidrp.mocks.create_nonlinear_dataset(nonlin_filepath, filedir=None, numfiles=2, em_gain=2000)[source]#
Create simulated data to non-linear data to test non-linearity correction.
- Parameters:
nonlin_filepath (str) – path to FITS file containing nonlinear calibration data (e.g., tests/test_data/nonlin_sample.fits)
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Defaults to 2 (not creating the cal here, just testing the function)
em_gain (int) – The EM gain to use for the simulated data. Defaults to 2000.
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.create_cr_dataset(nonlin_filepath, filedir=None, obs_datetime=None, numfiles=2, em_gain=500, numCRs=5, plateau_length=10)[source]#
Create simulated non-linear data with cosmic rays to test CR detection.
- Parameters:
nonlin_filepath (str) – path to FITS file containing nonlinear calibration data (e.g., tests/test_data/nonlin_sample.fits)
filedir (str) – (Optional) Full path to directory to save to.
obs_datetime (astropy.time.Time) – (Optional) Date and time of the observations to simulate.
numfiles (int) – Number of files in dataset. Defaults to 2 (not creating the cal here, just testing the function)
em_gain (int) – The EM gain to use for the simulated data. Defaults to 2000.
numCRs (int) – The number of CR hits to inject. Defaults to 5.
plateau_length (int) – The minimum length of a CR plateau that will be flagged by the filter.
- Returns:
The simulated dataset.
- Return type:
- corgidrp.mocks.create_prescan_files(filedir=None, numfiles=2, arrtype='SCI')[source]#
Create simulated raw data.
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Defaults to 2.
arrtype (str) – Observation type. Defaults to “SCI”.
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.create_badpixelmap_files(filedir=None, col_bp=None, row_bp=None)[source]#
Create simulated bad pixel map data. Code value is 4.
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
col_bp (array) – (Optional) Array of column indices where bad detector pixels are found.
row_bp (array) – (Optional) Array of row indices where bad detector pixels are found.
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.nonlin_coefs(filename, EMgain, order)[source]#
Reads TVAC nonlinearity table from location specified by ‘filename’. The column in the table closest to the ‘EMgain’ value is selected and fits a polynomial of order ‘order’. The coefficients of the fit are adjusted so that the polynomial function equals unity at 3000 DN. Outputs array polynomial coefficients, array of DN values from the TVAC table, and an array of the polynomial function values for all the DN values.
- Parameters:
filename (string) – file name
EMgain (int) – em gain value
order (int) – polynomial order
- Returns:
fit coefficients np.array: DN values np.array: fit values
- Return type:
np.array
- corgidrp.mocks.nonlin_factor(coeffs, DN)[source]#
Takes array of nonlinearity coefficients (from nonlin_coefs function) and an array of DN values and returns the nonlinearity values array. If the DN value is less 800 DN, then the nonlinearity value at 800 DN is returned. If the DN value is greater than 10000 DN, then the nonlinearity value at 10000 DN is returned.
- Parameters:
coeffs (np.array) – nonlinearity coefficients
DN (int) – DN value
- Returns:
nonlinearity value
- Return type:
float
- corgidrp.mocks.make_fluxmap_image(f_map, bias, kgain, rn, emgain, time, coeffs, nonlin_flag=False, divide_em=False)[source]#
This function makes a SCI-sized frame with simulated noise and a fluxmap. It also performs bias-subtraction and division by EM gain if required. It is used in the unit tests test_nonlin.py and test_kgain_cal.py
- Parameters:
f_map (np.array) – fluxmap in e/s/px. Its size is 1024x1024 pixels.
bias (float) – bias value in electrons.
kgain (float) – value of K-Gain in electrons per DN.
rn (float) – read noise in electrons.
emgain (float) – calue of EM gain.
time (float) – exposure time in sec.
coeffs (np.array) – array of cubic polynomial coefficients from nonlin_coefs.
nonlin_flag (bool) – (Optional) if nonlin_flag is True, then nonlinearity is applied.
divide_em (bool) – if divide_em is True, then the emgain is divided
- Returns:
corgidrp.data.Image
- corgidrp.mocks.create_astrom_data(field_path, filedir=None, image_shape=(1024, 1024), target=(80.553428801, -69.514096821), offset=(0, 0), subfield_radius=0.03, platescale=21.8, rotation=45, add_gauss_noise=True, distortion_coeffs_path=None, dither_pointings=0, bpix_map=None, sim_err_map=False)[source]#
Create simulated data for astrometric calibration.
- Parameters:
field_path (str) – Full path to directory with test field data (ra, dec, vmag, etc.)
filedir (str) – (Optional) Full path to directory to save to. (default: None)
image_shape (tuple of ints) – The desired shape of the image (num y pixels, num x pixels), (default: (1024, 1024))
target (tuple) – The original pointing target in RA/DEC [deg] (default: (80.553428801, -69.514096821))
offset (tuple) – The RA/DEC [deg] injected offset from the target pointing (default: (0,0))
subfield_radius (float) – The radius [deg] around the target coordinate for creating a subfield to produce the image from (default: 0.03 [deg])
platescale (float) – The plate scale of the created image data (default: 21.8 [mas/pixel])
rotation (float) – The north angle of the created image data (default: 45 [deg])
add_gauss_noise (boolean) – Argument to determine if gaussian noise should be added to the data (default: True)
distortion_coeffs_path (str) – Full path to csv with the distortion coefficients and the order of polynomial used to describe distortion (default: None))
dither_pointings (int) – Number of dithers to include with the dataset. Dither offset is assumed to be half the FoV. (default: 0)
bpix_map (np.array) – 2D bad pixel map to apply to simulated data (default: None)
sim_err_map (boolean) – If True, simulates an error map (default: False)
- Returns:
The simulated dataset
- Return type:
- corgidrp.mocks.create_not_normalized_dataset(filedir=None, numfiles=10)[source]#
Create simulated data not normalized for the exposure time.
- Parameters:
filedir (str) – (Optional) Full path to directory to save to.
numfiles (int) – Number of files in dataset. Default is 10.
- Returns:
the simulated dataset
- Return type:
- corgidrp.mocks.generate_mock_pump_trap_data(output_dir, meta_path, EMgain=10, read_noise=100, eperdn=6, e2emode=False, nonlin_path=None, arrtype='SCI')[source]#
Generate mock pump trap data, save it to the output_directory
- Parameters:
output_dir (str) – output directory
meta_path (str) – metadata path
EMgain (float) – desired EM gain for frames
read_noise (float) – desired read noise for frames
eperdn (float) – desired k gain (e-/DN conversion factor)
e2emode (bool) – If True, e2e simulated data made instead of data for the unit test. Difference b/w the two: This e2emode data differs from the data generated when e2emode is False in the following ways: -The bright pixel of each trap is simulated in a more realistic way (i.e., at every phase time frame). -Simulated readout is more realistic (read noise, EM gain, k gain, nonlinearity, bias invoked after traps simulated). In the other dataset (when e2emode is False), readout was simulated before traps were added, and no nonlinearity was applied. Also, the number of electrons in the dark pixels of the dipoles can no longer be negative, and this condition is enforced. -The number of pumps and injected charge are much higher in these frames so that traps stand out above the read noise. This was not an issue in the other dataset since read noise was added to frames that were EM-gained before charge was injected, which suppressed the effective read noise. -The EM gain used is 1.5. For a large injected charge amount, the EM gain cannot be very high because of the risk of saturation. -The number of phase times is 10 per scheme, to reduce the dataset size (compared to 100 when e2emode is False). -The frame format is ENG, as real trap-pump data is.
nonlin_path (str) – Path of nonlinearity correction file to use. The inverse is applied, implementing rather than correcting nonlinearity. If None, no nonlinearity is applied. Defaults to None.
arrtype (str) – array type (for this function, choice of ‘SCI’ or ‘ENG’)
- corgidrp.mocks.create_photon_countable_frames(Nbrights=30, Ndarks=40, EMgain=5000.0, kgain=7.0, exptime=0.05, cosmic_rate=0, full_frame=True, smear=True, flux=1, bad_frames=0, cic=0.01, dark_current=0.000833, read_noise=100.0, bias=20000, qe=0.9)[source]#
This creates mock L1 Dataset containing frames with large gain and short exposure time, illuminated and dark frames. Used for unit tests for photon counting.
- Parameters:
Nbrights (int) – number of illuminated frames to simulate
Ndarks (int) – number of dark frames to simulate
EMgain (float) – EM gain
kgain (float) – k gain (e-/DN)
exptime (float) – exposure time (in s)
cosmic_rate – (float) simulated cosmic rays incidence, hits/cm^2/s
full_frame – (bool) If True, simulated frames are SCI full frames. If False, 50x50 images are simulated. Defaults to True.
smear – (bool) If True, smear is simulated. Defaults to True.
flux – (float) Number of photons/s per pixel desired. Defaults to 1.
bad_frames (int) – Number of simulated bad frames (with primary header keyword ‘OVEREXP’ set to True) to include in output datasets that frame_select would catch by default. Defaults to 0.
cic (float) – simulated clock-induced charge (CIC) in e-/pix/frame. Defaults to 0.01.
dark_current (float) – simulated dark current in e-/pix/s. Defaults to 8.33e-4.
read_noise (float) – simulated read noise in e-/pix/frame. Defaults to 100.
bias (float) – simulated bias in e-. Defaults to 20000.
qe (float) – quantum efficiency, e-/photon. Defaults to 0.9.
- Returns:
Dataset containing the illuminated frames dark_dataset (corgidrp.data.Dataset): Dataset containing the dark frames ill_mean (float): mean electron count value simulated in the illuminated frames dark_mean (float): mean electron count value simulated in the dark frames
- Return type:
ill_dataset (corgidrp.data.Dataset)
- corgidrp.mocks.gaussian_array(array_shape=[50, 50], sigma=2.5, amp=100.0, xoffset=0.0, yoffset=0.0)[source]#
Generate a 2D square array with a centered gaussian surface (for mock PSF data).
- Parameters:
array_shape (int, optional) – Shape of desired array in pixels. Defaults to [50,50].
sigma (float, optional) – Standard deviation of the gaussian curve, in pixels. Defaults to 5.
amp (float,optional) – Amplitude (peak) of gaussian curve. Defaults to 1.
xoffset (float,optional) – x offset of gaussian from array center. Defaults to 0.
yoffset (float,optional) – y offset of gaussian from array center. Defaults to 0.
- Returns:
2D array of a gaussian surface.
- Return type:
np.array
- corgidrp.mocks.create_flux_image(star_flux, fwhm, cal_factor, filter='3C', fpamname='HOLE', target_name='Vega', fsm_x=0.0, fsm_y=0.0, exptime=1.0, filedir=None, platescale=21.8, background=0, add_gauss_noise=True, noise_scale=1.0, file_save=False)[source]#
Create simulated data for absolute flux calibration. This is a point source with a 2D-Gaussian PSF and Gaussian noise.
- Parameters:
star_flux (float) – Flux of the point source in erg/(s*cm^2*AA)
fwhm (float) – Full width at half max (FWHM) of the centroid
cal_factor (float) – Calibration factor erg/(s*cm^2*AA)/electron/s
filter (str) – (Optional) The CFAM filter used.
fpamname (str) – (Optional) Position of the FPAM
target_name (str) – (Optional) Name of the calspec star
fsm_x (float) – (Optional) X position shift in milliarcseconds (mas)
fsm_y (float) – (Optional) Y position shift in milliarcseconds (mas)
exptime (float) – (Optional) Exposure time (s)
filedir (str) – (Optional) Directory path to save the output file
platescale (float) – Plate scale in mas/pixel (default: 21.8 mas/pixel)
background (float) – optional additive background value
add_gauss_noise (bool) – Whether to add Gaussian noise to the data (default: True)
noise_scale (float) – Spread of the Gaussian noise
file_save (bool) – Whether to save the image (default: False)
- Returns:
The simulated image
- Return type:
- corgidrp.mocks.create_pol_flux_image(star_flux_left, star_flux_right, fwhm, cal_factor, filter='3C', dpamname='POL0', fpamname='HOLE', target_name='Vega', fsm_x=0.0, fsm_y=0.0, exptime=1.0, filedir=None, platescale=21.8, background=0, add_gauss_noise=True, noise_scale=1.0, file_save=False)[source]#
Create simulated data for polarimetric absolute flux calibration. Two point sources to simulate images split by polarization, with a 2D-Gaussian PSF and Gaussian noise.
- Parameters:
star_flux_left (float) – Flux of the point source on the left size of the image in erg/(s*cm^2*AA)
star_flux_right (float) – Flux of the point source on the right size of the image in erg/(s*cm^2*AA)
fwhm (float) – Full width at half max (FWHM) of the centroid
cal_factor (float) – Calibration factor erg/(s*cm^2*AA)/electron/s
filter (str) – (Optional) The CFAM filter used.
dpamname (str) – (Optional) The wollaston prism being used
fpamname (str) – (Optional) Position of the FPAM
target_name (str) – (Optional) Name of the calspec star
fsm_x (float) – (Optional) X position shift in milliarcseconds (mas)
fsm_y (float) – (Optional) Y position shift in milliarcseconds (mas)
exptime (float) – (Optional) Exposure time (s)
filedir (str) – (Optional) Directory path to save the output file
platescale (float) – Plate scale in mas/pixel (default: 21.8 mas/pixel)
background (float) – optional additive background value
add_gauss_noise (bool) – Whether to add Gaussian noise to the data (default: True)
noise_scale (float) – Spread of the Gaussian noise
file_save (bool) – Whether to save the image (default: False)
- Returns:
The simulated image
- Return type:
- corgidrp.mocks.generate_reference_star_dataset_with_flux(n_frames=3, pa_aper_degs=None, flux_erg_s_cm2=1e-13, fwhm=3.0, cal_factor=10000000000.0, optical_throughput=1.0, color_cor=1.0, filter='3C', fpamname='HOLE', target_name='Vega', fsm_x=0.0, fsm_y=0.0, exptime=1.0, pltscale_mas=21.8, background=0, add_gauss_noise=True, noise_scale=1.0, filedir=None, file_save=False, shape=(1024, 1024))[source]#
Generate simulated reference star dataset with flux calibration. This function creates multiple frames of a reference star (with no planet) using create_flux_image(), and assigns unique PA_APER angles to each frame’s header. The generated frames can then be used for RDI or ADI+RDI processing in pyKLIP.
- Parameters:
n_frames (int) – Number of frames to generate.
pa_aper_degs (list or None) – PA_APER angles (in degrees) for each frame. If None, all frames use 0.0.
flux_erg_s_cm2 (float) – Stellar flux in erg s⁻¹ cm⁻².
fwhm (float) – Full Width at Half Maximum of the star’s PSF.
cal_factor (float) – Calibration factor [e⁻/erg] to convert flux to electron counts.
optical_throughput (float) – Overall optical throughput factor.
color_cor (float) – Color correction factor.
filter (str) – Filter identifier.
fpamname (str) – FPAM name indicating the pupil mask configuration.
target_name (str) – Name of the target star.
fsm_x (float) – Field Stabilization Mirror (FSM) x-offset.
fsm_y (float) – Field Stabilization Mirror (FSM) y-offset.
exptime (float) – Exposure time in seconds.
pltscale_mas (float) – Plate scale (e.g., mas/pixel or arcsec/pixel) of the image.
background (int) – Background level counts.
add_gauss_noise (bool) – If True, add Gaussian noise to the image.
noise_scale (float) – Scaling factor for the Gaussian noise.
filedir (str or None) – Directory to save the generated files if file_save is True.
file_save (bool) – Flag to save each generated frame to disk.
shape (tuple) – Shape (ny, nx) of the generated images.
- Returns:
A Dataset object containing the generated reference star frames.
- Return type:
Dataset (corgidrp.Data.Dataset)
- corgidrp.mocks.create_ct_psfs(fwhm_mas, cfam_name='1F', n_psfs=10, e2e=False)[source]#
Create simulated data for core throughput calibration. This is a set of individual, noiseless 2D Gaussians, one per image.
- Parameters:
fwhm_mas (float) – PSF’s FWHM in mas
cfam_name (str) (optional) – CFAM filter name.
n_psfs (int) (optional) – Number of simulated PSFs.
e2e (bool) (optional) – Whether these simulated data are for the CT e2e test or not. If they are, the files are L2b. Otherwise, they are L3.
- Returns:
The simulated PSF Images np.array: PSF locations np.array: PSF CT values
- Return type:
- corgidrp.mocks.create_ct_psfs_with_mask(fwhm_mas, cfam_name='1F', n_psfs=10, image_shape=(1024, 1024), apply_mask=True, total_counts=10000.0)[source]#
Create simulated data for core throughput calibration. This is a set of individual, noiseless 2D Gaussians with a spatially varying throughput that mimics a central occulting mask when apply_mask=True.
- Parameters:
fwhm_mas (float) – PSF FWHM in mas.
cfam_name (str) – CFAM filter name.
n_psfs (int) – Number of PSFs to generate.
image_shape (tuple) – Full image shape.
apply_mask (bool) – If True, apply the mask transmission function. If False, the transmission is set to 1 everywhere.
total_counts (float) – The desired total integrated counts in the unmasked PSF.
- Returns:
List of Image objects with the PSF stamp inserted. psf_loc (np.array): Array of PSF locations. half_psf (np.array): Array of “half” throughput values (roughly total_counts/2 after mask).
- Return type:
data_psf (list)
- corgidrp.mocks.create_ct_cal(fwhm_mas, cfam_name='1F', cenx=50.5, ceny=50.5, nx=21, ny=21, psfsize=None)[source]#
Creates a mock CoreThroughputCalibration object with gaussian PSFs.
- Parameters:
fwhm_mas (float) – FWHM in milliarcseconds
cfam_name (str, optional) – CFAM name, defaults to ‘1F’.
cenx (float, optional) – EXCAM mask center X location (measured from bottom left corner of bottom left pixel)
ceny (float, optional) – EXCAM mask center Y location (measured from bottom left corner of bottom left pixel)
nx (int, optional) – Number of x positions at which to simulate mock PSFs. Must be an odd number. PSFs will be generated in the center of each pixel within nx/2 pixels of the mask center. Defaults to 21.
ny (int, optional) – Number of y positions at which to simulate mock PSFs. Must be an odd number. PSFs will be generated in the center of each pixel within nx/2 pixels of the mask center. Defaults to 21.
psfsize (int,optional) – Size of psf model array in pixels. Must be an odd number. Defaults to 6 * the FWHM.
- Returns:
mock CoreThroughputCalibration object
- Return type:
- corgidrp.mocks.create_ct_interp(n_radii=9, n_azimuths=5, min_angle=0, max_angle=6.2831853072, norm=1, fpm_x=0, fpm_y=0, pop_index=None)[source]#
Create simulated data to test the class function that does core throughput interpolation. We want to set the CT to a known function. We accomplish it by using a synthetic PSF shape with a well defined CT profile. The PSF is needed because the interpolation function takes a CT cal file that is generated from a Dataset of PSF images.
- Parameters:
n_radii (int) – Number of divisions along a radial direction.
n_azimuths (int) – Number of divisions along the azimuth, from zero to max_angle.
min_angle (float) – Minimum angle in radians to be considered.
max_angle (float) – Maximum angle in radians to be considered.
norm (float) – Factor to multiply the CT profile. Useful if one wants the CT to be between 0 and 1 after the division by the total counts that happens when estimating the CT of the Dataset in corethroughput.py.
fpm_x (float) – FPM location in EXCAM (fractional) pixels. First dimension.
fpm_y (float) – FPM location in EXCAM (fractional) pixels. Second dimension.
pop_index (int) (optional) – the Dataset skips the PSF with this index. Useful when testing interpolation by popping some PSFs and comparing the interpolated values with the original ones at the same location.
- Returns:
The simulated PSF Images np.array: PSF locations np.array: PSF CT values
- Return type:
- corgidrp.mocks.default_wcs_string = Multiline-String[source]#
Show Value
"""WCSAXES = 2 / Number of coordinate axes CRPIX1 = 0.0 / Pixel coordinate of reference point CRPIX2 = 0.0 / Pixel coordinate of reference point CDELT1 = 1.0 / Coordinate increment at reference point CDELT2 = 1.0 / Coordinate increment at reference point CRVAL1 = 0.0 / Coordinate value at reference point CRVAL2 = 0.0 / Coordinate value at reference point LATPOLE = 90.0 / [deg] Native latitude of celestial pole MJDREF = 0.0 / [d] MJD of fiducial time """
- corgidrp.mocks.create_psfsub_dataset(n_sci, n_ref, pa_aper_degs, darkhole_scifiles=None, darkhole_reffiles=None, wcs_header=None, data_shape=[100, 100], centerxy=None, outdir=None, st_amp=100.0, noise_amp=1.0, fwhm_pix=2.5, ref_psf_spread=1.0, pl_contrast=0.001, pl_sep=10.0)[source]#
Generate a mock science and reference dataset ready for the PSF subtraction step. TODO: reference a central pixscale number, rather than hard code.
- Parameters:
n_sci (int) – number of science frames, must be >= 1.
n_ref (int) – nummber of reference frames, must be >= 0.
pa_aper_degs (list-like) – list of the PA_APER angles of each science and reference frame, with the science frames listed first.
darkhole_scifiles (list of str, optional) – Filepaths to the darkhole science frames. If not provided, a noisy 2D gaussian will be used instead. Defaults to None.
darkhole_reffiles (list of str, optional) – Filepaths to the darkhole reference frames. If not provided, a noisy 2D gaussian will be used instead. Defaults to None.
wcs_header (astropy.fits.Header, optional) – Fits header object containing WCS information. If not provided, a mock header will be created. Defaults to None.
data_shape (list of int) – desired shape of data array, with the last two axes in xy order. Must have length 2 or 3. Defaults to [100,100].
centerxy (list of float) – Desired PSF center in xy order. Must have length 2. Defaults to image center.
outdir (str, optional) – Desired output directory. If not provided, data will not be saved. Defaults to None.
st_amp (float) – Amplitude of stellar psf added to fake data. Defaults to 100.
fwhm_pix (float) – FWHM of the stellar (and optional planet) PSF. Defaults to 2.5.
noise_amp (float) – Amplitude of gaussian noise added to fake data. Defaults to 1.
ref_psf_spread (float) – Fractional increase in gaussian PSF width between science and reference PSFs. Defaults to 1.
pl_contrast (float) – Flux ratio between planet and starlight incident on the detector. Defaults to 1e-3.
pl_sep (float) – Planet-star separation in pixels. Defaults to 10.
- Returns:
corgiDRP science Dataset object and reference Dataset object.
- Return type:
tuple
- corgidrp.mocks.generate_coron_dataset_with_companions(n_frames=1, shape=(1024, 1024), host_star_center=None, host_star_counts=100000.0, pa_aper_degs=None, companion_sep_pix=None, companion_pa_deg=None, companion_counts=100.0, filter='1F', pltscale_as=21.8, add_noise=False, noise_std=0.01, outdir=None, darkhole_file=None, apply_coron_mask=True, coron_mask_radius=5, throughput_factors=1)[source]#
Create a mock coronagraphic dataset with a star and (optionally) one or more companions.
In this version, a Gaussian star is always injected at host_star_center. When the coronagraph mask is applied, the flux within the inner mask region is scaled down by a factor of 1e-3.
- Parameters:
n_frames (int) – Number of frames.
shape (tuple) – (ny, nx) image shape.
host_star_center (tuple) – (x, y) pixel coordinates of the host star. If None, uses image center.
host_star_counts (float) – Total counts for the star.
pa_aper_degs (list of float) – One PA_APER angle per frame (in degrees).
companion_sep_pix (float or list) – On-sky separation(s) of the companion(s) in pixels.
companion_pa_deg (float or list) – On-sky position angle(s) of the companion(s) (counterclockwise from north).
companion_counts (float or list) – Total flux (counts) of the companion(s).
filter (str) – Filter name.
pltscale_as (float) – Plate scale in arcsec per pixel.
add_noise (bool) – Whether to add random noise.
noise_std (float) – Stddev of the noise.
outdir (str or None) – If given, saves the frames to disk.
darkhole_file (Image) – Ignored in this version.
apply_coron_mask (bool) – Whether to apply the simulated coronagraph mask.
coron_mask_radius (int) – Coronagraph mask radius in pixels.
throughput_factors (float) – Optical throughput of companion due to the presence of a coronagraph mask.
- Returns:
A dataset of frames (each an Image) with the star and companion(s) injected.
- Return type:
- corgidrp.mocks.create_mock_fpamfsam_cal(fpam_matrix=None, fsam_matrix=None, date_valid=None, save_file=False, output_dir=None, filename=None)[source]#
Create and optionally save a mock FpamFsamCal object.
- Parameters:
fpam_matrix (np.ndarray of shape (2,2) or None) – The custom transformation matrix from FPAM to EXCAM. If None, defaults to FpamFsamCal.fpam_to_excam_modelbased.
fsam_matrix (np.ndarray of shape (2,2) or None) – The custom transformation matrix from FSAM to EXCAM. If None, defaults to FpamFsamCal.fsam_to_excam_modelbased.
date_valid (astropy.time.Time or None) – Date/time from which this calibration is valid. If None, defaults to the current time.
save_file (bool, optional) – If True, save the generated calibration file to disk.
output_dir (str, optional) – Directory in which to save the file if save_file=True. Defaults to current dir.
filename (str, optional) – Filename to use if saving to disk. If None, a default name is generated.
- Returns:
- The newly-created FpamFsamCal
object (in memory).
- Return type:
FpamFsamCal (corgidrp.data.FpamFsamCal object)
- corgidrp.mocks.create_mock_ct_dataset_and_cal_file(fwhm=50, n_psfs=100, cfam_name='1F', pupil_value_1=1, pupil_value_2=3, seed=None, save_cal_file=False, cal_filename=None, image_shape=(1024, 1024), total_counts=10000.0)[source]#
Create simulated data for core throughput calibration. This function generates a mock dataset consisting of off-axis PSF images and pupil images, which are used to compute a core throughput calibration file. Two sets of PSF images are created: one with a simulated coronagraph mask (throughput reduced) and one without (unmasked). A calibration object is then generated from the masked dataset. Optionally, the calibration file can be saved to disk.
- Parameters:
fwhm (float) – Full Width at Half Maximum of the off-axis PSFs.
n_psfs (int) – Number of PSF images to generate.
cfam_name (str) – CFAM filter name used in the image headers.
pupil_value_1 (int) – Pixel value to assign to the first pupil image patch.
pupil_value_2 (int) – Pixel value to assign to the second pupil image patch.
seed (int or None) – Random seed for reproducibility. If provided, sets the NumPy random seed.
save_cal_file (bool) – If True, save the generated core throughput calibration file to disk.
cal_filename (str or None) – Filename for the calibration file. If None, a filename is generated based on the current time.
image_shape (tuple) – Shape (ny, nx) of the generated images.
total_counts (float) – Total counts assigned to the PSF images.
- Returns:
Dataset of masked (throughput reduced) PSF images. ct_cal (CoreThroughputCalibration): Generated core throughput calibration object. dataset_ct_nomask (Dataset): Dataset of unmasked PSF images.
- Return type:
dataset_ct_masked (Dataset)
- corgidrp.mocks.generate_reference_star_dataset(n_frames=3, shape=(200, 200), star_center=(100, 100), host_star_counts=100000.0, pa_aper_degs=None, add_noise=False, noise_std=0.01, outdir=None)[source]#
Generate a simulated reference star dataset for RDI or ADI+RDI processing. This function creates a set of mock frames of a reference star behind a coronagraph (with no planet), represented as a 2D Gaussian with a central masked (throughput-reduced) region. The resulting frames are assembled into a Dataset object and can optionally be saved to disk.
- Parameters:
n_frames (int) – Number of frames to generate.
shape (tuple) – Image shape (ny, nx) for each generated frame.
star_center (tuple) – Pixel coordinates (x, y) of the star center in the image.
host_star_counts (float) – Total integrated counts for the host star.
pa_aper_degs (list or None) – PA_APER angles (in degrees) for each frame. If None, all frames are assigned 0.0.
add_noise (bool) – If True, add Gaussian noise to the images.
noise_std (float) – Standard deviation of the Gaussian noise.
outdir (str or None) – Directory to which the frames are saved if provided.
- Returns:
A Dataset object containing the generated reference star frames.
- Return type:
dataset (corgidrp.Data.Dataset)
- corgidrp.mocks.create_synthetic_satellite_spot_image(image_shape, bg_sigma, bg_offset, gaussian_fwhm, separation, star_center=None, angle_offset=0, amplitude_multiplier=10)[source]#
Creates a synthetic 2D image with Gaussian background noise, a constant background, and four symmetric Gaussians.
- Parameters:
image_shape (tuple of int) – The (ny, nx) shape of the image.
bg_sigma (float) – Standard deviation of the background Gaussian noise.
bg_offset (float) – Constant background level added to the entire image.
gaussian_fwhm (float) – Full width at half maximum (FWHM) for the 2D Gaussian sources (in pixels).
separation (float) – Radial separation (in pixels) of each Gaussian from the specified center.
star_center (tuple of float, optional) – Absolute (x, y) position in the image at which the four Gaussians will be centered. If None, defaults to the image center (nx//2, ny//2).
angle_offset (float, optional) – An additional angle (in degrees) to add to each default position angle. The default Gaussians are at [0, 90, 180, 270] degrees; the final angles will be these plus the angle_offset. Positive offsets rotate the Gaussians counterclockwise.
amplitude_multiplier (float, optional) – Multiplier for the amplitude of the Gaussians relative to bg_sigma. By default, each Gaussian’s amplitude is 10 * bg_sigma.
- Returns:
The synthetic image (2D NumPy array) with background noise, a constant background, and four added Gaussians.
- Return type:
numpy.ndarray
- corgidrp.mocks.rename_files_to_cgi_format(list_of_fits=None, output_dir=None, level_suffix='l1', pattern=None)[source]#
Renames FITS files to match CGI filename convention. Extracts visit ID and filetime from headers and creates proper CGI format filenames.
- Parameters:
list_of_fits (list, optional) – List of FITS file paths or Image objects to rename. If None, will search for files using pattern.
output_dir (str, optional) – Directory to write renamed files to. If None, files are renamed in-place.
level_suffix (str, optional) – Level suffix for filenames (e.g., “l1”, “l2a”, etc.)
pattern (str, optional) – Glob pattern to find files if list_of_fits is None. Used for pump trap data renaming.
- Returns:
Updated list of file paths with new CGI filenames
- Return type:
list
- corgidrp.mocks.create_satellite_spot_observing_sequence(n_sci_frames, n_satspot_frames, image_shape=(201, 201), bg_sigma=1.0, bg_offset=10.0, gaussian_fwhm=5.0, separation=14.79, star_center=None, angle_offset=0, amplitude_multiplier=100, observing_mode='NFOV')[source]#
Creates a single dataset of synthetic observing frames. The dataset contains:
Science frames (with amplitude_multiplier=0), simulating no satellite spots.
Satellite spot frames (with amplitude_multiplier > 0), simulating the presence of spots.
Synthetic frames are generated using the create_synthetic_satellite_spot_image function, with added Gaussian noise and adjustable parameters for background level, spot separation, and overall amplitude scaling.
- Parameters:
n_sci_frames (int) – Number of science frames without satellite spots.
n_satspot_frames (int) – Number of frames with satellite spots.
image_shape (tuple, optional) – Shape of the synthetic image (height, width). Defaults to (201, 201).
bg_sigma (float, optional) – Standard deviation of the background noise. Defaults to 1.0.
bg_offset (float, optional) – Offset of the background noise. Defaults to 10.0.
gaussian_fwhm (float, optional) – Full width at half maximum of the Gaussian spot. Defaults to 5.0.
separation (float, optional) – Separation between the satellite spots. Defaults to 14.79.
star_center (tuple of float, optional) – Absolute (x, y) position in the image at which the four Gaussians will be centered. If None, defaults to the image center (nx//2, ny//2).
angle_offset (float, optional) – Offset of the spot angles. Defaults to 0.
amplitude_multiplier (int, optional) – Amplitude multiplier for the satellite spots. Defaults to 100.
observing_mode (str, optional) – Observing mode. Must be one of [‘NFOV’, ‘WFOV’, ‘SPEC660’, ‘SPEC730’]. Defaults to ‘NFOV’.
- Returns:
A single dataset object containing both science frames (no satellite spots) and satellite spot frames. The science frames have header value “SATSPOTS” set to 0, while the satellite spot frames have “SATSPOTS” set to 1.
- Return type:
- corgidrp.mocks.get_formatted_filename(dt, visitid)[source]#
Generate filename with proper format: cgi_VISITID_YYYYMMDDtHHMMSSS_l2b.fits
- Parameters:
dt (datetime) – Datetime object
visitid (str) – Visit ID
- Returns:
Formatted filename
- Return type:
str
- corgidrp.mocks.create_spatial_pol(dataset, filedir=None, nr=None, pfov_size=174, image_center_x=512, image_center_y=512, separation_diameter_arcsec=7.5, alignment_angle_WP1=0, alignment_angle_WP2=45, planet=None, band=None, dpamname='POL0')[source]#
Turns a dataset of neptune or uranus images with single planet images into the images observed through the wollaston prisms also incorporates the spatial variation of polarization on the surface of the planet
- Parameters:
dataset (corgidrp.data.Dataset) – a dataset of image frames that are raster scanned (L2a-level)
filedir (str) – Full path to directory to save the raster scanned images.
nr (int) – planet radius
pfov_size (int) – size of the image created for the polarization variation, typically ~ 2 x nr
image_center_x (int) – x coordinate of the center pixel of the final image with two orthogonal pol components
image_center_y (int) – y coordinate of the center pixel of the final image with two orthogonal pol components
separation_diameter_arcsec (float) – separation between the two orthogonal pol components in arcsecs
alignment_angle_WP1 (int) – wollaston prism angle for Pol0 - 0
alignment_angle_WP2 (int) – wollaston prism angle for Pol45- 45
planet (str) – neptune or uranus
band (str) – 1F or 4F
dpamname (str) – wollaston prism pol0 or pol45
- Returns:
dataset of uranus or neptune with spatial variation of polarization corresponding to specific wollaston prism
- Return type:
- corgidrp.mocks.create_mock_l2b_polarimetric_image(image_center=(512, 512), dpamname='POL0', observing_mode='NFOV', left_image_value=1, right_image_value=1, image_separation_arcsec=7.5, alignment_angle=None)[source]#
Creates mock L2b polarimetric data with two polarized images placed on the larger detector frame. Image size and placement depends on the wollaston used and the observing mode.
- Parameters:
image_center (optional, tuple(int, int)) – pixel location of where the two images are centered on the detector
dpamname (optional, string) – name of the wollaston prism used, accepted values are ‘POL0’ and ‘POL45’
observing_mode (optional, string) – observing mode of the coronagraph
left_image_value (optional, int) – value to fill inside the radius of the left image, corresponding to 0 or 45 degree polarization
right_image_value (optional, int) – value to fill inside the radius of the right image, corresponding to 90 or 135 degree polarization
image_separation_arcsec (optional, float) – Separation between the two polarized images in arcseconds.
alignment_angle (optional, float) – the angle in degrees of how the two polarized images are aligned with respect to the horizontal, defaults to 0 for WP1 and 45 for WP2
- Returns:
The simulated L2b polarimetric image
- Return type:
- corgidrp.mocks.create_mock_l2b_polarimetric_image_with_satellite_spots(image_center=(512, 512), dpamname='POL0', observing_mode='NFOV', left_image_value=1, right_image_value=1, image_separation_arcsec=7.5, alignment_angle=None, image_shape=(1024, 1024), star_center=None, bg_sigma=0.0001, bg_offset=0, gaussian_fwhm=2, separation=14.79, angle_offset=0, amplitude_multiplier=10)[source]#
Creates a mock L2b polarimetric image with two separated polarized channels (left and right), where each channel contains four synthetic Gaussian satellite spots.
The function first establishes the geometry and background of the dual-channel image and then overlays the satellite spot pattern, centered on the middle of each channel.
- Parameters:
image_center (optional, tuple(int, int)) – Pixel location (x, y) where the two images are centered on the larger detector frame.
dpamname (optional, string) – Name of the Wollaston prism used, accepted values are ‘POL0’ and ‘POL45’.
observing_mode (optional, string) – Observing mode of the coronagraph.
left_image_value (optional, int) – Constant value to fill inside the radius of the left polarized image (0 or 45 degree polarization), before adding spots.
right_image_value (optional, int) – Constant value to fill inside the radius of the right polarized image (90 or 135 degree polarization), before adding spots.
image_separation_arcsec (optional, float) – Separation between the two polarized images in arcseconds.
alignment_angle (optional, float) – The angle in degrees of how the two polarized images are aligned with respect to the horizontal. Defaults to 0 for POL0 and 45 for POL45.
image_shape (tuple of int, optional) – The (ny, nx) shape of the detector array.
star_center (list of tuple of float, optional) – displacement (dx, dy) from the center of each channel at which the four Gaussians will be centered for each slice. If None, defaults to the center of each channel.
bg_sigma (float, optional) – Standard deviation of the background Gaussian noise applied to the entire image.
bg_offset (float, optional) – Constant background level added to the entire image.
gaussian_fwhm (float, optional) – Full width at half maximum (FWHM, in pixels) for the 2D Gaussian satellite spots.
separation (float, optional) – Radial separation (in pixels) of each satellite spot from the center of its respective polarized image.
angle_offset (float, optional) – An additional angle (in degrees) to rotate the four satellite spots in each channel (counterclockwise).
amplitude_multiplier (float, optional) – Multiplier for the amplitude of the Gaussians relative to bg_sigma. By default, amplitude is 10 * bg_sigma.
- Returns:
The simulated L2b polarimetric image containing satellite spots.
- Return type:
- corgidrp.mocks.create_mock_stokes_image_l4(image_size=256, fwhm=3, I0=10000.0, badpixel_fraction=0.0, add_noise=True, p=0.1, theta_deg=20.0, rng=None, seed=None)[source]#
Generate mock L4 Stokes cube with Gaussian source and controlled polarization.
- Parameters:
image_size (int) – H x W size
fwhm (float) – Gaussian FWHM in pixels
I0 (float) – Peak intensity
badpixel_fraction (float) – Fraction of bad pixels
add_noise (bool) – If True, add random noise to the Stokes cube; if False, return a noiseless realization (errors remain).
p (float) – Fractional polarization
theta_deg (float) – Polarization angle in degrees
rng (numpy.random.Generator, optional) – RNG instance for reproducibility. Defaults to None.
seed (int, optional) – Random seed
- Returns:
Stokes cube Image object with data, err, dq, and headers
- Return type:
- corgidrp.mocks.create_mock_stokes_i_image(total_counts, target_name, col_cor=None, seed=0, is_coronagraphic=False, xoffset=0.0, yoffset=0.0)[source]#
Create a mock L4 Stokes I image from a mock L4 Stokes cube.
- Parameters:
total_counts (float) – Total counts in the image
target_name (str) – Name of the target
col_cor (float, optional) – Color correction factor
seed (int, optional) – Random seed
is_coronagraphic (bool, optional) – Whether the image is coronagraphic
xoffset (float, optional) – X offset for the Gaussian source position in pixels. Defaults to 0.0 (center).
yoffset (float, optional) – Y offset for the Gaussian source position in pixels. Defaults to 0.0 (center).
- Returns:
Mock Image object with data of shape [4, n, m], err and dq arrays included.
- Return type:
- corgidrp.mocks.create_mock_IQUV_image(n=64, m=64, fwhm=20, amp=1.0, pfrac=0.1, bg=0.0)[source]#
Create a mock Image with [I, Q, U, V] planes for testing.
- Parameters:
n (int) – Image height (pixels).
m (int) – Image width (pixels).
fwhm (float) – FWHM of the Gaussian PSF used for I.
amp (float) – Peak amplitude of the Gaussian PSF.
pfrac (float) – Polarization fraction. Q, U are scaled by this fraction.
bg (float) – Background level added to the image.
- Returns:
Mock Image object with data of shape [4, n, m], err and dq arrays included.
- Return type:
- corgidrp.mocks.create_mock_polarization_l3_dataset(image_size=1024, fwhm=100.0, I0=10000.0, badpixel_fraction=0.001, fractional_error=None, p=0.1, theta_deg=20.0, pa_aper_degs=None, prisms=None, seed=None, return_image_list=False)[source]#
Generate mock L3 polarimetric datasets with controlled fractional polarization and polarization angles, including optional bad pixels and configurable intensity.
Each dataset can contain multiple images corresponding to different Wollaston prisms and PA_APER angles. For each image, a dual-beam simulation is performed to produce the two analyzer channels (e.g., 0/90 deg for POL0, 45/135 deg for POL45), and observational noise is applied according to the specified fractional error or photon noise.
- Parameters:
image_size (int) – Size of the square image (H x W).
fwhm (float) – Full width at half maximum of the Gaussian source in pixels.
I0 (float) – Peak intensity of the Gaussian source.
badpixel_fraction (float) – Fraction of randomly placed bad pixels (0-1).
fractional_error (float or None) – Fractional Gaussian noise; if None, photon noise is used.
p (float) – Fractional polarization (0-1).
theta_deg (float) – Polarization angle in degrees.
pa_aper_degs (list of float, optional) – PA_APER angles per prism. Defaults to [-15, 15, -15, 15].
prisms (list of str, optional) – Prism orientations (‘POL0’, ‘POL45’). Defaults to [‘POL0’,’POL0’,’POL45’,’POL45’].
seed (int, optional) – Random seed.
return_image_list (bool) – If True, return list of Image objects instead of Dataset.
- Returns:
- Synthetic Dataset object containing Image objects with data, error maps,
and data quality arrays.
- Return type:
- Raises:
ValueError – If pa_aper_degs and prisms lengths mismatch or prism name is invalid.
- corgidrp.mocks.get_pol_image_centers(image_separation_arcsec, alignment_angle, pixel_scale=0.0218, image_center=(512, 512))[source]#
Calculate the centers of the two polarized images based on the separation and alignment angle.
- Parameters:
image_separation_arcsec (float) – Separation between the two polarized images in arcseconds.
alignment_angle (float) – Angle in degrees of how the two polarized images are aligned with respect to the horizontal.
pixel_scale (float) – Plate scale in arcseconds per pixel.
image_center (tuple(int, int), optional) – Pixel location of where the two images are centered on the detector.
- Returns:
Pixel locations of the centers of the two polarized images.
- Return type:
tuple
- corgidrp.mocks.generate_mock_polcal_dataset(path_to_pol_ref_file, read_noise=200, image_separation_arcsec=7.5, q_inst=0.5, u_inst=-0.1, q_eff=0.8, uq_ct=0.05, u_eff=0.7, qu_ct=0.03)[source]#
Generate a mock L2b polarimetric dataset for polcal testing
- Parameters:
path_to_pol_ref_file (str) – Path to the CSV file containing the reference polarization values
read_noise (float) – Read noise to be added to the images
image_separation_arcsec (float) – Separation between the two polarized images in arcseconds
q_inst (float) – Instrumental Q polarization in percentage
u_inst (float) – Instrumental U polarization in percentage
q_eff (float) – Q efficiency
uq_ct (float) – U to Q crosstalk
u_eff (float) – U efficiency
qu_ct (float) – Q to U crosstalk
- Returns:
The simulated L2b polarimetric dataset for polcal testing
- Return type:
- corgidrp.mocks.make_1d_spec_image(spec_values, spec_err, spec_wave, pa_aper_deg=None, exp_time=None, col_cor=None)[source]#
Create a mock L4 file with 1-D spectroscopy extensions.
- Parameters:
spec_values (ndarray) – flux values (photoelectron/s) for SPEC.
spec_err (ndarray) – uncertainty array matching SPEC shape.
spec_wave (ndarray) – wavelength grid in nm for SPEC_WAVE.
pa_aper_deg (float, optional) – PA_APER (on-sky position angle east of north)
exp_time (float, optional) – exposure time in seconds
col_cor (float, optional) – color-correction factor to record.
- Returns:
image with SPEC, SPEC_ERR, SPEC_DQ, SPEC_WAVE, and SPEC_WAVE_ERR extensions populated.
- Return type: