Data model attributes

The purpose of the data model is to abstract away the peculiarities of the underlying file format. The same data model may be used for data created from scratch in memory, loaded from FITS or ASDF files, or from some other future format.

Calling sequences of models

List of current models

The current models are as follows:

AmiLgModel, AsnModel, ContrastModel, CubeModel, CubeFlatModel, DarkModel, DarkMIRIModel, DrizParsModel, NircamDrizParsModel, MiriImgDrizParsModel, DrizProductModel, FilterModel, FlatModel, FringeModel, GainModel, GLS_RampFitModel, IFUCubeModel, ImageModel, IPCModel, IRS2Model, LastFrameModel, LinearityModel, MaskModel, MIRIRampModel, ModelContainer, MultiExposureModel, MultiProductModel, MultiSlitModel, MultiSpecModel, NRSFlatModel, NirspecFlatModel, NirspecQuadFlatModel, PathlossModel, PhotomModel, FgsPhotomModel, MiriImgPhotomModel, MiriMrsPhotomModel, NircamPhotomModel, NirissPhotomModel, NirspecPhotomModel, NirspecFSPhotomModel, PixelAreaModel, QuadModel, RampModel, RampFitOutputModel, ReadnoiseModel, ReferenceFileModel, ReferenceImageModel, ReferenceCubeModel, ReferenceQuadModel, ResetModel, RSCDModel, SaturationModel, SpecModel, StrayLightModel, SuperBiasModel

Commonly used attributes

Here are a few model attributes that are used by some of the pipeline steps.

For uncalibrated data _uncal.fits. Getting the number of integrations and the number of groups from the first and second axes assumes that the input data array is 4-D data. Pixel coordinates in the data extensions are 1-indexed as in FORTRAN and FITS headers, not 0-indexed as in Python.

  • input_model.data.shape[0]: number of integrations
  • input_model.data.shape[1]: number of groups
  • input_model.meta.exposure.nframes: number of frames per group
  • input_model.meta.exposure.groupgap: number of frames dropped
    between groups
  • input_model.meta.subarray.xstart: starting pixel in X (1-based)
  • input_model.meta.subarray.ystart: starting pixel in Y (1-based)
  • input_model.meta.subarray.xsize: number of columns
  • input_model.meta.subarray.ysize: number of rows

The data, err, dq, etc., attributes of most models are assumed to be numpy.ndarray arrays, or at least objects that have some of the attributes of these arrays. numpy is used explicitly to create these arrays in some cases (e.g. when a default value is needed). The data and err arrays are a floating point type, and the data quality arrays are an integer type.

Some of the step code makes assumptions about image array sizes. For example, full-frame MIRI data have 1032 columns and 1024 rows, and all other detectors have 2048 columns and rows; anything smaller must be a subarray. Also, full-frame MIRI data are assumed to have four columns of reference pixels on the left and right sides (the reference output array is stored in a separate image extension). Full-frame data for all other instruments have four columns or rows of reference pixels on each edge of the image.

DataModel Base Class

class jwst.datamodels.DataModel(init=None, schema=None, extensions=None, pass_invalid_values=False)[source]

Base class of all of the data models.

Parameters:
  • init (shape tuple, file path, file object, astropy.io.fits.HDUList, numpy array, None) –
    • None: A default data model with no shape
    • shape tuple: Initialize with empty data of the given shape
    • file path: Initialize from the given file (FITS or ASDF)
    • readable file object: Initialize from the given file object
    • astropy.io.fits.HDUList: Initialize from the given HDUList.
    • A numpy array: Used to initialize the data array
    • dict: The object model tree for the data model
  • schema (tree of objects representing a JSON schema, or string naming a schema, optional) – The schema to use to understand the elements on the model. If not provided, the schema associated with this class will be used.
  • extensions (classes extending the standard set of extensions, optional.) – If an extension is defined, the prefix used should be ‘url’.
  • pass_invalid_values (If true, values that do not validate the schema can) – be read and written and only a warning will be generated
  • available built-in formats are (The) –
  • ==== ===== ============= (=========) – Format Read Write Auto-identify
  • ==== ===== =============
  • Yes Yes Yes (datamodel) –
  • ==== ===== =============
