Skip to content

Commit

Permalink
Update Docs for Path changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alrobbertz committed May 23, 2024
1 parent e64ec2e commit e365669
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/examples/tutorial1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This module provides an example for creating a CDF File using the `~hermes_core.
class. This class is an abstraction of underlying data structures to make the handling of
measurement data easier when reading and writing CDF data.

>>> from pathlib import Path
>>> from collections import OrderedDict
>>> import numpy as np
>>> import astropy.units as u
Expand Down Expand Up @@ -140,7 +141,8 @@ measurement data easier when reading and writing CDF data.
>>> DRYRUN=True
>>> if DRYRUN:
... with tempfile.TemporaryDirectory() as tmpdirname:
... cdf_file_path = example_data.save(output_path=tmpdirname)
... tmp_path = Path(tmpdirname)
... cdf_file_path = example_data.save(output_path=tmp_path)
... else:
... cdf_file_path = example_data.save(output_path="./", overwrite=True)

Expand Down
12 changes: 7 additions & 5 deletions docs/user-guide/reading_writing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ automatically generated as you might make the resulting CDF file non-compliant.
Creating a ``HermesData`` from an existing CDF File
===================================================

Given a current CDF File you can load it into a :py:class:`~hermes_core.timedata.HermesData` by providing a path to the CDF file::
Given a current CDF File you can load it into a :py:class:`~hermes_core.timedata.HermesData` by providing a :py:class:`~pathlib.Path` to the CDF file::

>>> from pathlib import Path
>>> from hermes_core.timedata import HermesData
>>> hermes_data = HermesData.load("hermes_eea_default_ql_20240406T120621_v0.0.1.cdf") # doctest: +SKIP
>>> data_path = Path("hermes_eea_default_ql_20240406T120621_v0.0.1.cdf")
>>> hermes_data = HermesData.load(data_path) # doctest: +SKIP

The :py:class:`~hermes_core.timedata.HermesData` can the be updated, measurements added, metadata added, and written to a new CDF file.

Expand Down Expand Up @@ -492,18 +494,18 @@ Writing a CDF File
==================

The :py:class:`~hermes_core.timedata.HermesData` class writes CDF files using the `~spacepy.pycdf` module.
This can be done using the :py:func:`~hermes_core.timedata.HermesData.save` method which only requires a path to the folder where the CDF file should be saved.
This can be done using the :py:func:`~hermes_core.timedata.HermesData.save` method which only requires a :py:class:`~pathlib.Path` to the folder where the CDF file should be saved.
The filename is automatically derived consistent with HERMES file naming requirements.
If no path is provided it writes the file to the current directory.
This function returns the full path to the CDF file that was generated.
This function returns the full :py:class:`~pathlib.Path` to the CDF file that was generated.
From this you can validate and distribute your CDF file.

Validating a CDF File
=====================

The :py:class:`~hermes_core.timedata.HermesData` uses the `~spacepy.pycdf.istp` module for CDF validation, in addition to custom
tests for additional metadata. A CDF file can be validated using the :py:func:`~hermes_core.util.validation.validate` method
and by passing, as a parameter, the full path to the CDF file to be validated::
and by passing, as a parameter, the full :py:class:`~pathlib.Path` to the CDF file to be validated::

>>> from hermes_core.util.validation import validate
>>> validation_errors = validate(cdf_file_path) # doctest: +SKIP
Expand Down

0 comments on commit e365669

Please sign in to comment.