|
1 | 1 | .. image:: https://ci.appveyor.com/api/projects/status/github/ScientificDataFormat/SDF-Python?branch=master |
2 | 2 |
|
| 3 | + |
3 | 4 | Scientific Data Format for Python |
4 | 5 | ================================= |
5 | 6 |
|
6 | 7 | SDF 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. |
| 8 | +The Scientific Data Format is an open file format based on HDF5_ to store |
| 9 | +multi-dimensional data such as parameters, simulation results or measurements. |
9 | 10 | It supports... |
10 | 11 |
|
11 | 12 | - very large files |
12 | 13 | - up to 32 dimensions |
13 | 14 | - hierarchical structure |
14 | 15 | - units, comments and custom meta-information |
15 | 16 |
|
16 | | -For detailed information see the SDF specification. |
| 17 | +For detailed information see the `SDF specification`_. |
17 | 18 |
|
18 | 19 |
|
19 | 20 | Installation |
20 | 21 | ------------ |
21 | 22 |
|
22 | | -Install the latest release from PyPI |
| 23 | +To install the latest release from `PyPI <https://pypi.python.org/pypi/sdf/>`_ or update an existing installation:: |
| 24 | + |
| 25 | + python -m pip install --upgrade sdf |
| 26 | + |
| 27 | +To install the latest development version:: |
| 28 | + |
| 29 | + python -m pip install --upgrade https://github.com/ScientificDataFormat/SDF-Python/archive/develop.zip |
| 30 | + |
| 31 | + |
| 32 | +Tutorial |
| 33 | +-------- |
| 34 | + |
| 35 | +Import the ``SDF`` and ``NumPy`` packages: |
| 36 | + |
| 37 | + >>> import sdf |
| 38 | + >>> import numpy as np |
| 39 | + |
| 40 | +Create the data arrays: |
| 41 | + |
| 42 | + >>> t = np.linspace(0, 10, 51) |
| 43 | + >>> v = np.sin(t) |
| 44 | + |
| 45 | +Create the datasets: |
| 46 | + |
| 47 | + >>> ds_t = sdf.Dataset('t', data=t, unit='s', is_scale=True, display_name='Time') |
| 48 | + >>> ds_v = sdf.Dataset('v', data=v, unit='V', scales=[ds_t]) |
| 49 | + |
| 50 | +Create the root group and write the file: |
| 51 | + |
| 52 | + >>> g = sdf.Group('/', comment='A sine voltage', datasets=[ds_t, ds_v]) |
| 53 | + >>> sdf.save('sine.sdf', g) |
| 54 | + |
| 55 | +Read the dataset from the SDF file asserting the correct unit of the dataset and scale: |
23 | 56 |
|
24 | | -:: |
| 57 | + >>> ds_v2 = sdf.load('sine.sdf', '/v', unit='V', scale_units=['s']) |
25 | 58 |
|
26 | | - $ sudo pip install sdf |
| 59 | +Get the meta info and data array from the dataset: |
27 | 60 |
|
28 | | -or install the latest development version from source |
| 61 | + >>> ds_v2.unit |
| 62 | + 'V' |
| 63 | + >>> ds_v2.data.shape |
| 64 | + (51,) |
29 | 65 |
|
30 | | -:: |
| 66 | +Get the scale for the first dimension: |
31 | 67 |
|
32 | | - $ git clone --branch develop --recursive https://github.com/ScientificDataFormat/SDF-Python.git |
33 | | - $ cd SDF-Python |
34 | | - $ sudo pip install . |
| 68 | + >>> ds_t2 = ds_v2.scales[0] |
| 69 | + >>> ds_t2.unit |
| 70 | + 's' |
35 | 71 |
|
36 | 72 |
|
37 | 73 | ----------------------------- |
38 | 74 |
|
39 | | -|copy| 2017 Dassault Systèmes |
| 75 | +|copyright| 2017 |Dassault Systemes| |
40 | 76 |
|
41 | | -.. |copy| unicode:: U+000A9 |
| 77 | +.. _SDF specification: https://github.com/ScientificDataFormat/SDF |
| 78 | +.. _HDF5: https://www.hdfgroup.org/hdf5/ |
| 79 | +.. |copyright| unicode:: U+000A9 |
| 80 | +.. |Dassault Systemes| unicode:: Dassault U+0020 Syst U+00E8 mes |
0 commit comments