add_schema_entry(position, new_schema)[source]

Extend the model’s schema by placing the given new_schema at the given dot-separated position in the tree.

Parameters:
  • position (str) –
  • new_schema (schema tree) –
copy(memo=None)[source]

Returns a deep copy of this model.

extend_schema(new_schema)[source]

Extend the model’s schema using the given schema, by combining it in an “allOf” array.

Parameters:new_schema (schema tree) –
find_fits_keyword(keyword, return_result=True)[source]

Utility function to find a reference to a FITS keyword in this model’s schema. This is intended for interactive use, and not for use within library code.

Parameters:keyword (str) – A FITS keyword name
Returns:locations – If return_result is True, a list of the locations in the schema where this FITS keyword is used. Each element is a dot-separated path.
Return type:list of str

Example

>>> model.find_fits_keyword('DATE-OBS')
['observation.date']
classmethod from_asdf(init, schema=None)[source]

Load a data model from a ASDF file.

Parameters:
  • init (file path, file object, asdf.AsdfFile object) –
    • file path: Initialize from the given file
    • readable file object: Initialize from the given file object
    • asdf.AsdfFile: Initialize from the given AsdfFile.
  • schema – Same as for __init__
Returns:

model

Return type:

DataModel instance

classmethod from_fits(init, schema=None)[source]

Load a model from a FITS file.

Parameters:
  • init (file path, file object, astropy.io.fits.HDUList) –
    • file path: Initialize from the given file
    • readable file object: Initialize from the given file object
    • astropy.io.fits.HDUList: Initialize from the given HDUList.
  • schema – Same as for __init__
Returns:

model

Return type:

DataModel instance

get_fits_wcs(hdu_name='SCI', hdu_ver=1, key=' ')[source]

Get a astropy.wcs.WCS object created from the FITS WCS information in the model.

Note that modifying the returned WCS object will not modify the data in this model. To update the model, use set_fits_wcs.

Parameters:
  • hdu_name (str, optional) – The name of the HDU to get the WCS from. This must use named HDU’s, not numerical order HDUs. To get the primary HDU, pass 'PRIMARY'.
  • key (str, optional) – The name of a particular WCS transform to use. This may be either ' ' or 'A'-'Z' and corresponds to the "a" part of the CTYPEia cards. key may only be provided if header is also provided.
  • hdu_ver (int, optional) – The extension version. Used when there is more than one extension with the same name. The default value, 1, is the first.
Returns:

wcs – The type will depend on what libraries are installed on this system.

Return type:

astropy.wcs.WCS or pywcs.WCS object

get_item_as_json_value(key)[source]

Equivalent to __getitem__, except returns the value as a JSON basic type, rather than an arbitrary Python type.

get_primary_array_name()[source]

Returns the name “primary” array for this model, which controls the size of other arrays that are implicitly created. This is intended to be overridden in the subclasses if the primary array’s name is not “data”.

items()

Iterates over all of the schema items in a flat way.

Each element is a pair (key, value). Each key is a dot-separated name. For example, the schema element meta.observation.date will end up in the result as:

("meta.observation.date": "2012-04-22T03:22:05.432")
iteritems()[source]

Iterates over all of the schema items in a flat way.

Each element is a pair (key, value). Each key is a dot-separated name. For example, the schema element meta.observation.date will end up in the result as:

("meta.observation.date": "2012-04-22T03:22:05.432")
iterkeys()[source]

Iterates over all of the schema keys in a flat way.

Each result of the iterator is a key. Each key is a dot-separated name. For example, the schema element meta.observation.date will end up in the result as the string "meta.observation.date".

itervalues()[source]

