Skip to main content

sdfascii

PyPI Version Python Versions CI Status Coverage Status License Badge

sdfascii is a Python 3.12+ module for reading the HP/Agilent Standard Data Format (SDF) binary files and the ASCII files saved by HP/Agilent Dynamic Signal Analyzers (DSA). A few examples of using sdfascii can be found at this example repository.

The HP/Agilent 35670A Dynamic Signal Analyzer has the ability to save files as either SDF or ASCII format.

WARNING: Only SDF revision 2 is read in full. The revision 1 and 3 branches decode the fields the revisions share and leave the rest.

HP/Agilent SDF Binary Format

The "Standard Data Format Utilities User's Guide" version B.02.01, P/N 5963-1715 was used to determine the SDF file format while developing sdfascii.

HP/Agilent DSA ASCII Format

Four files are created when saving to the HP/Agilent DSA ASCII format:

  1. .HDR contains SDF header information
  2. .TXT contains the y-axis information, preserving the same units as displayed on the analyzer screen when the trace was saved
  3. .X contains the x-axis information
  4. .Z contains the z-axis information, if the trace contains waterfall data

Installation

You can install sdfascii either via the Python Package Index (PyPI) or from source.

To add it to a project managed with uv, which records it in your pyproject.toml and lock file:

$ uv add sdfascii

Or to install it with pip:

$ pip install sdfascii

Source: https://github.com/questrail/sdfascii

Requirements

sdfascii requires the following Python package:

Public API

The following functions are provided:

  • read_sdf_file(sdf_filename) returns the header as a dictionary and the y-axis data as a numpy array. The data is None if the file carries no y-data record.
  • read_ascii_files(input_ascii_base_filename) reads the .X and .TXT files sharing the given base name and returns them as a structured numpy array with frequency and amplitude fields.

Command Line

python -m sdfascii parses an SDF file and writes its header to JSON, which is how the files in examples/ are produced:

$ python -m sdfascii sdf examples/HP35670A.DAT examples/hp35670a.json

Contributing

Contributions are welcome! To contribute please:

  1. Fork the repository
  2. Create a feature branch
  3. Add code and tests
  4. Pass lint and tests
  5. Submit a pull request

Development Setup

The project is managed with uv, and the development tasks are just recipes.

$ brew install uv just

uv sync creates the virtualenv and installs the dependencies, including the development group, and just on its own lists the available recipes.

$ uv sync
$ just

The most common recipes are:

$ just test       # Run the tests using pytest
$ just lint       # Check lint, formatting, types, and workflows
$ just fix        # Lint and format the code using ruff, applying fixes
$ just cov        # Run the tests and report coverage
$ just examples   # Regenerate the parsed header JSON in examples/
$ just add X      # Add X as a dependency
$ just out        # List the outdated dependencies

ruff and pyright are deliberately absent from that brew install line. Both are dev dependencies pinned in uv.lock and reached through uv run, so every recipe and every CI job uses the same version. A brew install ruff would put a second, unpinned copy on the path for an editor to find, and ruff releases change how code is formatted: the editor would then reformat code that ruff format --check rejects on the next run.

Releasing to PyPI

just release cuts the release. It first checks that a release is possible at all, then lints, type checks, and tests, then shows the entries waiting under Unreleased and the version each kind of bump would produce, and asks which to cut. Once answered it bumps the version, closes out the CHANGELOG, updates the lock file, commits, and tags. Pushing the tag is what publishes.

$ just release
...
Which release? [1] 2

Tagged v0.9.0. Publish it with:

    git push --follow-tags

The tag push runs the release workflow, which waits on the whole CI workflow before it does anything else: the 3.12, 3.13, and 3.14 matrix and the dependency floor job. It then checks that the tagged commit is on master, since a tag is only a pointer and one placed anywhere else would otherwise publish whatever it points at, rechecks the tag against the version in pyproject.toml, and builds.

Every check to that point runs against the source tree, so the workflow then installs the wheel it just built somewhere src/ is not on the path and exercises it there, which is the only step that can catch a packaging mistake. It uploads once that passes. There is no PyPI API token anywhere: the workflow authenticates with trusted publishing, which mints a short lived credential from the GitHub OIDC identity of that run. That same identity signs a PEP 740 attestation for each distribution, which PyPI serves beside the file it attests.

Uploading is followed by a GitHub release for the tag, carrying the CHANGELOG section for that version as its notes and the built distributions as its assets.

Pushing the tag is the point of no return, since PyPI never lets a version number be reused. Everything just release does is local and amendable until then, and it refuses to start against a dirty working tree, off master, on a master behind its upstream, with a CHANGELOG whose Unreleased section is empty, or when the tag it would create already exists. just release-check runs those refusals on their own.

just build runs the same checks and produces the same distributions without releasing anything, which is the way to inspect what CI would upload.

This depends on one piece of configuration that lives outside the repository. A trusted publisher has to be registered for sdfascii on PyPI, pointing at the questrail/sdfascii repository, the release.yml workflow, and the pypi environment. It is a one time setup per project.

License

sdfascii is released under the MIT license. Please see the LICENSE.txt file for more information.

Download files

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

Source Distribution

sdfascii-0.9.0.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

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

sdfascii-0.9.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file sdfascii-0.9.0.tar.gz.

File metadata

  • Download URL: sdfascii-0.9.0.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sdfascii-0.9.0.tar.gz
Algorithm Hash digest
SHA256 16501fb4df880a0d3e487dd36d3586af49d2c4032beb424ad1d2f1ee770fd819
MD5 73df3bb26043f0ca4dc70a0c85e4f794
BLAKE2b-256 4e6af6df3c26e7f243279e59eed6ec87dc369f016348124a541cbd874c171b16

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdfascii-0.9.0.tar.gz:

Publisher: release.yml on questrail/sdfascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdfascii-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: sdfascii-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sdfascii-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72c9689193e9659858c02fd915a256cb50044c116bd154c44388cd47fc0a6671
MD5 6cc0fd0faf7d3574170b74b05467067a
BLAKE2b-256 c206596bbca9e19b16519778821c6db8853842224d0c692e042c1ab16a862c1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdfascii-0.9.0-py3-none-any.whl:

Publisher: release.yml on questrail/sdfascii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.4

2 files

0.5.2

2 files

0.5.1

1 file

0.5.0

1 file

0.3.1

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2

1 file

0.1

1 file

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