PolynomialConverter

class asdf_astropy.converters.PolynomialConverter[source]

Bases: TransformConverterBase

ASDF support for serializing the 1D and 2D polynomial models.

Attributes Summary

tags

types

Methods Summary

from_yaml_tree(node, tag, ctx)

Convert a YAML node into an instance of a custom type.

from_yaml_tree_transform(node, tag, ctx)

Convert an ASDF node into an instance of the appropriate model class.

to_yaml_tree(model, tag, ctx)

Convert an object into a node suitable for YAML serialization.

to_yaml_tree_transform(model, tag, ctx)

Convert a model's parameters into a dict suitable for ASDF serialization.

Attributes Documentation

tags = ('tag:stsci.edu:asdf/transform/polynomial-*',)
types = ('astropy.modeling.polynomial.Polynomial1D', 'astropy.modeling.polynomial.Polynomial2D')

Methods Documentation

from_yaml_tree(node, tag, ctx)

Convert a YAML node into an instance of a custom type.

For container types received by this method (dict or list), the children of the container will have already been converted by prior calls to from_yaml_tree implementations.

Note on circular references: trees that reference themselves among their descendants must be handled with care. Most implementations need not concern themselves with this case, but if the custom type supports circular references, then the implementation of this method will need to return a generator. Consult the documentation for more details.

Parameters:
nodedict or list or str

The YAML node to convert.

tagstr

The YAML tag of the object being converted.

ctxasdf.extension.SerializationContext

The context of the current deserialization request.

Returns:
object

An instance of one of the types listed in the types property, or a generator that yields such an instance.

from_yaml_tree_transform(node, tag, ctx)[source]

Convert an ASDF node into an instance of the appropriate model class. The implementing class need only instantiate the model and set parameter values; common model properties such as name and inverse will be handled by this base class.

Parameters:
nodedict

The ASDF node to convert.

tagstr

The tag identifying the YAML type of the node.

ctxasdf.asdf.SerializationContext

The context of the current serialization request.

Returns:
astropy.modeling.Model

The resulting model instance.

to_yaml_tree(model, tag, ctx)

Convert an object into a node suitable for YAML serialization. This method is not responsible for writing actual YAML; rather, it converts an instance of a custom type to a built-in Python object type (such as dict, list, str, or number), which can then be automatically serialized to YAML as needed.

For container types returned by this method (dict or list), the children of the container need not themselves be converted. Any list elements or dict values will be converted by subsequent calls to to_yaml_tree implementations.

The returned node must be an instance of dict, list, or str. Children may be any type supported by an available Converter.

Parameters:
objobject

Instance of a custom type to be serialized. Guaranteed to be an instance of one of the types listed in the types property.

tagstr

The tag identifying the YAML type that obj should be converted into. Selected by a call to this converter’s select_tag method.

ctxasdf.extension.SerializationContext

The context of the current serialization request.

Returns:
dict or list or str

The YAML node representation of the object.

to_yaml_tree_transform(model, tag, ctx)[source]

Convert a model’s parameters into a dict suitable for ASDF serialization. Common model properties such as name and inverse will be handled by this base class.

Parameters:
modelastropy.modeling.Model

The model instance to convert.

tagstr

The tag identifying the YAML type that astropy.modeling.Model should be converted into.

ctxasdf.asdf.SerializationContext

The context of the current serialization request.

Returns:
dict

ASDF node.