asdf Documentation

asdf is a tool for reading and writing Advanced Scientific Data Format (ASDF) files.


This is the Advanced Scientific Data Format - if you are looking for the Adaptable Seismic Data Format, go here:


asdf requires:

Support for units, time, transform, wcs, or running the tests also requires:

Getting Started

The fundamental data model in ASDF is the tree, which is a nested combination of basic data structures: dictionaries, lists, strings and numbers. In addition, ASDF understands how to handle other types, such as Numpy arrays.

In the simplest example, you create a tree, and write it to a ASDF file. asdf handles saving the Numpy array as a binary block transparently:

from asdf import AsdfFile
import numpy as np

tree = {
  'author': 'John Doe',
  'my_array': np.random.rand(8, 8)
ff = AsdfFile(tree)


b'#ASDF' 1.2.0
%YAML 1.1
%TAG !
--- !core/asdf-1.1.0
asdf_library: !core/software-1.0.0 {author: Space Telescope Science Institute, homepage: '',
  name: asdf, version: 2.0.0.dev1248}
author: John Doe
my_array: !core/ndarray-1.0.0
  source: 0
  datatype: float64
  byteorder: little
  shape: [8, 8]
    allocated_size: 512
    used_size: 512
    data_size: 512
    data: b'1325f616c175e33f48e6a0c62092d03f5c90a575...'
%YAML 1.1
--- [378]

Other Examples are provided below.

Commandline tool

asdf includes a command-line tool, asdftool that performs a number of basic operations:

  • explode: Convert a self-contained ASDF file into exploded form.
  • implode: Convert an ASDF file in exploded form into a self-contained file.
  • to_yaml: Inline all of the data in an ASDF file so that it is pure YAML.
  • defragment: Remove unused blocks and extra space.

Run asdftool --help for more information.


asdf Package

asdf: Python library for reading and writing Advanced Scientific Data Format (ASDF) files


open Open an existing ASDF file.
test([package, test_path, args, plugins, …]) Run the tests using py.test.


AsdfFile([tree, uri, extensions, version, …]) The main class that represents a ASDF file.
CustomType Base class for all user-defined types.
AsdfExtension Subclass to define an extension to ASDF.
Stream(shape, dtype[, strides]) Used to put a streamed array into the tree.
ValidationError(message[, validator, path, …])
ExternalArrayReference(fileuri, target, …) Store a reference to an array in an external File.

Class Inheritance Diagram

Inheritance diagram of asdf.asdf.AsdfFile, asdf.asdftypes.CustomType, asdf.extension.AsdfExtension,, asdf.ValidationError, asdf.tags.core.external_reference.ExternalArrayReference

asdf.fits_embed Module

Utilities for embedded ADSF files in FITS.


AsdfInFits([hdulist, tree]) Embed ASDF tree content in a FITS file.

Class Inheritance Diagram

Inheritance diagram of asdf.fits_embed.AsdfInFits