Iterates over all of the schema values in a flat way.

keys()

Iterates over all of the schema keys in a flat way.

Each result of the iterator is a key. Each key is a dot-separated name. For example, the schema element meta.observation.date will end up in the result as the string "meta.observation.date".

on_save(path=None)[source]

This is a hook that is called just before saving the file. It can be used, for example, to update values in the metadata that are based on the content of the data.

Override it in the subclass to make it do something, but don’t forget to “chain up” to the base class, since it does things there, too.

Parameters:path (str) – The path to the file that we’re about to save to.
read(init=None, schema=None, extensions=None, pass_invalid_values=False)
Parameters:
  • init (shape tuple, file path, file object, astropy.io.fits.HDUList, numpy array, None) –
    • None: A default data model with no shape
    • shape tuple: Initialize with empty data of the given shape
    • file path: Initialize from the given file (FITS or ASDF)
    • readable file object: Initialize from the given file object
    • astropy.io.fits.HDUList: Initialize from the given HDUList.
    • A numpy array: Used to initialize the data array
    • dict: The object model tree for the data model
  • schema (tree of objects representing a JSON schema, or string naming a schema, optional) – The schema to use to understand the elements on the model. If not provided, the schema associated with this class will be used.
  • extensions (classes extending the standard set of extensions, optional.) – If an extension is defined, the prefix used should be ‘url’.
  • pass_invalid_values (If true, values that do not validate the schema can) – be read and written and only a warning will be generated
  • available built-in formats are (The) –
  • ==== ===== ============= (=========) – Format Read Write Auto-identify
  • ==== ===== =============
  • Yes Yes Yes (datamodel) –
  • ==== ===== =============
save(path, *args, **kwargs)[source]

Save to either a FITS or ASDF file, depending on the path.

Parameters:
  • path (string) –
  • available built-in formats are (The) –
  • ==== ===== ============= (=========) – Format Read Write Auto-identify
  • ==== ===== =============
  • Yes Yes Yes (datamodel) –
  • ==== ===== =============
search_schema(substring)[source]

Utility function to search the metadata schema for a particular phrase.

This is intended for interactive use, and not for use within library code.

The searching is case insensitive.

Parameters:substring (str) – The substring to search for.
Returns:locations
Return type:list of tuples
set_fits_wcs(wcs, hdu_name='SCI')[source]

Sets the FITS WCS information on the model using the given astropy.wcs.WCS object.

Note that the “key” of the WCS is stored in the WCS object itself, so it can not be set as a parameter to this method.

Parameters:
  • wcs (astropy.wcs.WCS or pywcs.WCS object) – The object containing FITS WCS information
  • hdu_name (str, optional) – The name of the HDU to set the WCS from. This must use named HDU’s, not numerical order HDUs. To set the primary HDU, pass 'PRIMARY'.
to_asdf(init, *args, **kwargs)[source]

Write a DataModel to an ASDF file.

Parameters:
  • init (file path or file object) –
  • kwargs (args,) – Any additional arguments are passed along to asdf.AsdfFile.write_to.
to_fits(init, *args, **kwargs)[source]

Write a DataModel to a FITS file.

Parameters:
  • init (file path or file object) –
  • kwargs (args,) – Any additional arguments are passed along to astropy.io.fits.writeto.
to_flat_dict(include_arrays=True)[source]

Returns a dictionary of all of the schema items as a flat dictionary.

Each dictionary key is a dot-separated name. For example, the schema element meta.observation.date will end up in the dictionary as:

{ "meta.observation.date": "2012-04-22T03:22:05.432" }
update(d, only='')[source]

Updates this model with the metadata elements from another model.

Parameters:
  • d (model or dictionary-like object) – The model to copy the metadata elements from. Can also be a dictionary or dictionary of dictionaries or lists.
  • only (only update the named hdu from extra_fits, e.g.) – only=’PRIMARY’. Can either be a list of hdu names or a single string. If left blank, update all the hdus.
