How to use the gwcs.utils.UnsupportedProjectionError 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 / utils.py View on Github external
def get_projcode(wcs_info):
    # CTYPE here is only the imaging CTYPE keywords
    sky_axes, _, _ = get_axes(wcs_info)
    if not sky_axes:
        return None
    projcode = wcs_info['CTYPE'][sky_axes[0]][5:8].upper()
    if projcode not in projections.projcodes:
        raise UnsupportedProjectionError('Projection code %s, not recognized' % projcode)
    return projcode
github spacetelescope / gwcs / gwcs / wcstools.py View on Github external
def _verify_projection(projection):
    if projection is None:
        raise ValueError("Celestial coordinate frame requires a projection to be specified.")
    if not isinstance(projection, projections.Projection):
        raise UnsupportedProjectionError(projection)
github spacetelescope / gwcs / gwcs / utils.py View on Github external
Parameters
    ----------
    projcode : str
        FITS WCS projection code.

    Returns
    -------
    transform : astropy.modeling.Model
        Projection transform.
    """

    projklassname = 'Pix2Sky_' + projcode
    try:
        projklass = getattr(projections, projklassname)
    except AttributeError:
        raise UnsupportedProjectionError(projcode)

    projparams = {}
    return projklass(**projparams)
github spacetelescope / gwcs / gwcs / utils.py View on Github external
unit = u.deg
    else:
        lon, lat = skycoord
        if isinstance(lat, u.Quantity):
            unit = u.deg
        else:
            unit = None
    if isinstance(projection, projections.Zenithal):
        lon_pole = 180
    elif isinstance(projection, projections.Cylindrical):
        if lat >= 0:
            lon_pole = 0
        else:
            lon_pole = 180
    else:
        raise UnsupportedProjectionError("Projection {0} is not supported.".format(projection))
    if unit is not None:
        lon_pole = lon_pole * unit
    return lon_pole
github spacetelescope / gwcs / gwcs / utils.py View on Github external
def __init__(self, code):
        message = "Unsupported projection: {0}".format(code)
        super(UnsupportedProjectionError, self).__init__(message)
github spacetelescope / gwcs / gwcs / wcstools.py View on Github external
one of "polynomial", "chebyshev", "legendre"

    Returns
    -------
    wcsobj : `~gwcs.wcs.WCS`
        a WCS object for this observation.
    """
    supported_poly_types = {"polynomial": models.Polynomial2D,
                            "chebyshev": models.Chebyshev2D,
                            "legendre": models.Legendre2D
                           }
    x, y = xy
    lon, lat = world_coordinates

    if not isinstance(projection, projections.Projection):
        raise UnsupportedProjectionError("Unsupported projection code {0}".format(projection))
    if polynomial_type not in supported_poly_types.keys():
        raise ValueError("Unsupported polynomial_type: {}. "
                         "Only one of {} is supported.".format(polynomial_type, supported_poly_types.keys()))
    skyrot = models.RotateCelestial2Native(fiducial.data.lon, fiducial.data.lat, 180*u.deg)
    trans = (skyrot | projection)
    projection_x, projection_y = trans(lon, lat)
    poly = supported_poly_types[polynomial_type](degree)
    fitter = fitting.LevMarLSQFitter()
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        poly_x = fitter(poly, x, y, projection_x)
        poly_y = fitter(poly, x, y, projection_y)
    transform = models.Mapping((0, 1, 0, 1)) | poly_x & poly_y | projection.inverse | skyrot.inverse

    skyframe = CelestialFrame(reference_frame=fiducial.frame)
    detector = Frame2D(name="detector")