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

Bases: JwstDataModel

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:

>>> from jwst.datamodels import SpecModel
>>> multispec_model = MultiSpecModel()
>>> multispec_model.spec.append(SpecModel())
>>> multispec_model.spec[0] 

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.

  • int_times (numpy table) – table of times for each integration

  • spec.items.spec_table (numpy table) – Extracted spectral data table


>>> output_model = MultiSpecModel()
>>> spec = SpecModel()       # for the default data type
>>> for slit in input_model.slits:  
...     slitname =
...     slitmodel = ExtractModel()
...     slitmodel.fromJSONFile(extref, slitname)
...     column, wavelength, countrate = slitmodel.extract(
...     otab = np.array(zip(column, wavelength, countrate),
...                     dtype=spec.spec_table.dtype)
...     spec = datamodels.SpecModel(spec_table=otab)
...     output_model.spec.append(spec)
  • init (str, tuple, HDUList, ndarray, dict, None) –

    • None : Create a default data model with no shape.

    • tuple : Shape of the data array. Initialize with empty data array with shape specified by the.

    • file path: Initialize from the given file (FITS or ASDF)

    • readable file object: Initialize from the given file object

    • 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 (dict, str (optional)) – Tree of objects representing a JSON schema, or string naming a schema. The schema to use to understand the elements on the model. If not provided, the schema associated with this class will be used.

  • memmap (bool) – Turn memmap of FITS file on or off. (default: False). Ignored for ASDF files.

  • pass_invalid_values (bool or None) – If True, values that do not validate the schema will be added to the metadata. If False, they will be set to None. If None, value will be taken from the environmental PASS_INVALID_VALUES. Otherwise the default value is False.

  • strict_validation (bool or None) – If True, schema validation errors will generate an exception. If False, they will generate a warning. If None, value will be taken from the environmental STRICT_VALIDATION. Otherwise, the default value is False.

  • validate_on_assignment (bool or None) – Defaults to ‘None’. If None, value will be taken from the environmental VALIDATE_ON_ASSIGNMENT, defaulting to ‘True’ if no environment variable is set. If ‘True’, attribute assignments are validated at the time of assignment. Validation errors generate warnings and values will be set to None. If ‘False’, schema validation occurs only once at the time of write. Validation errors generate warnings.

  • cast_fits_arrays (bool) – If True, arrays will be cast to the dtype described by the schema when read from a FITS file. If False, arrays will be read without casting.

  • validate_arrays (bool) – If True, arrays will be validated against ndim, max_ndim, and datatype validators in the schemas.

  • ignore_missing_extensions (bool) – When False, raise warnings when a file is read that contains metadata about extensions that are not available. Defaults to True.

  • kwargs (dict) –

    Additional keyword arguments passed to lower level functions. These arguments are generally file format-specific. Arguments of note are:

    • FITS

      skip_fits_update - bool or None

      True to skip updating the ASDF tree from the FITS headers, if possible. If None, value will be taken from the environmental SKIP_FITS_UPDATE. Otherwise, the default value is True.

Attributes Summary


The schema URI to validate the model against.

Attributes Documentation

schema_url = ''

The schema URI to validate the model against. If None, only basic validation of required metadata properties (filename, model_type) will occur.