DataSet

class jwst.photom.photom.DataSet(model, inverse=False, source_type=None, apply_time_correction=True)[source]

Bases: object

Input dataset to which the photom information will be applied.

Store vital params, such as instrument, detector, filter, pupil, and exposure type.

Parameters:
modelJwstDataModel

Input data model object. Updated in-place.

inversebool

Invert the math operations used to apply the corrections.

source_typestr or None

Force processing using the specified source type.

apply_time_correctionbool

Switch to apply/not apply a time correction, if available.

Methods Summary

apply_photom(photom_fname, area_fname)

Apply the photom calibration step.

calc_fgs(ftab)

Apply photometric calibration data to dataset and update conversion factor.

calc_miri(ftab)

Apply photometric calibration data to dataset and update conversion factor.

calc_nircam(ftab)

Apply photometric calibration data to dataset and update conversion factor.

calc_niriss(ftab)

Apply photometric calibration data to dataset and update conversion factor.

calc_nirspec(ftab, area_fname)

Apply photometric calibration data to dataset and update conversion factor.

calc_nrs_ifu_sens2d(area_data)

Create the 2-D wavelength and pixel area arrays.

calc_wfss(ftab, correction_table, match_fields)

Apply photometric calibration to all slits in a WFSS exposure.

create_1d_conversion(model, conversion, ...)

Resample the photometric conversion array.

create_2d_conversion(model, exptype, ...[, ...])

Create a 2D array of photometric conversion values.

get_dispersion_array(wavelength_array, dispaxis)

Create an array of dispersion values from the wavelength array.

photom_io(tabdata[, order, time_correction, ...])

Combine photometric conversion factors and apply to the science dataset.

pixarea_from_ftab(ftab)

Get pixel area in steradians and arsec^2 from photom reference file.

save_area_info(ftab, area_fname)

Populate area attributes in science dataset.

save_area_nirspec(pix_area)

Populate the pixel area attributes of science dataset.

Methods Documentation

apply_photom(photom_fname, area_fname)[source]

Apply the photom calibration step.

Open the reference file, retrieve the conversion factors from the reference file that are appropriate to the instrument mode. This can consist of both a scalar factor and an array of wavelength-dependent factors. The combination of both factors are applied to the input model. The scalar factor is also written to the PHOTMJSR and PHOTUJA2 keywords in the model. If a pixel area map reference file exists for the instrument mode, it is attached to the input model.

Parameters:
photom_fnamestr

Photom reference file name.

area_fnamestr

Pixel area map reference file name.

Returns:
output_modelJwstDataModel

Output data model with the flux calibrations applied.

calc_fgs(ftab)[source]

Apply photometric calibration data to dataset and update conversion factor.

For FGS, there is no matching required, because the instrument does not contain any filters or pupil wheel elements. The only mode is CLEAR.

The routine will find the corresponding information in the reference file (which should have only a single row), apply it to the data, and write the conversion factor to the output model.

Parameters:
ftabFgsImgPhotomModel

FGS photom reference file data model.

calc_miri(ftab)[source]

Apply photometric calibration data to dataset and update conversion factor.

For MIRI imaging and LRS modes, matching is based on FILTER and SUBARRAY. For MIRI WFSS the matching is based on FILTER and SUBARRAY. MIRI MRS uses dedicated photom reference files per CHANNEL + BAND.

For Imaging and LRS, the routine will find the corresponding row of information in the reference file, apply it, and store the scalar conversion factor in the output model PHOTMJSR keyword. If wavelength-dependent conversion values exist, which is the case for LRS mode, they will be included in the applied conversion.

Parameters:
ftabMirImgPhotomModel, MirMrsPhotomModel, or MirLrsPhotomModel

MIRI photom reference file data model.

calc_nircam(ftab)[source]

Apply photometric calibration data to dataset and update conversion factor.

For NIRCAM, matching is based on FILTER and PUPIL. The routine will find the corresponding information in the reference file, apply the conversion factors, and store the scalar conversion factor in the output model. If wavelength-dependent conversion factors exist, they will be included in the calibration. For WFSS (grism) mode, the calibration information extracted from the reference file is applied to each slit instance in the science data.

Parameters:
ftabNrcImgPhotomModel or NrcWfssPhotomModel

NIRCam photom reference file data model.

calc_niriss(ftab)[source]

Apply photometric calibration data to dataset and update conversion factor.

For NIRISS matching is based on FILTER and PUPIL, as well as ORDER for spectroscopic modes. There may be multiple entries for a given FILTER + PUPIL combination, corresponding to different spectral orders. Data for all orders will be retrieved.

The routine will find the corresponding information in the reference file and apply the conversions to the science arrays. If wavelength-dependent conversion factors exist, which will be the case for spectroscopic modes, they will be loaded and applied along with the scalar conversion.

Parameters:
ftabNisSossPhotomModel, NisWfssPhotomModel, or NisImgPhotomModel

NIRISS photom reference file data model.

calc_nirspec(ftab, area_fname)[source]

Apply photometric calibration data to dataset and update conversion factor.

For the NIRSPEC instrument, reference file matching is based on FILTER and GRATING, as well as SLIT name for the fixed-slits mode. The routine will find the corresponding information in the reference file, apply it to the data, and write the scalar conversion factor to the output model. All NIRSpec modes use wavelength-dependent flux calibration factors.