values()

Iterates over all of the schema values in a flat way.

write(path, *args, **kwargs)

Save to either a FITS or ASDF file, depending on the path.

Parameters:
  • path (string) –
  • available built-in formats are (The) –
  • ==== ===== ============= (=========) – Format Read Write Auto-identify
  • ==== ===== =============
  • Yes Yes Yes (datamodel) –
  • ==== ===== =============

Specific Model Classes

class jwst.datamodels.AmiLgModel(init=None, fit_image=None, resid_image=None, closure_amp_table=None, closure_phase_table=None, fringe_amp_table=None, fringe_phase_table=None, pupil_phase_table=None, solns_table=None, **kwargs)[source]

A data model for AMI LG analysis results.

class jwst.datamodels.AsnModel(init=None, asn_table=None, **kwargs)[source]

A data model for association tables.

class jwst.datamodels.ContrastModel(init=None, contrast_table=None, **kwargs)[source]

A data model for coronagraphic contrast curve files.

class jwst.datamodels.CubeModel(init=None, data=None, dq=None, err=None, zeroframe=None, relsens=None, area=None, wavelength=None, var_poisson=None, var_rnoise=None, **kwargs)[source]

A data model for 3D image cubes.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 3-D.
  • dq (numpy array) – The data quality array. 3-D.
  • err (numpy array) – The error array. 3-D
  • zeroframe (numpy array) – The zero-frame array. 3-D
  • relsens (numpy array) – The relative sensitivity array.
  • area (numpy array) – The pixel area array. 2-D
  • wavelength (numpy array) – The wavelength array. 2-D
  • var_poisson (numpy array) – The variance due to Poisson noise array. 3-D
  • var_rnoise (numpy array) – The variance due to read noise array. 3-D
class jwst.datamodels.IFUCubeModel(init=None, data=None, dq=None, err=None, weightmap=None, hdrtab=None, **kwargs)[source]

A data model for 3D IFU cubes.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 3-D.
  • dq (numpy array) – The data quality array. 3-D.
  • err (numpy array) – The error array. 3-D
  • weightmap (numpy array) – The weight map array. 3-D
class jwst.datamodels.DarkModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for dark reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.DarkMIRIModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for dark MIRI reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data (integration dependent)
  • dq (numpy array) – The data quality array. (integration dependent)
  • err (numpy array (integration dependent)) – The error array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.DrizParsModel(init=None, drizpars_table=None, **kwargs)[source]

A data model for drizzle parameters reference tables.

class jwst.datamodels.NircamDrizParsModel(init=None, drizpars_table=None, **kwargs)[source]

A data model for NIRCam drizpars reference files.

class jwst.datamodels.MiriImgDrizParsModel(init=None, drizpars_table=None, **kwargs)[source]

A data model for MIRI imaging drizpars reference files.

class jwst.datamodels.DrizProductModel(init=None, data=None, con=None, wht=None, hdrtab=None, relsens=None, **kwargs)[source]

A data model for drizzle-generated products.

class jwst.datamodels.FlatModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for 2D flat-field images.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 2-D.
  • dq (numpy array) – The data quality array. 2-D.
  • err (numpy array) – The error array. 2-D.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.NRSFlatModel(init=None, flat_table=None, **kwargs)[source]

A base class for NIRSpec flat-field reference file models.

class jwst.datamodels.NirspecFlatModel(init=None, data=None, dq=None, err=None, wavelength=None, flat_table=None, dq_def=None, **kwargs)[source]

A data model for NIRSpec flat-field reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 2-D or 3-D.
  • dq (numpy array) – The data quality array. 2-D or 3-D.
  • err (numpy array) – The error array. 2-D or 3-D.
  • wavelength (numpy array) – The wavelength for each plane of the data array. This will only be needed if data is 3-D.
  • flat_table (numpy array) – A table of wavelengths and flat-field values, to specify the component of the flat field that can vary over a relatively short distance (can be pixel-to-pixel).
