ModelArray#

class corona_lab.corona.ModelArray(value: QuantityLike, unit=None, dtype=<class 'numpy.inexact'>, copy=True, order=None, subok=False, ndmin=0)[source]#

Bases: Quantity

Quantitative array with associated metadata, supporting serialization to and from JSON files. Base class for array-based synthetic observation classes.

Parameters:
  • value (array-like) – Numeric data array.

  • unit (Quantity or str or Unit) – Unit for the array values. Can be an astropy.units.Unit object, a ~astropy.units.Quantity (unit part is used), or a string parsable by u.Unit.

  • meta (dict, optional) – Initial metadata dictionary. Defaults to an empty metadata container.

meta#

Metadata container for storing arbitrary key–value pairs.

Type:

MetaData

unit#

Physical unit of the array values.

Type:

Unit

value#

Underlying numeric data array.

Type:

numpy.ndarray

Notes

Inherits from ~astropy.units.Quantity, so all Quantity operations apply to ModelArray instances.

Attributes Summary

Methods Summary

read(filename)

Deserialize a ModelArray from a JSON file.

write(filename)

Serialize this ModelArray to a JSON file.

Attributes Documentation

distance#
meta = None#
observation_angle#
parent_uid#
uid#

Methods Documentation

classmethod read(filename)[source]#

Deserialize a ModelArray from a JSON file.

Reads the JSON file written by write(), reconstructs the array, unit, and metadata.

Parameters:

filename (str) – Path to the JSON file to read.

Returns:

New instance created from the file contents.

Return type:

ModelArray

Raises:

IOError – If the file cannot be read.

write(filename)[source]#

Serialize this ModelArray to a JSON file.

The output file will contain: - “meta”: metadata dictionary, JSON-serializable. - “unit”: unit string, as from ~astropy.units.Unit.to_string(). - “array”: raw array data encoded in Latin-1 after being saved

with numpy.save.

Parameters:

filename (str) – Path to the JSON file to write. Overwrites existing files.

Raises:

IOError – If the file cannot be written.