Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def from_tree_transform(cls, node, ctx):
transform_type = node['transform_type']
if transform_type == 'to_direction_cosines':
return ToDirectionCosines()
elif transform_type == 'from_direction_cosines':
return FromDirectionCosines()
else:
raise TypeError(f"Unknown model_type {transform_type}")
def inverse(self):
return FromDirectionCosines()
"""
ASDF tags for geometry related models.
"""
from asdf import yamlutil
from ..gwcs_types import GWCSTransformType
from .. geometry import (ToDirectionCosines, FromDirectionCosines,
SphericalToCartesian, CartesianToSpherical)
__all__ = ['DirectionCosinesType', 'SphericalCartesianType']
class DirectionCosinesType(GWCSTransformType):
name = "direction_cosines"
types = [ToDirectionCosines, FromDirectionCosines]
version = "1.1.0"
@classmethod
def from_tree_transform(cls, node, ctx):
transform_type = node['transform_type']
if transform_type == 'to_direction_cosines':
return ToDirectionCosines()
elif transform_type == 'from_direction_cosines':
return FromDirectionCosines()
else:
raise TypeError(f"Unknown model_type {transform_type}")
@classmethod
def to_tree_transform(cls, model, ctx):
if isinstance(model, FromDirectionCosines):
transform_type = 'from_direction_cosines'