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, BarshadowModel, CameraModel, CollimatorModel, ContrastModel, CubeModel, IFUCubeModel, DarkModel, DarkMIRIModel, DisperserModel, DistortionModel, DistortionMRSModel, DrizParsModel, DrizProductModel, Extract1dImageModel, FilteroffsetModel, FlatModel, CubeFlatModel, NRSFlatModel, NirspecFlatModel, NirspecQuadFlatModel, FOREModel, FPAModel, FringeModel, GainModel, GLS_RampFitModel, NIRCAMGrismModel, NIRISSGrismModel, GuiderCalModel, GuiderRawModel, ImageModel, IFUImageModel, IFUCubeParsModel, NirspecIFUCubeParsModel, MiriIFUCubeParsModel, IFUFOREModel, IFUPostModel, IFUSlicerModel, IPCModel, IRS2Model, LastFrameModel, Level1bModel, LinearityModel, MaskModel, MSAModel, ModelContainer, MultiExposureModel, MultiProductModel, MultiSlitModel, MultiSpecModel, OTEModel, OutlierParsModel, PathlossModel, PersistenceSatModel, PhotomModel, FgsPhotomModel, MiriImgPhotomModel, MiriMrsPhotomModel, NircamPhotomModel, NirissPhotomModel, NirspecPhotomModel, NirspecFSPhotomModel, PixelAreaModel, PsfMaskModel, QuadModel, RampModel, MIRIRampModel, RampFitOutputModel, ReadnoiseModel, ReferenceFileModel, ReferenceImageModel, ReferenceCubeModel, ReferenceQuadModel, RegionsModel, ResetModel, ResolutionModel, MiriResolutionModel, RSCDModel, SaturationModel, SpecModel, SpecwcsModel, StrayLightModel, SuperBiasModel, ThroughputModel, TrapDensityModel, TrapParsModel, TrapsFilledModel, TsoPhotModel, WaveCorrModel, WavelengthrangeModel, WfssBkgModel

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, strict_validation=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) – will be added to the metadata. If false, they will be set to None
  • strict_validation (if true, an schema validation errors will generate) – an excption. If false, they will generate a warning.
  • 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”.

history

Get the history as a list of entries

info()[source]

Return datatype and dimension for each array or table

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".

my_attribute(attr)[source]

Test if attribute is part of the NDData interface

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, strict_validation=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) – will be added to the metadata. If false, they will be set to None
  • strict_validation (if true, an schema validation errors will generate) – an excption. If false, they will generate a warning.
  • available built-in formats are (The) –
  • ==== ===== ============= (=========) – Format Read Write Auto-identify
  • ==== ===== =============
  • Yes Yes Yes (datamodel) –
  • ==== ===== =============
save(path, dir_path=None, *args, **kwargs)[source]

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

Parameters:
  • path (string or func) – File path to save to. If function, it takes one argument with is model.meta.filename and returns the full path string.
  • dir_path (string) – Directory to save to. If not None, this will override any directory information in the path
Returns:

output_path – The file path the model was saved in.

Return type:

str

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.
validate()[source]

Re-validate the model instance againsst its schema

values()

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

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.

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.AsnModel(init=None, asn_table=None, **kwargs)[source]

A data model for association tables.

class jwst.datamodels.BarshadowModel(init=None, data1x1=None, var1x1=None, data1x3=None, var1x3=None, **kwargs)[source]

A data model for Bar Shadow correction information.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – Array defining the bar shadow correction as a function of Y and wavelength.
  • variance (numpy array) – Variance array.
class jwst.datamodels.CameraModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “camera”.

populate_meta()[source]

Subclasses can overwrite this to populate specific meta keywords.

class jwst.datamodels.CollimatorModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “collimator”.

populate_meta()[source]

