casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
nf_regression.py
Go to the documentation of this file.
00001 #############################################################################
00002 ## $Id:$
00003 # Test Name:                                                                
00004 #  Narrow field imaging of small-diameter sources
00005 #
00006 #  The ms contains simulated data taken from the u-v coverage
00007 #  for VLA-Bconfiguration data of 3C219.  The source data were
00008 #  replaced by a visibility associated with discrete sources.  One
00009 #  source pair is a point double, another is a displaced core-halo.
00010 
00011 #                                                          (Jy)
00012 #  SOURCE      dX        dY      bmaj    bmin   bpa    I    Q     U
00013 #    1        +20"      -50"      0"      0"     0d   1.2  0.00  0.00 core
00014 #    2        +21       -49      2.0     1.5    60    1.5  0.07  0.04 halo
00015 #    3        -40       +30      1.0     1.0     0    0.6  0.02 -0.02
00016 #    4        +54       -27      1.5     0.5    30    0.5 -0.06  0.03
00017 #    5        +60       +30      0.0     0.0     0    0.4  0.03 -0.02 double
00018 #    6        +60.5     +30.2    0.0     0.0     0    0.2 -0.01 +0.03 double
00019 #    7       +300      -150      0.0     0.0     0    1.0  0.10 -0.08 outside pb
00020 
00021 #  Gaussian noise of 0.3 Jy has been added to each uv-point,
00022 #  resulting in a map rms of 0.33 mJy.
00023 
00024 #  The input files are:
00025 #   1.  model7.ms contains the measurement set
00026 #   2.  model2.txt contains the parameters for the two fields
00027 #   3.  M7_0.mask and M7_1.mask are the cleaning masks for the two fields
00028 #   4.  Double_I.ext and Double_U.ext are imfit estimates for doubles.
00029 
00030 #  Image/clean all Stokes parameters; main field an outlier field
00031 #
00032 
00033 import os
00034 import time
00035 import regression_utility as tstutl
00036 from __main__ import default
00037 from tasks import *
00038 from taskinit import *
00039 
00040 # Enable benchmarking?
00041 benchmarking = True
00042 usedasync = False
00043 
00044 # The testdir where all output files will be kept
00045 testdir='nf_regression/'
00046 prefix='narrowfield'
00047 
00048 # Input files
00049 msfile = 'model7.ms'
00050 modelfile = 'model2.txt'
00051 mask0 = 'M7_0.mask'
00052 mask1 = 'M7_1.mask'
00053 doubleI = 'Double_I.ext'
00054 doubleU = 'Double_U.ext'
00055 
00056 # Make new test directory
00057 # (WARNING! Removes old test directory of the same name if one exists)
00058 tstutl.maketestdir(testdir)
00059 
00060 # Start benchmarking
00061 if benchmarking:
00062     startTime = time.time()
00063     startProc = time.clock()
00064 
00065 ###############################################
00066 # Run clean
00067 #
00068 print '--Clean--'
00069     
00070 taskname = 'clean'
00071 default(taskname)
00072 vis = msfile
00073 imagename = testdir+'MG_IQUV'
00074 outlierfile = modelfile
00075 niter = 2000
00076 threshold = '0.8mJy'
00077 mask = [[mask0],[mask1]]
00078 cell = '0.2arcsec'
00079 weighting = 'briggs'
00080 imagermode = 'csclean'
00081 restoringbeam = ['0.65','0.65','0.0deg'] 
00082 stokes = 'IQUV'
00083 clean()
00084 
00085 
00086 ###############################################
00087 # Run immath
00088 #
00089 print '--Immath--'
00090 
00091 #  Make separate images in each stokes
00092 
00093 taskname = 'immath'
00094 default(taskname)
00095 imagename = testdir+'MG_IQUV_0.image'
00096 expr = 'IM0'
00097 stokes = 'I'; outfile = testdir+'MG_I_0.im'; immath()
00098 stokes = 'Q'; outfile = testdir+'MG_Q_0.im'; immath()
00099 stokes = 'U'; outfile = testdir+'MG_U_0.im'; immath()
00100 stokes = 'V'; outfile = testdir+'MG_V_0.im'; immath()
00101 imagename = testdir+'MG_IQUV_1.image'
00102 expr = 'IM0'
00103 stokes = 'I'; outfile = testdir+'MG_I_1.im'; immath()
00104 stokes = 'Q'; outfile = testdir+'MG_Q_1.im'; immath()
00105 stokes = 'U'; outfile = testdir+'MG_U_1.im'; immath()
00106 stokes = 'V'; outfile = testdir+'MG_V_1.im'; immath()
00107 
00108 ###############################################
00109 # Run imfit
00110 #
00111 #  Do selected imfits on some images
00112 #  point source at field center
00113 
00114 print '--Point sources--'
00115 print '--Imfit I--'
00116 taskname = 'imfit'
00117 default (taskname)
00118 box = '63,54,74,64'
00119 append = F
00120 stokes='I'
00121 imagename = testdir+'MG_I_1.im'
00122 logfile = testdir+'MG_I_1.log'
00123 newestimates = testdir+'MG_I_1.est'
00124 imfit() 
00125 #!more MG_I_1.log
00126 #  Peak/Int should be about 1.00 Jy, nearly unresolved 
00127 #
00128 
00129 print '--Imfit Q--'
00130 imagename = testdir+'MG_Q_1.im'
00131 logfile = testdir+'MG_Q_1.log'
00132 stokes='Q'
00133 imfit() 
00134 #!more MG_Q_1.log
00135 #  Peak/Int should be about 100 mJy, nearly unresolved 
00136 #
00137 
00138 print '--Imfit U--'
00139 imagename = testdir+'MG_U_1.im'
00140 logfile = testdir+'MG_U_1.log'
00141 stokes='U'
00142 imfit() 
00143 #!more MG_U_1.log
00144 #  Peak/Int should be about -80 mJy, nearly unresolved 
00145 #
00146 
00147 print '--Imfit V--'
00148 imagename = testdir+'MG_V_1.im'
00149 logfile = testdir+'MG_V_1.log'
00150 stokes='V'
00151 imfit() 
00152 #!more MG_V_1.log
00153 #  Pure noise, fit may blow up, but should not
00154 
00155 print '--Extended source--'
00156 print '--Imfit I--'
00157 # Fit on an extended source
00158 taskname = 'imfit'
00159 default (taskname)
00160 box = '231,367,252,391'
00161 apend = F
00162 stokes='I'
00163 imagename = testdir+'MG_I_0.im'
00164 logfile = testdir+'MG_I_0.log'
00165 imfit() 
00166 #!more MG_I_0.log
00167 #  Int should be about 0.5 Jy, size 1.5x0.5 in pa 30 
00168 #
00169 
00170 print '--Imfit Q--'
00171 imagename = testdir+'MG_Q_0.im'
00172 logfile = testdir+'MG_Q_0.log'
00173 stokes='Q'
00174 imfit() 
00175 #!more MG_Q_0.log
00176 #  Int should be about -0.06 Jy, size 1.5x0.5 in pa 30 
00177 #
00178 
00179 print '--Imfit U--'
00180 imagename = testdir+'MG_U_0.im'
00181 logfile = testdir+'MG_U_0.log'
00182 stokes='U'
00183 imfit() 
00184 #!more MG_Q_0.log
00185 #  Int should be about +0.03 Jy, size 1.5x0.5 in pa 30 
00186 
00187 print '--Point double source--'
00188 print '--Imfit I--'
00189 # Fit on point double source
00190 taskname = 'imfit'
00191 default (taskname)
00192 box = '203,657,221,671'
00193 append = F
00194 stokes='I'
00195 imagename = testdir+'MG_I_0.im'
00196 logfile = testdir+'Double_I_0.log'
00197 estimates = doubleI
00198 imfit() 
00199 #!more Double_I_0.log
00200 #  Peaks are 0.4 and 0.2, separated by 2.5 xpix and 1.0 ypix
00201 
00202 print '--Imfit U--'
00203 imagename = testdir+'MG_U_0.im'
00204 logfile = testdir+'Double_U_0.log'
00205 estimates = doubleU
00206 stokes='U'
00207 imfit() 
00208 #!more Double_U_0.log
00209 #  Peaks are -0.02 and +0.04, separated by 2.5 xpix and 1.0 ypix