Skip to content

Commit

Permalink
More document testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-harter committed Feb 9, 2022
1 parent 3112b7c commit eda67a0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cdflib/cdf_to_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,52 @@ def _verify_dimension_sizes(created_data_vars, created_coord_vars):


def cdf_to_xarray(filename, to_datetime=False, to_unixtime=False, fillval_to_nan=False):
"""
This function converts CDF files into XArray Dataset Objects
Parameters:
filename : str
The CDF file to read into memory
to_datetime : bool, optional
Whether or not to convert CDF_EPOCH/EPOCH_16/TT2000 to datetime, or leave them as is
to_unixtime : bool, optional
Whether or not to convert CDF_EPOCH/EPOCH_16/TT2000 to unixtime, or leave them as is
fillval_to_nan : bool, optional
If True, any data values that match the FILLVAL attribute for a variable will be set to NaN
Returns:
An XArray Dataset Object
Examples:
>>> #Plot a single line in bokeh
>>> import pytplot
>>> x_data = [2,3,4,5,6]
>>> y_data = [1,2,3,4,5]
>>> pytplot.store_data("Variable1", data={'x':x_data, 'y':y_data})
>>> pytplot.tplot("Variable1",bokeh=True)
>>> #Display two plots
>>> x_data = [1,2,3,4,5]
>>> y_data = [[1,5],[2,4],[3,3],[4,2],[5,1]]
>>> pytplot.store_data("Variable2", data={'x':x_data, 'y':y_data})
>>> pytplot.tplot(["Variable1", "Variable2"])
>>> #Display 2 plots, using Variable1 as another x axis
>>> x_data = [1,2,3]
>>> y_data = [ [1,2,3] , [4,5,6], [7,8,9] ]
>>> v_data = [1,2,3]
>>> pytplot.store_data("Variable3", data={'x':x_data, 'y':y_data, 'v':v_data})
>>> pytplot.options("Variable3", 'spec', 1)
>>> pytplot.tplot(["Variable2", "Variable3"], var_label='Variable1')
>>> #Plot all 3 tplot variables, sending the output to an HTML file
>>> pytplot.tplot(["Variable1", "Variable2", "Variable3"], save_file='C:/temp/pytplot_example.html')
>>> #Plot all 3 tplot variables, sending the HTML output to a pair of strings
>>> div, component = pytplot.tplot(["Variable1", "Variable2", "Variable3"], gui=True)
"""



# Convert the CDF file into a series of dicts, so we don't need to keep reading the file
global_attributes, all_variable_attributes, all_variable_data, all_variable_properties = _convert_cdf_to_dicts(filename,
Expand Down

0 comments on commit eda67a0

Please sign in to comment.