HermesData

class hermes_core.timedata.HermesData(timeseries: TimeSeries | dict[str, TimeSeries], support: dict[Quantity | NDData] | None = None, spectra: NDCollection | None = None, meta: dict | None = None)[source]

Bases: SWXData

A generic object for loading, storing, and manipulating HERMES time series data.

Parameters:
  • timeseries (Union[astropy.timeseries.TimeSeries, Dict[str, astropy.timeseries.TimeSeries]]) – The time-series data. This can be a single astropy.timeseries.TimeSeries object or a dictionary of str to astropy.timeseries.TimeSeries objects. If a dictionary, one key must be named ‘epoch’, the primary time axis. If non-index/time columns are included in any of the TimeSeries objects, they must be Quantity arrays.

  • support (Optional[dict[Union[astropy.units.Quantity, astropy.nddata.NDData]]]) – Support data arrays which do not vary with time (i.e. Non-Record-Varying data).

  • spectra (Optional[ndcube.NDCollection]) – One or more ndcube.NDCube objects containing spectral or higher-dimensional timeseries data.

  • meta (Optional[dict]) – The metadata describing the time series in an ISTP-compliant format.

Examples

>>> import numpy as np
>>> import astropy.units as u
>>> from astropy.timeseries import TimeSeries
>>> from ndcube import NDCube, NDCollection
>>> from astropy.wcs import WCS
>>> from astropy.nddata import NDData
>>> from hermes_core.timedata import HermesData
>>> # Create a TimeSeries structure
>>> data = u.Quantity([1, 2, 3, 4], "gauss", dtype=np.uint16)
>>> ts = TimeSeries(time_start="2016-03-22T12:30:31", time_delta=3 * u.s, data={"Bx": data})
>>> # Create a Spectra structure
>>> spectra = NDCollection(
...     [
...         (
...             "test_spectra",
...             NDCube(
...                 data=np.random.random(size=(4, 10)),
...                 wcs=WCS(naxis=2),
...                 meta={"CATDESC": "Test Spectra Variable"},
...                 unit="eV",
...             ),
...         )
...     ]
... )
>>> # Create a Support Structure
>>> support_data = {
...     "data_mask": NDData(data=np.eye(100, 100, dtype=np.uint16), meta={"CATDESC": "Data Mask", "VAR_TYPE": "metadata"})
... }
>>> # Create Global Metadata Attributes
>>> input_attrs = HermesData.global_attribute_template("eea", "l1", "1.0.0")
>>> # Create HermesData Object
>>> hermes_data = HermesData(timeseries=ts, support=support_data, spectra=spectra, meta=input_attrs)
Raises:

References

Methods Summary

global_attribute_template([instr_name, ...])

Function to generate a template of the required ISTP-compliant global attributes.

measurement_attribute_template()

Function to generate a template of the required measurement attributes.

validate(file_path)

Validate the CDF file.

Methods Documentation

static global_attribute_template(instr_name: str = '', data_level: str = '', version: str = '') OrderedDict[source]

Function to generate a template of the required ISTP-compliant global attributes.

Parameters:
  • instr_name (str) – The instrument name. Must be “eea”, “nemisis”, “merit” or “spani”.

  • data_level (str) – The data level of the data. Must be “l0”, “l1”, “ql”, “l2”, “l3”, “l4”

  • version (str) – Must be of the form X.Y.Z.

Returns:

template (collections.OrderedDict) – A template for required global attributes.

static measurement_attribute_template() OrderedDict[source]

Function to generate a template of the required measurement attributes.

Returns:

template (collections.OrderedDict) – A template for required variable attributes that must be provided.

static validate(file_path: Path) list[str][source]

Validate the CDF file.

Parameters:

file_path (pathlib.Path) – A fully specified file path of the CDF data file to validate.

Returns:

errors (list[str]) – A list of validation errors returned. A valid file will result in an empty list being returned.