Skip to main content

Work with Scientific Data Format files in Python

Project description

sdf-logo

Scientific Data Format for Python

SDF is a Python package to read, write and interpolate multi-dimensional data. The Scientific Data Format is an open file format based on HDF5 to store multi-dimensional data such as parameters, simulation results or measurements. It supports...

  • very large files
  • up to 32 dimensions
  • hierarchical structure
  • units, comments and custom meta-information

For detailed information see the SDF specification.

Installation

To install the latest release from PyPI or update an existing installation:

python -m pip install --upgrade sdf

Tutorial

Import the SDF and NumPy packages:

>>> import sdf
>>> import numpy as np

Create the data arrays:

>>> t = np.linspace(0, 10, 51)
>>> v = np.sin(t)

Create the datasets:

>>> ds_t = sdf.Dataset('t', data=t, unit='s', is_scale=True, display_name='Time')
>>> ds_v = sdf.Dataset('v', data=v, unit='V', scales=[ds_t])

Create the root group and write the file:

>>> g = sdf.Group('/', comment='A sine voltage', datasets=[ds_t, ds_v])
>>> sdf.save('sine.sdf', g)

Read the dataset from the SDF file asserting the correct unit of the dataset and scale:

>>> ds_v2 = sdf.load('sine.sdf', '/v', unit='V', scale_units=['s'])

Get the meta info and data array from the dataset:

>>> ds_v2.unit
'V'
>>> ds_v2.data.shape
(51,)

Get the scale for the first dimension:

>>> ds_t2 = ds_v2.scales[0]
>>> ds_t2.unit
's'

License

The code is released under the 2-Clause BSD license.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdf-0.3.8-py3-none-any.whl (343.0 kB view details)

Uploaded Python 3

File details

Details for the file sdf-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: sdf-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 343.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sdf-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4d51a175ae21b01466ffa6d0d56ffdc3224988d5d551cd1747b23b53fbefee58
MD5 ed73d82a14f5deceee596f4c99e11609
BLAKE2b-256 07a4116c2d80f9384d856906a36efdeff3bfdc4c2154f9812037edd679ca5763

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page