class jwst.datamodels.NirspecQuadFlatModel(init=None, **kwargs)[source]

A data model for NIRSpec flat-field files that differ by quadrant.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 2-D or 3-D.
  • dq (numpy array) – The data quality array. 2-D or 3-D.
  • err (numpy array) – The error array. 2-D or 3-D.
  • wavelength (numpy array) – The wavelength for each plane of the data array. This will only be needed if data is 3-D.
  • flat_table (numpy array) – A table of wavelengths and flat-field values, to specify the component of the flat field that can vary over a relatively short distance (can be pixel-to-pixel).
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.FringeModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for 2D fringe correction images.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.GainModel(init=None, data=None, **kwargs)[source]

A data model for 2D gain.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The 2-D gain array
class jwst.datamodels.GLS_RampFitModel(init=None, yint=None, sigyint=None, pedestal=None, crmag=None, sigcrmag=None, **kwargs)[source]

A data model for the optional output of the ramp fitting step for the GLS algorithm.

class jwst.datamodels.ImageModel(init=None, data=None, dq=None, err=None, relsens=None, relsens2d=None, zeroframe=None, area=None, wavelength=None, var_poisson=None, var_rnoise=None, **kwargs)[source]

A data model for 2D images.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
  • relsens (numpy array) – The relative sensitivity table.
  • relsens2d (numpy array) – The relative sensitivty 2D array.
  • zeroframe (numpy array) – The zero-frame array.
  • area (numpy array) – The pixel area array.
  • wavelength (numpy array) – The wavelength array.
  • var_poisson (numpy array) – The variance due to Poisson noise array.
  • var_rnoise (numpy array) – The variance due to read noise array.
class jwst.datamodels.IPCModel(init=None, data=None, **kwargs)[source]

A data model for IPC kernel checking information.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The deconvolution kernel (a very small image).
class jwst.datamodels.IRS2Model(init=None, irs2_table=None, **kwargs)[source]

A data model for the IRS2 reference file.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • irs2_table (numpy array) – A table with 8 columns and 2916352 (2048 * 712 * 2) rows. All values are float, but these are interpreted as alternating real and imaginary parts (real, imag, real, imag, …) of complex values. There are four columns for ALPHA and four for BETA.
class jwst.datamodels.LastFrameModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for Last frame correction reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.LinearityModel(init=None, coeffs=None, dq=None, dq_def=None, **kwargs)[source]

A data model for linearity correction information.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • coeffs (numpy array) – Coefficients defining the nonlinearity function.
  • dq (numpy array) – The data quality array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.MaskModel(init=None, dq=None, dq_def=None, **kwargs)[source]

A data model for 2D masks.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • dq (numpy array) – The data quality array.
  • dq_def (numpy array) – The data quality definitions table.
get_primary_array_name()[source]

Returns the name “primary” array for this model, which controls the size of other arrays that are implicitly created. This is intended to be overridden in the subclasses if the primary array’s name is not “data”.

class jwst.datamodels.ModelContainer(init=None, persist=True, **kwargs)[source]

A container for holding DataModels.

This functions like a list for holding DataModel objects. It can be iterated through like a list, DataModels within the container can be addressed by index, and the datamodels can be grouped into a list of lists for grouped looping, useful for NIRCam where grouping together all detectors of a given exposure is useful for some pipeline steps.

Parameters:
  • init (file path, list of DataModels, or None) –
    • file path: initialize from an association table
    • list: a list of DataModels of any type
    • None: initializes an empty ModelContainer instance, to which DataModels can be added via the append() method.
  • persist (boolean. If True, do not close model after opening it) –

Examples

>>> container = datamodels.ModelContainer('example_asn.json')
>>> for dm in container:
...     print(dm.meta.filename)

