ASDF Coordinates Schemas

0.5.1 · active · verified Thu Apr 16

ASDF Coordinates Schemas (asdf-coordinates-schemas) provides ASDF schemas specifically for validating astronomical coordinate tags, primarily those defined by `astropy.coordinates`. This package is typically consumed as a dependency by higher-level integration packages like `asdf-astropy` rather than being installed directly by end-users. It is part of the broader ASDF ecosystem, is actively maintained, and is currently at version 0.5.1.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how `asdf-coordinates-schemas` works implicitly. By installing `asdf-astropy` (which depends on `asdf-coordinates-schemas`), `astropy.coordinates` objects like `SkyCoord` can be seamlessly serialized into and deserialized from ASDF files. The schemas provided by this library ensure the correct validation and structure of the coordinate data within the ASDF file.

import asdf
import astropy.units as u
from astropy.coordinates import SkyCoord, ICRS

# This example relies on asdf-astropy being installed to register the schemas and converters.
# If you run this without asdf-astropy, it will likely fail to serialize SkyCoord.

# Create an Astropy SkyCoord object
coord = SkyCoord(ra=10.68458 * u.deg, dec=41.26917 * u.deg, frame=ICRS())

# Create an ASDF tree with the coordinate object
tree = {'my_coordinate': coord}

# Save the ASDF tree to a file
# This will use the schemas provided by asdf-coordinates-schemas (via asdf-astropy)
with asdf.AsdfFile(tree) as af:
    af.write('my_coordinates.asdf')

print("ASDF file 'my_coordinates.asdf' created successfully.")

# Read the ASDF file back
with asdf.open('my_coordinates.asdf') as af_read:
    read_coord = af_read['my_coordinate']
    print(f"Read coordinate: {read_coord}")
    print(f"Type: {type(read_coord)}")

view raw JSON →