DataModel
- class roman_datamodels.datamodels.DataModel(init=None, **kwargs)[source]
Bases:
ABCBase class for all top level datamodels
Handle the case where one passes in an already instantiated version of the model. In this case the constructor should just directly return the model.
Attributes Summary
override_handle identifies in-memory models where a filepath would normally be used.
Methods Summary
check_type(asdf_file)Subclass is expected to check for proper type of node
clone(target, source[, deepcopy, memo])close()copy([deepcopy, memo])create_fake_data([defaults, shape])Class method that constructs a model filled with fake data.
create_minimal([defaults])Class method that constructs an "minimal" model.
Get parameters used by CRDS to select references for this model.
Returns the name "primary" array for this model, which controls the size of other arrays that are implicitly created.
info(*args, **kwargs)items()Iterates over all of the model items in a flat way.
open_asdf([init])save(path[, dir_path, ...])schema_info(*args, **kwargs)search(*args, **kwargs)to_asdf(init, *args[, ...])to_flat_dict([include_arrays])Returns a dictionary of all of the model items as a flat dictionary.
validate()Re-validate the model instance against the tags
Attributes Documentation
- crds_observatory = 'roman'
- override_handle
override_handle identifies in-memory models where a filepath would normally be used.
- schema_uri
- shape
Methods Documentation
- classmethod create_fake_data(defaults=None, shape=None)[source]
Class method that constructs a model filled with fake data.
Similar to
DataModel.create_minimalthis only creates required attributes.Fake arrays will have a number of dimensions matching the schema requirements. If shape is provided only the dimensions matching the schema requirements will be used. For example if a 3 dimensional shape is provided but a fake array only requires 2 dimensions only the first 2 values from shape will be used.
- Parameters:
- Returns:
A valid model with fake data.
- Return type:
- classmethod create_minimal(defaults=None)[source]
Class method that constructs an “minimal” model.
The “minimal” model will contain schema-required attributes where a default value can be determined:
node class defining a default value
defined in the schema (for example single item enums)
empty container classes (for example a “meta” dict)
required items with a corresponding provided default
- get_crds_parameters()[source]
Get parameters used by CRDS to select references for this model.
This will only return items under
roman.meta.- Return 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()[source]
Iterates over all of the model items in a flat way.
Each element is a pair (
key,value). Eachkeyis a dot-separated name. For example, the schema elementmeta.observation.datewill end up in the result as:("meta.observation.date": "2012-04-22T03:22:05.432")
Unlike the JWST DataModel implementation, this does not use schemas directly.
- save(path, dir_path=None, *args, all_array_compression='lz4', all_array_storage='internal', **kwargs)[source]
- to_flat_dict(include_arrays=True)[source]
Returns a dictionary of all of the model items as a flat dictionary.
Each dictionary key is a dot-separated name. For example, the model element
meta.observation.datewill end up in the dictionary as:{ "meta.observation.date": "2012-04-22T03:22:05.432" }
This differs from the JWST data model in that the schema is not directly used