Metadata and extensions
GWCS.to_metadata — Function
to_metadata(value; registry=default_transform_registry())
to_metadata(value, context::TransformWriteContext; path=metadata_path(context))Return the tagged metadata tree of a WCS, step, transform, frame, bounding box, or label mapper, or of a dictionary or vector holding them. It is the tree write_asdf writes, made of GWCS.jl's tagged nodes, dictionaries, vectors, strings, and numbers; parse_wcs and parse_transform read it back. A value without a serializer throws an ArgumentError. A registered serializer writes a nested value with the second form, which keeps its context's registry.
GWCS.parse_transform — Function
parse_transform(node; path="transform", registry=default_transform_registry()) -> AbstractTransform
parse_transform(node, context::TransformParseContext; path=metadata_path(context)) -> AbstractTransformBuild a transform from a tagged metadata node. Its tag and version select the constructor registered in registry. An inverse property becomes an explicit inverse (WithInverse), and name, inputs, and outputs become annotations (AnnotatedTransform). Malformed metadata or an unsupported tag throws an ArgumentError naming path. A registered constructor parses a child node with the second form, which keeps its context's registry.
GWCS.TransformRegistry — Type
TransformRegistry()The constructors and serializers that read and write transforms in metadata, by tag. register_transform! and register_transform_serializer! add to a registry, and parse_wcs, parse_transform, and to_metadata take one with their registry keyword. A new registry starts with GWCS.jl's schemas but no transforms; copy(default_transform_registry()) starts from the built-in transforms. Registration is thread-safe.
GWCS.default_transform_registry — Function
default_transform_registry() -> TransformRegistryReturn the registry that metadata reading and writing use by default. It holds the built-in transforms, and external packages register theirs in it, typically from their __init__.
GWCS.register_transform! — Function
register_transform!([registry], tag, constructor; min_version=v"1.0.0", max_version=v"2.0.0", versions=nothing,
validate, normalize, angles=(), dimensionless=(), properties=nothing) -> TransformRegistryRegister a constructor for the metadata tag family tag, given without a version, such as "tag:example.org:gwcs/offset". The callback constructor(node, context) returns an AbstractTransform, and context is a TransformParseContext. The registry defaults to default_transform_registry. required_metadata reads required properties, metadata_value unwraps scalars, and materialize_metadata reads arrays.
The constructor handles the versions in [min_version, max_version), or exactly those in versions. Ranges that overlap a registration of the same tag throw an ArgumentError. validate(node, context) checks a node and normalize(node, context) rewrites it before the constructor sees it.
angles and dimensionless name properties that may hold an ASDF quantity. The constructor sees a plain number: an angle in degrees, or a dimensionless value, whose unit must be empty. The transform records each unit, and writing restores it.
properties names the properties the constructor and its serializer handle, besides name, inputs, outputs, and inverse. A parsed node's other properties are kept and written back with the transform, as long as it is written with the same tag family. Without properties, none are kept.
Python equivalent: the from_yaml_tree of an asdf.extension.Converter.
GWCS.register_transform_serializer! — Function
register_transform_serializer!([registry], type, tag, serializer; version) -> TransformRegistryRegister a serializer for type, a subtype of AbstractTransform. The callback serializer(transform, context) returns a dictionary of node properties without a tag, and context is a TransformWriteContext.
The registry tags the node tag-version, which a constructor registered with register_transform! must accept. Nested values are written with to_metadata(value, context); see to_metadata.
A type with a serializer already registered throws an ArgumentError. A transform uses the serializer of its most specific registered supertype.
Python equivalent: the to_yaml_tree of an asdf.extension.Converter.
GWCS.TransformParseContext — Type
TransformParseContextWhat a registered constructor is given about the node it builds: the tag family and version, from metadata_tag and metadata_version, and the node's metadata_path for error messages.
GWCS.TransformWriteContext — Type
TransformWriteContextWhat a registered serializer is given about the node it writes: the tag family and version it writes, from metadata_tag and metadata_version, and the node's metadata_path for error messages.
GWCS.metadata_tag — Function
metadata_tag(context) -> StringReturn the tag family of the node a constructor or serializer is handling, without its version, such as "tag:stsci.edu:asdf/transform/shift".
GWCS.metadata_version — Function
metadata_version(context) -> VersionNumberReturn the schema version of the node a constructor or serializer is handling.
GWCS.metadata_path — Function
metadata_path(context) -> StringReturn the path of the node a constructor or serializer is handling within the metadata tree, such as "wcs/steps/1/transform", for error messages.
GWCS.required_metadata — Function
required_metadata(node, key, context::TransformParseContext)Return the property key of a metadata node. A missing property throws an ArgumentError naming its path.
GWCS.metadata_value — Function
metadata_value(value)Return the plain value of a metadata scalar, such as the string inside a tagged scalar node, and any other value unchanged.
GWCS.materialize_metadata — Function
materialize_metadata(value)Return the Julia array of a metadata array, reading a lazy ASDF block as needed. A matrix keeps the file's row and column order rather than being transposed to an image's data[x, y] order, so m[i + 1, j + 1] is NumPy's m[i, j]. Any other value is returned unchanged.