Say the association was a NIRCam dithered dataset. The models_grouped attribute is a list of lists, the first index giving the list of exposure groups, with the second giving the individual datamodels representing each detector in the exposure (2 or 8 in the case of NIRCam).

>>> total_exposure_time = 0.0
>>> for group in container.models_grouped:
...     total_exposure_time += group[0].meta.exposure.exposure_time
>>> c = datamodels.ModelContainer()
>>> m = datamodels.open('myfile.fits')
>>> c.append(m)
copy()[source]

Returns a deep copy of the models in this model container.

from_asn(filepath, **kwargs)[source]

Load fits files from a JWST association file.

Parameters:filepath (str) – The path to an association file.
get_recursively(field)[source]

Returns a list of values of the specified field from meta.

group_names

Return list of names for the DataModel groups by exposure.

models_grouped

Returns a list of a list of datamodels grouped by exposure.

Data from different detectors of the same exposure will have the same group id, which allows grouping by exposure. The following metadata is used for grouping:

meta.observation.program_number meta.observation.observation_number meta.observation.visit_number meta.observation.visit_group meta.observation.sequence_id meta.observation.activity_id meta.observation.exposure_number meta.instrument.name meta.instrument.channel

save(path_not_used, path=None, *args, **kwargs)[source]

Write out models in container to FITS or ASDF.

Parameters:
  • path_not_used (string) – This first argument is ignored in this implementation of the save method. It is used by pipeline steps to save individual files, but that is not applicable here. Instead, we use the path arg below and read the filename output from meta.filename in each file in the container.
  • path (string) – Directory to write out files. Defaults to current working dir. If directory does not exist, it creates it. Filenames are pulled from meta.filename of each datamodel in the container.
class jwst.datamodels.MultiExposureModel(init=None, **kwargs)[source]

A data model for multi-slit images derived from numerous exposures. The intent is that all slits in this model are of the same source, with each slit representing a separate exposure of that source.

This model has a special member exposures that can be used to deal with an entire slit at a time. It behaves like a list:

>>> multislit_model.exposures.append(image_model)
>>> multislit_model.exposures[0]
<ImageModel>

Also, there is an extra attribute, meta. This will contain the meta attribute from the exposure from which each slit has been taken.

See the module exp_to_source for the initial creation of these models. This is part of the Level 3 processing of multi-objection observations.

class jwst.datamodels.MultiProductModel(init=None, **kwargs)[source]

A data model for multi-DrizProduct images.

This model has a special member products that can be used to deal with each DrizProduct at a time. It behaves like a list:

>>> multiprod_model.products.append(image_model)
>>> multislit_model.products[0]
<DrizProductModel>

If init is a file name or an DrizProductModel instance, an empty DrizProductModel will be created and assigned to attribute products[0], and the data, wht, con, and relsens attributes from the input file or DrizProductModel will be copied to the first element of products.

Parameters:init (any) – Any of the initializers supported by DataModel.
class jwst.datamodels.MultiSlitModel(init=None, **kwargs)[source]

A data model for multi-slit images.

This model has a special member slits that can be used to deal with an entire slit at a time. It behaves like a list:

>>> multislit_model.slits.append(image_model)
>>> multislit_model.slits[0]
<ImageModel>

If init is a file name or an ImageModel instance, an empty ImageModel will be created and assigned to attribute slits[0], and the data, dq, err, and relsens attributes from the input file or ImageModel will be copied to the first element of slits.

Parameters:init (any) – Any of the initializers supported by DataModel.
class jwst.datamodels.MultiSpecModel(init=None, **kwargs)[source]

A data model for multi-spec images.

This model has a special member spec that can be used to deal with an entire spectrum at a time. It behaves like a list:

>>> multispec_model.spec.append(spec_model)
>>> multispec_model.spec[0]
<SpecModel>

If init is a SpecModel instance, an empty SpecModel will be created and assigned to attribute spec[0], and the spec_table attribute from the input SpecModel instance will be copied to the first element of spec. SpecModel objects can be appended to the spec attribute by using its append method.

