DataModel

class roman_datamodels.datamodels.DataModel(init=None, **kwargs)[source]

Bases: ABC

Base 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

crds_observatory

override_handle

override_handle identifies in-memory models where a filepath would normally be used.

schema_uri

shape

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_crds_parameters()

Get parameters used by CRDS to select references for this model.

get_primary_array_name()

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

check_type(asdf_file)[source]

Subclass is expected to check for proper type of node

static clone(target, source, deepcopy=False, memo=None)[source]
close()[source]
copy(deepcopy=True, memo=None)[source]
classmethod create_fake_data(defaults=None, shape=None)[source]

Class method that constructs a model filled with fake data.

Similar to DataModel.create_minimal this 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:
  • defaults (None or dict) – If provided, defaults will be used in place of schema defined or fake values for required attributes.

  • shape (None or tuple of int) – When provided use this shape to determine the shape used to construct fake arrays.

Returns:

A valid model with fake data.

Return type:

DataModel

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

Parameters:

defaults (None or dict) – If provided, defaults will be used in place of schema defined values for required attributes.

Returns:

“Empty” model with optional defaults. This will often be incomplete (invalid) as not all required attributes can be guessed.

Return type:

DataModel

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:

dict

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

info(*args, **kwargs)[source]
items()[source]

Iterates over all of the model 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")

Unlike the JWST DataModel implementation, this does not use schemas directly.

open_asdf(init=None, **kwargs)[source]
save(path, dir_path=None, *args, all_array_compression='lz4', all_array_storage='internal', **kwargs)[source]
schema_info(*args, **kwargs)[source]
search(*args, **kwargs)[source]
to_asdf(init, *args, all_array_compression=None, all_array_storage=None, **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.date will 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

validate()[source]

Re-validate the model instance against the tags