ASDF Transform Schemas

0.6.0 · active · verified Thu Apr 16

asdf-transform-schemas provides ASDF (Advanced Scientific Data Format) schemas primarily for validating transform tags, specifically those related to serializing `astropy.modeling` models into ASDF files. It acts as a dependency for higher-level packages like `asdf-astropy`, which implement the serialization logic. The library is currently at version 0.6.0 and generally follows the release cadence of the broader ASDF Standard.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how `asdf-transform-schemas` facilitates the serialization and deserialization of `astropy.modeling` objects within ASDF files. While `asdf-transform-schemas` provides the schema definitions, the actual Python object handling is performed by the `asdf` library using the `asdf-astropy` extension. The example creates a `Rotation2D` model, saves it to an ASDF file, and then reads it back, implicitly using the schemas for validation.

import asdf
from astropy.modeling.models import Rotation2D
import os

# Create an Astropy model
rot_model = Rotation2D(angle=45)

# Save the model to an ASDF file (asdf-astropy extension handles serialization)
afd = asdf.AsdfFile({'rotation_transform': rot_model})
file_path = 'rotation_transform.asdf'
afd.write_to(file_path)

print(f"ASDF file '{file_path}' created successfully.")

# Read the ASDF file back
with asdf.open(file_path) as afd_read:
    read_model = afd_read['rotation_transform']
    print(f"Read model: {read_model}")
    print(f"Angle of read model: {read_model.angle.value}")

# Clean up
os.remove(file_path)

view raw JSON →