@@ -4,38 +4,77 @@ Scientific Data Format for Python
44=================================
55
66SDF is a Python package to read, write and interpolate multi-dimensional data.
7- The Scientific Data Format is an open file format based on HDF5 to store
8- multi-dimensional data such as parameters, simulations results or measurements.
7+ The Scientific Data Format is an open file format based on HDF5 _ to store
8+ multi-dimensional data such as parameters, simulation results or measurements.
99It supports...
1010
1111- very large files
1212- up to 32 dimensions
1313- hierarchical structure
1414- units, comments and custom meta-information
1515
16- For detailed information see the SDF specification.
16+ For detailed information see the ` SDF specification `_ .
1717
1818
1919Installation
2020------------
2121
22- Install the latest release from PyPI
22+ Install the latest release from PyPI::
2323
24- ::
24+ $ pip install sdf
2525
26- $ sudo pip install sdf
27-
28- or install the latest development version from source
29-
30- ::
26+ or install the latest development version from source::
3127
3228 $ git clone --branch develop --recursive https://github.com/ScientificDataFormat/SDF-Python.git
3329 $ cd SDF-Python
34- $ sudo pip install .
30+ $ pip install .
31+
32+
33+ Tutorial
34+ --------
35+
36+ Import the ``SDF `` and ``NumPy `` packages:
37+
38+ >>> import sdf
39+ >>> import numpy as np
40+
41+ Create the data arrays:
42+
43+ >>> t = np.linspace(0 , 10 , 51 )
44+ >>> v = np.sin(t)
45+
46+ Create the datasets:
47+
48+ >>> ds_t = sdf.Dataset(' t' , data = t, unit = ' s' , is_scale = True , display_name = ' Time' )
49+ >>> ds_v = sdf.Dataset(' v' , data = v, unit = ' V' , scales = [ds_t])
50+
51+ Create the root group and write the file:
52+
53+ >>> g = sdf.Group(' /' , comment = ' A sine voltage' , datasets = [ds_t, ds_v])
54+ >>> sdf.save(' sine.sdf' , g)
55+
56+ Read the dataset from the SDF file asserting the correct unit of the dataset and scale:
57+
58+ >>> ds_v2 = sdf.load(' sine.sdf' , ' /v' , unit = ' V' , scale_units = [' s' ])
59+
60+ Get the meta info and data array from the dataset:
61+
62+ >>> ds_v2.unit
63+ 'V'
64+ >>> ds_v2.data.shape
65+ (51,)
66+
67+ Get the scale for the first dimension:
68+
69+ >>> ds_t2 = ds_v2.scales[0 ]
70+ >>> ds_t2.unit
71+ 's'
3572
3673
3774-----------------------------
3875
3976|copy | 2017 Dassault Systèmes
4077
78+ .. _SDF specification : https://github.com/ScientificDataFormat/SDF-Specification
79+ .. _HDF5 : https://www.hdfgroup.org/hdf5/
4180.. |copy | unicode :: U+000A9
0 commit comments