Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 import time
00021 import os
00022
00023
00024
00025
00026
00027
00028
00029 scriptmode = True
00030
00031
00032
00033
00034
00035
00036
00037 prefix='jupiter6cm.demo'
00038
00039 msfile = prefix + '.ms'
00040
00041
00042
00043
00044 calprefix = prefix + '.cal'
00045
00046 srcname = 'JUPITER'
00047 srcsplitms = calprefix + '.' + srcname + '.split.ms'
00048
00049
00050
00051
00052
00053
00054 polprefix = prefix + '.polimg'
00055
00056
00057 os.system('rm -rf '+polprefix+'*')
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 clncell = [4.,4.]
00073
00074
00075
00076
00077 clnalg = 'hogbom'
00078 clnmode = 'csclean'
00079 clnimsize = [288,288]
00080
00081
00082 clniter = 10000
00083
00084
00085
00086
00087
00088
00089 clnthreshold=0.05
00090
00091 polimname = polprefix + '.clean'
00092 polimage = polimname+'.image'
00093 polmodel = polimname+'.model'
00094 polresid = polimname+'.residual'
00095 polmask = polimname+'.clean_interactive.mask'
00096
00097
00098
00099
00100 ipolimage = polimage+'.I'
00101 qpolimage = polimage+'.Q'
00102 upolimage = polimage+'.U'
00103
00104 poliimage = polimage+'.poli'
00105 polaimage = polimage+'.pola'
00106
00107
00108
00109
00110
00111
00112 print '--Clean (Polarization)--'
00113 default('clean')
00114
00115 print "Now clean polarized data"
00116
00117 vis = srcsplitms
00118
00119 imagename = polimname
00120
00121 field = '*'
00122 spw = ''
00123 mode = 'mfs'
00124 gain = 0.1
00125
00126
00127 stokes = 'IQUV'
00128
00129 psfmode = clnalg
00130 imagermode = clnmode
00131
00132 imsize = clnimsize
00133 cell = clncell
00134 niter = clniter
00135 threshold = clnthreshold
00136
00137 weighting = 'briggs'
00138 robust = 0.5
00139
00140 interactive = True
00141 npercycle = 100
00142
00143 saveinputs('clean',imagename+'.clean.saved')
00144 clean()
00145
00146 print ""
00147 print "----------------------------------------------------"
00148 print "Clean"
00149 print "Final restored clean image is "+polimage
00150 print "Final clean model is "+polmodel
00151 print "The clean residual image is "+polresid
00152 print "Your final clean mask is "+polmask
00153
00154
00155
00156
00157
00158
00159
00160 print '--Final Pol Imstat--'
00161 default('imstat')
00162
00163 imagename = polimage
00164
00165 on_statistics = {}
00166 off_statistics = {}
00167
00168
00169 onbox = ''
00170
00171 offbox = '216,1,287,72'
00172
00173 for stokes in ['I','Q','U','V']:
00174 box = onbox
00175 on_statistics[stokes] = imstat()
00176 box = offbox
00177 off_statistics[stokes] = imstat()
00178
00179
00180
00181
00182 print '--Immath--'
00183 default('immath')
00184
00185 mode = 'evalexpr'
00186
00187 stokes = 'I'
00188 outfile = ipolimage
00189 expr = '\"'+polimage+'\"'
00190
00191 immath()
00192 print "Created I image "+outfile
00193
00194 stokes = 'Q'
00195 outfile = qpolimage
00196 expr = '\"'+polimage+'\"'
00197
00198 immath()
00199 print "Created Q image "+outfile
00200
00201 stokes = 'U'
00202 outfile = upolimage
00203 expr = '\"'+polimage+'\"'
00204
00205 immath()
00206 print "Created U image "+outfile
00207
00208
00209
00210
00211
00212 stokes = ''
00213 outfile = poliimage
00214 mode = 'poli'
00215 imagename = [qpolimage,upolimage]
00216
00217 mysigma = 0.5*( off_statistics['Q']['rms'][0] + off_statistics['U']['rms'][0] )
00218
00219
00220 sigma = '0.0Jy/beam'
00221
00222 immath()
00223 print "Created POLI image "+outfile
00224
00225 outfile = polaimage
00226 mode = 'pola'
00227
00228 immath()
00229 print "Created POLA image "+outfile
00230
00231
00232
00233
00234 default('imstat')
00235
00236 imagename = poliimage
00237 stokes = ''
00238 box = onbox
00239 on_statistics['POLI'] = imstat()
00240 box = offbox
00241 off_statistics['POLI'] = imstat()
00242
00243
00244
00245
00246
00247
00248
00249 viewer(polimage,'image')
00250
00251 print "Displaying pol I now. You should overlay pola vectors"
00252 print "Bring up the Load Data panel:"
00253 print ""
00254 print "Use LEL for POLA VECTOR with cut above 6*mysigma in POLI = "+str(6*mysigma)
00255 print "For example:"
00256 print "\'"+polaimage+"\'[\'"+poliimage+"\'>0.0048]"
00257 print ""
00258 print "In the Data Display Options for the vector plot:"
00259 print " Set the x,y increments to 2 (default is 3)"
00260 print " Use an extra rotation this 90deg to get B field"
00261 print "Note the lengths are all equal. You can fiddle these."
00262 print ""
00263 print "You can also load the poli image as contours"
00264
00265
00266 if scriptmode:
00267 user_check=raw_input('Return to continue script\n')
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 po = casac.imagepol()
00282 po.open(polimage)
00283
00284 complexlinpolimage = polimname + '.cmplxlinpol'
00285 po.complexlinpol(complexlinpolimage)
00286 po.close()
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300 print ""
00301 print ' Jupiter polarization results '
00302 print ' ============================ '
00303 print ''
00304 for stokes in ['I','Q','U','V','POLI']:
00305 print ''
00306 print ' =============== '
00307 print ''
00308 print ' Polarization (Stokes '+stokes+'):'
00309 mymax = on_statistics[stokes]['max'][0]
00310 mymin = on_statistics[stokes]['min'][0]
00311 myrms = off_statistics[stokes]['rms'][0]
00312 absmax = max(mymax,mymin)
00313 mydra = absmax/myrms
00314 print ' Clean image ON-SRC max = ',mymax
00315 print ' Clean image ON-SRC min = ',mymin
00316 print ' Clean image OFF-SRC rms = ',myrms
00317 print ' Clean image dynamic rng = ',mydra
00318
00319
00320 print '--- Done ---'
00321
00322
00323