Source code for glue.plugins.wcs_autolinking.wcs_autolinking

import copy

import numpy as np
from astropy.wcs.utils import pixel_to_pixel
from astropy.wcs.wcsapi import BaseHighLevelWCS, SlicedLowLevelWCS, HighLevelWCSWrapper
from scipy.optimize import leastsq
from glue.config import autolinker, link_helper
from glue.core.link_helpers import MultiLink


__all__ = ['IncompatibleWCS', 'WCSLink', 'wcs_autolink', 'AffineLink', 'OffsetLink',
           'NoAffineApproximation']


[docs]class NoAffineApproximation(Exception): pass
[docs]class IncompatibleWCS(Exception): pass
def get_cids_and_functions(wcs1, wcs2, pixel_cids1, pixel_cids2): def forwards(*pixel_input): return pixel_to_pixel(wcs1, wcs2, *pixel_input) def backwards(*pixel_input): return pixel_to_pixel(wcs2, wcs1, *pixel_input) pixel_input = [0] * len(pixel_cids1) try: # the case with wcs linkages forwards(*pixel_input) backwards(*pixel_input) except Exception: # the case without wcs linkages return None, None, None, None return pixel_cids1, pixel_cids2, forwards, backwards