How to use the gwcs.coordinate_frames.Frame2D 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 astropy / photutils / photutils / datasets / make.py View on Github external
cd_matrix = np.array([[-scale * np.cos(rho), scale * np.sin(rho)],
                          [scale * np.sin(rho), scale * np.cos(rho)]])

    rotation = models.AffineTransformation2D(cd_matrix, translation=[0, 0])
    rotation.inverse = models.AffineTransformation2D(
        np.linalg.inv(cd_matrix), translation=[0, 0])

    tan = models.Pix2Sky_TAN()
    celestial_rotation = models.RotateNative2Celestial(197.8925, -1.36555556,
                                                       180.0)

    det2sky = shift_by_crpix | rotation | tan | celestial_rotation
    det2sky.name = 'linear_transform'

    detector_frame = cf.Frame2D(name='detector', axes_names=('x', 'y'),
                                unit=(u.pix, u.pix))

    if galactic:
        sky_frame = cf.CelestialFrame(reference_frame=coord.Galactic(),
                                      name='galactic', unit=(u.deg, u.deg))
    else:
        sky_frame = cf.CelestialFrame(reference_frame=coord.ICRS(),
                                      name='icrs', unit=(u.deg, u.deg))

    pipeline = [(detector_frame, det2sky), (sky_frame, None)]

    return gwcs_wcs.WCS(pipeline)
github spacetelescope / gwcs / gwcs / coordinate_frames.py View on Github external
ph_type = ("em.wl",)
            elif self.unit[0].physical_type == "energy":
                ph_type = ("em.energy",)
            elif self.unit[0].physical_type == "speed":
                ph_type = ("spect.dopplerVeloc",)
                logging.warning("Physical type may be ambiguous. Consider "
                                "setting the physical type explicitly as "
                                "either 'spect.dopplerVeloc.optical' or "
                                "'spect.dopplerVeloc.radio'.")
            else:
                ph_type = ("custom:{}".format(self.unit[0].physical_type),)

        elif isinstance(self, TemporalFrame):
            ph_type = ("time",)

        elif isinstance(self, Frame2D):
            if all(self.axes_names):
                ph_type = self.axes_names
            else:
                ph_type = self.axes_type
            ph_type = tuple("custom:{}".format(t) for t in ph_type)

        else:
            ph_type = tuple("custom:{}".format(t) for t in self.axes_type)

        validate_physical_types(ph_type)
        return tuple(ph_type)
github spacetelescope / gwcs / gwcs / coordinate_frames.py View on Github external
def __init__(self, axes_order=(0, 1), unit=(u.pix, u.pix), axes_names=('x', 'y'),
                 name=None, axis_physical_types=None):

        super(Frame2D, self).__init__(naxes=2, axes_type=["SPATIAL", "SPATIAL"],
                                      axes_order=axes_order, name=name,
                                      axes_names=axes_names, unit=unit,
                                      axis_physical_types=axis_physical_types)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
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)
        return CelestialFrame(**node)
github spacetelescope / gwcs / gwcs / tags / wcs.py View on Github external
def from_tree(cls, node, ctx):
        node = cls._from_tree(node, ctx)
        return Frame2D(**node)