Skip to content

Commit

Permalink
Refactor and Rename timedata to HermesData (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alrobbertz committed Sep 28, 2023
1 parent 4ef8f3f commit 1e2259a
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 451 deletions.
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# The full version, including alpha/beta/rc tags
from hermes_core import __version__
from hermes_core.util.schema import HERMESDataSchema
from hermes_core.util.schema import HermesDataSchema

version = __version__

Expand Down Expand Up @@ -50,15 +50,15 @@
automodapi_toctreedirnm = "generated/api"

# -- Generate CSV Files for Docs ---------------------------------------------
if not os.path.exists('generated'):
os.mkdir('generated') # generate the directory before putting things in it
if not os.path.exists("generated"):
os.mkdir("generated") # generate the directory before putting things in it
# Global Attributes to CSV

global_info = HERMESDataSchema.global_attribute_info()
global_info = HermesDataSchema.global_attribute_info()
global_info.write("./generated/global_attributes.csv", overwrite=True)

# Variable Attributes to CSV
variable_info = HERMESDataSchema.measurement_attribute_info()
variable_info = HermesDataSchema.measurement_attribute_info()
variable_info.write("./generated/variable_attributes.csv", overwrite=True)

# Add any paths that contain templates here, relative to this directory.
Expand Down
24 changes: 12 additions & 12 deletions docs/examples/tutorial1.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Creating a CDF File
===================

This module provides an example for creating a CDF File using the `~hermes_core.timedata.TimeData`
This module provides an example for creating a CDF File using the `~hermes_core.timedata.HermesData`
class. This class is an abstraction of underlying data structures to make the handling of
measurement data easier when reading and writing CDF data.

Expand All @@ -13,7 +13,7 @@ measurement data easier when reading and writing CDF data.
from astropy.timeseries import TimeSeries
# Import the `hermes_core` Package
from hermes_core.timedata import TimeData
from hermes_core.timedata import HermesData
from hermes_core.util.validation import validate
# Create a np.ndarray of example measurement data
Expand All @@ -32,8 +32,8 @@ measurement data easier when reading and writing CDF data.
name="By GSE")
# To make the creation of global metadata easier you can use the static
# `TimeData.global_attribute_template()` function.
global_attrs_template = TimeData.global_attribute_template()
# `HermesData.global_attribute_template()` function.
global_attrs_template = HermesData.global_attribute_template()
global_attrs_template["DOI"] = "https://doi.org/<PREFIX>/<SUFFIX>"
global_attrs_template["Data_level"] = "L1>Level 2"
Expand All @@ -60,21 +60,21 @@ measurement data easier when reading and writing CDF data.
global_attrs_template["PI_name"] = "Dr. Eftyhia Zesta"
global_attrs_template["TEXT"] = "Sample HERMES NEMISIS CDF File"
timedata = TimeData(data=ts, meta=global_attrs_template)
example_data = HermesData(timeseries=ts, meta=global_attrs_template)
# To make the creation of variable metadata easier you can use the static
# `TimeData.measurement_attribute_template()` function.
template = TimeData.measurement_attribute_template()
# `HermesData.measurement_attribute_template()` function.
template = HermesData.measurement_attribute_template()
# Update the Metadata for each of the Measurements
timedata["Bx GSE"].meta.update(
example_data["Bx GSE"].meta.update(
OrderedDict({"CATDESC": "X component of magnetic Field GSE"}))
timedata["By GSE"].meta.update(
example_data["By GSE"].meta.update(
OrderedDict({"CATDESC": "Y component of magnetic Field GSE"}))
# You can also add new Measurements to the TimeData container
# You can also add new Measurements to the HermesData container
bz = np.random.choice(a=[-1, 0, 1], size=1000).cumsum(0)
timedata.add_measurement(
example_data.add_measurement(
measure_name="Bz GSE",
data=u.Quantity(value=bz, unit="nanoTesla", dtype=np.int16),
meta={
Expand All @@ -84,7 +84,7 @@ measurement data easier when reading and writing CDF data.
)
# create the CDF File
cdf_file_path = timedata.save(output_path="./", overwrite=True)
cdf_file_path = example_data.save(output_path="./", overwrite=True)
The file that this code generates is made available as a sample file in this
repository in :file:`hermes_core/data/sample/hermes_nms_default_l1_20160322_123031_v0.0.1.cdf`.
10 changes: 5 additions & 5 deletions docs/user-guide/cdf_format_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HERMES CDF Format Guide
1. Introduction
===============

The :py:class:`~hermes_core.util.schema.HERMESDataSchema` class provides an interface to
The :py:class:`~hermes_core.util.schema.HermesDataSchema` class provides an interface to
examine the HERMES CDF Format Guide.

---------------------
Expand Down Expand Up @@ -200,12 +200,12 @@ information is provided:
* 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
:py:class:`~hermes_core.util.schema.HERMESDataSchema` class
:py:class:`~hermes_core.util.schema.HermesDataSchema` class
* required: (`bool`) Whether the attribute is required by HERMES standards
* validate: (`bool`) Whether the attribute is included in the
:py:func:`~hermes_core.util.validation.validate` checks (Note, not all attributes that
are required are validated)
* overwrite: (`bool`) Whether the :py:class:`~hermes_core.util.schema.HERMESDataSchema`
* overwrite: (`bool`) Whether the :py:class:`~hermes_core.util.schema.HermesDataSchema`
attribute derivations will overwrite an existing attribute value with an updated
attribute value from the derivation process.

Expand Down Expand Up @@ -529,9 +529,9 @@ information is provided:

* description: (`str`) A brief description of the attribute
* derived: (`bool`) Whether the attibute can be derived by the HERMES
:py:class:`~hermes_core.util.schema.HERMESDataSchema` class
:py:class:`~hermes_core.util.schema.HermesDataSchema` class
* required: (`bool`) Whether the attribute is required by HERMES standards
* overwrite: (`bool`) Whether the :py:class:`~hermes_core.util.schema.HERMESDataSchema`
* overwrite: (`bool`) Whether the :py:class:`~hermes_core.util.schema.HermesDataSchema`
attribute derivations will overwrite an existing attribute value with an updated
attribute value from the derivation process.
* valid_values: (`list`) List of allowed values the attribute can take for HERMES products,
Expand Down

0 comments on commit 1e2259a

Please sign in to comment.