Subclasses can overwrite this to populate specific meta keywords.

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, int_times=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.
  • int_times (table) – The int_times table
  • 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, wavetable=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
  • wavetable (1-D table) – Optional table of wavelengths of IFUCube slices
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.DisperserModel(init=None, angle=None, gwa_tiltx=None, gwa_tilty=None, kcoef=None, lcoef=None, tcoef=None, pref=None, tref=None, theta_x=None, theta_y=None, theta_z=None, groovedensity=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “disperser”.

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.
to_fits()[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.
validate()[source]

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

class jwst.datamodels.DistortionModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “distortion”.

validate()[source]

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

class jwst.datamodels.DistortionMRSModel(init=None, x_model=None, y_model=None, alpha_model=None, beta_model=None, bzero=None, bdel=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “distortion” for the MIRI MRS.

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.
to_fits()[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.
validate()[source]

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

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

A data model for drizzle parameters reference tables.

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.Extract1dImageModel(init=None, data=None, **kwargs)[source]

A data model for the extract_1d reference image array.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – An array of values that define the extraction regions.
class jwst.datamodels.FilteroffsetModel(init=None, filters=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “disperser”.

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.
validate()[source]

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

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.FOREModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “fore”.

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.
populate_meta()[source]

Subclasses can overwrite this to populate specific meta keywords.

validate()[source]

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

class jwst.datamodels.FPAModel(init=None, nrs1_model=None, nrs2_model=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “fpa”.

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.
to_fits()[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.
validate()[source]

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

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.NIRCAMGrismModel(init=None, displ=None, dispx=None, dispy=None, invdispl=None, invdispx=None, invdispy=None, orders=None, **kwargs)[source]

A model for a reference file of type “specwcs” for NIRCAM grisms.

This reference file contains the models for wave, x, and y polynomial solutions that describe dispersion through the grism

to_fits()[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.
validate()[source]

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

class jwst.datamodels.NIRISSGrismModel(init=None, displ=None, dispx=None, dispy=None, invdispl=None, orders=None, fwcpos_ref=None, **kwargs)[source]

A model for a reference file of type “specwcs” for NIRISS grisms.

to_fits()[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.
validate()[source]

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

class jwst.datamodels.GuiderCalModel(init=None, data=None, dq=None, err=None, plan_star_table=None, flight_star_table=None, pointing_table=None, centroid_table=None, track_sub_table=None, **kwargs)[source]

A data model for FGS pipeline output files

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. 2-D
  • err (numpy array) – The error array. 3-D
  • plan_star_table (table) – The planned reference star table
  • flight_star_table (table) – The flight reference star table
  • pointing_table (table) – The pointing table
  • centroid_table (table) – The centroid packet table
  • track_sub_table (table) – The track subarray table
class jwst.datamodels.GuiderRawModel(init=None, data=None, dq=None, err=None, plan_star_table=None, flight_star_table=None, pointing_table=None, centroid_table=None, track_sub_table=None, **kwargs)[source]

A data model for FGS pipeline input files

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. 2-D.
  • err (numpy array) – The error array. 4-D.
  • plan_star_table (table) – The planned reference star table
  • flight_star_table (table) – The flight reference star table
  • pointing_table (table) – The pointing table
  • centroid_table (table) – The centroid packet table
  • track_sub_table (table) – The track subarray table
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.IFUImageModel(init=None, data=None, dq=None, err=None, relsens2d=None, zeroframe=None, area=None, pathloss_uniformsource=None, pathloss_pointsource=None, wavelength_pointsource=None, wavelength_uniformsource=None, **kwargs)[source]

A data model for 2D IFU 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.
  • relsens2d (numpy array) – The relative sensitivity 2D array.
class jwst.datamodels.IFUCubeParsModel(init=None, ifucubepars_table=None, ifucubepars_msn_table=None, **kwargs)[source]

A data model for IFU Cube parameters reference tables.

class jwst.datamodels.NirspecIFUCubeParsModel(init=None, ifucubepars_table=None, ifucubepars_msn_table=None, ifucubepars_prism_wavetable=None, ifucubepars_med_wavetable=None, ifucubepars_high_wavetable=None, **kwargs)[source]

A data model for Nirspec ifucubepars reference files.

class jwst.datamodels.MiriIFUCubeParsModel(init=None, ifucubepars_table=None, ifucubepars_msn_table=None, ifucubepars_multichannel_wavetable=None, **kwargs)[source]

A data model for MIRI mrs ifucubepars reference files.

class jwst.datamodels.IFUFOREModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “ifufore”.

populate_meta()[source]

Subclasses can overwrite this to populate specific meta keywords.

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

A model for a NIRSPEC reference file of type “ifupost”.

Parameters:
  • init (str) – A file name.
  • slice_models (dict) –

    A dictionary with slice transforms with the following entries: {“slice_N”: {‘linear’: astropy.modeling.Model,

    ’xpoly’: astropy.modeling.Model, ‘xpoly_distortion’: astropy.modeling.Model, ‘ypoly’: astropy.modeling.Model, ‘ypoly_distortion’: astropy.modeling.Model, }

    }

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.
to_fits()[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.
validate()[source]

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

class jwst.datamodels.IFUSlicerModel(init=None, model=None, data=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “ifuslicer”.

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.
to_fits()[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.
validate()[source]

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

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 refpix 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.Level1bModel(init=None, data=None, refout=None, zeroframe=None, group=None, int_times=None, **kwargs)[source]

A data model for raw 4D ramps level-1b products.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The science data
  • zeroframe (numpy array) – The zero-frame data
  • refout (numpy array) – The MIRI reference output data
  • group (table) – The group parameters table
  • int_times (table) – The int_times 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.
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.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.MSAModel(init=None, models=None, data=None, **kwargs)[source]

A model for a NIRSPEC reference file of type “msa”.

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.
to_fits()[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.
validate()[source]

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

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(memo=None)[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

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

Write out models in container to FITS or ASDF.

Parameters:
  • path (str or func or None) –
    • If None, the meta.filename is used for each model.
    • If a string, the string is used as a root and an index is appended.
    • If a function, the function takes the two arguments: the value of model.meta.filename and the idx index, returning constructed file name.
  • dir_path (str) – 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.
  • save_model_func (func or None) – Alternate function to save each model instead of the models save method. Takes one argument, the model, and keyword argument idx for an index.
Returns:

output_paths – List of output file paths of where the models were saved.

Return type:

[str[, ..]]

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]
>>> multislit[0]
<SlitModel>

If init is a file name or an ImageModel or a SlitModel``instance, an empty ``SlitModel will be created and assigned to attribute slits[0], and the data, dq, err, var_rnoise, var_poisson``and ``relsens attributes from the input file or model 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, int_times=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.OTEModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “ote”.

populate_meta()[source]

Subclasses can overwrite this to populate specific meta keywords.

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

A data model for outlier detection parameters reference tables.

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.PersistenceSatModel(init=None, data=None, dq=None, dq_def=None, **kwargs)[source]

A data model for the persistence saturation value (full well).

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.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.PsfMaskModel(init=None, data=None, **kwargs)[source]

A data model for coronagraphic 2D PSF mask reference files

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The 2-D mask array
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, int_times=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
  • int_times (table) – The int_times 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_poisson=None, var_rnoise=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_poisson (numpy array (n_int, max_seg, ny, nx)) –
  • var_rnoise (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.RegionsModel(init=None, regions=None, **kwargs)[source]

A model for a reference file of type “regions”.

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.
to_fits()[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.
validate()[source]

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

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.ResolutionModel(init=None, resolution_table=None, **kwargs)[source]

A data model for Spectral Resolution parameters reference tables.

class jwst.datamodels.MiriResolutionModel(init=None, resolving_power_table=None, psf_fwhm_alpha_table=None, psf_fwhm_beta_table=None, **kwargs)[source]

A data model for MIRI Resolution reference files.

Parameters:
  • init (any) – Any of the initializers supported by ‘~jwst.datamodels.DataModel’
  • resolving_power_table (table) – A table containing resolving power of the MRS. THe table consist of 11 columns and 12 rows. Each row corresponds to a band. The columns give the name of band, central wavelength, and polynomial coefficeints (a,b,c) needed to obtain the limits and average value of the spectral resolution.
  • psf_fwhm_alpha_table (table) – A table with 5 columns. Column 1 gives the cutoff wavelength where the polynomials describing alpha FWHM change. Columns 2 and 3 give the polynomial cofficients (a,b) describing alpha FWHM for wavelengths shorter than cuttoff. Columns 4 and 5 give the polynomial coefficients (a,b) describing alpha FWHM for wavelengths longer than the cutoff.
  • psf_fwhm_beta_table (table) – A table with 5 columns. Column 1 gives the cutoff wavelength where the polynomials describing alpha FWHM change. Columns 2 and 3 give the polynomial cofficients (a,b) describing beta FWHM for wavelengths shorter than cuttoff. Columns 4 and 5 give the polynomial coefficients (a,b) describing beta FWHM for wavelengths longer than the cutoff.
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.SpecwcsModel(init=None, model=None, input_units=None, output_units=None, **kwargs)[source]

A model for a reference file of type “specwcs”.

validate()[source]

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

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.

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

A data model for filter throughput.

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

A data model for the trap density of a detector, for persistence.

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.TrapParsModel(init=None, trappars_table=None, **kwargs)[source]

A data model for trap capture and decay parameters.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • trappars_table (numpy array) – A table with three columns for trap-capture parameters and one column for the trap-decay parameter. Each row of the table is for a different trap family.
class jwst.datamodels.TrapsFilledModel(init=None, data=None, **kwargs)[source]

A data model for the number of traps filled for a detector, for persistence.

Parameters:
  • init (any) – Any of the initializers supported by DataModel.
  • data (numpy array) – The map of the number of traps filled over the detector, with one plane for each “trap family.”
class jwst.datamodels.TsoPhotModel(init=None, radii=None, **kwargs)[source]

A model for a reference file of type “tsophot”.

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.
to_fits()[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.
validate()[source]

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

class jwst.datamodels.WaveCorrModel(init=None, apertures=None, **kwargs)[source]
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.
validate()[source]

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

class jwst.datamodels.WavelengthrangeModel(init=None, wrange_selector=None, wrange=None, order=None, wunits=None, **kwargs)[source]

A model for a reference file of type “wavelengthrange”. The model is used by MIRI, NIRSPEC, NIRCAM, and NIRISS

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.
to_fits()[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.
validate()[source]

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

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

A data model for 2D WFSS master background reference files.

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.