csdmpy¶
The csdmpy is a python package for importing and exporting files serialized with the core scientific dataset model file-format. The package supports a \(p\)-component dependent variable, \(\mathbf{U} \equiv \{\mathbf{U}_{0}, \ldots,\mathbf{U}_{q}, \ldots,\mathbf{U}_{p-1} \}\), which is discretely sampled at \(M\) unique points in a \(d\)-dimensional space \((\mathbf{X}_0, \ldots \mathbf{X}_k, \ldots \mathbf{X}_{d-1})\). Besides, the package also supports multiple dependent variables, \(\mathbf{U}_i\), sharing the same \(d\)-dimensional space.
Here, every dataset is an instance of the CSDM class, which holds a list of dimensions and dependent variables. Every dimension, \(\mathbf{X}_k\), is an instance of the Dimension class, while every dependent variable, \(\mathbf{U}_i\), is an instance of the DependentVariable class.
Methods¶
Methods Summary
|
Load a .csdf/.csdfe file and return an instance of CSDM class. |
|
Create a new instance of the CSDM class containing a 0D{0} dataset. |
|
Parse a CSDM compliant python dictionary and return a CSDM object. |
|
Loads a JSON serialized string as a CSDM object. |
|
Helper function for plotting basic 1D and 2D datasets. |
Method Documentation
-
csdmpy.
load
(filename=None, application=False)[source]¶ Load a .csdf/.csdfe file and return an instance of CSDM class.
The file must be a JSON serialization of the CSD Model.
Example
>>> data1 = cp.load('local_address/file.csdf') >>> data2 = cp.load('url_address/file.csdf')
- Parameters
filename (str) – A local or remote address to the .csdf or `.csdfe file.
application (bool) – If true, the application metadata from application that last serialized the file will be imported. Default is False.
sort_fft_order (bool) – If true, the coordinates and the components corresponding to the dimension with complex_fft as True will be sorted upon import and the corresponding complex_fft key-value will be set to False. Default is True.
- Returns
A CSDM instance.
-
csdmpy.
new
(description='')[source]¶ Create a new instance of the CSDM class containing a 0D{0} dataset.
- Parameters
description (str) – A string describing the the csdm object. This is optional.
Example
>>> import csdmpy as cp >>> emptydata = cp.new(description='Testing Testing 1 2 3') >>> print(emptydata.data_structure) { "csdm": { "version": "1.0", "description": "Testing Testing 1 2 3", "dimensions": [], "dependent_variables": [] } }
- Returns
A CSDM instance.
-
csdmpy.
parse_dict
(dictionary)[source]¶ Parse a CSDM compliant python dictionary and return a CSDM object.
- Parameters
dictionary – A CSDM compliant python dictionary.
-
csdmpy.
loads
(string)[source]¶ Loads a JSON serialized string as a CSDM object.
- Parameters
string – A JSON serialized CSDM string.
- Returns
A CSDM object
Example
>>> object_from_string = cp.loads(cp.new('A test dump').dumps()) >>> print(object_from_string.data_structure) { "csdm": { "version": "1.0", "timestamp": "2019-10-21T20:33:17Z", "description": "A test dump", "dimensions": [], "dependent_variables": [] } }
-
csdmpy.
plot
(data_object, **kwargs)[source]¶ Helper function for plotting basic 1D and 2D datasets.
- Parameters
data_object – The csdm object
reverse_axis – An array of boolean specifying which dimensions will be displayed in reverse.
kwargs – Additional kwargs which are passed to the matplotlib plot or imshow functions.
Example
>>> cp.plot(data_object)