Parameters:init (any) – Any of the initializers supported by DataModel.

Examples

>>> output_model = datamodels.MultiSpecModel()
>>> spec = datamodels.SpecModel()       # for the default data type
>>> for slit in input_model.slits:
>>>     slitname = slit.name
>>>     slitmodel = ExtractModel()
>>>     slitmodel.fromJSONFile(extref, slitname)
>>>     column, wavelength, countrate = slitmodel.extract(slit.data)
>>>     otab = np.array(zip(column, wavelength, countrate),
>>>                     dtype=spec.spec_table.dtype)
>>>     spec = datamodels.SpecModel(spec_table=otab)
>>>     output_model.spec.append(spec)
class jwst.datamodels.PathlossModel(init=None, pointsource=None, psvar=None, uniform=None, **kwargs)[source]

A data model for pathloss correction information.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • pointsource (numpy array) – Array defining the pathloss parameter for point sources.
  • psvar (numpy array) – Variance array.
  • uniform (numpy array) – Pathloss parameter for uniform illumination
class jwst.datamodels.PhotomModel(init=None, phot_table=None, **kwargs)[source]

A base class for photometric reference file models.

class jwst.datamodels.FgsPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for FGS photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[5000]
    • relresponse: float32[5000]
class jwst.datamodels.MiriImgPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for MIRI imaging photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • filter: str[12]
    • subarray: str[15]
    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[500]
    • relresponse: float32[500]
class jwst.datamodels.MiriMrsPhotomModel(init=None, data=None, err=None, dq=None, dq_def=None, pixsiz=None, **kwargs)[source]

A data model for MIRI MRS photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – An array-like object containing the pixel-by-pixel conversion values in units of DN / sec / mJy / pixel.
  • err (numpy array) – An array-like object containing the uncertainties in the conversion values, in the same units as the data array.
  • dq (numpy array) – An array-like object containing bit-encoded data quality flags, indicating problem conditions for values in the data array.
  • dq_def (numpy array) – A table-like object containing the data quality definitions table.
  • pixsiz (numpy array) – An array-like object containing pixel-by-pixel size values, in units of square arcseconds (arcsec^2).
class jwst.datamodels.NircamPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for NIRCam photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • filter: str[12]
    • pupil: str[12]
    • order: int16
    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[3000]
    • relresponse: float32[3000]
class jwst.datamodels.NirissPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for NIRISS photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • filter: str[12]
    • pupil: str[12]
    • order: int16
    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[5000]
    • relresponse: float32[5000]
class jwst.datamodels.NirspecPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for NIRSpec imaging, IFU, and MOS photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • filter: str[12]
    • grating: str[12]
    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[150]
    • relresponse: float32[150]
    • reluncertainty: float32[150]
class jwst.datamodels.NirspecFSPhotomModel(init=None, phot_table=None, **kwargs)[source]

A data model for NIRSpec Fixed-Slit (FS) photom reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • phot_table (numpy array) –

    A table-like object containing row selection criteria made up of instrument mode parameters and photometric conversion factors associated with those modes.

    • filter: str[12]
    • grating: str[12]
    • slit: str[12]
    • photmjsr: float32
    • uncertainty: float32
    • nelem: int16
    • wavelength: float32[150]
    • relresponse: float32[150]
    • reluncertainty: float32[150]
class jwst.datamodels.PixelAreaModel(init=None, data=None, **kwargs)[source]

A data model for the pixel area map

class jwst.datamodels.QuadModel(init=None, data=None, dq=None, err=None, **kwargs)[source]

A data model for 4D image arrays.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data. 4-D.
  • dq (numpy array) – The data quality array. 4-D.
  • err (numpy array) – The error array. 4-D
class jwst.datamodels.RampModel(init=None, data=None, pixeldq=None, groupdq=None, err=None, zeroframe=None, group=None, **kwargs)[source]

