open
- stdatamodels.jwst.datamodels.open(init=None, guess=True, **kwargs)
Load a data model, list of models, or association from file.
- Parameters:
- initshape tuple, file path, astropy.io.fits.HDUList, numpy array, dict, None
file path: Initialize from the given file (FITS, JSON or ASDF)
dict: Dictionary representing an association. The association will be returned as a ModelContainer with the models loaded from the files specified in the association dict.
list[str]: Initialize from a list of files. The list will be returned as a ModelContainer with the models loaded from the specified files.
JwstDataModel: Initialize from an existing model. The output model will be a shallow copy of the input model. This is supported for pipeline code convenience, but is not recommended for general use as it may cause unexpected behavior.
- guessbool
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.
- **kwargs
Additional keyword arguments passed to the DataModel constructor. Some arguments are general, others are file format-specific. Arguments of note are:
validate_arrays : bool If True, arrays will be validated against ndim, max_ndim, and datatype validators in the schemas.
- Returns:
- DataModel
A new model instance.
Warning
The
openfunction is not intended for creating models from scratch. Use the DataModel constructors directly instead, i.e.JwstDataModelfor a generic model or one of the many model subclasses (e.g.ImageModel,MultiSlitModel) for specific applications. None, shape tuple, and numpy array are all valid inputs to those constructors. See the documentation for each model class for details on how to use them.