HermesDataSchema

class hermes_core.util.schema.HermesDataSchema[source]

Bases: object

Class representing the schema of a file type.

Attributes Summary

default_global_attributes

(dict) Default Global Attributes applied for all HERMES Data Files

global_attribute_schema

(dict) Schema for variable attributes of the file.

variable_attribute_schema

(dict) Schema for variable attributes of the file.

Methods Summary

derive_global_attributes(data)

Function to derive global attributes for the given measurement data.

derive_measurement_attributes(data, var_name)

Function to derive metadata for the given measurement.

derive_time_attributes(data)

Function to derive metadata for the time measurement.

global_attribute_info([attribute_name])

Function to generate a astropy.table.Table of information about each global metadata attribute.

global_attribute_template()

Function to generate a template of required global attributes that must be set for a valid CDF.

measurement_attribute_info([attribute_name])

Function to generate a astropy.table.Table of information about each variable metadata attribute.

measurement_attribute_template()

Function to generate a template of required measurement attributes that must be set for a valid CDF measurement variable.

Attributes Documentation

default_global_attributes

(dict) Default Global Attributes applied for all HERMES Data Files

global_attribute_schema

(dict) Schema for variable attributes of the file.

variable_attribute_schema

(dict) Schema for variable attributes of the file.

Methods Documentation

derive_global_attributes(data) OrderedDict[source]

Function to derive global attributes for the given measurement data.

Parameters:

data (hermes_core.timedata.HermesData) – An instance of HermesData to derive metadata from.

Returns:

attributes (OrderedDict) – A dict containing key: value pairs of global metadata attributes.

derive_measurement_attributes(data, var_name: str, guess_types: list[int] | None = None) OrderedDict[source]

Function to derive metadata for the given measurement.

Parameters:
  • data (hermes_core.timedata.HermesData) – An instance of HermesData to derive metadata from

  • var_name (str) – The name of the measurement to derive metadata for

  • guess_types (list[int], optional) – Guessed CDF Type of the variable

Returns:

attributes (OrderedDict) – A dict containing key: value pairs of derived metadata attributes.

derive_time_attributes(data) OrderedDict[source]

Function to derive metadata for the time measurement.

Parameters:

data (hermes_core.timedata.HermesData) – An instance of HermesData to derive metadata from.

Returns:

attributes (OrderedDict) – A dict containing key: value pairs of time metadata attributes.

static global_attribute_info(attribute_name: str | None = None) Table[source]

Function to generate a astropy.table.Table of information about each global metadata attribute. The astropy.table.Table contains all information in the HERMES global attribute schema including:

  • description: (str) A brief description of the attribute

  • default: (str) The default value used if none is provided

  • derived: (bool) Whether the attibute can be derived by the HERMES

    HermesDataSchema class

  • required: (bool) Whether the attribute is required by HERMES standards

  • validate: (bool) Whether the attribute is included in the

    validate() checks (Note, not all attributes that are required are validated)

  • overwrite: (bool) Whether the HermesDataSchema

    attribute derivations will overwrite an existing attribute value with an updated attribute value from the derivation process.

Parameters:

attribute_name (str, optional, default None) – The name of the attribute to get specific information for.

Returns:

info (astropy.table.Table) – A table of information about global metadata.

Raises:

KeyError – If attribute_name is not a recognized global attribute.:

static global_attribute_template() OrderedDict[source]

Function to generate a template of required global attributes that must be set for a valid CDF.

Returns:

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

static measurement_attribute_info(attribute_name: str | None = None) Table[source]

Function to generate a astropy.table.Table of information about each variable metadata attribute. The astropy.table.Table contains all information in the HERMES variable attribute schema including:

  • description: (str) A brief description of the attribute

  • derived: (bool) Whether the attibute can be derived by the HERMES

    HermesDataSchema class

  • required: (bool) Whether the attribute is required by HERMES standards

  • overwrite: (bool) Whether the HermesDataSchema

    attribute derivations will overwrite an existing attribute value with an updated attribute value from the derivation process.

  • valid_values: (str) List of allowed values the attribute can take for HERMES products,

    if applicable

  • alternate: (str) An additional attribute name that can be treated as an alternative

    of the given attribute. Not all attributes have an alternative and only one of a given attribute or its alternate are required.

  • var_types: (str) A list of the variable types that require the given

    attribute to be present.

Parameters:

attribute_name (str, optional, default None) – The name of the attribute to get specific information for.

Returns:

info (astropy.table.Table) – A table of information about variable metadata.

Raises:

KeyError – If attribute_name is not a recognized global attribute.:

static measurement_attribute_template() OrderedDict[source]

Function to generate a template of required measurement attributes that must be set for a valid CDF measurement variable.

Returns:

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