A data model for 4D ramps.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • pixeldq (numpy array) – 2-D data quality array.
  • groupdq (numpy array) – 3-D or 4-D data quality array.
  • err (numpy array) – The error array.
  • group (table) – The group parameters table
class jwst.datamodels.MIRIRampModel(init=None, data=None, pixeldq=None, groupdq=None, err=None, refout=None, zeroframe=None, group=None, **kwargs)[source]

A data model for MIRI ramps. Includes the refout array.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • pixeldq (numpy array) – 2-D data quality array.
  • groupdq (numpy array) – 3-D or 4-D data quality array.
  • err (numpy array) – The error array.
  • refout (numpy array) – The array of reference output data.
  • group (table) – The group parameters table.
class jwst.datamodels.RampFitOutputModel(init=None, slope=None, sigslope=None, var_p=None, var_r=None, yint=None, sigyint=None, pedestal=None, weights=None, crmag=None, **kwargs)[source]

A data model for the optional output of the ramp fitting step.

In the parameter definitions below, n_int is the number of integrations, max_seg is the maximum number of segments that were fit, nreads is the number of reads in an integration, and ny and nx are the height and width of the image.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • slope (numpy array (n_int, max_seg, ny, nx)) –
  • sigslope (numpy array (n_int, max_seg, ny, nx)) –
  • var_p (numpy array (n_int, max_seg, ny, nx)) –
  • var_r (numpy array (n_int, max_seg, ny, nx)) –
  • yint (numpy array (n_int, max_seg, ny, nx)) –
  • sigyint (numpy array (n_int, max_seg, ny, nx)) –
  • pedestal (numpy array (n_int, max_seg, ny, nx)) –
  • weights (numpy array (n_int, max_seg, ny, nx)) –
  • crmag (numpy array (n_int, max_seg, ny, nx)) –
class jwst.datamodels.ReadnoiseModel(init=None, data=None, **kwargs)[source]

A data model for 2D readnoise.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – Read noise for all pixels. 2-D.
class jwst.datamodels.ReferenceFileModel(init=None, **kwargs)[source]

A data model for reference tables

Parameters:init (any) – Any of the initializers supported by DataModel.
validate()[source]

Convenience function to be run when files are created. Checks that required reference file keywords are set.

class jwst.datamodels.ReferenceImageModel(init=None, data=None, dq=None, err=None, **kwargs)[source]

A data model for 2D reference images

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
class jwst.datamodels.ReferenceCubeModel(init=None, data=None, dq=None, err=None, **kwargs)[source]

A data model for 3D reference images

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
class jwst.datamodels.ReferenceQuadModel(init=None, data=None, dq=None, err=None, **kwargs)[source]

A data model for 4D reference images

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
class jwst.datamodels.ResetModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for reset correction reference files.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • err (numpy array) – The error array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.RSCDModel(init=None, rscd_table=None, **kwargs)[source]

A data model for the RSCD reference file.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • rscd_table (numpy array) – A table with seven columns, three string-valued that identify which row to select, and four float columns containing coefficients.
class jwst.datamodels.SaturationModel(init=None, data=None, dq=None, dq_def=None, **kwargs)[source]

A data model for saturation checking information.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data.
  • dq (numpy array) – The data quality array.
  • dq_def (numpy array) – The data quality definitions table.
class jwst.datamodels.SpecModel(init=None, spec_table=None, **kwargs)[source]

A data model for 1D spectra.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • spec_table (numpy array) – A table with at least four columns: wavelength, flux, an error estimate for the flux, and data quality flags.
class jwst.datamodels.StrayLightModel(init=None, data=None, **kwargs)[source]

A data model for 2D straylight mask.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – 2-D straylight mask array.
class jwst.datamodels.SuperBiasModel(init=None, data=None, dq=None, err=None, dq_def=None, **kwargs)[source]

A data model for 2D super-bias images.