ASDF WCS Schemas

0.5.0 · active · verified Thu Apr 16

The `asdf-wcs-schemas` library provides ASDF (Advanced Scientific Data Format) schemas specifically designed for validating World Coordinate System (WCS) tags. It is a crucial component within the broader ASDF ecosystem, particularly for astronomical data, and is typically consumed as a dependency by higher-level packages like `gwcs`. The current version is 0.5.0, and its release cadence is tied to updates in the ASDF Standard and related scientific data formats.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to create and serialize a `gwcs` WCS object into an ASDF file. The `asdf-wcs-schemas` package is implicitly utilized by the `asdf` library during the write and read operations to validate the structure of the WCS data. This package is not intended for direct Python imports for user-level functionality, but rather provides the underlying schema definitions.

import asdf
from gwcs import wcs
from astropy.modeling import models
from astropy import units as u
from gwcs.coordinate_frames import Frame2D, CelestialFrame
from astropy.coordinates import ICRS
import os

# Create a simple WCS object using gwcs
detector_frame = Frame2D(name="detector", axes_names=("x", "y"))
celestial_frame = CelestialFrame(reference_frame=ICRS(), name='icrs', unit=(u.deg, u.deg))

transform = models.Scale(0.1 * u.deg) & models.Scale(0.1 * u.deg)

my_wcs_object = wcs.WCS(transform, input_frame=detector_frame, output_frame=celestial_frame)

tree = {"my_wcs_data": my_wcs_object}

# Save the WCS object to an ASDF file
file_path = "example_wcs.asdf"
with asdf.AsdfFile(tree) as af:
    af.write_to(file_path)

print(f"WCS object saved to {file_path}")

# Read the ASDF file back. The WCS schemas are implicitly used for validation.
with asdf.open(file_path) as af:
    loaded_wcs = af.tree["my_wcs_data"]
    print("Loaded WCS object:")
    print(loaded_wcs)

# Clean up the created file
os.remove(file_path)

view raw JSON →