open

jwst.datamodels.open(init=None, guess=True, memmap=False, **kwargs)[source]

Creates a DataModel from a number of different types

Parameters
  • init (shape tuple, file path, file object, astropy.io.fits.HDUList,) –

    numpy array, dict, 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, JSON or ASDF)

    • readable file object: Initialize from the given file object

    • astropy.io.fits.HDUList: Initialize from the given HDUList

    • A numpy array: A new model with the data array initialized to what was passed in.

    • dict: The object model tree for the data model

  • guess (bool) – Guess as to the model type if the model type is not specifically known from the file. If not guess and the model type is not explicit, raise a TypeError.

  • memmap (bool) – Turn memmap of file on or off. (default: False).

  • kwargs (dict) –

    Additional keyword arguments passed to the DataModel constructor. Some arguments are general, others are file format-specific. Arguments of note are:

    • General

      validate_arraysbool

      If True, arrays will be validated against ndim, max_ndim, and datatype validators in the schemas.

    • FITS

      cast_fits_arraysbool

      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.

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

Returns

model

Return type

DataModel instance