$ Procedures to reduce EVN data $ $------------------------------------------------------------------ $ Cormac Reynolds - January 2001: original adapted from BD046.RUN by Phil $ Diamond $ 5 April 2001: updated to allow single polarization expts. $ 8 April 2001: Added clrtemp commands to prevent 'BLEW TEMP $ C' $ 21 May 2001: Made the number of IFs an input variable and $ split into two procedures to overcome $ procedure length limits. $ 1 June 2001: Allow sciter<2 and no selfcal if desired. $ 5 June 2001: added clplt $ 3 Dec 2001: Added listr output of AMP SN table, and use of $ uncompresed data sets in fitld. $ 12 Mar 2002: VBGLU etc. added to allow 2-head datasets. $ 23 Apr 2002: doprint=0 really doesn't print now. $ 4 Jun 2002: Now runs on 31DEC01 version of AIPS. UVPLT of $ calibrated data has been added. u,v coverage $ plot added. $ 10 Jun 2002: ncomp=0 in plots of model and in uvsub done $ before plotting closure phases. Use all sources $ in srclst to make the sensitivity plot at $ the end. ECHAN=2048 in vplots. $ 13 Jun 2002: new proc EVN_SAVE to save the PI products to $ disk. $ 8 Aug 2002: use APCAL and FITLD from DEC02 version $ 9 Jan 2003: PA correction and use .uvflg instead of .flag $ 23 Jan 2003: interpolate APCAL sn table using doblank $ options to avoid losing data where antab file $ is blanked. $ 24 Jan 2003: added some spectral line specific sections $ (provided by Hiroshi). Added Phase reference $ pairs option, bpass calibrator selection, $ multiple FITS files can be specified by nfits $ parameter. $ 31 Jan 2003: Plot bandpass phase with self-scale range. $ 21 Feb 2003: Updated several tasks to run 31DEC02 version. $ 2 Dec 2003: changed snplt to plot all IFs/Pols at once. $ Added 'global' parameter to do vlog/antab for $ VLBA antennas. $ 4 Dec 2003: POSSM now does both stokes in one go. $ Added BADIF parameter. Changed font/character sizes to $ make plots more readable. $ 8 Dec 2003: now deletes old versions of files before $ creating new ones $ 10 Dec 2003: made CLPLT more robust (removed opcod='INDE') $ 17 Dec 2003: selfcal solutions printed with source names in $ plot title. $ 29 Mar 2004: fixed bug in 2 head stuff. $ 5 Jul 2004: changed some things to agree with new archive $ policy $ 14 Jul 2004: fixed small bug in 'goodif'. Changed fqtol in $ VLOG. $ 26 Feb 2005: Added P-band imaging defaults restore 0 clrtemp dowait 1 proc declare array plotref(32) scalar uvdisk, uvseq, tapeuse, antref, uv2disk scalar imask, nplots, k1, k2, disk, solcal scalar itab, jtab, ii, jj, ant2ref, k scalar t1, t2, t3 scalar refan2, oint, tcutof, tseq, texist, nn scalar nif, incif, incey, nheads, cpols scalar disk2 scalar doprint, allmask, iscal, i, l, m, nbl, inc, nsrc, cntsrc scalar patchmin, snr, delch, peakflux, rmsflux, doedit, firstif, lastif scalar ncc, avg, nfits, doavr, nchan, npairs, nsc, match, nbpass scalar plotavg, pr2file, sciter, npols, lpol, rpol, tsol, firstsrc, global scalar nvlba, rownum, nsparm, nant, gotant string*6 uvclass string*16 uvnam, ropey string*48 fitsfile, inbase string*6 rr, ll, tcout string*50 pounds; string*8 tsknam; string*6 tclass string*6 tclass1; string*2 table; string*2 extype string*6 tmpl, tver, aver string*2 tabtyp; string*50 text; string*50 excl; string*2 badif(32); string*12 sauce, tname, oname, tasavext; scalar oseq string*4 tintp string*48 dir, dir2, filout, filename string*2 ttype; string*1 polty; string*16 expname, antabext, flagext, chflag string*32 srclst(128), calsrclst(128), bpasslst(128), preflst(128) string*32 scallst(128) string*32 src1, src2 string*2 obsband, pols, wtfn, vlba_ants(10), iant, jant, an_name string*3 soln string*4 plottyp ret; fin $ procedure to store the inputs and set up defaults. proc checkin $ some useful default sizes nbpass = 30; $ set up default imaging parameters for the observing band if (obsband='p') then cellsize = 0.0050; imsize=512; bmaj=0; bmin=0; bpa=0; ncc=300; flux=0; shift=0; end if (obsband='l') then cellsize = 0.0010; imsize=512; bmaj=0; bmin=0; bpa=0; ncc=300; flux=0; shift=0; end if (obsband='c') then cellsize = 0.0004; imsize=512; bmaj=0; bmin=0; bpa=0; ncc=300; flux=0; shift=0; end if (obsband='x') then cellsize = 0.0002; imsize=512; bmaj=0; bmin=0; bpa=0; ncc=300; flux=0; shift=0; end if (obsband='k') then cellsize = 0.00008; imsize=1024; bmaj=0; bmin=0; bpa=0; ncc=300; flux=0; shift=0; end patchmin=imsize(1)/2; $ HImai Oct 10 2002: for spectral lines if (nchan > 64) then doavr=1; else doavr=0; end $ filein=infile; infile=''; nfiles=0; antref=refant; refant=0; ant2ref=refan2; uv2disk=in2disk; in2disk=0; $ allmask permanently stores the tmask input by the user. allmask=tmask; $ min number of selfcal iterations=0 $ if (sciter < 2) then $ sciter = 2; $ end $ where to send printouts to dir = dir!!'/' dir2 = dir2!!'/' pr2file=0 if (doprint=-2) then filout = dir2!!expname pr2file = 1 doprint=-1 end $ external files antabext='.antab flagext='.uvflg chflag='.chflag chflag=expname!!chflag $ what polarizations are in the data set (D=dual, LL=LCP only, RR=RCP only) if (pols='') then pols='D' end if (pols='D') then npols=2 lpol=1 rpol=1 end if (pols='LL') then npols=1 lpol=1 rpol=0 end if (pols='RR') then npols=1 lpol=0 rpol=1 end if (intape=0) then; intape=1; end; tapeuse=intape; pounds='##################################################' excl='!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' rr='rr'; ll='ll'; uvnam=expname; uvclass='uvdata'; uvseq=1; uvdisk=indisk; $typ 'allmask ='allmask typ 'tmask ='tmask $ form an array of sources which are to be self-calibrated, and don't form $ part of a phase-ref pair nsc=0; if (npairs > 0) then for (i=1 to nsrc) match = 0; for (j=1 to npairs*2) if (srclst(i) = preflst(j) ) then match = 1 end end if (match < 1) then nsc=nsc+1 scallst(nsc) = srclst(i); end end end type 'preflst=' for (i=1 to npairs*2) typ preflst(i) end type 'scallst=' for (i=1 to nsc) typ scallst(i) end if (nfits < 1) then nfits = 1 end $ $ Declare versions $ $ orver = version tver = 'OLD'; aver = 'NEW'; ret; fin $------------------------------------------------------------------ $ Frequently used procedures proc prpound; typ pounds; ret; fin proc prexcl; typ excl; ret; fin proc startof(tsknam) prpound; typ '# begin ', tsknam; prpound; ret; fin proc endof(tsknam) prpound; typ '# ',tsknam, 'successfully completed'; prpound; ret; fin proc mess(text) prexcl; typ text, ; prexcl; ret; fin proc runcl (tname, disk, tclass, t1, t2, t3, tintp, tcutof, src1, src2) $ disk = disk #, tclass = file class; $ t1 = SN to use; t2 = CL to update, new CL = t3 $ tintp = interpolation method $ tcutof = time cutoff for interpolation $ src1 is the calibrator source $ src2 is the target source $ N.B: Always set tcutof = 0. It behaves in some bizarre way that results in $ good solutions being ignored. $ startof('clcal'); version = tver; task 'clcal'; indisk=disk; innam=tname; inclass=tclass; inseq=uvseq; source=src2,src1; soucode=' '; calsour=src1,' '; qual -1; calcode ' '; timer 0; suba 1; anten 0; selband -1; selfreq -1; freqid -1; opcode='cali'; interpol=tintp; intparm 0; doblank 0; cutoff=tcutof; smotype ' '; refant=antref; snver=t1; gainver=t2; gainuse=t3; baddisk 0; go; endof('clcal') ret; fin proc runnx (tname, disk, tclass) $ disk = disk #, tclass = file class $ startof('indxr'); version = tver; task 'indxr' indisk=disk; innam=tname; inclass=tclass; inseq=uvseq; infile ' '; cparm 0, 22, 0.067; in2file ''; bparm 0; in2file ''; go; endof('indxr') ret; fin proc coptb (tname, tclass, oname, tclass1, i, j, table, k1, k2) $ tclass = i/p file class; tclass1 = o/p file class; $ i, j = i/p & o/p disks; table = type of table; $ k1, k2 = inver, outver $ startof('tacop'); version = tver; task 'tacop'; indisk=i; innam=tname; inclass=tclass; inseq=uvseq; outdisk=j; outnam=oname; outcl=tclass1; outseq=inseq; keyword ''; keyval 0; keystr ''; inext=table; inver=k1; outver=k2; ncount=1; go; endof('tacop') ret; fin proc tbfind (tabtyp, nplots) nplots = 0 for incey = 1 to 20 $ do some pointless concatenation to get round strange '!!' bug that occurs $ when checking whether to delete cl table 4 before doing the sensitivity plot. $ Don't understand what the bug is, but must be something to do with a limit on $ the number of !!s you can do? if (incey<2) then ropey = 'ropey='!!'ropey' end keyword = 'extype'!!char(incey); geth; extype = substr(keystrng,1,2) if (extype = tabtyp) then keyword = 'extver'!!char(incey); geth; nplots = keyval(1) end keyword=' '; keyval=0; keystr=' ' end ret; fin proc doplot(itab, jtab, filename) dparm 0; outfile=filename; lpen 1; aspmm 0; functype ' '; copies 1; userid 0; invers 0; dparm(6) 4; dparm(8)=10; plver=itab; inver=jtab; dodark 1; ofmfile ''; docolor 0; plcolors 0; $ use 31DEC03 for lwpla, because better string printing version = aver; if (doprint = -1) then; go lwpla; end if (doprint = 1) then; go tkpl; end $ for plver = itab to jtab; $ if (doprint = -1) then; go lwpla; end $ if (doprint = 1) then; go tkpl; end $ end ret; fin proc doextd (tabtyp, itab, jtab) inext = tabtyp; for invers = itab to jtab; extd; end; ret; fin proc domult (disk, tclass, sauce) $ disk = disk #, tclass = input file class $ sauce = source name $ tcout = output file class startof ('multi'); version=tver; task 'multi' indisk=disk; innam=sauce; inclass=tclass; inseq=uvseq outd=disk; outnam=' '; outcl=' '; outseq=uvseq; source = ''; source(1)=sauce; aparm = 0.067,0; go; endof('multi'); ret; fin proc exist (disk, tname, tclass, tseq, texist) $ disk,tname,tclass,tseq = disk, name, class, seq. no. userid=0; inname=tname; inclass=tclass; inseq=tseq; intype=' '; indisk=disk; chkname; if (error=0) then texist=true else texist=false end; ret; fin proc dozap (disk, tname, tclass, tseq, ttype) $ delete a file if it exists $ disk,tname,tclass,tseq = disk, name, class, seq. no. $ type = 'UV' or 'MA' exist (disk, tname, tclass, tseq, texist); if (texist) then userid=0; inname=tname; inclass=tclass; inseq=tseq; indisk=disk; intype=ttype; clrstat; zap; recat; type 'Deleted ', tname, '.', tclass, '.', tseq end; ret; fin proc dosnp (disk, tname, tclass, tseq, tabtyp, k1, tmpl, ttype, firstif, lastif) $ run SNPLT $ disk,tname,tclass,tseq = disk, name, class, seq. no. $ tabtyp = table type, k1 = version # $ tmpl = optype $ ttype = stokes $ whichif = which IF to plot (can't plot all at once because of bug in SNPLT $ which causes IF 2 solutions to not be plotted if there are no $ solutions for IF 1. NOTE this was fixed by November 2003) startof ('snplt'); version = tver; task 'snplt' indisk=disk; innam=tname; inclass=tclass; inseq=tseq; inext=tabtyp; inver=k1; source ' '; qual -1; timer 0; stokes=ttype; selband -1; selfreq -1; freqid 1; bif=firstif; eif=lastif; antennas 0; pixr 0; nplots 10; xinc 1; optyp=tmpl; opcode ''; bcount 1; xaxis 0; factor=0.5; doebar -1; cutoff 1e-6; ltype 3; dotv -1; grchan 1; go; endof('snplt'); ret; fin proc dofr (disk,tname,tclass,tseq,i,j,k,k1,k2,ii,jj,nn) $ run FRING $ disk,tname,tclass,tseq = disk, name, class, seq. no. $ i,j = start and stop channel numbers $ k = CL table version to apply $ k1 = FG table version to apply $ k2 = Sn table to write $ ii = solint $ jj = doband $ nn = bpver $ *** Note, user sets calsour,dparm & aparm before calling proc **** startof('fring'); version = tver; task 'fring'; indisk=disk; innam=tname; inclass=tclass; inseq=tseq; qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; timer 0; bchan=i; echan=j; anten 0; dofit 0; suba 1; $ careful using docal=2. Can't work out how AIPS uses the weights. uvrange 0; wtuv 0; docal 1; gainuse k; flagver k1; doband -1; bpver 0; smooth 0; clr2n; ncomp 0; nmaps 0; smodel 0; clron; refant=antref; search ant2ref; solint=ii; snver k2; antwt 1; baddisk 0; go; endof('fring'); ret; fin $ HImai Oct 10 2002: for spectral lines proc doavspc (disk, tname, tclass, tseq, disk2, oname, i, j, k) $ average spectral channels into 16 channels $ disk = i/p disk, tname, tclass, tseq = input uv file $ disk2 = o/p disk, oname = output name $ i,j = start, stop channels $ k = Flag table version startof('avspc'); version = tver; task 'avspc'; indisk=disk; innam=tname; inclass=tclass; inseq=tseq; outdisk=disk2; innam=tname; outclass='avspc'; outseq=1; ichansel i,j,1;avoption 'subs';bif=1;eif=0;flagver=k; channel=j/16 go; endof('avspc'); ret; fin proc domx (polty, disk, tname,tclass,tseq, disk2,oname,oseq, i, j, k, l, wtfn) $ generate image using imagr $ note: cellsize etc. are set in proc checkin $ polty = polzn to map ('R','L','I','Q','U','V') $ disk = i/p disk, tname, tclass, tseq = input uv file $ disk2 = o/p disk, oname = output name, oseq = output sequence $ i,j = start, stop channels $ k = CL table to use $ l = niter $ wtfn=uvwtfn startof ('imagr'); version=tver; task 'imagr' indisk=disk; innam=tname; inclass=tclass; inseq=tseq; source=tname,''; qual -1; calcode ''; timer 0; selband -1; selfreq -1; freqid 1; subarray 1; docal 2; gainuse k; dopol -1; blver -1; flagver 0; doband -1; bpver -1; smooth 0; stokes = polty; bchan = i; echan = j; channel=0; nchav = 1; chinc 1; bif 1; eif 0; outnam=oname; outd = disk2; outseq = oseq; outver 0; clr2n; nfield 1; do3dimag 0; fldsize 0; rashift 0; decshift 0; uvtaper 0; uvrange 0; guard 0; rotate 0; zerosp 0; uvwtfn = wtfn; uvsize 0; robust=0; uvbox 0; uvbxfn 1; xtype 5; ytype 5; xparm 0; yparm 0; niter=l; bcomp 0; allokay=0; nbox 0; clbox 0; boxfile ''; oboxfile ''; gain 0.05; minpatch=patchmin; overlap 0; phat 0; factor 0; cmethod ' '; imagrprm=0; imagrprm(8) ~ -0.1e-4, 1; ngauss 0; wgauss 0; fgauss 0; maxpixel 0; dotv -1; baddisk 0; go; endof('imagr') ret; fin proc selfcal(sauce, tseq, tclass, disk, iscal, j, k, l, m, soln, snr, tsol) $self-calibrate the split data $ set in2nam, in2d etc. before calling routine $sauce is the source name $iscal = value for docal $j = CL table to calibrate with $k = flagver to use $l = number of clean components to use $m = flux density of smodel $soln = type of solution $ snr = min SNR for good solutions $ tsol = solution interval $ $ min no. of antennas is 3 for phase only selfcal, 4 for A&P. if (soln='P') then nbl=3 else nbl=4 end startof ('calib'); version=tver; task 'calib' indisk=disk; innam=sauce; inseq=tseq; inclass=tclass; calsour=sauce,''; qual -1; calcode ''; selband -1; selfreq -1; freqid -1; timer 0; bchan 1; echan 0; antenn 0; dofit 0; antuse=antref,0; subarr 1; uvrange 0; wtuv 0; docal=iscal; gainuse=j; flagver = k; doband -1; bpver -1; smooth 0; inver 0; ncomp=l,0; flux 0; nmaps 0; cmethod ' '; cmodel ' '; smodel=0; smodel(1) = m; outn ' '; outc ' '; outseq 0; outd uv2disk; refant=antref; solint tsol; aparm 0; aparm(1)= nbl; aparm(6)=3; aparm(7)=snr; soltyp 'L1'; solmod=soln; $ 4Dec03: cparm(2)=0, because renormalisation too sensitive to outliers minamper=10; minphser=20; cparm 0; cparm(1)=10; cparm(2)=0; cparm(3)=10; cparm(4)=20; snver 0; antwt 0; gainerr 0; baddisk 0; go; endof('calib') ret; fin proc getstats(disk, tname, tclass, tseq, t1, t2) $ t1 = blc, t2=trc startof('imstat'); version =tver; task 'imstat'; innam=tname; inclass=tclass; inseq=tseq; indi=disk; blc=t1; trc=t2; doinvers -1; imstat; endof('imstat') ret; fin proc plotmap (disk, tname, tclass, tseq, disk2, t1, t2) $ t1=rms flux in map $ t2=peak flux in map if (t1/t2 > 0.4) then t1 = t2*0.2 end startof('kntr'); version=tver; task 'kntr'; docont 1; dogrey 0; dovect 0; innam=tname; inclass=tclass; inseq=tseq; indi=disk; clr2n; clr3n; clr4n; blc=0; trc=0; zinc 1; ny 0; xyratio=0; pixrange 0; functype ''; ofmfile ''; docolor 0; ltype=4; doalign 1; doblank=-1; docirc=-1; factor 0; rotate 0; xinc 1; yinc 1; pcut 0; icut 0; doblank 0; dowedge 0; docircle -1; invers 0; ctype 0; stfactor 0; cbplot 1; label 0; dotv -1; tvchan 1; grchan 1; dodark 0; darkline 0; tvcorn 0; plev 0; clev= peakflux; levs 0; levs(1)=0-t1/t2; levs(2)=t1/t2; for i=3 to 15; levs(i)=levs(i-1)*2;end; for i=3 to 15; if (levs(i)>1) then levs(i)=0; end end go; endof('kntr') ret; fin proc runfittp (disk, tname, tclass, tseq, filename) startof ('fittp') version=tver; task 'fittp'; innam=tname; inclass=tclass; inseq=tseq; indi=disk; doall=-1; intype ''; outtape 1; outfile=filename; doeot 1; dostokes -1; donewtab 1; format 0; blocking 10; go; endof ('fittp') ret; fin proc antname (rownum); $ Returns the antenna name for a given antenna number. inext = 'an' pixxy = rownum, 1, 1; tabget; an_name = substr(keystrng,1,2) return an_name; finish proc goodif(incif) string*2 thisif scalar isgood, incif isgood = 1; for j = 1 to nif*npols thisif = substr (stokes,1,1); thisif = thisif!!char(incif); if (thisif = badif(j)) then isgood = 0; end end return isgood; finish $ $--------------------------------------------------------------------- $ Begin proc EVN_PRECAL $ $ Check inputs $ checkin; $ $ $---------------- # 1, load and sort the data -------------------------------- $ $ read the tape using FITLD $ if (allmask=0) then tmask=1; end if (allmask<0) then if (allmask > -1.5) then tmask=1; end end imask=1; if (tmask=imask) then startof('fitld'); version = tver; task 'fitld' outdisk=uvdisk; outnam=uvnam; outcl=uvclass; outseq=uvseq intape=tapeuse; nfiles 0; inbase=fitsfile; typ 'nheads= ',nheads if (nheads=2) then typ 'nheads= ',nheads typ 'fitsfile=',fitsfile inbase=fitsfile!!'_1.IDI' ; typ 'infile=',infile outnam=uvnam!!'_1'; end ncount 999; douvc 0; optype ' '; dotable 1; doconcat 1; source ' '; qual -1; calcode ' '; timer 0; bchan 0; echan 0; clint = 0.0333; bif 1; eif 0; digicor 0; delcorr 0; selband -1; selfreq -1; fqtol -1; wtth 0.2; opcode ' '; for i=1 to nfits infile=inbase!!char(i); typ 'INFILE= ',infile go; endof('fitld') end version = tver; if (nheads = 2) then if (fitsfile <> '') then inbase = fitsfile!!'_2.IDI' end startof('fitld'); version = tver; task 'fitld' outdisk=uvdisk; outnam=uvnam!!'_2'; outcl=uvclass; outseq=uvseq intape=tapeuse; nfiles 0; ncount 999; douvc 0; optype ' '; dotable 1; doconcat 1; source ' '; qual -1; calcode ' '; timer 0; bchan 0; echan 0; clint = 0.0333; bif 1; eif 0; digicor 0; delcorr 0; selband -1; selfreq -1; fqtol -1; wtth 0.2; opcode ' '; for i=1 to nfits infile=inbase!!char(i); typ 'INFILE= ',infile go; endof('fitld') end end if (fitsfile = '') then dism; end version = tver startof('msort'); version=tver; task 'msort' innam=uvnam; indisk=uvdisk; inclass=uvclass; inseq=uvseq; if (nheads=2) then innam = innam!!'_1' end clron; outd=uv2disk; sort ' '; prtlev 1; go; endof('msort') if (nheads=2) then version = tver startof('msort'); version=tver; task 'msort' innam=uvnam!!'_2'; indisk=uvdisk; inclass=uvclass; inseq=uvseq; clron; outd=uv2disk; sort ' '; prtlev 1; go; endof('msort') uvclass='msort' runnx(uvnam!!'_1', uvdisk, uvclass) runnx(uvnam!!'_2', uvdisk, uvclass) startof('vbglu'); version = tver; task 'vbglu'; inname=uvnam!!'_1'; inclass=uvclass; inseq=uvseq; indisk=uvdisk; in2nam=uvnam!!'_2'; in2class=uvclass; in2seq=uvseq; in2disk=uvdisk; clr3n; clr4n; outn=uvnam; outd=uvdisk; go; endof('vbglu') end $ Average data if required. uvclass='msort' if (nheads=2) then uvclass = 'vbglu' end if (avg > 0.001) then version = tver startof('uvavg'); version=tver; task 'uvavg' inname=uvnam; inclass=uvclass; inseq=uvseq; indisk=uvdisk; outd=uv2disk; xinc=1; yinc=avg; zinc=oint; opcod ''; optyp ''; go; endof('uvavg') oint = avg; uvclass = 'uvavg' end end uvclass='msort' if (nheads=2) then uvclass = 'vbglu' end if (avg>0.001) then uvclass = 'uvavg' end clrstat $ $---------------- # 2, A priori data flagging and Indxr --------------------- $ if (allmask=0) then tmask=2 end if (allmask<0) then if (allmask > -2.5) then tmask=2; end end imask=2; if (tmask=imask) then $delete any old flag tables inname = uvnam; inclass = uvclass; inseq = uvseq; indisk=uvdisk tbfind ('FG', ii); if (ii >= 1) doextd ('FG', 1, ii); $ startof ('uvflg'); version = tver; task 'uvflg' inname = uvnam; inclass = uvclass; inseq = uvseq; indisk=uvdisk infile=dir!!expname!!flagext; source ' '; subarr 1; selband -1; selfreq -1; freqid -1; timerang 0; bchan 1; echan 0; bif 1; eif 0; antenn 0; baseline 0; stokes ' '; flagver 0; aparm 0; opcod 'flag'; reason ''; bdrop 0; edrop 0; dohist 0; go; endof ('uvflg') $ $ delete the outermost channels because of the bad bandpass $ if (delch = 1) then startof ('uvflg'); version = tver; task 'uvflg' inname = uvnam; inclass = uvclass; inseq = uvseq; indisk=uvdisk infile=dir!!chflag; source ' '; subarr 1; selband -1; selfreq -1; freqid -1; timerang 0; bchan 1; echan 0; bif 1; eif 0; antenn 0; baseline 0; stokes ' '; flagver 0; aparm 0; opcod 'flag'; reason ' '; bdrop 0; edrop 0; dohist 0; go; endof ('uvflg') end $ runnx(uvnam, uvdisk, uvclass) end $ $---------------- # 3, check the data ------------------------------- $ $ check the data using LISTR, DTSUM, VPLOT and POSSM $ $ set the printer to the one in the JIVE visitors room printer 2 if (allmask=0) then tmask=3; end if (allmask<0) then if (allmask > -3.5) then tmask=3; end end imask=3; if (tmask=imask) then $ scan list if (doprint <> 0) then outprint='' startof('listr'); version = tver; task 'listr' if (pr2file=1) then outprint=filout!!'.scan' end indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; optyp 'scan'; docrt=doprint; go; endof('listr') $ $ list of stations and number of vis. outprint='' startof('dtsum'); version = tver; task 'dtsum' if (pr2file=1) then outprint=filout!!'.dtsum' end indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; aparm 1,0; docrt=doprint; go; endof('dtsum') outprint='' end $ $ possm plot of the auto-correlations $ if (doprint <> 0) then tsol = 22; if (nsrc > 1) then; tsol = -1; end tbfind ('PL', ii); stokes = pols if (pols = 'D') then stokes = 'HALF' end startof('possm'); version = aver; task 'possm' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; for j=1 to nsrc; source(j)=srclst(j); end selfreq -1; freqid 1; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=0; baseline 0; docalib 0; gainuse 3;dopol -1; flagver 0; doband -1; bpver 0; smooth 0; shift 0; aparm=0; aparm(2)=1; aparm(3)=0; aparm(4)=0; aparm(5)=-180; aparm(6)=180;aparm(7) 1;aparm(8) 1; aparm(9)=1; codetype 'A&P'; polplot ' '; solint=tsol; nplots 9; bparm 0; outfile= ' '; ltype 3; baddisk 0; dotv -1; grchan 1; go; stokes '' endof('possm') $ tbfind('PL', jj); if (jj > ii) then doplot(ii+1, jj, filout!!'_possm_autocorr.ps') doextd ('PL', ii+1, jj) end end $ $ plot uncalibrated amplitudes and phases $ if (doprint <> 0) then tbfind ('PL', ii); for i=1 to npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end for incif=1 to nif doif = goodif(incif); if (doif = 1) then startof('vplot'); version = tver; task 'vplot'; indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; clr2n; ncomp 0; nmaps 0; source ' '; for j=1 to nsrc; source(j)=srclst(j); end qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=plotref,0; baseline 0; docal -1; gainuse 0; dopol -1; blver -1; flagver 0; doband -1; bpver 0; smooth 0; suba 1; doebar -1; solint=plotavg ; optype ' '; aparm 0; bparm 0; bparm(2)=-1; bparm(3)=1; bparm(8)=-180; bparm(9)=180; alias 0; nplots 4; doarray 0; polplot ' '; symbol 0; ltype 3; dotv -1; grchan 1; go; endof('vplot'); end end $ end $ tbfind ('PL', jj); if (jj > ii) then doplot(ii+1,jj, filout!!'_vplot_uncal.ps'); doextd('PL', ii+1, jj); end; end $ $ possm plot of the uncalibrated data (cross-correlations) $ $ scan break for multi-source files, otherwise use predefined timeranges. typ 'NSRC='nsrc if (doprint <> 0) then tsol = 11; if (nsrc > 1) then; tsol = -1; end tbfind ('PL', ii); stokes = pols if (pols = 'D') then stokes = 'HALF' end startof('possm'); version = aver; task 'possm' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; for j=1 to nsrc; source(j)=srclst(j); end selfreq -1; freqid 1; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=plotref,0; baseline 0; docalib 0; gainuse 3;dopol -1; flagver 0; doband -1; bpver 0; smooth 0; shift 0; aparm=0; aparm(2)=1; aparm(3)=0; aparm(4)=0; aparm(5)=-180; aparm(6)=180; aparm(9)=1; codetype 'A&P'; polplot ' '; solint=tsol; nplots 9; bparm 0; outfile= ' '; ltype 3; baddisk 0; dotv -1; grchan 1; go; stokes '' endof('possm') $ tbfind('PL', jj); if (jj > ii) then doplot(ii+1, jj, filout!!'_possm_uncal.ps') doextd ('PL', ii+1, jj) end end version = tver $ $ plot the cross-hands if (cpols = 1 & doprint <> 0) then startof('possm'); version = aver; task 'possm' stokes = 'LR'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; for j=1 to nsrc; source(j)=srclst(j); end selfreq -1; freqid 1; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=plotref,0; baseline 0; docalib 0; gainuse 3;dopol -1; flagver 0; doband -1; bpver 0; smooth 0; shift 0; aparm=0; aparm(2)=1; aparm(3)=0; aparm(4)=0; aparm(5)=-180; aparm(6)=180; aparm(9)=1; codetype 'A&P'; polplot ' '; solint=tsol; nplots 9; bparm 0; outfile= ' '; ltype 3; baddisk 0; dotv -1; grchan 1; go; stokes '' endof('possm') end tbfind('PL', jj); if (jj > ii) then doplot(ii+1, jj, filout!!'_possm_cpol.ps') doextd ('PL', ii+1, jj) end version = tver $ end $ $ $ $ $---------------- # 4, amplitude calibration and PA correction ------------- $ $ amplitude calibration $ $ $ load tsys data using ANTAB $ $ clrtemp if (allmask=0) then tmask=4; end if (allmask<0) then if (allmask > -4.5) then tmask=4; end end imask=4; if (tmask=imask) then $ delete pre-existing tables indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; tbfind ('TY', ii); if (ii > 0) doextd ('TY', 1, ii); tbfind ('GC', ii); if (ii > 0) doextd ('GC', 1, ii); tbfind ('SN', ii); if (ii > 0) doextd ('SN', 1, ii); tbfind ('CL', ii); if (ii >= 2) doextd ('CL', 2, ii); $ startof('antab'); version = tver; task 'antab' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; infile=dir!!expname!!antabext suba 0; tyver 1; gcver 1; blver -1; sparm ' '; prtlev 0; offset=0.3; go; endof('antab') if (global = 1) then startof ('vlog'); version = tver; task = 'vlog' indisk = uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; infile=dir!!expname!!'.vlbacal outfile = dir!!expname!!'.vlba fqtol = 100; prtlev = 1; go; endof('vlog'); $ clrstat seems necessary after vlog clrstat; $ also try to work out which VLBA antennas should be excluded from the $ ANTAB. nvlba=10; vlba_ants = 'BR','FD','HN','KP','LA','MK','NL','OV','PT','SC' nsparm = 0; $ find the number of rows in the antenna table inext= 'an'; inver =1 ; keyword = 'num row'; getthead; nant = keyvalue(1) indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; for i=1 to nvlba gotant = 0 iant = vlba_ants(i); for j=1 to nant jant = antname (j); if (iant = jant) then gotant = 1 end end if (gotant = 0) then nsparm = nsparm+1; sparm(nsparm) = vlba_ants(i); end end startof('antab'); version = tver; task 'antab'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; infile=dir!!expname!!'.vlba.TSYS suba 0; tyver 1; gcver 1; blver -1; prtlev 0; $ sparm is set above offset=0.3; go; endof('antab') end $ if (doprint <> 0) then tbfind ('PL', ii); $if (rpol=1) then $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'R', 1, 0) $end $if (lpol=1) then $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'L', 1, 0) $end dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', '', 1, 0) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_tsys.ps') doextd ('PL', ii+1, jj) end end $ tbfind('PL', ii); startof('apcal'); version = tver; task 'apcal'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; anten 0; suba 1; stokes ' '; bif=1; eif=0; freqid 1; source ' '; timer 0; tyver 1; gcver 1; snver 1; opcode ' '; aparm 0; solint 0; infile ''; invers 0; trec 0; tau0 0; dofit 0; prtlev 1; dotv -1; ltype 3; go; endof('apcal') version=tver $ $ plot SN file $ $ tbfind ('PL', ii); $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'SN', 1, 'AMP', 'R') $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'SN', 1, 'AMP', 'L') $$ $ tbfind ('PL',jj) $ if (jj > ii) then $ doplot (ii+1, jj) $ doextd ('PL', ii+1, jj) $ end $ $ apply amplitude calibration, cl1 + sn1 = cl2 $ $ run in dec02 version to take advantage of doblank option $ also, use 'box' etc. to make this work. startof('clcal'); version = aver; task 'clcal'; innam=uvnam; inclass=uvclass; inseq=uvseq; indisk=disk; source=' '; soucode=' '; calsour=' '; qual -1; calcode ' '; timer 0; suba 1; anten 0; selband -1; selfreq -1; freqid -1; opcode='cali'; interpol='box'; intparm 0.00001; doblank=1; cutoff=0; smotype ' '; refant=antref; snver=1; gainver=1; gainuse=2; baddisk 0; go; endof('clcal') $ $ plot the cl table $ if (doprint <> 0) then tbfind ('PL', ii); $if (rpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','L',incif,incif) $ end $end dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','',1,0) $ tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_gain.ps') doextd ('PL', ii+1, jj) end end $ Do the parallactic angle correction. startof('clcor'); version = tver; task 'clcor'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; stokes ' '; selband -1; selfreq -1; freqid -1; bif 1; eif 0; timerang 0; antennas 0; subarray 0; gainver 2; opcod 'pang'; clcorprm=1,0; baddisk 0; go; endof('clcor') version = tver end $ $---------------- # 5, fringe fitting ----------------------------- $ $ fringe-fit $ $ $ if (allmask=0) then tmask=5; end if (allmask<0) then if (allmask > -5.5) then tmask=5; end end imask=5; if (tmask=imask) then $ $ delete pre-existing tables $ indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; tbfind ('SN', ii); if (ii > 1) doextd ('SN', 2, ii); tbfind ('CL', ii); if (ii >= 3) doextd ('CL', 3, ii); $ typ 'NSRC='nsrc for i=1 to nsrc; calsour(i) = calsrclst(i); end; $ HImai Oct 10 2002: for spectral lines $ Pre-averaging spectral channles if (doavr = 1) then dozap (uv2disk, uvnam, 'avspc', 1, 'uv'); doavspc (uv2disk, uvnam, uvclass, uvseq, uv2disk, oname, 1, nchan, 1); end $ run fring aparm=0; aparm(1)=4; aparm(5)=0; aparm(6)=1; aparm(7)=11; aparm(9)=1; dparm=0; dparm(1)=2; dparm(4)=oint $ HImai Oct 10 2002: for spectral lines if (doavr = 1) then $dofr (uv2disk,uvnam,'avspc',uvseq,1,0,2,0,2,solcal,0,0); dofr (uv2disk,uvnam,'avspc',uvseq,1,0,2,-1,2,solcal,0,0); coptb (uvnam, 'avspc', uvnam, uvclass, uv2disk, uv2disk, 'SN', 2, 2) else dofr (uv2disk,uvnam,uvclass,uvseq,1,0,2,0,2,solcal,0,0); end $ $ apply fringe-fit solutions: cl2 + sn2 = cl3 $ use cutoff=0, because of strange way that CLCAL uses cutoff to determine $ whether interpolation should be done or not in multisource files (possibly a $ bug). $ typ 'SOLCAL='solcal; if (npairs=0) then runcl (uvnam, uv2disk, uvclass, 2, 2, 3, 'ambg', 0, '', ''); else for (i=1 to npairs) ii = i*2 - 1; src1 = preflst(ii); src2 = preflst(ii+1); typ 'Calibrating ', src2, 'with ', src1 runcl (uvnam, uv2disk, uvclass, 2, 2, 3, 'ambg', 0, src1,src2); end for (i=1 to nsc) src1 = scallst(i); typ 'Self-calibrating ',i, src1 runcl (uvnam, uv2disk, uvclass, 2, 2, 3, 'ambg', 0, src1,src1); end end end $ $---------------- # 6, Bandpass Calibration ----------------------- $ clrtemp if (allmask=0) then tmask=6; end if (allmask<0) then if (allmask > -6.5) then tmask=6; end end imask=6; if (tmask=imask) then $ $ delete pre-existing tables $ indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; tbfind ('BP', ii); if (ii > 1) doextd ('BP', 1, ii); $ startof('bpass'); version=tver; task 'bpass'; $typ 'NPBASS=',nbpass for i=1 to nbpass; calsour(i) = bpasslst(i); end; indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; qual=-1; calcode ''; uvrang 0; timerang 0; selband=-1; selfreq=-1; freqid 1; bif 1; eif 0; subarray 1; anten 0; clr2n; ncomp 0; flux 0; nmaps 0; cmethod ''; smodel 0; docal 2; gainuse 3; dopol=-1; flagver 0; solint=-1; refant=antref; bpver 0; smooth=1,0; antwt=0; minamper 0; minphser 0; bpassprm=0; ichansel 0; specindx 0; clr3n; baddisk 0; go; endof('bpass'); $ $ plot the bandpass $ if (doprint <> 0) then tbfind ('PL', ii); stokes = pols if (pols = 'D') then stokes = 'HALF' end startof('possm'); version = aver; task 'possm' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=0; baseline 0; docalib 2; gainuse 3;dopol -1; flagver 0; doband -1; bpver 0; smooth 0; shift 0; aparm=0; aparm(2)=1; aparm(3)=0; aparm(4)=1.3; aparm(5)=0; aparm(6)=0; aparm(8)=2; aparm(9)=1; codetype 'A&P'; polplot ' '; solint 0; nplots 9; bparm 0; outfile ' '; ltype 3; baddisk 0; dotv -1; grchan 1; go; stokes '' endof('possm') $ tbfind('PL', jj); if (jj > ii) then doplot(ii+1, jj, filout!!'_bandpass.ps') doextd ('PL', ii+1, jj) end end $ end $ $---------------- # 6, interactive editing ------------------------ $ $ $ if (allmask=0) then $ tmask=6; $ end $ if (allmask<0) then $ if (allmask > -6.5) then $ tmask=6; $ end $ end $ imask=6; if (tmask=imask) then $ if (doedit=2) then $ startof('ibled'); version=tver; task 'ibled'; $ innam=uvnam; inclass=uvclass; inseq=uvseq; docat 1; clr2n; $ dohist=-1; source ''; calcode ''; clr3n; nmaps 0; ncomp 0; $ flux 0; timer 0; stokes ''; selband=-1; selfreq=-1; freqid 1; $ bif 1; eif 0; bchan 1; echan 0; antenn 0; basel 0; uvrange 0; $ docal 0; gainuse 0; blver -1; flagver 0; doband -1; bpver 0; $ smooth 0; dparm 0; baddisk 0; $ go; endof('ibled'); $ end $ end $ $---------------- # 7, Plot the results after fringe fitting -------- $ indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; if (allmask=0) then tmask=7; end if (allmask<0) then if (allmask > -7.5) then tmask=7; end end imask=7; if (tmask=imask) then $ $ plot the delay, rate and phase solutions from fring $ if (doprint <> 0) then tbfind ('PL', ii); $if (rpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',3,'PHAS','R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',3,'PHAS','L',incif,incif) $ end $end dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',3,'PHAS','',1,0) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_fring_phas'!!'.ps') doextd ('PL', ii+1, jj) end tbfind ('PL', ii); $if (rpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'DELA','R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'DELA','L',incif,incif) $ end $end dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'DELA','',1,0) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_fring_delay'!!'.ps') doextd ('PL', ii+1, jj) end tbfind ('PL', ii); $if (rpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'RATE','R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'RATE','L',incif,incif) $ end $end dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'RATE','',1,0) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_fring_rate'!!'.ps') doextd ('PL', ii+1, jj) end end $ $ possm plot of the calibrated data $ $ scan break for multi-source files, otherwise use predefined timeranges. typ 'NSRC='nsrc if (doprint <> 0) then tsol = 44; if (nsrc > 1) then; tsol = -1; end; tbfind ('PL', ii); stokes = pols if (pols = 'D') then stokes = 'HALF' end startof('possm'); version = aver; task 'possm' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; for j=1 to nsrc; source(j)=srclst(j); end selfreq -1; freqid 1; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=plotref,0; baseline 0; docalib 2; gainuse 3;dopol -1; flagver 0; doband 1; bpver 0; smooth 0; shift 0; aparm=0; aparm(2)=1; aparm(3)=0; aparm(4)=0; aparm(5)=0; aparm(6)=0; $aparm(5)=-180; aparm(6)=180; aparm(9)=1; codetype 'A&P'; polplot ' '; solint=tsol; nplots 9; bparm 0; outfile ' '; ltype 3; baddisk 0; dotv -1; grchan 1; go; stokes '' endof('possm') $ tbfind('PL', jj); if (jj > ii) then doplot(ii+1, jj, filout!!'_possm_cal.ps') doextd ('PL', ii+1, jj) end end $ $ plot the pre-calibrated visibilites against time $ if (doprint <> 0) then tbfind ('PL', ii); for i=1 to npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end for incif=1 to nif doif = goodif(incif); if (doif=1) then startof('vplot'); version = tver; task 'vplot'; indisk=uvdisk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; clr2n; ncomp 0; nmaps 0; source ' '; qual -1; for j=1 to nsrc; source(j)=srclst(j); end calcode ' '; selband -1; selfreq -1; freqid 1; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=plotref,0; baseline 0; docal 2; gainuse 3; dopol -1; blver -1; flagver 0; doband 1; bpver 0; smooth 0; suba 1; doebar -1; solint=plotavg; optype ' '; aparm 0; bparm 0; bparm(2)=-1; bparm(3)=1; bparm(8)=-180; bparm(9)=180; alias 0; nplots 4; doarray 0; polplot ' '; symbol 0; ltype 3; dotv -1; grchan 1; go; endof('vplot'); end end $ end $ tbfind ('PL', jj); if (jj > ii) then doplot(ii+1,jj, filout!!'_vplot_cal.ps'); doextd('PL', ii+1, jj); end; end version = tver end $ $ $ $---------------- # 8, Split -------------- $ clrtemp if (allmask=0) then tmask=8; end if (allmask<0) then if (allmask > -8.5) then tmask=8; end end imask=8; if (tmask=imask) then startof('split'); version= tver; task 'split' source ' '; for j=1 to nsrc; source(j)=srclst(j); dozap (uv2disk, source(j), 'split', 1, 'uv'); end indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; outd=uv2disk; qual -1; calcode ' '; timer 0; stokes ' ' selband -1; selfreq -1; bif 1; eif 0; bchan 1; echan 0; suba 1; docal 2; gainuse 3; dopol -1; blver -1; flagv 0; doband 1; bpver 0; smooth 0; outcl=' '; outseq=uvseq; outdisk=uv2disk; douvc 1; aparm 2,0,0,1; chansel 0; baddisk 0; go; endof('split'); $ end $ $ $ return; finish $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ THE NEXT SECTION OF THIS RUN FILE IS LOOPED OVER EVERY SOURCE IN srclst $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ need to split the script into two procedures because of limits on procedure $ lengths - BAH! proc EVN_MAP $ $---------------- # 9, Produce a multi file and automatic flagging ------ $ $ $ transform to a multi file $ if (allmask=0) then tmask=9; end if (allmask<0) then if (allmask > -9.5) then tmask=9; end end imask=9; if (tmask=imask) then clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc clrtemp sauce=srclst(cntsrc);uvclass='split'; uvseq=1; $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end $ $ Do the automatic flagging with VPLOT. The auto-flagging is left until $ this stage because of the strange feature in VPLOT that limits SOLINT to less $ than approx. one hour for multi-source files. $ tbfind ('PL', ii); if (doedit=1) then for i=1 to npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end for incif=1 to nif doif = goodif(incif); if (doif = 1) then startof('vplot'); version = tver; task 'vplot'; indisk=uvdisk; innam=sauce; inclass=uvclass; inseq=uvseq; userid 0; clr2n; ncomp 0; nmaps 0; source ' '; qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=0; baseline 0; docal 0; gainuse 0; dopol -1; blver -1; flagver 0; doband -1; bpver 0; smooth 0; suba 1; doebar -1; solint=1000; optype ' '; aparm 0; aparm(1) 1; aparm(2) 1; bparm 0; bparm(2)=1; bparm(3)=1; bparm(8)=-180; bparm(9)=180; alias 0; nplots 4; doarray 0; polplot ' '; symbol 0; ltype 3; dotv -1; grchan 1; go; endof('vplot'); end end $ end end $ $ and run multi and indxr $ dozap (uvdisk, sauce, 'multi', 1, 'uv'); domult (uvdisk, uvclass, sauce) uvclass='multi'; uvseq=0; runnx(sauce, uvdisk, uvclass) end end uvclass='multi'; uvseq=0; $ $---------------- # 10, First round of imagr -------------- $ if (allmask=0) then tmask=10; end if (allmask<0) then if (allmask > -10.5) then tmask=10; end end imask=10; if (tmask=imask) then clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc $clrtemp sauce=srclst(cntsrc);uvclass='multi'; uvseq=1; $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end $ $ Make the dirty map with natural weighting $ dozap (uv2disk, sauce, 'iim001', 1, 'ma'); dozap (uv2disk, sauce, 'ibm001', 1, 'ma'); domx ('I', uv2disk, sauce,uvclass,uvseq, uv2disk,' ',1, 0, 0, 0, 0,'N') $ $ plot the dirty map $ getstats(uvdisk, sauce, 'iim001', 0, 0, 0) peakflux=pixval getstats(uvdisk, sauce, 'iim001', 0, 0, imsize(1)/4) rmsflux=pixstd*3 tbfind ('PL', ii); plotmap (uv2d, sauce, 'iim001', 0, uv2d, rmsflux, peakflux) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_IMAPN.ps') doextd ('PL', ii+1, jj) end $ save a fits version of the map too. runfittp (uv2d, sauce, 'iim001', 0, filout!!'_'!!sauce!!'_IMAPN.FITS') end $ $ make the dirty map with uniform weigthing $ clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc $clrtemp sauce=srclst(cntsrc);uvclass='multi'; uvseq=1; $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end dozap (uv2disk, sauce, 'iim001', 2, 'ma'); dozap (uv2disk, sauce, 'ibm001', 2, 'ma'); domx ('I', uv2disk,sauce,uvclass,uvseq, uv2disk, ' ', 2, 0, 0, 0, 0,'U') $ $ plot the dirty map $ getstats(uvdisk, sauce, 'iim001', 0, 0, 0) peakflux=pixval getstats(uvdisk, sauce, 'iim001', 0, 0, imsize(1)/4) rmsflux=pixstd*3 tbfind ('PL', ii); plotmap (uv2d, sauce, 'iim001', 0, uv2d, rmsflux, peakflux) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_IMAPU.ps') doextd ('PL', ii+1, jj) end runfittp (uv2d, sauce, 'iim001', 0, filout!!'_'!!sauce!!'_IMAPU.FITS') end $ $ $ $ first round of cleaning with imagr (always do) $ clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc $clrtemp sauce=srclst(cntsrc);uvclass='multi'; uvseq=1; $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end dozap (uv2disk, sauce, 'icl001', 3, 'ma'); dozap (uv2disk, sauce, 'ibm001', 3, 'ma'); domx ('I', uv2disk, sauce, uvclass, uvseq,uv2disk,'',3, 0, 0, 0,ncc,'N') $ end end $ $---------------- # 11, Continue mapping -------------- $ if (allmask=0) then tmask=11; end if (allmask<0) then if (allmask > -11.5) then tmask=11; end end imask=11; if (tmask=imask) then clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc clrtemp sauce=srclst(cntsrc);uvclass='multi'; uvseq=1; $ $ delete sn/cl tables from last run $ indisk=uv2disk; innam=sauce; inclass=uvclass; inseq=uvseq; tbfind ('SN', ii); if (ii >= 1) doextd ('SN', 1, ii); tbfind ('CL', ii); if (ii >= 2) doextd ('CL', 2, ii); $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end $ $ need to wrap "for" statement in an "if" block else the for statement is $ guaranteed to be executed at least once, even if inc<1. if (sciter+firstsrc > 0) then for inc = 1 to sciter+firstsrc; if (mod(inc,2)=1) then soln = 'P' plottyp = 'PHAS' end if (mod(inc,2)=0) then soln = 'A&P' plottyp = 'amp' end if (inc=1) then; tsol=2; snr=3; end if (inc=2) then; tsol=2; snr=5; end if (inc=3) then; tsol=0.5; snr=6; end if (inc=4) then; tsol=0.5; snr=6; end if (inc=5) then; tsol=20/60; snr=6; end if (inc=6) then; tsol=20/60; snr=6; end if (inc>6) then; tsol=1; snr=6; end in2name=sauce; in2class='icl001'; in2seq=inc+2; in2d=uv2disk; uvseq = 0; $ using ncomp=-1 (use only +ve clean components) is not v. satisfactory so $ instead set ncomp=0 $ (perhaps can get imagr to only write significant clean components to cc $ table?) selfcal(sauce,uvseq,uvclass,uvdisk, 1, inc, 0, 0, 0, soln,snr,tsol) $ NCOMP $$ $ CR 4Jun01: be careful using SNSMO because $ it has a bug that causes it to forget the renormalisation factor $ calculated when calib is run with cparm(2)=1. So don't use it on the first $ run of selfcal. $ CR 4Dec03: added SNSMO back in again, because stopped using cparm(2)=1 $ in CALIB - it is unduly sensitive to outliers. $ $ clip any large Amplitude gains from the SN table $ startof('snsmo'); version = tver; task 'snsmo'; innam=sauce; inclass=uvclass; inseq=0; indi=uv2disk; source=sauce,''; selband=-1; selfreq=-1; freqid=1; bif=1; eif=0; timer=0; anten=0; subarray=1; interpol 'MWF'; bparm 0; doblank=-1; smotyp 'AMPL'; cparm 0; cparm(1)=10; cparm(2)=10; cparm(6)=2; invers inc; outvers=inc; refant=antref; baddisk 0; go; endof('snsmo'); $ if (doprint <> 0) then tbfind ('PL', ii); $if (rpol=1) then $ for incif =1 to nif $excuse the formatting... $ dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'L',incif,incif) $ end $end dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'',1,0) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_calib_'!!plottyp!!char(inc)!!'.ps') doextd ('PL', ii+1, jj) end $ also get a text listing of the amplitude GAINs (for more accurate reading). if (plottyp='amp') then outprint='' startof('listr'); version = tver; task 'listr' if (pr2file=1) then outprint=filout!!'_'!!sauce!!'_calib_amp'!!char(inc)!!'.txt' end indisk=uvdisk; innam=sauce; inclass=uvclass; inseq=uvseq; optyp 'gain'; inext 'sn'; inver inc; sources ''; calcode ''; timerang 0; stokes ''; selband -1; selfreq -1; freqid 1; bif 0; eif 0; bchan 1; echan 0; antennas 0; basel 0; uvrang 0; docalib 0; gainuse 0; dopol -1; blver -1; flagver 0; doband -1; bpver 0; smooth 0; dparm 0; dparm(3) 6; factor 0; docrt=doprint; go; endof('listr') end end $ $ apply the selfcal solutions $ runcl (sauce, uv2disk, uvclass, inc, inc, inc+1, '2pt', 0, '', ''); $ $ next round of imagr $ dozap (uv2disk, sauce, 'icl001', inc+3, 'ma'); dozap (uv2disk, sauce, 'ibm001', inc+3, 'ma'); domx ('I',uv2disk,sauce,uvclass,uvseq,uv2disk,'',inc+3, 0,0,inc+1,ncc,'N') $ end end end end $ $---------------- # 12, Plot the map and the model with the data ----- $ if (allmask=0) then tmask=12; end if (allmask<0) then if (allmask > -12.5) then tmask=12; end end imask=12; if (tmask=imask) then clrtemp typ 'NSRC='nsrc for cntsrc=1 to nsrc clrtemp sauce=srclst(cntsrc);uvclass='multi'; uvseq=1; $ set the variable firstsrc for the first source in srclst. This $ is used later to ensure that at least two rounds of selfcal are $ done on the first source (so the antenna sensitivities can be $ plotted later on). firstsrc = 0 if (cntsrc = 1) then if (sciter < 2) then firstsrc = 2 - sciter end end $ $ plot the self-calibrated visibilites against time $ if (doprint <> 0) then tbfind ('PL', ii); for i=1 to npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end for incif=1 to nif doif = goodif(incif); if (doif=1) then startof('vplot'); version = tver; task 'vplot'; indisk=uvdisk; innam=sauce; inclass=uvclass; inseq=uvseq; in2disk=uv2disk; in2nam=sauce; in2class='icl001'; in2seq=0; userid 0; ncomp=0; nmaps 1; source=sauce,''; qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=plotref,0; baseline 0; docal 2; gainuse=sciter+firstsrc+1; dopol -1; blver -1; flagver 0; doband -1; bpver 0; smooth 0; suba 1; doebar -1; solint=plotavg; optype ' '; aparm 0; bparm 0; bparm(2)=-1; bparm(3)=1; bparm(8)=-180; bparm(9)=180; alias 0; nplots 4; doarray 0; polplot ' '; symbol 0; ltype 3; dotv -1; grchan 1; go; endof('vplot'); end end $ end $ tbfind ('PL', jj); if (jj > ii) then doplot(ii+1,jj, filout!!'_'!!sauce!!'_vplot_model.ps'); doextd('PL', ii+1, jj); end; end $ $ plot the map $ getstats(uvdisk, sauce, 'icl001', 0, 0, 0) peakflux=pixval getstats(uvdisk, sauce, 'icl001', 0, 0, imsiz(1)/4) rmsflux=pixstd*3 tbfind ('PL', ii); plotmap (uv2d, sauce, 'icl001', 0, uv2d, rmsflux, peakflux) tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_ICLN.ps') doextd ('PL', ii+1, jj) end runfittp (uv2d, sauce, 'icl001', 0, filout!!'_'!!sauce!!'_ICLN.FITS') $ $ uvplt the calibrated vis. Vs uvdist $ tbfind ('PL', ii); startof('uvplt'); version=tver; task 'uvplt'; userid 0; indisk=uv2disk; innam=sauce; inclass='multi'; inseq=uvseq; qual=-1; calcod ''; stokes 'i'; selband=-1; selfreq=-1; freqid=-1; timerang=0; anten=0; basel=0; uvrange=0; subarray=0; bchan=1; echan=0; chinc=1; bif=1; eif=0; docal=2; gainuse=sciter+firstsrc+1; dopol=-1; blver=-1; flagver=0; doband=-1; bpver=0; smooth=0; xinc=1; bparm=0,1,0; doweight 1; refant=0; rotate 0; factor=0; ltype 3; baddisk=0; dotv=-1; grchan=0; go; endof('uvplt') tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_UVPLT.ps') doextd ('PL', ii+1, jj) end $ $ uvplt the uv coverage. $ indisk=uv2disk; innam=sauce; inclass='multi'; inseq=uvseq; tbfind ('PL', ii); startof('uvplt'); version=tver; task 'uvplt'; userid 0; indisk=uv2disk; innam=sauce; inclass='multi'; inseq=uvseq; qual=-1; calcod ''; stokes 'i'; selband=-1; selfreq=-1; freqid=-1; timerang=0; anten=0; basel=0; uvrange=0; subarray=0; bchan=1; echan=0; chinc=1; bif=1; eif=0; docal=2; gainuse=sciter+firstsrc+1; dopol=-1; blver=-1; flagver=0; doband=-1; bpver=0; smooth=0; xinc=1; bparm=6,7,2,0; doweight 1; refant=0; rotate 0; factor=0; ltype 3; baddisk=0; dotv=-1; grchan=0; go; endof('uvplt') tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_UVCOV.ps') doextd ('PL', ii+1, jj) end $ $ plot the closure phases (clplt only works on single source files) $ $first subtract the model from the data: dozap (uv2disk, sauce, 'split', 2, 'uv'); startof('split'); version= tver; task 'split' indisk=uv2disk; innam=sauce; inclass='multi'; inseq=uvseq; outd=uv2disk; source ' '; qual -1; calcode ' '; timer 0; stokes ' ' selband -1; selfreq -1; bif 1; eif 0; bchan 1; echan 0; suba 1; docal 2; gainuse sciter+firstsrc+1; dopol -1; blver -1; flagv 0; doband 0; bpver 0; smooth 0; outcl=' '; outseq=2; outdisk=uv2disk; douvc 1; aparm 2,0,0,1; chansel 0; baddisk 0; go; endof('split'); $ dozap (uv2disk, sauce, 'uvsub', 1, 'uv'); startof('uvsub'); version = tver; task 'uvsub'; innam=sauce; inclass='split'; uvseq=2; indi=uvdisk; nmaps=1 channel=0; bif 1; eif 0; in2n=sauce; in2clas='icl001'; in2seq=0; in2d=uvdisk; inver=0; clron; outd=uvdisk; bcomp 0; ncomp=0; flux 0; cmethod ''; cmodel ''; factor 0; opcod 'DIV'; smodel 0; baddisk 0; go; endof ('uvsub'); $ if (doprint <> 0) then tbfind ('PL', ii); for i=1 to npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end startof('clplt'); version = tver; task 'clplt'; userid 0; indisk=uvdisk; innam=sauce; inclass='uvsub'; inseq=1; clr2n; ncomp=0; flux=0; nmaps 0; source=''; qual -1; calcode ' '; selband -1; selfreq -1; freqid 1; bchan 1; echan 2048; bif=1; eif=nif; xinc 1; uvrange 0; timer 0; docal 0; gainuse=0; dopol -1; blver -1; flagver 0; doband -1; bpver 0; smooth 0; suba 1; doebar -1; solint=20/60; opcode ''; phslimit 0; bparm 0; bparm(8)=5; polplot ' '; symbol 0; ltype 4; dotv -1; grchan 1; go; endof('clplt'); $ end $ tbfind ('PL', jj); if (jj > ii) then doplot(ii+1,jj, filout!!'_'!!sauce!!'_clphs.ps'); doextd('PL', ii+1, jj); end; end; end end $ $ $---------------------- 13, Calculate the antenna sensitivities ------ $ clrtemp sauce=srclst(1);uvclass='msort'; uvseq=1; if (nheads=2) then uvclass='vbglu' end if (avg>0.0001) then uvclass='uvavg' end $ $ copy the SN tables resulting from 'A&P' selfcal to a copy of the original $ multi-source file and apply to old CL table to give the total gains for the $ telescopes i.e. the antenna sensitivities. $ if (allmask=0) then tmask=13; end if (allmask<0) then if (allmask > -13.5) then tmask=13; end end imask=13; if (tmask=imask) then $$ $$delete old cl table 4 and old SN table 3 if they exist $$ $ innam=uvnam; inclass=uvclass; inseq=uvseq;ind=uvdisk; $ tbfind ('CL', ii); if (ii >= 4) doextd ('CL', 4, ii); $ tbfind ('SN', ii); if (ii >= 3) doextd ('SN', 3, ii); $ $ Copy tables from the pre-split multi source file. exist (uvdisk, uvnam, 'tmp', 1, texist); if (texist) then; dozap (uvdisk, uvnam, 'tmp', 1, 'uv');end startof('tasav');task'tasav'; version=tver; inname=uvnam;indisk=uvdisk;inclass=uvclass;inseq 1; outname=uvnam;outdisk=uvdisk;outclass='tmp';outseq 1; go;endof('tasav') $ $ delete the old SN tables innam=uvnam; inclass='tmp'; inseq=uvseq;ind=uvdisk; tbfind ('SN', ii); doextd ('SN', 1, ii); $ copy the A&P solutions from each of the single source files. for cntsrc=1 to nsrc sauce=srclst(cntsrc) $ coptb (sauce, 'multi', uvnam, uvclass, uv2disk, uvdisk, 'SN', 2, 0) coptb (sauce, 'multi', uvnam, 'tmp', uv2disk, uvdisk, 'SN', 2, 0) end $ runcl (uvnam, uvdisk, uvclass, 3, 3, 4, '2PT', 0) $ apply all SN tables from A&P selfcal to the CL table with the ANTAB GAINS runcl (uvnam, uvdisk, 'tmp', 0, 3, 4, '2PT', 0, '', '') $ $ plot the cl table $ if (doprint <> 0) then tbfind ('PL', ii); $if (rpol=1) then $ for incif=1 to nif $ $ dosnp (uv2disk,uvnam,uvclass,uvseq,'CL',4,'AMP','R',incif,incif) $ dosnp (uv2disk,uvnam,'tmp',0,'CL',4,'AMP','R',incif,incif) $ end $end $if (lpol=1) then $ for incif=1 to nif $ $ dosnp (uv2disk,uvnam,uvclass,uvseq,'CL',4,'AMP','L',incif,incif) $ dosnp (uv2disk,uvnam,'tmp',0,'CL',4,'AMP','L',incif,incif) $ end $end dosnp (uv2disk,uvnam,'tmp',0,'CL',4,'AMP','',1,0) $ tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_sens.ps') doextd ('PL', ii+1, jj) end end end $ $--------------------------------------------------------------------- $ return; finish $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ proc EVN_SAVE $ write out useful PI information. if (allmask=0) then tmask=14; end if (allmask<0) then if (allmask > -14.5) then tmask=14; end end imask=14; if (tmask=imask) then $ delete old TASAV. exist (uvdisk, uvnam, 'TASAV', 1, texist); if (texist) then; dozap (uvdisk, uvnam, 'TASAV', 1, 'uv');end startof('tasav');task 'tasav'; version=tver; inname=uvnam;indisk=uvdisk;inclass=uvclass;inseq 1; outname=uvnam;outdisk=uvdisk;outclass=' ';outseq 1; go;endof('tasav') startof('prthi'); inname=uvnam;indisk=uvdisk;inclass=uvclass;inseq 1; userid=0; docrt=-1; outprint=dir2!!expname!!'.his histart=1; hiend=0; prtask ''; prthi; endof('prthi') startof('fittp'); task 'fittp'; inname=uvnam;indisk=uvdisk;inclass='TASAV';inseq 1; doall=-1; intype='UV'; outtape=1; tasavext='.tasav.FITS outfile=dir2!!expname!!tasavext go;endof('fittp') for cntsrc=1 to nsrc clrtemp sauce=srclst(cntsrc); startof('fittp'); task 'fittp'; inname=sauce;indisk=uvdisk;inclass='SPLIT';inseq 1; doall=-1; intype='UV'; outtape=1; outfile=dir2!!expname!!'_'!!sauce!!'.UVDATA.FITS' go;endof('fittp') end end return; finish $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ proc EVN evn_precal evn_map evn_save return; finish