casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
3C219D_regression.py
Go to the documentation of this file.
00001 #############################################################################
00002 ## $Id:$
00003 # Test Name:                                                                #
00004 #    Regression Test Script for 3C219D ()                                   #
00005 #                                                                           #
00006 # Rationale for Inclusion:                                                  #
00007 #    It ensures that the task is working properly.                          #
00008 #                                                                           # 
00009 # Features tested:                                                          #
00010 #    1) Is the task working properly?                                       #
00011 #    2) Is the task producing the same results as the reference?            #
00012 #   The script will as well test the following features:                    #
00013 #                                                                           #
00014 #    Input Data                  Process              Output Data           #
00015 # 3C219D_CAL.UVFITS.fits--->  importuvfits ----> 3C219Dtemp.ms.ms           #
00016 #                                  |                                        #
00017 #                                  v                                        #
00018 #                               fixvis     ----> 3C219D.ms                  #
00019 #                                  |                                        #
00020 #                                  v                                        #
00021 #                               vishead    ----> print on screen            #
00022 #                                  |                                        #
00023 #                                  v                                        #
00024 #   1-field, one scale           clean     ----> D-1scale                   #
00025 #   mask  rgn3C219D.rgn            |                                        #
00026 #                                  |                                        #
00027 #                                  v                                        #
00028 #   1-field, multi-scale         clean     ----> D-3scale                   #
00029 #   mask  rgn3C219D.rgn            |                                        #
00030 #                                  |                                        #
00031 #                                  v                                        #
00032 #   3-field mosaic, one scale    clean     ----> D-1scale_moz               #
00033 #   mask  rgn3C219D.rgn            |                                        #
00034 #                                  |                                        #
00035 #                                  v                                        #
00036 #   3-field mosaic, multi-scale  clean   ----> D-3scale_moz                 #
00037 #   mask  rgn3C219D.rgn                                                     #
00038 #                                                                           #
00039 #                                                                           #
00040 #                                                                           #
00041 # Input data:                                                               #
00042 #    3C219D_CAL.UVFITS, rgn3C219D.rgn                                       #
00043 #                                                                           #
00044 # Description:                                                              #
00045 #    3C219 VLA data, D-configuration                                        #                               
00046 #                                                                           #
00047 # Author: Ed Fomalont                                                       #
00048 #                                                                           #
00049 #                                                                           #
00050 # Note: all input data have relative paths to the local directory           #
00051 #############################################################################
00052 
00053 import os
00054 import regression_utility as tstutl
00055 from __main__ import default
00056 from tasks import *
00057 from taskinit import *
00058 
00059 
00060 # Initialization
00061 regstate=True
00062 
00063 #
00064 # Set up some useful variables
00065 #
00066 # FITS data and mask
00067 fitsdata='3C219D_CAL.UVFITS'
00068 rgnmask='rgn3C219D.rgn'
00069 
00070 # The testdir where all output files will be kept
00071 testdir='3C219D_regression/'
00072 
00073 # The prefix to use for output files.
00074 prefix=testdir+'3C219D'
00075 tmpfile = prefix+'temp.ms'
00076 msfile=prefix+'.ms'
00077 
00078 # Make new test directory
00079 # (WARNING! Removes old test directory of the same name if one exists)
00080 tstutl.maketestdir(testdir)
00081 
00082 ''' Version with breakpoints. It will raise an Exception if any task fails.'''
00083 
00084 #
00085 #=====================================================================
00086 #
00087 # Import the data from FITS to MS
00088 #
00089 #try:
00090 print '--Importuvfits--'
00091 status = True
00092 taskname = 'importuvfits'
00093 default(taskname)
00094 fitsfile = fitsdata
00095 vis=tmpfile
00096 antnamescheme = 'new'
00097 status = importuvfits()
00098     
00099 if status == False:
00100     regstate=False
00101     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00102     
00103 #
00104 #=====================================================================
00105 #
00106 # List data to check
00107 #
00108 #  2 IF's, Field 1,2,3 = 3C219, 3C219NE, 3C219SW
00109 #          Field 0 = 0917+449 main calibrator
00110 #          Field 4 = 3C286 flux/pol calibrator
00111 print '--Listobs--'
00112 status = True
00113 taskname = 'listobs'
00114 default(taskname)
00115 vis=tmpfile
00116 status = listobs()
00117 
00118 if status == False:
00119     regstate=False
00120     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00121     
00122 #
00123 #=====================================================================
00124 #
00125 #  Change data equinox to J2000
00126 #
00127 print '--Fixvis--'
00128 status = True
00129 taskname = 'fixvis'
00130 default (taskname)
00131 vis = tmpfile
00132 outputvis = msfile
00133 refcode = 'J2000'
00134 status  = fixvis()
00135 
00136 if status == False:
00137     regstate=False
00138     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00139     
00140 #
00141 #=====================================================================
00142 #
00143 #  Compare equinox before and after
00144 #
00145 print '--Vishead--'
00146 taskname = 'vishead'
00147 default (vishead)
00148 mode = 'list'
00149 listitems = []
00150 vis = tmpfile
00151 a=vishead()
00152 vis = msfile
00153 b=vishead()
00154 
00155 if (a == False or b == False):
00156     regstate=False
00157     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00158 
00159 print "original equinox: ", a['ptcs'][1]['MEASINFO']['Ref']
00160 print "     new equinox: ", b['ptcs'][1]['MEASINFO']['Ref']
00161     
00162     
00163 #
00164 #=====================================================================
00165 #
00166 #  Normal clean Image field 1 (3C219)
00167 #
00168 print '--Clean 1-field, 1 scale--'
00169 status = True
00170 taskname = 'clean'
00171 default(taskname)
00172 vis = msfile
00173 imagename = testdir+'D-1scale'
00174 field = '1'
00175 imagermode = ''
00176 niter = 4000
00177 imsize = 512
00178 cell = '2arcsec'
00179 mask = rgnmask
00180 weighting = 'briggs'
00181 robust = 0.5
00182 pbcor = T
00183 restoringbeam = ['9arcsec']
00184 threshold = '0.4mJy'
00185 status = clean()
00186 
00187 if status == False:
00188     regstate=False
00189     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00190 
00191     
00192 #
00193 #=====================================================================
00194 #
00195 #  Multi-scale Image field 1 (3C219)
00196 #
00197 print '--Clean 1-field, multi-scale--'
00198 status = True
00199 taskname = 'clean'
00200 default(taskname)
00201 vis = msfile
00202 imagename = testdir+'D-3scale'
00203 field = '1'
00204 imagermode=''
00205 niter = 2000
00206 imsize = 512
00207 multiscale = [0,5,15]
00208 cell = '2arcsec'
00209 mask = rgnmask
00210 weighting = 'briggs'
00211 robust = 0.5
00212 pbcor = T
00213 restoringbeam = ['9arcsec']
00214 threshold = '0.4mJy'
00215 status = clean()
00216 
00217 if status == False:
00218     regstate=False
00219     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00220     
00221 #
00222 #=====================================================================
00223 #
00224 #  Mosaic on fields 1,2,3
00225 # 3C219+3C219NE+3C219SW
00226 #
00227 print '--Clean 3-field mosaic, 1 scale--'
00228 status = True
00229 taskname = 'clean'
00230 default(taskname)
00231 vis = msfile
00232 imagename = testdir+'D-1scale_mos'
00233 phasecenter = '1'
00234 field = '1,2,3'
00235 imagermode=''
00236 niter = 4000
00237 imsize = 512
00238 imagermode = 'mosaic'
00239 cell = '2arcsec'
00240 mask = rgnmask
00241 weighting = 'briggs'
00242 robust = 0.5
00243 restoringbeam = ['9arcsec']
00244 pbcor = T
00245 threshold = '0.4mJy'
00246 status = clean()
00247 
00248 if status == False:
00249     regstate=False
00250     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00251     
00252 #
00253 #=====================================================================
00254 #
00255 #  Multi-scale mosaic
00256 #
00257 print '--Clean 3-field mosaic, multi-scale--'
00258 status = True
00259 taskname = 'clean'
00260 default(taskname)
00261 vis = msfile
00262 imagename = testdir+'D-3scale_mos'
00263 imagermode = 'mosaic'
00264 phasecenter = '1'
00265 field = '1,2,3'
00266 niter = 4000
00267 imsize = 512
00268 multiscale = [0,5,15]
00269 imagermode = 'mosaic'
00270 cell = '2arcsec'
00271 mask = rgnmask
00272 weighting = 'briggs'
00273 robust = 0.5
00274 restoringbeam = ['9arcsec']
00275 pbcor = T
00276 threshold = '0.4mJy'
00277 status = clean()
00278 
00279 if status == False:
00280     regstate=False
00281     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00282     
00283 #
00284 #=====================================================================
00285 #
00286 #  Make difference images of multi-scale
00287 #
00288 print '--Immath--'
00289 status = True
00290 taskname = 'immath'
00291 default (taskname)
00292 imagename = [testdir+'D-3scale.image',testdir+'D-3scale_mos.image']
00293 mode = 'evalexpr'
00294 outfile = testdir+'DIFF1.image'
00295 expr = ' (IM0 - IM1)'
00296 status = immath()
00297 
00298 if status == None:
00299     regstate=False
00300     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00301     
00302 #
00303 #=====================================================================
00304 #
00305 #  Min/max of difference images in source region
00306 #
00307 taskname = 'imstat'
00308 default (taskname)
00309 #region = rgnmask
00310 box = '200,200,300,300'
00311 imagename = testdir+'DIFF1.image'
00312 a1=imstat()
00313 
00314 if a1 == False:
00315     regstate=False
00316     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00317     
00318 #
00319 #=====================================================================
00320 #
00321 #  Make difference images of single-scale
00322 #
00323 status = True
00324 taskname = 'immath'
00325 default (taskname)
00326 imagename = [testdir+'D-1scale.image',testdir+'D-3scale.image']
00327 mode = 'evalexpr'
00328 outfile = testdir+'DIFF2.image'
00329 expr = ' (IM0 - IM1)'
00330 immath()
00331 
00332 if status == None:
00333     regstate=False
00334     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00335     
00336 #
00337 #=====================================================================
00338 #
00339 #  Min/max of difference images in source region
00340 #
00341 taskname = 'imstat'
00342 default (taskname)
00343 #region = rgnmask
00344 box = '200,200,300,300'
00345 imagename = testdir+'DIFF2.image'
00346 a2=imstat()
00347 
00348 if a2 == False:
00349     regstate=False
00350     raise Exception, "Regression test failed for 3C219D in task \"%s\"" %(taskname)
00351 
00352     
00353 # Do regressions tests
00354 # Reference values:
00355 
00356 ref1_rms=0.0005
00357 ref2_rms=0.0002
00358 
00359 print "difference between D-3scale.image and D-3scale_mos.image"
00360 print "diff:  rms = ",a1['rms'][0],";  minimum= ",a1['min'][0],": maximum= ",a1['max'][0]    
00361 print "difference between D-1scale.image and D-1scale_mos.image"
00362 print "diff:  rms = ",a2['rms'][0],";  minimum= ",a2['min'][0],": maximum= ",a2['max'][0]    
00363     
00364 if((abs(ref1_rms-a1['rms']) > 0.001) or (abs(ref2_rms-a2['rms']) > 0.001)):
00365     print abs(ref1_rms-a1['rms'])
00366     print abs(ref2_rms-a2['rms'])
00367     regstate=False
00368     print ''
00369     print 'Regression FAILED'
00370     print ''
00371     raise Exception, 'Regression test failed for 3C219D. Absolute differences are larger than 1e-03.'
00372 else:
00373     print ''
00374     print 'Regression PASSED'
00375     print ''
00376         
00377 
00378 #  End of 3C219D regression
00379