casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
fits-import-export.py
Go to the documentation of this file.
00001 # wrapper script for FITS import/export regression test
00002 import sys
00003 import os
00004 import string
00005 from locatescript import copydata
00006 from locatescript import locatescript
00007 import inspect
00008 
00009 # Short description
00010 def description():
00011     return "Test of the exportfits() and importfits() tasks, compliance with FITS standard"
00012 
00013 # Reference data
00014 #  The dictionary of test datasets
00015 #  Each entry is a tuple of filename (w/o extension), expected pixel position of the maximum flux,
00016 #  expected absolute position of the maximum flux (RA, DEC), name.
00017 pass_on = { 'datasets': { 1: ('1904-66_AIR', [109, 167], '19:39:23.885, -63.45.36.905', 'Airy Projection (AIR)'), 
00018                           2: ('1904-66_AIT', [109, 168], '19:39:41.653, -63.43.54.147', 'Hammer-Aitoff Projection (AIT)'),  
00019                           3: ('1904-66_ARC', [110, 170], '19:39:28.622, -63.41.53.659', 'Zenithal Equidistant Projection (ARC)'), 
00020                           4: ('1904-66_AZP', [116, 186], '19:39:21.120, -63.44.26.642', 'Zenithal Perspective Projection (AZP)'), 
00021                           5: ('1904-66_BON', [108, 173], '19:39:28.718, -63.41.12.383', 'Bonne\'s Equal Area Projection (BON)'), 
00022                           6: ('1904-66_CAR', [113, 168], '19:39:42.371, -63.41.36.035', 'Plate Caree Projection (CAR)'),
00023                           7: ('1904-66_CEA', [113, 167], '19:39:35.136, -63.41.56.055', 'Cylindrical Equal Area Projection (CEA)'),
00024                           8: ('1904-66_COD', [109, 166], '19:39:39.760, -63.42.02.640', 'Conic Equidistant Projection (COD)'), 
00025                           9: ('1904-66_COE', [112, 172], '19:39:34.041, -63.44.23.296', 'Conic Equal-Area Projection (COE)'), 
00026                           10: ('1904-66_COO', [109, 161], '19:39:31.237, -63.44.09.556', 'Conic Orthomorphic Projection (COO)'), 
00027                           11: ('1904-66_COP', [110, 161], '19:39:28.345, -63.44.40.626', 'Conic Perspective Projection (COP)'), 
00028                           12: ('1904-66_CSC', [113, 180], '19:39:41.073, -63.43.25.624', 'COBE Quadrilateralized Spherical Cube Projection (CSC)'),  
00029                           13: ('1904-66_CYP', [108, 157], '19:39:12.028, -63.43.07.315', 'Cylindrical Perspective Projection (CYP)'),  
00030                           14: ('1904-66_HPX', [113, 179], '19:39:16.552, -63.42.47.347', 'HEALPix Grid Projection (HPX)'), 
00031                           15: ('1904-66_MER', [113, 168], '19:39:16.276, -63.42.48.107', 'Mercator Projection (MER)'), 
00032                           16: ('1904-66_MOL', [109, 175], '19:39:20.341, -63.41.44.201', 'Mollweide Projection (MOL)'), 
00033                           17: ('1904-66_NCP', [107, 167], '19:39:38.614, -63.42.51.577', 'North Celetial Pole (SIN spcial case) Projection (NCP)'), 
00034                           18: ('1904-66_PAR', [109, 171], '19:39:32.698, -63.42.04.737', 'Parabolic Projection (PAR)'), 
00035                           19: ('1904-66_PCO', [108, 174], '19:39:21.403, -63.43.49.358', 'Polyconic Projection (PCO)'), 
00036                           20: ('1904-66_QSC', [120, 182], '19:39:23.808, -63.41.22.666', 'Quadrilateralized Spherical Cube Projection (QSC)'), 
00037                           21: ('1904-66_SFL', [108, 167], '19:39:16.950, -63.45.15.188', 'Samson-Flamsteed Projection (SFL)'), 
00038                           22: ('1904-66_SIN', [107, 167], '19:39:38.614, -63.42.51.577', 'Slant Orthographic Projection (SIN)'), 
00039                           23: ('1904-66_STG', [111, 171], '19:39:14.752, -63.44.20.882', 'Stereographic Projection (STG)'), 
00040                           24: ('1904-66_SZP', [110, 177], '19:39:42.475, -63.42.13.751', 'Slant Zenithal Perspective Projection (SZP)'),
00041                           25: ('1904-66_TAN', [116, 177], '19:39:30.753, -63.42.59.218', 'Gnomonic Projection (TAN)'), 
00042                           26: ('1904-66_TSC', [112, 160], '19:39:39.997, -63.41.14.586', 'Tangential Spherical Cube Projection (TSC)'), 
00043                           27: ('1904-66_ZEA', [109, 169], '19:39:26.872, -63.43.26.060', 'Zenithal Equal Area Projection (ZEA)'), 
00044                           28: ('1904-66_ZPN', [94, 150], '19:39:24.948, -63.46.43.636', 'Zenithal Polynomial Projection (ZPN)'),
00045                           29: ('1904-66_AIT-obsgeo', [109, 168], '19:39:41.653, -63.43.54.147', 'Hammer-Aitoff Projection (AIT)')  
00046                           }
00047             }
00048 
00049 a=inspect.stack()
00050 stacklevel=0
00051 for k in range(len(a)):
00052     if (string.find(a[k][1], 'ipython console') > 0):
00053         stacklevel=k
00054         break
00055 gl=sys._getframe(stacklevel).f_globals
00056 
00057 
00058 def data():
00059     ### return the data files that are needed by the regression script
00060     myfiles = []
00061     for i in (pass_on['datasets']).keys():
00062         myfiles.append(pass_on['datasets'][i][0] + '.fits')
00063     myfiles.append('stokeslast-test.image')    
00064     myfiles.append('xxx-clean.image')    
00065     myfiles.append('spec-test-freq.fits')    
00066     myfiles.append('spec-test-vopt.fits')    
00067     myfiles.append('spec-test-vrad.fits')    
00068     myfiles.append('spec-test-wave.fits')    
00069     myfiles.append('spec-test-awav.fits')    
00070     return myfiles
00071 
00072 def doCopy():
00073     ### return a list of the same length as that returned by data()
00074     ###   containing 0 if the corresponding file should be just linked
00075     ###   (i.e. is read-only)
00076     ###   or 1 if the corresponding file should be really copied to
00077     ###   the work directory
00078     cp = []
00079     for i in (pass_on['datasets']).keys():
00080         cp.append(0)
00081     cp.append(0)
00082     cp.append(0)
00083     cp.append(0)
00084     cp.append(0)
00085     cp.append(0)
00086     cp.append(0)
00087     cp.append(0)
00088     return cp
00089 
00090 def run( fetch=False ):
00091 
00092     #####fetch data
00093     if fetch:
00094         for f in data( ):
00095             copydata( f, os.getcwd( ) )
00096     
00097     #####locate the regression script
00098     try: 
00099         lepath=locatescript('fits-import-export_regression.py')
00100         print 'Script used is ',lepath
00101         execfile(lepath, gl, pass_on)
00102     except:
00103         print 'execution failed: ', sys.exc_info()
00104         raise
00105 ###return the images that will be templated and compared in future runs
00106     return []