Skip to content

Commit

Permalink
Adding in documentation on the main function
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-harter committed Feb 19, 2022
1 parent 0b0f56e commit e13a213
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
24 changes: 24 additions & 0 deletions cdflib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@


def CDF(path, cdf_spec=None, delete=False, validate=None, string_encoding='ascii'):
"""
This is a wrapper function for the cdfread and cdfwrite modules. If you specify a file that exists, it returns a CDF reading class.
If you specify a file that does not yet exist, one will be created and this function will return a CDF writing class.
Parameters:
path (str): The path to a cdf file that exists -or- to one you wish to create
cdf_spec (dict, optional): If you are writing a CDF file, this specifies general parameters about data is written. See the cdfwrite class for more details.
delete (bool, optional): Delete the file if it exists and return immediately
validate (bool, optional):
string_encoding (str, optional): How strings are encoded in a CDF file that you are reading. Another common encoding is 'utf-8'.
Returns:
A CDF object that can be used for reading a file (if it exists) or writing to a file (if it does not exist)
Note:
With this library, you cannot both read and write a file at the same time. You need to choose one or the other!
Example:
>>> # Simply open an existing CDF file and get some data from a variable
>>> import cdflib
>>> cdf_file = cdflib.CDF('/path/to/existing/cdf_file.cdf')
>>> x = cdf_file.varget("NameOfVariable", startrec = 0, endrec = 150)
"""
path = Path(path).resolve().expanduser()

if path.is_file():
Expand Down
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ cdflib requires python 3 and numpy. To install run
.. toctree::
:maxdepth: 2
:maxdepth: 1
:caption: Contents:

introduction
modules/CDF function
modules/cdfread
modules/cdfwrite
modules/epochs
Expand Down
7 changes: 7 additions & 0 deletions doc/modules/CDF function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CDF
=====

CDF function
--------------

.. autofunction:: cdflib.CDF

0 comments on commit e13a213

Please sign in to comment.