csdmpy

The csdmpy is a python package for importing and exporting files serialized with the core scientific dataset model file format. The package supports \(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})\). In addition, 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. .. A UML class diagram of the csdmpy module is shown below.

Methods

Methods Summary

load([filename, application])

Load a .csdf/.csdfe file and return an instance of CSDM class.

new([description])

Create a new instance of the CSDM class containing a 0D{0} dataset.

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') # doctest: +SKIP
>>> data2 = cp.load('url_address/file.csdf') # doctest: +SKIP
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.