ASDF Standard Schemas

1.5.0 · active · verified Thu Apr 16

asdf-standard is a Python package that provides the schemas and specification for the Advanced Scientific Data Format (ASDF). It defines the structure and requirements for creating, editing, and reading ASDF files. The package itself primarily distributes YAML schema files; the actual Python implementation for interacting with ASDF files is provided by the separate 'asdf' library. It is currently at version 1.5.0 and releases are made as the ASDF standard evolves.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically locate and load a core ASDF schema file provided by the `asdf-standard` package using `importlib.resources`. This package is primarily a source of schema definitions, which are consumed by the `asdf` library for validation and serialization, rather than directly by end-user applications.

import importlib.resources as resources
import yaml

# Asdf-standard provides schemas as data files.
# This example shows how to locate and load a core schema.

try:
    # For Python 3.9+ (or importlib_resources backport)
    schema_path = resources.files('asdf_standard.schemas.stsci.edu.asdf') / 'core-1.6.0.yaml'
    with open(schema_path, 'r') as f:
        core_schema = yaml.safe_load(f)
    print("Successfully loaded core-1.6.0.yaml schema.")
except Exception as e:
    print(f"Could not load schema: {e}")
    print("This might happen if the path or filename is incorrect, or if `asdf` library is expected for schema access.")

# In typical usage, the 'asdf' library internally manages these schemas.
# For example, to validate an ASDF tree against schemas, you'd use the 'asdf' library:
# import asdf
# with asdf.open('my_file.asdf') as af:
#     # Validation happens automatically on open and write
#     pass

view raw JSON →