Python implementation of the ASDF Standard, a language-agnostic serialization format for scientific data. It handles serialization of Python objects (including NumPy arrays, Astropy objects, and custom types) into ASDF files, which are YAML-based with support for binary data. The library is actively developed with several releases per year, and the current version is 5.2.0.
Install & Compatibility
Where this runs
tested against v5.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
109MB installed
● package 109MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
While technically correct, the top-level import is preferred and canonical.
from asdf import AsdfFile
import asdf; asdf.open(...)
This quickstart demonstrates how to create a simple ASDF data structure, write it to a file, and then read the data back. It uses a dictionary for the tree structure and includes a NumPy array, a common use case for ASDF.
import asdf
import numpy as np
import os
# Create some data
tree = {
'scientific_name': 'M42',
'coordinates': {
'ra': 83.822083,
'dec': -5.391111
},
'data': np.array([[1, 2], [3, 4]], dtype=np.int64)
}
# Create an ASDF file object
ff = asdf.AsdfFile(tree)
# Define file path
file_path = "example.asdf"
# Write the file
ff.write_to(file_path)
print(f"ASDF file written to {file_path}")
# Read the file back
with asdf.open(file_path) as af:
print(f"Read data:\n{af.tree['data']}")
print(f"Read coordinates: {af.tree['coordinates']}")
# Clean up the created file
os.remove(file_path)
asdf --version
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.