#NEWLINE# def use( wcspkg , raise_err = True ) : #NEWLINE# #INDENT# 'Choose WCS package.' #NEWLINE# global coord_types , wcs_configured , WCS , have_kapteyn , kapwcs , have_astlib , astWCS , astCoords , have_starlink , Ast , Atl , have_astropy , pywcs , pyfits , astropy , coordinates , units #NEWLINE# if ( wcspkg == 'kapteyn' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from kapteyn import wcs as kapwcs #NEWLINE# coord_types = [ 'icrs' , 'fk5' , 'fk4' , 'galactic' , 'ecliptic' ] #NEWLINE# have_kapteyn = True #NEWLINE# wcs_configured = True #NEWLINE# WCS = KapteynWCS #NEWLINE# return True #NEWLINE# #UNINDENT# except ImportError as e : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wcspkg == 'starlink' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import starlink.Ast as Ast #NEWLINE# import starlink.Atl as Atl #NEWLINE# coord_types = [ 'icrs' , 'fk5' , 'fk4' , 'galactic' , 'ecliptic' ] #NEWLINE# have_starlink = True #NEWLINE# wcs_configured = True #NEWLINE# WCS = StarlinkWCS #NEWLINE# return True #NEWLINE# #UNINDENT# except ImportError as e : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wcspkg == 'astlib' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from astLib import astWCS , astCoords #NEWLINE# try : #NEWLINE# #INDENT# from astropy.io import fits as pyfits #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import pyfits #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ImportError ( 'Need pyfits module to use astLib WCS' ) #NEWLINE# #UNINDENT# #UNINDENT# astWCS . NUMPY_MODE = True #NEWLINE# coord_types = [ 'j2000' , 'b1950' , 'galactic' ] #NEWLINE# have_astlib = True #NEWLINE# wcs_configured = True #NEWLINE# WCS = AstLibWCS #NEWLINE# return True #NEWLINE# #UNINDENT# except ImportError as e : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wcspkg == 'astropy2' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import astropy #NEWLINE# from distutils.version import LooseVersion #NEWLINE# if ( LooseVersion ( astropy . __version__ ) <= LooseVersion ( '1' ) ) : #NEWLINE# #INDENT# raise ImportError ( 'astropy2 wrapper requires version 1 of astropy' ) #NEWLINE# #UNINDENT# import astropy.coordinates #NEWLINE# import astropy.wcs as pywcs #NEWLINE# from astropy.io import fits as pyfits #NEWLINE# import astropy.units as u #NEWLINE# from astropy.version import version #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# have_pywcs = True #NEWLINE# have_astropy = True #NEWLINE# wcs_configured = True #NEWLINE# WCS = AstropyWCS2 #NEWLINE# try : #NEWLINE# #INDENT# import sunpy.coordinates #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# coord_types = [ f . name for f in astropy . coordinates . frame_transform_graph . frame_set ] #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wcspkg == 'astropy' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import astropy.wcs as pywcs #NEWLINE# from astropy.io import fits as pyfits #NEWLINE# have_pywcs = True #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import pywcs #NEWLINE# have_pywcs = True #NEWLINE# #UNINDENT# except ImportError as e : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# from astropy import coordinates #NEWLINE# from astropy import units #NEWLINE# have_astropy = True #NEWLINE# wcs_configured = True #NEWLINE# WCS = AstropyWCS #NEWLINE# if hasattr ( coordinates , 'SkyCoord' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import sunpy.coordinates #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# coord_types = [ f . name for f in coordinates . frame_transform_graph . frame_set ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coord_types = [ 'icrs' , 'fk5' , 'fk4' , 'galactic' ] #NEWLINE# #UNINDENT# return True #NEWLINE# #UNINDENT# except ImportError as e : #NEWLINE# #INDENT# if raise_err : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( wcspkg == 'barebones' ) : #NEWLINE# #INDENT# coord_types = [ 'fk5' ] #NEWLINE# WCS = BareBonesWCS #NEWLINE# wcs_configured = True #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return False