Parameters:
ftabNrsFsPhotomModel or NrsMosPhotomModel

NIRSpec photom reference file data model.

area_fnamestr

Pixel area map reference file name.

calc_nrs_ifu_sens2d(area_data)[source]

Create the 2-D wavelength and pixel area arrays.

These are needed for constructing a NIRSpec IFU sensitivity map.

Parameters:
area_datandarray

Array of 1-D pixel area values for the IFU slices.

Returns:
wave2dndarray

Array of 2-D wavelengths per pixel.

area2dndarray

Array of 2-D pixel area values.

dqmapndarray

Array of 2-D DQ flags per pixel.

calc_wfss(ftab, correction_table, match_fields)[source]

Apply photometric calibration to all slits in a WFSS exposure.

Iterates over each slit in the input MultiSlitModel, looks up the row in the photom reference table matched by the attributes specified in match_fields, and calls photom_io() to apply the conversion.

Parameters:
ftabNrcWfssPhotomModel or NisWfssPhotomModel

Photom reference file data model.

correction_tablearray-like

Time-dependence correction values.

match_fieldslist of str

List of field names to use for matching rows in the photom reference table.

create_1d_conversion(model, conversion, waves, relresps, integ_row)[source]

Resample the photometric conversion array.

Create a 1D array of photometric conversion values based on wavelength array of input spectrum and response as a function of wavelength.

Parameters:
modelJwstDataModel

Input data model containing the necessary wavelength information.

conversionfloat

Initial scalar photometric conversion value.

wavesndarray

1D wavelength vector on which relative response values are sampled.

relrespsndarray

1D photometric response values, as a function of waves.

integ_rowint

Table row number for the spectrum for the current integration.

Returns:
conversionndarray

1D array of computed photometric conversion values.

no_calndarray

1D mask indicating where no conversion is available.

create_2d_conversion(model, exptype, conversion, waves, relresps, order, use_wavecorr=None, include_dispersion=False)[source]

Create a 2D array of photometric conversion values.

This array is based on wavelengths per pixel and response as a function of wavelength.

Parameters:
modelJwstDataModel

Input data model containing the necessary wavelength information.

exptypestr

Exposure type of the input.

conversionfloat

Initial scalar photometric conversion value.

wavesndarray

1D wavelength vector on which relative response values are sampled.

relrespsndarray

1D photometric response values, as a function of waves.

orderint

Spectral order number.

use_wavecorrbool or None

Flag indicating whether or not to use corrected wavelengths. Typically only used for NIRSpec fixed-slit data.

include_dispersionbool or None

Flag indicating whether the dispersion needs to be incorporated into the 2-D conversion factors.

Returns:
conversionndarray

2D array of computed photometric conversion values.

no_calndarray

2D mask indicating where no conversion is available.

get_dispersion_array(wavelength_array, dispaxis)[source]

Create an array of dispersion values from the wavelength array.

Parameters:
wavelength_arrayfloat

2-D array of wavelength values, assumed to be in microns.

dispaxisint

Direction along which light is dispersed:

  • 1 = along rows

  • 2 = along columns

Returns:
dispersion_arrayfloat

2-D array of dispersion values, in microns/pixel.

photom_io(tabdata, order=None, time_correction=None, phot_unit=None)[source]

Combine photometric conversion factors and apply to the science dataset.

Parameters:
tabdataFITS_rec

Single row of data from reference table.

orderint

Spectral order number.

time_correctionfloat or None

Multiplicative correction for time dependence, defined as the fractional amount of light recorded now divided by the light recorded on the zero-day MJD (t0). The scalar conversion factor will be divided by the correction value if provided, and if self.apply_time_correction is True.

phot_unitstr or None

Unit string for the photometric conversion factor from the reference file phot_unit attribute (e.g., "MJy Angstrom s / (DN sr)"). When provided, it is used to compute a numeric conversion factor to the expected unit for the relevant observing mode. If None, no unit conversion is applied. Currently only implemented for WFSS data.

pixarea_from_ftab(ftab)[source]

Get pixel area in steradians and arsec^2 from photom reference file.

Read the pixel area values in the PIXAR_A2 and PIXAR_SR keys from the primary header of the photom reference file.

Parameters:
ftabJwstDataModel

A photom reference file data model.

Returns:
area_sterfloat

Pixel area in steradians.

area_a2float

Pixel area in arcsec^2.

save_area_info(ftab, area_fname)[source]

Populate area attributes in science dataset.

Read the pixel area values in the PIXAR_A2 and PIXAR_SR keys from the primary header of the pixel area reference file or (for NIRSpec data) from the PIXAREA column in the selected row of the AREA table in the area reference file. Use that information to populate the pixel area keywords in the output product.

Except for NIRSpec data, also copy the pixel area data array from the pixel area reference file to the area extension of the output product.

Parameters:
ftabJwstDataModel

A photom reference file data model.

area_fnamestr

Pixel area reference file name.

save_area_nirspec(pix_area)[source]

Populate the pixel area attributes of science dataset.

Read the pixel area value from the PIXAREA column in the selected row of the AREA table in the area reference file. Use that information to populate the pixel area keywords in the output product.

Parameters:
pix_areaJwstDataModel

Pixel area reference file data model.