Debian Codegraph @

asdf_astropy/converters/transform/spline.py

raw
1 from .core import TransformConverterBase
2
3
4 class SplineConverter(TransformConverterBase):
5 """
6 ASDF support for serializing 1D spline models
7 """
8
9 tags = ("tag:stsci.edu:asdf/transform/spline1d-*",)
10 types = ("astropy.modeling.spline.Spline1D",)
11
12 def to_yaml_tree_transform(self, model, tag, ctx):
13 return {"knots": model.t, "coefficients": model.c, "degree": model.degree}
14
15 def from_yaml_tree_transform(self, node, tag, ctx):
16 from astropy.modeling.spline import Spline1D
17
18 knots = node["knots"]
19 coeffs = node["coefficients"]
20 degree = node["degree"]
21
22 return Spline1D(knots, coeffs, degree)