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 singleastropy.timeseries.TimeSeries
object or a dictionary ofstr
toastropy.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 beQuantity
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 morendcube.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:
ValueError – If the number of columns is less than 2 or the required ‘time’ column is missing.:
TypeError – If any column, excluding ‘time’, is not an
astropy.units.Quantity
object with units.:ValueError – If the elements of a
TimeSeries
column are multidimensional:TypeError – If any
supoport
data elements are not typeastropy.nddata.NDData
:TypeError – If
spectra
is not anNDCollection
object.:
References
Methods Summary
global_attribute_template
([instr_name, ...])Function to generate a template of the required ISTP-compliant global attributes.
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:
- 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.