How to use the gwcs.tags.wcs.FrameType function in gwcs

To help you get started, we’ve selected a few gwcs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
    @classmethod
    def to_tree(cls, frame, ctx):
        return {
            'name': frame.name,
            'frames': yamlutil.custom_tree_to_tagged_tree(frame.frames, ctx)
        }

    @classmethod
    def assert_equal(cls, old, new):
        from asdf.tests import helpers
        assert old.name == new.name  # nosec
        for old_frame, new_frame in zip(old.frames, new.frames):
            helpers.assert_tree_match(old_frame, new_frame)


class TemporalFrameType(FrameType):
    name = "temporal_frame"
    requires = _REQUIRES
    types = [TemporalFrame]
    version = '1.0.0'


    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return TemporalFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)

    @classmethod
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)


class Frame2DType(FrameType):
    name = "frame2d"
    types = [Frame2D]

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return Frame2D(**node)


class CelestialFrameType(FrameType):
    name = "celestial_frame"
    types = [CelestialFrame]

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return CelestialFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)

    @classmethod
    def assert_equal(cls, old, new):
        cls._assert_equal(old, new)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return CelestialFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)

    @classmethod
    def assert_equal(cls, old, new):
        cls._assert_equal(old, new)

        assert old.reference_position == new.reference_position  # nosec


class SpectralFrameType(FrameType):
    name = "spectral_frame"
    types = [SpectralFrame]
    version = "1.0.0"

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)

        if 'reference_position' in node:
            node['reference_position'] = node['reference_position'].upper()

        return SpectralFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        node = cls._to_tree(frame, ctx)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
    @classmethod
    def assert_equal(cls, old, new):
        cls._assert_equal(old, new)

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return CoordinateFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)


class Frame2DType(FrameType):
    name = "frame2d"
    types = [Frame2D]

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return Frame2D(**node)


class CelestialFrameType(FrameType):
    name = "celestial_frame"
    types = [CelestialFrame]

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
    @classmethod
    def to_tree(cls, frame, ctx):
        return cls._to_tree(frame, ctx)

    @classmethod
    def assert_equal(cls, old, new):
        assert old.name == new.name  # nosec
        assert old.axes_order == new.axes_order  # nosec
        assert old.axes_names == new.axes_names  # nosec
        assert old.unit == new.unit  # nosec

        assert old.reference_frame == new.reference_frame  # nosec


class StokesFrameType(FrameType):
    name = "stokes_frame"
    types = [StokesFrame]

    @classmethod
    def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return StokesFrame(**node)

    @classmethod
    def _to_tree(cls, frame, ctx):

        node = {}

        node['name'] = frame.name
        if frame.axes_order:
            node['axes_order'] = list(frame.axes_order)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
if 'reference_position' in node:
            node['reference_position'] = node['reference_position'].upper()

        return SpectralFrame(**node)

    @classmethod
    def to_tree(cls, frame, ctx):
        node = cls._to_tree(frame, ctx)

        if frame.reference_position is not None:
            node['reference_position'] = frame.reference_position.lower()

        return node


class CompositeFrameType(FrameType):
    name = "composite_frame"
    types = [CompositeFrame]

    @classmethod
    def from_tree(cls, node, ctx):
        if len(node) != 2:
            raise ValueError("CompositeFrame has extra properties")

        name = node['name']
        frames = node['frames']

        return CompositeFrame(frames, name)

    @classmethod
    def to_tree(cls, frame, ctx):
        return {