Skip to main content

pySDDS

Efficient Python SDDS reader and writer

GitHub CI GitHub release (latest by date) GitHub release (latest by date including pre-releases)

About

Self Describing Data Set (SDDS) file format is a common format used in accelerator physics, notably by elegant simulation code and other tools developed at the Advanced Photon Source/ANL. pysdds is a pure-Python SDDS reader and writer with several nifty features that help with integration into standard Python ML and data analysis workflows.

Getting started

Prerequisites

  • Python >= 3.8
  • numpy >= 1.19
  • pandas >=1.0

Installation

Clone this repository:

git clone https://github.com/nikitakuklev/pysdds.git

and add to path during runtime or install in pip development mode:

sys.path.append(<location where repo was cloned>/pysdds)

If you have access to ANL APS network, you can install latest development version with:

pip install -e /home/oxygen/NKUKLEV/software/pysdds

Usage

Reading a file:

import pysdds

# All parameters are automatically inferred
sdds = pysdds.read('file.sdds')

# Compressed files will be decompressed on the fly
sdds = pysdds.read('file.sdds.xz')

# All reader options can be explicitly provided
sdds = pysdds.read('file.sdds.xz', mode='binary', compression='xz', endianness='little')

# Select only the necessary arrays, columns, and pages - other data is discarded without memory allocation
sdds = pysdds.read('file.sdds', pages=[0,2], columns=['x','y'], arrays=['matrix1'])

Working with data:

sdds = pysdds.read('file.sdds')

# Get column 'x' and parameter 'betax'
column = sdds.col('x')
parameter = sdds.par('betax')

# NumPy array of values for column 'x' on page 0
column.data[0]

# Single value for parameter 'betax' on page 3
parameter.data[3]

# Convert page 1 to a dataframe with appropriate column labels
sdds.columns_to_df(page=1)

# Convert all parameters to a dataframe, indexed by page number
sdds.parameters_to_df()

Writing data:

# Easiest way to write SDDS is to create sdds object from dataframes
sdds = pysdds.SDDSFile.from_df([df_page1, df_page2], parameter_dict={'param1': ['v0', 'v1']})
pysdds.write(sdds, 'filepath.sdds')

# If necessary, SDDS objects can be manually assembled (but you really shouldn't)
sdds = pysdds.SDDSFile()
col = pysdds.Column(namelist,sdds)
col.data = [...]
sdds.columns = [col]
...

See demos directory for more examples.

Advanced considerations

pysdds is designed for maximum performance (insofar as possible in Python) without depending on any compiled code beyond standard library and numpy/pandas). It is an independent implementation based on SDDS specification, not associated with the official SDDSPython3 package.

Major differences are:

  • Pure Python, and platform agnostic (official package is a thin wrapper for core C library)
  • Comparable read performance for numerical data, but slower for text data. You should do your own benchmarks if performance is critical.
  • Intelligent file buffering - helps with network file systems
  • Large file reads without full memory pre-allocation
  • Serializable data structures (for example allowing data passing during batch computations through Dask)
  • Easier debugging and partial parsing of corrupted/abnormal data

Package architecture is straightforward - file header is first parsed to determine overall structure. Then, dispatch method picks one of multiple reader and writer implementations depending on file contents and compatibility constraints. Custom implementations can be provided as well (might perform better for your particular use case).

Contributing

Pull requests are welcome, but current codebase is expected to evolve quickly until 1.0 release. It is probably more useful to just submit a feature request.

Should you decide to contribute, please ensure that all tests pass and that your code conforms to Google Python styleguide with exception of comments, which should follow NumPy convention.

License

This project has been developed as personal helper tool for various accelerator physics research, and is released under a permissive MIT license. Notably however, I am not responsible if this breaks your shiny particle accelerator toys.

Release files for pysdds 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysdds 0.6.0
File Size Uploaded
pysdds-0.6.0.tar.gz 55.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysdds 0.6.0
File Interpreter ABI Platform
pysdds-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 108.7 kB

Release files / pysdds-0.6.0.tar.gz

Download URL pysdds-0.6.0.tar.gz
Size 55.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0df981d19c63ce03c84f795b3b9a69ab8bbcb5f0aa3c8dbd94f6062dbdc39b94
BLAKE2b-256 checksum
How to use checksums
66bd4882475c574b9c519429072c2dd6b2dd257f335087c8e75f0adf90d72af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / pysdds-0.6.0-py3-none-any.whl

Download URL pysdds-0.6.0-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62fc3e7187673f9e42c2afd1241474c9090920b7644f2981228e1b651f4d2358
BLAKE2b-256 checksum
How to use checksums
8ca244bc0cf09c3584da7e831d516e2c6b686f9da90c11a9c18edd0635b9b197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page