corgidrp.data#
Attributes#
Classes#
A sequence of data of the same kind. Can be indexed and looped over |
|
Base class for 2-D image data. Data can be created by passing in the data/header explicitly, or |
|
Dark calibration frame for a given exposure time and EM gain. |
|
Master flat generated from raster scan of uranus or Neptune. |
|
Calibration product that stores fitted PSF centroid (x, y) positions |
|
Calibration product that stores a flux profile vs. wavelength of a narrowband observation and the fitted Gaussian parameters |
|
Class for dispersion model parameter data structure |
|
calibration class that contains a dictionary of the x/y offsets of the different used filters. |
|
Class for non-linearity calibration files. Although it's not strictly an image that you might look at, it is a 2D array of data |
|
Class for KGain calibration file. Until further insights it is just one float value. |
|
Class for bad pixel map. The bad pixel map indicates which pixels are hot |
|
Class for DetectorNoiseMaps calibration file. The data is a 3-D stack of 3 frames, each of which is a full SCI frame of fitted |
|
Class containing detector parameters that may change over time. |
|
Class for astrometric calibration file. |
|
Class for data related to charge traps that cause charge transfer inefficiency. |
|
Class containing the flux calibration factor (and corresponding error) for each band in unit erg/(s * cm^2 * AA)/photo-electrons/s. |
|
Class containing the wavelength dependent absolute spectral flux calibration (spectro-photometric calibration) |
|
Contains the slit transmission map of a defined slit. This consists of an |
|
Class containing the FPAM to EXCAM and FSAM to EXCAM transformation matrices. |
|
Class containing a core throughput calibration file |
|
Class containing a corethroughput map. |
|
A pyKLIP instrument class for Roman Coronagraph Instrument data. |
|
Class for an ND filter sweet spot dataset product. |
|
ND filter calibration product for spectroscopy. |
|
Class for a Mueller matrix dataset product. |
|
Class for a Mueller matrix dataset product made with ND filter data. |
|
Functions#
|
Round the input FTIMEUTC time to the nearest 0.01 sec and reformat as: |
|
Loads the supplied FITS file filepath using the appropriate data class |
|
Unpacking bits from a 64-bit unsigned integer array |
|
Packing bits into a 64-bit unsigned integer array |
Returns a dictionary mapping flag names to bit positions. |
|
Returns a dictionary mapping flag names to their decimal flag values. Example usage is as follows: |
|
Returns a dictionary mapping flag decimal values to flag names. Example usage is as follows: |
|
Returns a dictionary mapping bit positions to flag names. Example usage is as follows: |
|
|
Return a copy containing only the Stokes I plane for photometry. |
Module Contents#
- corgidrp.data.typical_cal_invalid_keywords = ['VISITID', 'FILETIME', 'PROGNUM', 'EXECNUM', 'CAMPAIGN', 'SEGMENT', 'OBSNUM', 'VISNUM',...[source]#
- class corgidrp.data.Dataset(frames_or_filepaths, no_data=False, no_err=False, no_dq=False)[source]#
A sequence of data of the same kind. Can be indexed and looped over
- Parameters:
frames_or_filepaths (list) – list of either filepaths or data objects (e.g., Image class)
- all_data[source]#
an array with all the data combined together. First dimension is always number of images
- Type:
np.array
- frames#
list of data objects (probably corgidrp.data.Image)
- Type:
np.array
- save(filedir=None, filenames=None, ram_heavy_save=False)[source]#
Save each file of data in this dataset into directory
- Parameters:
filedir (str) – directory to save the files. Default: the existing filedir for each file
filenames (list) – a list of output filenames for each file. Default: unchanged filenames
ram_heavy_save (bool) – If True, the input is assumed to have no data loaded into memory. (Only metadata was
frame (manipulated in step leading up to save_data.) The data is loaded from the filepath frame by)
and
False. (each Image is saved to outputdir. Defaults to)
- update_after_processing_step(history_entry, new_all_data=None, new_all_err=None, new_all_dq=None, header_entries=None, update_err_header=True)[source]#
Updates the dataset after going through a processing step
- Parameters:
history_entry (str) – a description of what processing was done. Mention reference files used.
new_all_data (np.array) – (optional) Array of new data. Needs to be the same shape as all_data
new_all_err (np.array) – (optional) Array of new err. Needs to be the same shape as all_err except of second dimension
new_all_dq (np.array) – (optional) Array of new dq. Needs to be the same shape as all_dq
header_entries (dict) – (optional) a dictionary {} of ext_hdr and err_hdr entries to add or update
update_err_header (bool) – (optional) whether or not to add the new entry to the error header
- copy(copy_data=True)[source]#
Make a copy of this dataset, including all data and headers. Data copying can be turned off if you only want to modify the headers Headers should always be copied as we should modify them any time we make new edits to the data
- Parameters:
copy_data (bool) – (optional) whether the data should be copied. Default is True
- Returns:
a copy of this dataset
- Return type:
- add_error_term(input_error, err_name)[source]#
Calls Image.add_error_term() for each frame. Updates Dataset.all_err.
- Parameters:
input_error (np.array) – per-frame or per-dataset error layer
err_name (str) – name of the uncertainty layer
- rescale_error(scale_factor, scale_name)[source]#
Calls Image.rescale_errors() for each frame. Updates Dataset.all_err
- Parameters:
scale_factor (np.array or float) – scale factor value or array
scale_name (str) – name of the scaling reason
- split_dataset(prihdr_keywords=None, exthdr_keywords=None)[source]#
Splits up this dataset into multiple smaller datasets that have the same set of header keywords The code uses all keywords together to determine an unique group
- Parameters:
prihdr_keywords (list of str) – list of primary header keywords to split
exthdr_keywords (list of str) – list of 1st extension header keywords to split on
- Returns:
list of sub datasets list of tuples: list of each set of unique header keywords. pri_hdr keywords occur before ext_hdr keywords
- Return type:
list of datasets
- class corgidrp.data.Image(data_or_filepath, pri_hdr=None, ext_hdr=None, err=None, dq=None, err_hdr=None, dq_hdr=None, input_hdulist=None)[source]#
Base class for 2-D image data. Data can be created by passing in the data/header explicitly, or by passing in a filepath to load a FITS file from disk
- Parameters:
data_or_filepath (str or np.array) – either the filepath to the FITS file to read in OR the 2D image data
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw 2D data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw 2D data is passed in)
err (np.array) – 2-D/3-D uncertainty data
dq (np.array) – 2-D data quality, 0: good. Other values track different causes for bad pixels and other pixel-level effects in accordance with the DRP implementation document.x
err_hdr (astropy.io.fits.Header) – the error extension header
dq_hdr (astropy.io.fits.Header) – the data quality extension header
hdu_list (astropy.io.fits.HDUList) – an astropy HDUList object that contains any other extension types.
- data#
2-D data for this Image
- Type:
np.array
- err#
2-D uncertainty
- Type:
np.array
- dq#
2-D data quality
- Type:
np.array
- ext_hdr[source]#
image extension header. Generally this header will be edited/added to
- Type:
astropy.io.fits.Header
- err_hdr#
the error extension header
- Type:
astropy.io.fits.Header
- dq_hdr#
the data quality extension header
- Type:
astropy.io.fits.Header
- hdu_list#
an astropy HDUList object that contains any other extension types.
- Type:
astropy.io.fits.HDUList
- filename#
the filename corresponding to this Image
- Type:
str
- filedir#
the file directory on disk where this image is to be/already saved.
- Type:
str
- save(filedir=None, filename=None)[source]#
Save file to disk with user specified filepath
- Parameters:
filedir (str) – filedir to save to. Use self.filedir if not specified
filename (str) – filepath to save to. Use self.filename if not specified
- copy(copy_data=True)[source]#
Make a copy of this image file. including data and headers. Data copying can be turned off if you only want to modify the headers Headers should always be copied as we should modify them any time we make new edits to the data
- Parameters:
copy_data (bool) – (optional) whether the data should be copied. Default is True
- Returns:
a copy of this Image
- Return type:
- get_masked_data()[source]#
Uses the dq array to generate a numpy masked array of the data
- Returns:
the data masked
- Return type:
numpy.ma.MaskedArray
- add_error_term(input_error, err_name)[source]#
Add a layer of a specific additive uncertainty on the 3- or 4-dim error array extension and update the combined uncertainty in the first layer. Update the error header and assign the error name.
Only tracks individual errors if the “track_individual_errors” setting is set to True in the configuration file
- Parameters:
input_error (np.array) – error layer with same shape as data
err_name (str) – name of the uncertainty layer
- rescale_error(scale_factor, scale_name)[source]#
scale the 3-dim error array extension with a factor. Update the error header with the history and reason of the scaling.
- Parameters:
scale_factor (np.array or float) – scale factor value or array
scale_name (str) – name of the scaling reason
- get_hash()[source]#
Computes the hash of the data, err, and dq. Does not use the header information.
- Returns:
the hash of the data, err, and dq
- Return type:
str
- add_extension_hdu(name, data=None, header=None)[source]#
Create a new hdu extension and append it to the hdu_list
- Parameters:
name (str) – The name of the new extension
data (array, optional) – Some kind of data. Defaults to None.
header (astropy.io.fits.Header, optional) – _description_. Defaults to None.
- class corgidrp.data.Dark(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None, err=None, dq=None, err_hdr=None, dq_hdr=None)[source]#
Bases:
ImageDark calibration frame for a given exposure time and EM gain.
- Args:
data_or_filepath (str or np.array): either the filepath to the FITS file to read in OR the 2D image data pri_hdr (astropy.io.fits.Header): the primary header (required only if raw 2D data is passed in) ext_hdr (astropy.io.fits.Header): the image extension header (required only if raw 2D data is passed in) input_dataset (corgidrp.data.Dataset): the Image files combined together to make this dark (required only if raw 2D data is passed in and if raw data filenames not already archived in ext_hdr) err (np.array): the error array (required only if raw data is passed in) err_hdr (astropy.io.fits.Header): the error header (required only if raw data is passed in) dq (np.array): the DQ array (required only if raw data is passed in)
- class corgidrp.data.FlatField(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None)[source]#
Bases:
ImageMaster flat generated from raster scan of uranus or Neptune.
- Args:
data_or_filepath (str or np.array): either the filepath to the FITS file to read in OR the 2D image data pri_hdr (astropy.io.fits.Header): the primary header (required only if raw 2D data is passed in) ext_hdr (astropy.io.fits.Header): the image extension header (required only if raw 2D data is passed in) input_dataset (corgidrp.data.Dataset): the Image files combined together to make this flat file (required only if raw 2D data is passed in)
- class corgidrp.data.SpectroscopyCentroidPSF(data_or_filepath, pri_hdr=None, ext_hdr=None, err_hdr=None, err=None, input_dataset=None)[source]#
Bases:
ImageCalibration product that stores fitted PSF centroid (x, y) positions for a grid of simulated PSFs.
- Parameters:
data_or_filepath (str or np.ndarray) – 2D array of (x, y) centroid positions with shape (N, 2), where N is the number of PSFs.
err (np.ndarray) – 2D array of (x,y) errors of centroid positions with shape (N,2)
pri_hdr (fits.Header) – Primary header.
ext_hdr (fits.Header) – Extension header.
err_hdr (fits.Header) – error extension header
input_dataset (Dataset) – Dataset of raw PSF images used to generate this calibration.
- class corgidrp.data.LineSpread(data_or_filepath, pri_hdr=None, ext_hdr=None, gauss_par=None, input_dataset=None)[source]#
Bases:
ImageCalibration product that stores a flux profile vs. wavelength of a narrowband observation and the fitted Gaussian parameters
- Parameters:
data_or_filepath (str or np.ndarray) – 1D wavelength array (nm) 1D flux profile with shape (N, 2), where N is the length of the wavelength array.
pri_hdr (fits.Header) – Primary header.
ext_hdr (fits.Header) – Extension header.
gauss_par (np.ndarray) – Gaussian fit parameters + corresponding errors: [amplitude, mean_wavelen, fwhm, amp_err, wave_err, fwhm_err]
input_dataset (Dataset) – Dataset used to generate this calibration.
- Attr:
wavlens (np.array): wavelengths in nm flux_profile (np.array): normalized flux gauss_par (np.array): Gaussian fit parameters: [amplitude, mean_wavelen, fwhm, amp_err, wave_err, fwhm_err] amplitude (float): Gaussian amplitude mean_wave (float): mean wavelength fwhm (float): Gaussian FWHM amp_err (float): fit error of the amplitude wave_err (float): fit error of the mean wavelength fwhm_err (float): fit error of the Gaussian fwhm
- class corgidrp.data.DispersionModel(data_or_filepath, pri_hdr=None, ext_hdr=None)[source]#
Bases:
ImageClass for dispersion model parameter data structure
- Parameters:
data_or_filepath (str or dict) – either the filepath to the FITS file to read in OR the dictionary containing the dispersion data
pri_hdr (fits.Header) – Primary header.
ext_hdr (fits.Header) – Extension header.
- data#
table containing the dispersion data
- Type:
dict
- oriented in the direction of increasing wavelength, measured in degrees
- counterclockwise from the positive x-axis on the EXCAM data array
- (direction of increasing column index).
- clocking angle in degrees.
- source displacement on EXCAM along the dispersion axis as a function of
- wavelength, relative to the source position at the band reference
- wavelength#
- Type:
lambda_c = 730.0 nm for Band 3
- polynomial coefficients
- wavelength as a function of displacement along the dispersion axis on
- EXCAM, relative to the source position at the Band 3 reference
- wavelength#
- Type:
x_c at lambda_c = 730.0 nm
- polynomial coefficients
- class corgidrp.data.SpecFilterOffset(data_or_filepath, date_valid=None)[source]#
Bases:
Imagecalibration class that contains a dictionary of the x/y offsets of the different used filters.
- Parameters:
data_or_filepath (str or dict) – either the filepath to the FITS file to read in OR the dictionary containing the filter offsets in pixel units as a paired list [&x, &y], see SpecFilterOffset.default_offsets as an example
date_valid (astropy.time.Time) – date after which these offsets are valid
- default_offsets[source]#
dictionary containing the default filter offsets in pixel units [&x, &y]
- Type:
dict
- data#
table containing the new filter offsets
- Type:
astropy.Table
- offsets#
dictionary of updated filter offset positions
- Type:
dict
- class corgidrp.data.NonLinearityCalibration(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass for non-linearity calibration files. Although it’s not strictly an image that you might look at, it is a 2D array of data
- The required format for calibration data is as follows:
Minimum 2x2
First value (top left) must be assigned to nan
Row headers (dn counts) must be monotonically increasing
Column headers (EM gains) must be monotonically increasing
Data columns (relative gain curves) must straddle 1
- The first row will provide the the Gain axis values (accesssed via
gain_ax = non_lin_correction.data[0, 1:])
- The first column will provide the “count” axis value (accessed via
count_ax = non_lin_correction.data[1:, 0])
The rest of the array will be the calibration data (accessed via
relgains = non_lin_correction.data[1:, 1:])
For example: [
[nan, 1, 10, 100, 1000 ], <- gain axis [1, 0.900, 0.950, 0.989, 1.000], [1000, 0.910, 0.960, 0.990, 1.010], [2000, 0.950, 1.000, 1.010, 1.050], [3000, 1.000, 1.001, 1.011, 1.060],
^ count axis
],
where the row headers [1, 1000, 2000, 3000] are dn counts, the column headers [1, 10, 100, 1000] are EM gains, and the first data column [0.900, 0.910, 0.950, 1.000] is the first of the four relative gain curves.
- Args:
data_or_filepath (str or np.array): either the filepath to the FITS file to read in OR the 2D calibration data. See above for the required format. pri_hdr (astropy.io.fits.Header): the primary header (required only if raw 2D data is passed in) ext_hdr (astropy.io.fits.Header): the image extension header (required only if raw 2D data is passed in) input_dataset (corgidrp.data.Dataset): the Image files combined together to make this NonLinearityCalibration file (required only if raw 2D data is passed in)
- class corgidrp.data.KGain(data_or_filepath, err=None, ptc=None, pri_hdr=None, ext_hdr=None, err_hdr=None, ptc_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass for KGain calibration file. Until further insights it is just one float value.
- Parameters:
data_or_filepath (str or float) – either the filepath to the FITS file to read in OR the calibration data. See above for the required format.
err (float) – uncertainty value of kgain factor
ptc (np.array) – 2 column array with the photon transfer curve
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw data is passed in)
err_hdr (astropy.io.fits.Header) – the err extension header (required only if raw data is passed in)
ptc_hdr (astropy.io.fits.Header) – the ptc extension header (required only if raw data is passed in)
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this KGain file (required only if raw 2D data is passed in)
- Attrs:
value: the getter of the kgain value _kgain (float): the value of kgain error: the getter of the kgain error value _kgain_error (float): the value of kgain error
- class corgidrp.data.BadPixelMap(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass for bad pixel map. The bad pixel map indicates which pixels are hot pixels and thus unreliable. Note: These bad pixels are bad due to inherent nonidealities in the detector (applicable to any frame taken) and are separate from pixels marked per frame as contaminated by cosmic rays.
- Args:
data_or_filepath (str or np.array): either the filepath to the FITS file to read in OR the 2D image data pri_hdr (astropy.io.fits.Header): the primary header (required only if raw 2D data is passed in) ext_hdr (astropy.io.fits.Header): the image extension header (required only if raw 2D data is passed in) input_dataset (corgidrp.data.Dataset): the Image files combined together to make this bad pixel map (required only if raw 2D data is passed in)
- class corgidrp.data.DetectorNoiseMaps(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None, err=None, dq=None, err_hdr=None, dq_hdr=None)[source]#
Bases:
ImageClass for DetectorNoiseMaps calibration file. The data is a 3-D stack of 3 frames, each of which is a full SCI frame of fitted values for a given noise type at a given temperature. The 4th calibration product is bias offset, which is stored in the header. The 3 frames in the stack are in this order: index 0 for the fixed-pattern noise (FPN) map, index 1 for the clock-induced charge (CIC) map, index 2 for the dark current (DC) map. The input err should be a 4-D stack with first dimension of 1 and the next 3 corresponding to a 3-D stack with this order above. The input dq should be a 3-D stack corresponding to the order above. :param data_or_filepath: either the filepath to the FITS file to read in OR the 3-D calibration data. See above for the required format. :type data_or_filepath: str or np.array :param pri_hdr: the primary header (required only if data is passed in for data_or_filepath) :type pri_hdr: astropy.io.fits.Header :param ext_hdr: the image extension header (required only if data is passed in for data_or_filepath) :type ext_hdr: astropy.io.fits.Header :param input_dataset: the input data combined together to make the noise maps (required only if data is passed in for data_or_filepath and if the filenames for the raw data used to make the calibration data are not already archived in ext_hdr) :type input_dataset: corgidrp.data.Dataset :param err: the error 3-D array (required only if data is passed in for data_or_filepath) :type err: np.array :param dq: the 3-D DQ array (required only if data is passed in for data_or_filepath) :type dq: np.array :param err_hdr: the error header (required only if data is passed in for data_or_filepath) :type err_hdr: astropy.io.fits.Header
- class corgidrp.data.DetectorParams(data_or_filepath, date_valid=None)[source]#
Bases:
ImageClass containing detector parameters that may change over time.
- To create a new instance of DetectorParams, you only need to pass in the values you would like to change from default values:
new_valid_date = astropy.time.Time(“2027-01-01”) new_det_params = DetectorParams({‘gmax’ : 7500.0 }, date_valid=new_valid_date).
- Parameters:
data_or_filepath (dict or str) – either a filepath string corresponding to an existing DetectorParams file saved to disk or a dictionary of parameters to modify from default values
date_valid (astropy.time.Time) – date after which these parameters are valid
- class corgidrp.data.AstrometricCalibration(data_or_filepath, pri_hdr=None, ext_hdr=None, err=None, input_dataset=None)[source]#
Bases:
ImageClass for astrometric calibration file.
- Parameters:
data_or_filepath (str or np.array) – either the filepath to the FITS file to read in OR a single array of calibration measurements of the following lengths (boresight: length 2 (RA, DEC),
scale (plate) – length 1 (float), north angle: length 1 (float), average offset: length 2 (floats) of average boresight offset in RA/DEC [deg],
coeffs (distortion) – length dependent on order of polynomial fit but the last value should be an int describing the polynomial order). For a
37. (3rd order distortion fit the input array should be length)
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw 2D data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw 2D data is passed in)
- Attrs:
boresight (np.array): the corrected RA/DEC [deg] position of the detector center platescale (float): the platescale value in [mas/pixel] northangle (float): the north angle value in [deg] avg_offset (np.array): the average offset [deg] from the detector center distortion_coeffs (np.array): the array of legendre polynomial coefficients that describe the distortion map, where the last value of the array is the order of polynomial used
- class corgidrp.data.TrapCalibration(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass for data related to charge traps that cause charge transfer inefficiency. The calibration is generated by trap-pumped data.
The format will be [n,10], where each entry will have: [row, column, sub-electrode location, index numnber of trap at this pixel/electrode, capture time constant, maximum amplitude of the dipole, energy level of hole, cross section for holes, R^2 value of fit, release time constant]
- Args:
data_or_filepath (str or np.array): either the filepath to the FITS file to read in OR the 2D image data pri_hdr (astropy.io.fits.Header): the primary header (required only if raw 2D data is passed in) ext_hdr (astropy.io.fits.Header): the image extension header (required only if raw 2D data is passed in) input_dataset (corgidrp.data.Dataset): the Image files combined together to make the trap calibration
- class corgidrp.data.FluxcalFactor(data_or_filepath, err=None, pri_hdr=None, ext_hdr=None, err_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass containing the flux calibration factor (and corresponding error) for each band in unit erg/(s * cm^2 * AA)/photo-electrons/s.
To create a new instance of FluxcalFactor, you need to pass the value and error and the filter name in the ext_hdr:
- Parameters:
data_or_filepath (str or float) – either a filepath string corresponding to an existing FluxcalFactor file saved to disk or the data and error float values of the flux cal factor of a certain filter defined in the header
err (float) – uncertainty value of fluxcal factor
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw data is passed in)
err_hdr (astropy.io.fits.Header) – the err extension header (required only if raw data is passed in)
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this FluxcalFactor file (required only if raw 2D data is passed in)
- filter#
used filter name
- Type:
str
- class corgidrp.data.SpecFluxCal(data_or_filepath, err=None, dq=None, pri_hdr=None, ext_hdr=None, err_hdr=None, input_dataset=None)[source]#
Bases:
ImageClass containing the wavelength dependent absolute spectral flux calibration (spectro-photometric calibration) and corresponding error in unit erg/(s * cm^2 * AA)/photo-electrons/s/bin (spectral sensitivity) for each broad band.
To create a new instance of SpecFluxCal, you need to pass the 2d array (2, N) of wavelength and flux calibration and the corresponding error array:
- Parameters:
data_or_filepath (str or np.array) – either a filepath string corresponding to an existing SpecFluxCal file saved to disk or the data and error float values of the spectral flux cal factors vs. wavelength
err (np.array) – 2d array of uncertainties of wavelength and spectral flux calibration
dq (np.array) – 2d array of data quality
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw data is passed in)
err_hdr (astropy.io.fits.Header) – the err extension header (required only if raw data is passed in)
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this SpecFluxCal file
in) ((required only if raw 2D data is passed)
- band#
band name for which this calibration is valid
- Type:
str
- class corgidrp.data.SlitTransmission(data_or_filepath, pri_hdr=None, ext_hdr=None, x_offset=None, y_offset=None, input_dataset=None)[source]#
Bases:
ImageContains the slit transmission map of a defined slit. This consists of an 2D array with:
1/ Slit transmission map derived at different locations by interpolation. 2/ Corresponding locations along EXCAM +X direction with respect to the
zero-point in (fractional) EXCAM pixels where the slit transmission has been derived.
- 3/ Corresponding locations along EXCAM +Y direction with respect to the
zero-point in (fractional) EXCAM pixels where the slit transmission has been derived.
- Parameters:
data_or_filepath (str or np.array) – either a filepath string corresponding to an existing SlitTransmission file saved to disk or an 2D array with the slit transmission map
x_offset (np.array) – 1D array of x positions in slit
y_offset (np.array) – 1D array of y positions in slit
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw data is passed
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this SlitTransmission file
in) ((required only if raw 2D data is passed)
- x_offset#
1D array, locations along EXCAM +X direction with respect to the zero-point in (fractional) EXCAM pixels where the slit transmission has been derived.
- Type:
np.array
- y_offset#
1D array, locations along EXCAM +Y direction with respect to the zero-point in (fractional) EXCAM pixels where the slit transmission has been derived.
- Type:
np.array
- select_slit_transmission_curve(frame)[source]#
Select the slit-transmission curve for the frame from SlitTransmission cal product
- Parameters:
frame (corgidrp.data.Image) – L4 spectroscopy frame whose WV0_X/WV0_Y coordinates identify where the slit correction should be evaluated.
- Returns:
1-D slit throughput curve sampled on the frame’s SPEC wavelength grid.
- Return type:
numpy.ndarray
- class corgidrp.data.FpamFsamCal(data_or_filepath, date_valid=None)[source]#
Bases:
ImageClass containing the FPAM to EXCAM and FSAM to EXCAM transformation matrices. CGI model was consistent with FFT/TVAC tests. Transformation matrices are a 2x2 array with real values. Model cases are fpam_to_excam_modelbased and fsam_to_excam_modelbased, see below.
- Parameters:
data_or_filepath (dict or str) – either a filepath string corresponding to an existing FpamFsamCal file saved to disk or an array with the FPAM and FSAM rotation matrices
date_valid (astropy.time.Time) – date after which these parameters are valid
- class corgidrp.data.CoreThroughputCalibration(data_or_filepath, pri_hdr=None, ext_hdr=None, err=None, dq=None, err_hdr=None, dq_hdr=None, input_hdulist=None, input_dataset=None)[source]#
Bases:
ImageClass containing a core throughput calibration file
A CoreThroughput calibration file has two main data arrays:
- 3-d cube of PSF images, e.g, a N1xN1xN array where N1= +/- 3l/D about
PSF’s centroid in EXCAM pixels. The N PSF images are the ones in the CT dataset.
- N sets of (x, y, CT measurements). The (x, y) are pixel coordinates of the
PSF images in the CT dataset wrt EXCAM (0,0) pixel during core throughput observation.
- Parameters:
data_or_filepath (array or str) – either a filepath string corresponding to an existing CoreThroughputCalibration file saved to disk or an array with the elements of the core throughput calibration file.
hdu_list (astropy.io.fits.HDUList) – an astropy HDUList object that contains the elements of the core throughput calibration file.
- GetCTFPMPosition(corDataset, fpamfsamcal)[source]#
Gets the FPM’s center during a Core throughput observing sequence.
The use of the delta FPAM/FSAM positions and the rotation matrices is based on the prescription provided on 1/14/25: “H/V values to EXCAM row/column pixels”
delta_pam = np.array([[dh], [dv]]) # fill these in M = np.array([[ M00, M01], [M10, M11]], dtype=float32) delta_pix = M @ delta_pam
- Parameters:
corDataset (corgidrp.data.Dataset) – a dataset containing some coronagraphic observations.
fpamfsamcal (corgidrp.data.FpamFsamCal) – an instance of the FpamFsamCal class.
- Returns:
Returns the FPM’s center during a Core throughput observing sequence.
- InterpolateCT(x_cor, y_cor, corDataset, fpamfsamcal, logr=False)[source]#
- Interpolate CT value at a desired position of a coronagraphic
observation.
First implementation based on Max Millar-Blanchaer’s suggestions https://collaboration.ipac.caltech.edu/display/romancoronagraph/Max%27s+Interpolation+idea
Here we assume that the core throughput measurements with the star located along a series of radial spikes at various azimuths.
It throws an error if the radius of the new points is outside the range of the input radii. If the azimuth is greater than the maximum azimuth of the core throughput dataset, it will mod the azimuth to be within the range of the input azimuths.
Assumes that the input core_thoughput is between 0 and 1.
# TODO: review accuracy of the method with simulated data that are more # representative of future mission data, including error budget and # expected azimuthal dependence on the CT.
- Parameters:
x_cor (numpy.ndarray) – Values of the first dimension of the target locations where the CT will be interpolated. Locations are EXCAM pixels measured with respect to the FPM’s center.
y_cor (numpy.ndarray) – Values of the second dimension of the target locations where the CT will be interpolated. Locations are EXCAM pixels measured with respect to the FPM’s center.
corDataset (corgidrp.data.Dataset) – a dataset containing some coronagraphic observations.
fpamfsamcal (corgidrp.data.FpamFsamCal) – an instance of the FpamFsamCal calibration class.
logr (bool) (optional) – If True, radii are mapped into their logarithmic values before constructing the interpolant.
- Returns:
- Returns interpolated value of the CT, first, and positions for valid
locations as a numpy ndarray.
- GetPSF(x_cor, y_cor, corDataset, fpamfsamcal, method='nearest-polar')[source]#
Get a PSF at a given (x,y) location on HLC in a coronagraphic observation given a CT calibration file and the PAM transformation from encoder values to EXCAM pixels.
First implementation: nearest PSF in a polar sense. See below.
# TODO: Implement an interpolation method that takes into account other # PSF than the nearest one. Comply with any required precision from the # functions that will use the interpolated PSF.
- Parameters:
x_cor (numpy.ndarray) – Values of the first dimension of the target locations where the CT will be interpolated. Locations are EXCAM pixels measured with respect to the FPM’s center.
y_cor (numpy.ndarray) – Values of the second dimension of the target locations where the CT will be interpolated. Locations are EXCAM pixels measured with respect to the FPM’s center.
corDataset (corgidrp.data.Dataset) – a dataset containing some coronagraphic observations.
fpamfsamcal (corgidrp.data.FpamFsamCal) – an instance of the FpamFsamCal class. That is, a FpamFsamCal calibration file.
method (str) –
Interpolation method that will be used: ‘polar-nearest’: Given an (x,y) position wrt FPM’s center, the
associated PSF is the one in the CT calibration dataset whose radial distance to the FPM’s center is the closest to sqrt(x**2+y**2). If there is more than one CT PSF at the same radial distance, choose the one whose angular distance to the (x,y) location is the smallest.
- Returns:
- Array of interpolated PSFs for the valid
target locations.
x_interp_list (array): First dimension of the list of valid target positions. y_interp_list (array): Second dimension of the list of valid target positions.
- Return type:
psf_interp_list (array)
- class corgidrp.data.CoreThroughputMap(data_or_filepath, pri_hdr=None, ext_hdr=None, err=None, input_dataset=None)[source]#
Bases:
ImageClass containing a corethroughput map.
- The corethroughput map consists of M sets of (x, y, CT estimated). The
(x, y) are pixel coordinates wrt the FPM’s center. More details about the corethroughput map array can be found in the class method create_ct_map().
- Parameters:
data_or_filepath (array or str) – either the filepath to the FITS file to
a (read in OR the 2D image data. The FITS file or data must be from)
the (coronagraphic observation because the FPM's center is needed during)
map. (creation of the corethroughput)
- class corgidrp.data.PyKLIPDataset(dataset, psflib_dataset=None, highpass=False)[source]#
Bases:
pyklip.instruments.Instrument.DataA pyKLIP instrument class for Roman Coronagraph Instrument data.
# TODO: Add more bandpasses, modes to self.filter_wavs # Add wcs header info!
- Attrs:
input: Input corgiDRP dataset. centers: Star center locations. filenums: file numbers. filenames: file names. PAs: position angles. wvs: wavelengths. wcs: WCS header information. Currently None. IWA: inner working angle. OWA: outer working angle. psflib: corgiDRP dataset containing reference PSF observations. output: PSF subtracted pyKLIP dataset
- readdata(dataset, psflib_dataset, highpass=False)[source]#
Read the input science observations.
- Parameters:
dataset (corgidrp.data.Dataset) – Dataset containing input science observations.
psflib_dataset (corgidrp.data.Dataset, optional) – Dataset containing input reference observations. The default is None.
highpass (bool, optional) – Toggle to do highpass filtering. Defaults fo False.
- savedata(filepath, data, klipparams=None, filetype='', zaxis=None, more_keywords=None)[source]#
Function to save the data products that will be called internally by pyKLIP.
- Parameters:
filepath (path) – Path of the output FITS file.
data (3D-array) – KLIP-subtracted data of shape (nkl, ny, nx).
klipparams (str, optional) – PyKLIP keyword arguments used for the KLIP subtraction. The default is None.
filetype (str, optional) – Data type of the pyKLIP product. The default is ‘’.
zaxis (list, optional) – List of KL modes used for the KLIP subtraction. The default is None.
more_keywords (dict, optional) – Dictionary of additional header keywords to be written to the output FITS file. The default is None.
- class corgidrp.data.NDFilterSweetSpotDataset(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None, err=None, dq=None, err_hdr=None)[source]#
Bases:
ImageClass for an ND filter sweet spot dataset product. Typically stores an N×3 array of data:
[OD, x_center, y_center] for each measurement.
- Parameters:
data_or_filepath (str or np.array) – Either the filepath to the FITS file to read in OR the 2D array of ND filter sweet-spot data (N×3).
pri_hdr (astropy.io.fits.Header) – The primary header (required only if raw 2D data is passed in).
ext_hdr (astropy.io.fits.Header) – The image extension header (required only if raw 2D data is passed in).
input_dataset (corgidrp.data.Dataset) – The input dataset used to produce this calibration file (optional). If this is a new product, you should pass in the dataset so that the parent filenames can be recorded.
err (np.array) – Optional 3D error array for the data.
dq (np.array) – Optional 2D data-quality mask for the data.
err_hdr (astropy.io.fits.Header) – Optional error extension header.
- interpolate_od(x, y, method='nearest')[source]#
Interpolates the data to get the OD at the requested x/y location
- Parameters:
x (float) – x detector pixel location
y (float) – y detector pixel location
method (str) – only “nearest” supported currently
- Returns:
the OD at the requested point
- Return type:
float
- class corgidrp.data.NDSpectroscopy(data_or_filepath, err=None, dq=None, pri_hdr=None, ext_hdr=None, err_hdr=None, input_dataset=None)[source]#
Bases:
ImageND filter calibration product for spectroscopy.
For spectroscopy observations (DPAMNAME=PRISM*) - stores OD(lambda), the optical depth of the ND filter as a function of wavelength. Unlike the imaging mode ND filter calibration product, spectroscopy mode ND filter calibration product is only measured at a single detector location.
- Data shape: (2, M)
row 0: wavelengths in nm row 1: OD(lambda) values (dimensionless)
- Error shape: (1, 2, M)
err[0, 0, :]: wavelength uncertainties (nm) err[0, 1, :]: OD uncertainties
- Parameters:
data_or_filepath (str or np.array) – filepath to an existing NDSpectroscopy FITS file, or a (2, M) numpy array of [wavelengths, OD].
err (np.array) – (1, 2, M) error array.
dq (np.array) – (2, M) data-quality array.
pri_hdr (fits.Header) – primary header (required if raw array passed in).
ext_hdr (fits.Header) – extension header (required if raw array passed in).
err_hdr (fits.Header) – error extension header.
input_dataset (corgidrp.data.Dataset) – input frames used to create this product (required if raw array passed in without DRPNFILE in ext_hdr).
- od_err#
length-M OD uncertainty array.
- Type:
np.array
- wave_err#
length-M wavelength uncertainty array.
- Type:
np.array
- class corgidrp.data.MuellerMatrix(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None, err=None, err_hdr=None)[source]#
Bases:
ImageClass for a Mueller matrix dataset product. Stores a 4x4 Mueller matrix and its error
- Parameters:
data_or_filepath (str or np.array) – either the filepath to the FITS file to read in OR the 2D image data
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw 2D data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw 2D data is passed in)
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this Mueller Matrix (required only if raw 2D data is passed in)
- class corgidrp.data.NDMuellerMatrix(data_or_filepath, pri_hdr=None, ext_hdr=None, input_dataset=None, err=None, err_hdr=None)[source]#
Bases:
ImageClass for a Mueller matrix dataset product made with ND filter data. Stores a 4x4 Mueller matrix and its error.
- Parameters:
data_or_filepath (str or np.array) – either the filepath to the FITS file to read in OR the 2D image data
pri_hdr (astropy.io.fits.Header) – the primary header (required only if raw 2D data is passed in)
ext_hdr (astropy.io.fits.Header) – the image extension header (required only if raw 2D data is passed in)
input_dataset (corgidrp.data.Dataset) – the Image files combined together to make this Mueller Matrix (required only if raw 2D data is passed in)
err (astropy.io.fits.Header) – the error array (required only if raw 2D data is passed in)
err_hdr (astropy.io.fits.Header) – the error header (required only if raw 2D data is passed in)
- corgidrp.data.format_ftimeutc(ftime_str)[source]#
Round the input FTIMEUTC time to the nearest 0.01 sec and reformat as: yyyymmddthhmmsss.
- Parameters:
ftime_str (str) – Time string in ISO format, e.g. “2025-04-15T03:05:10.21”.
- Returns:
Reformatted time string in yyyymmddthhmmsss format.
- Return type:
formatted_time (str)
- class corgidrp.data.FluxcalFactorPOL0(ref: FluxcalFactor)[source]#
- class corgidrp.data.FluxcalFactorPOL45(ref: FluxcalFactor)[source]#
- corgidrp.data.autoload(filepath)[source]#
Loads the supplied FITS file filepath using the appropriate data class
Should be used sparingly to avoid accidentally loading in data of the wrong type
- Parameters:
filepath (str) – path to FITS file
- Returns:
an instance of one of the data classes specified here
- Return type:
corgidrp.data.*
- corgidrp.data.unpackbits_64uint(arr, axis)[source]#
Unpacking bits from a 64-bit unsigned integer array
- Parameters:
arr (np.ndarray) – the array to unpack
axis (int) – axis to unpack
- Returns:
np.ndarray of bits
- corgidrp.data.packbits_64uint(arr, axis)[source]#
Packing bits into a 64-bit unsigned integer array
- Parameters:
arr (np.ndarray) – the array to pack
axis (int) – axis to pack
- Returns:
np.ndarray of 64-bit unsigned integers
- corgidrp.data.get_flag_to_bit_map()[source]#
Returns a dictionary mapping flag names to bit positions.
- Returns:
A dictionary with flag names as keys and bit positions (int) as values.
- Return type:
dict
- corgidrp.data.get_flag_to_value_map()[source]#
Returns a dictionary mapping flag names to their decimal flag values. Example usage is as follows:
FLAG_TO_VALUE_MAP = get_flag_to_value_map() flag_value = FLAG_TO_VALUE_MAP[“TBD”] # Gives the decimal value corresponding to “TBD”
- Returns:
A dictionary with flag names as keys and decimal values (int) as values.
- Return type:
dict
- corgidrp.data.get_value_to_flag_map()[source]#
Returns a dictionary mapping flag decimal values to flag names. Example usage is as follows:
FLAG_TO_BIT_MAP = get_flag_to_bit_map() bit_position = FLAG_TO_BIT_MAP[“TBD”] # Gives which index it should be in with the key.
Expected position of bit_position of the unpacked array = 63 - bit_position
- Returns:
A dictionary with decimal values (int) as keys and flag names as values.
- Return type:
dict
- corgidrp.data.get_bit_to_flag_map()[source]#
Returns a dictionary mapping bit positions to flag names. Example usage is as follows:
BIT_TO_FLAG_MAP = get_bit_to_flag_map() flag_name_from_bit = BIT_TO_FLAG_MAP[8] # Expected: “TBD”
- Returns:
A dictionary with bit positions (int) as keys and flag names as values.
- Return type:
dict