$ Procedures to reduce EVN NME for spectral lines $ $------------------------------------------------------------------ $ Cormac Reynolds - January 2001: original adapted from BD046.RUN by Phil $ Diamond $ April 5 2001: updated to allow single polarization expts. $ April 8 2001: Added clrtemp commands to prevent 'BLEW TEMP $ C' $ May 21 2001: Made the number of IFs an input variable and $ split into two procedures to overcome $ procedure length limits. $ June 1 2001: Allow sciter<2 and no selfcal if desired. $ June 5 2001: added clplt $ Dec 3 2001: Added listr output of AMP SN table, and use of $ uncompresed data sets in fitld. $ Mar 12 2002: VBGLU etc. added to allow 2-head datasets. $ Apr 23 2002: doprint=0 really doesn't print now. $ Jun 4 2002: Now runs on 31DEC01 version of AIPS. UVPLT of $ calibrated data has been added. u,v coverage $ plot added. $ Jun 10 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. $ Jun 13 2002: new proc EVN_SAVE to save the PI products to $ disk. $ Aug 8 2002: use APCAL and FITLD from DEC02 version $ HImai Oct 10 2002: for spectral lines $ HImai Dec 02 2002: for multiple fits files $ HImai Dec 04 2002: freqid should be explicitely defined. $ HImai Dec 06 2002: TMASK=13 proc. improved for multiple setups $ HImai Dec 10 2002: EVN_SAVE improved to save self-cal. sols. restore 0 clrtemp dowait 1 proc declare scalar uvdisk, uvseq, uvtap, ntapes, tapeuse, antref, plotref, uv2disk scalar imask, nplots, k1, k2, disk, solcal, soltxc, soltmp scalar rsens, lsens, rtsys, ltsys, itab, jtab, ii, jj, ant2ref, k scalar refan2, dosmoth, smotim, oint, tcutof, tseq, texist, kk, nn scalar ss, nif, incif, incey, nheads, cpols scalar disk2, npoli, r1, r2 scalar ch5, doprint, allmask, iscal, i, l, m, nbl, inc, nsrc, cntsrc scalar patchmin, snr, delch, peakflux, rmsflux, doedit, firstif, lastif scalar plotavg, pr2file, sciter, npols, lpol, rpol, tsol, firstsrc $ HImai Oct 10 2002: for spectral lines $ HImai 02 Dec 2002: for spectral lines scalar nchan, doavr, nfits, idfreq string*32 bpasslst(256) string*1 fitsnum(9) array tmptim(8), wexist(3) string*6 uvclass string*16 uvnam, ropey string*48 fitsfile string*6 rlbas, rlcal, rlswp, rrll, difrl, rr, ll, tcout string*50 pounds; string*8 tsknam; string*2 epoch; string*6 tclass string*6 tclass1; string*2 table; string*6 cvelxc; string*2 extype string*6 tmpl, tver, aver, mclass, qcal, qfin string*2 tabtyp; string*50 text; string*50 excl; string*16 calnam string*12 sauce, tname, oname, tasavext; string*4 tintp string*48 dir, dir2, filout, filename string*16 wname(3); string*2 ttype; string*1 polty; string*5 string*16 expname, expcode, antabext, flagext, chflag, name2, seq2 string*32 srclst(256), calsrclst(256) string*2 ctst, obsband, pols string*3 soln string*4 plottyp ret; fin $ procedure to store the inputs and set up defaults. proc checkin $ set up default imaging parameters for the observing band if (obsband='c') then cellsize = 0.0004; imsize=512; bmaj=0; bmin=0; bpa=0; niter=500; flux=0; shift=0; end if (obsband='l') then cellsize = 0.0010; imsize=512; bmaj=0; bmin=0; bpa=0; niter=500; flux=0; shift=0; end if (obsband='x') then cellsize = 0.0002; imsize=512; bmaj=0; bmin=0; bpa=0; niter=500; flux=0; shift=0; end $ HImai Dec 02 2002: for spectral lines if (obsband='k') then cellsize = 0.00008; imsize=1024; bmaj=0; bmin=0; bpa=0; niter=500; flux=0; shift=0; end $ HImai Oct 10 2002: for spectral lines if (nchan > 64) then doavr=1; else doavr=0; end $ HImai 02 Dec 2002: for multiple FITS files fitsnum(1)='1' fitsnum(2)='2' fitsnum(3)='3' fitsnum(4)='4' fitsnum(5)='5' fitsnum(6)='6' fitsnum(7)='7' fitsnum(8)='8' fitsnum(9)='9' patchmin=imsize(1)/2; $ 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 pr2file=0 if (doprint=-2) then filout = dir2!!expname pr2file = 1 doprint=-1 end $ external files antabext='.antab flagext='.flag 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 $ $ Declare versions $ $ orver = version tver = 'NEW'; aver = 'TST'; 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, i, j, k, tintp, tcutof) $HImai 04 Dec 2002 for freqid proc runcl (tname, disk, tclass, i, j, k, tintp, tcutof, ii) $ disk = disk #, tclass = file class; $ i = SN to use; j = CL to update, new CL = k $ tintp = interpolation method $ tcutof = time cutoff for interpolation $ 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=' '; soucode=' '; calsour=' '; qual -1; calcode ' '; timer 0; suba 1; anten 0; selband -1; $ selfreq -1; freqid -1; opcode='cali'; interpol=tintp; $HImai 04 Dec 2002 for freqid selfreq -1; freqid=ii; opcode='cali'; interpol=tintp; intparm 0; cutoff=tcutof; smotype ' '; refant=antref; snver=i; gainver=j; gainuse=k; 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; 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) $ HImai 04 Dec 2002 Added task'lwpla' dparm 0; outfile=filename; lpen 3; aspmm 0; functype ' '; copies 1; userid 0; invers 0; dparm(6) 4; plver=itab; inver=jtab; version = tver; 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(1)=sauce; aparm = 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; end; ret; fin $proc dosnp (disk, tname, tclass, tseq, tabtyp, k1, tmpl, ttype, firstif, lastif) $HImai 04 Dec 2002 for freqid proc dosnp (disk,tname,tclass,tseq,tabtyp,k1,tmpl,ttype,firstif,lastif,kk) $ 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) 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; $HImai 04 Dec 2002 for freqid stokes=ttype; selband -1; selfreq -1; freqid=kk; bif=firstif; eif=lastif; antennas 0; pixr 0; nplots 10; xinc 1; optyp=tmpl; opcode ''; bcount 1; xaxis 0; 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) $HImai 04 Dec 2002 for freqid proc dofr (disk,tname,tclass,tseq,i,j,k,k1,k2,ii,jj,nn,kk) $ 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; $HImai 04 Dec 2002 for freqid qual -1; calcode ' '; selband -1; selfreq -1; freqid=kk 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, i, j, k) $ 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 $ i,j = start, stop channels $ k = CL table to use 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; $HImai 04 Dec 2002 for freqid 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; npoints 1; chinc 1; bif 1; eif 0; outnam=oname; outd = disk2; outseq = 0; outver 0; clr2n; nfield 1; do3dimag 0; fldsize 0; rashift 0; decshift 0; uvtaper 0; uvrange 0; guard 0; rotate 0; zerosp 0; uvwtfn 'N'; uvsize 0; robust=0; uvbox 0; uvbxfn 1; xtype 5; ytype 5; xparm 0; yparm 0; bcomp 0; allokay=0; nbox 0; clbox 0; boxfile ''; gain 0.05; minpatch=patchmin; overlap 0; phat 0; factor 0; cmethod ' '; imagrprm=0; imagrprm(8) ~ -0.1e-4, 1; ngauss 0; wgauss 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; minamper=10; minphser=20; cparm 0; cparm(1)=10; cparm(2)=1; cparm(3)=10; cparm(4)=20; snver 0; antwt 0; gainerr 0; baddisk 0; go; endof('calib') ret; fin $ $--------------------------------------------------------------------- $ 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 = aver; task 'fitld' outdisk=uvdisk; outnam=uvnam; outcl=uvclass; outseq=uvseq intape=tapeuse; nfiles 0; infile=fitsfile; if (nheads=2) then infile=infile!!'.1' ; 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 ' '; $ HImai 02 Dec 2002: for multiple FITS files if (nfits=0) then go; endof('fitld') else for i=1 to nfits infile=fitsfile!!fitsnum(i); typ '### INFILE= ',infile,'###' go; endof('fitld') end end version = tver; if (nheads = 2) then if (fitsfile <> '') then fitsfile = fitsfile!!'.2' end startof('fitld'); version = aver; task 'fitld' outdisk=uvdisk; outnam=uvnam!!'_2'; outcl=uvclass; outseq=uvseq intape=tapeuse; nfiles 0; infile=fitsfile ; 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 ' '; go; endof('fitld') 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('msort') end end uvclass='msort' if (nheads=2) then uvclass = 'vbglu' 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 'SCHED flags'; bdrop 0; edrop 0; dohist 0; go; endof ('uvflg') $ 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; 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('possm'); version = tver; 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; $HImai 04 Dec 2002 for freqid selfreq -1; freqid=idfreq; 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') end $ 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 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; $HImai 04 Dec 2002 for freqid calcode ' '; selband -1; selfreq -1; freqid=idfreq; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=plotref,0; baselin 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 $ 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); for i=1 to npols typ 'npols1='npols stokes = pols if (pols = 'D') then if (i=1) then stokes = 'LL' end if (i=2) then stokes = 'RR' end end startof('possm'); version = tver; 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; $HImai 04 Dec 2002 for freqid selfreq -1; freqid=idfreq; uvrang 0; timerang=0,0,0,1; bif 1; eif 0; bchan 0; echan 0; suba 1; antennas=plotref; 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 '' typ 'npols2='npols endof('possm') end $ 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 = tver; task 'possm' stokes = 'LR'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; userid 0; source ''; qual -1; calcode ' '; selband -1; $HImai 04 Dec 2002 for freqid freqid=idfreq; 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; 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 ------------- $ $ 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', 3, ii); $ HImai 02 Dec 2002 Buf fixed tbfind ('CL', ii); if (ii >= 2) doextd ('CL', 2, ii); $ $ 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 $ 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 (doprint <> 0) then tbfind ('PL', ii); if (rpol=1) then $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'R', 1, 0) $HImai 04 Dec 2002 for freqid dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'R',1,0,-1) end if (lpol=1) then $ dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'L', 1, 0) $HImai 04 Dec 2002 for freqid dosnp (uv2disk, uvnam, uvclass, uvseq, 'TY', 1, 'TSYS', 'L',1,0,-1) end tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_tsys.ps') doextd ('PL', ii+1, jj) end end $ $ run APCAL from 31DEC02 (version=aver) to take advantage of increased array $ sizes. tbfind('PL', ii); startof('apcal'); version = aver; task 'apcal'; indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; $ anten 0; suba 1; stokes ' '; bif=1; eif=0; freqid 1; $HImai 04 Dec 2002 for freqid anten 0; suba 1; stokes ' '; bif=1; eif=0; freqid=idfreq; source ' '; timer 0; tyver 1; gcver 1; snver 1; opcode ' '; aparm 0; solint 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 $ $ runcl (uvnam, uv2disk, uvclass, 1, 1, 2, '2PT', 0) $HImai 04 Dec 2002 for freqid runcl (uvnam, uv2disk, uvclass, 1, 1, 2, '2PT', 0, idfreq) $ $ 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','R',incif,incif,idfreq) end end if (lpol=1) then for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','L',incif,incif) $HImai 04 Dec 2002 for freqid dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',2,'AMP','L',incif,incif,idfreq) end end $ tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_gain.ps') doextd ('PL', ii+1, jj) end end 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 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); $HImai 04 Dec 2002 for freqid dofr (uv2disk,uvnam,'avspc',uvseq,1,0,2,0,2,solcal,0,0,idfreq); coptb (uvnam, 'avspc', uvnam, uvclass, uv2disk, uv2disk, 'SN', 2, 2) else $ dofr (uv2disk,uvnam,uvclass,uvseq,1,0,2,0,2,solcal,0,0); $HImai 04 Dec 2002 for freqid dofr (uv2disk,uvnam,uvclass,uvseq,1,0,2,0,2,solcal,0,0,idfreq); 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; $ runcl (uvnam, uv2disk, uvclass, 2, 2, 3, 'ambg', 0); $HImai 04 Dec 2002 for freqid runcl (uvnam, uv2disk, uvclass, 2, 2, 3, 'ambg', 0,idfreq); 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 'NSRC='nsrc for i=1 to nsrc; $ HImai Oct 10 2002: for spectral lines $ calsour(i) = calsrclst(i); 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; $HImai 04 Dec 2002 for freqid selfreq=-1; freqid=idfreq; bif 1; eif 0; subarray 1; anten 0; clr2n; ncomp 0; flux 0; nmaps 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; clr3n; baddisk 0; go; endof('bpass'); $ $ plot the bandpass $ 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('possm'); version = tver; 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; $HImai 04 Dec 2002 for freqid selfreq -1; freqid=idfreq; 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)=-30; aparm(6)=30; 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') end $ 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'CL',3,'PHAS','R',incif,incif,idfreq) end end if (lpol=1) then for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'CL',3,'PHAS','L',incif,incif) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'CL',3,'PHAS','L',incif,incif,idfreq) end end 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'SN',2,'DELA','R',incif,incif,idfreq) end end if (lpol=1) then for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'DELA','L',incif,incif) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'SN',2,'DELA','L',incif,incif,idfreq) end end 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'SN',2,'RATE','R',incif,incif,idfreq) end end if (lpol=1) then for incif=1 to nif $ dosnp (uv2disk, uvnam, uvclass, uvseq,'SN',2,'RATE','L',incif,incif) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,uvclass,uvseq,'SN',2,'RATE','L',incif,incif,idfreq) end end 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); 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('possm'); version = tver; 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 $HImai 04 Dec 2002 for freqid selfreq -1; freqid=idfreq;uvrang 0;timerang=0,0,0,1;bif 1;eif 0;bchan 0; echan 0; suba 1; antennas=plotref; 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)=-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_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 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; $HImai 04 Dec 2002 for freqid calcode ' '; selband -1; selfreq -1; freqid=idfreq; bchan 1; echan 2048; bif=incif; eif=incif; xinc 1; uvrange 0; timer 0; anten=plotref,0; baselin 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 $ 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' indisk=uv2disk; innam=uvnam; inclass=uvclass; inseq=uvseq; outd=uv2disk; source ' '; qual -1; calcode ' '; timer 0; stokes ' ' for j=1 to nsrc; source(j)=srclst(j); end selband -1; selfreq -1; bif 1; eif 0; bchan 1; echan 0; $HImai 04 Dec 2002 for freqid freqid=idfreq; 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 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 $ $---------------- # 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 $ $ 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 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; baselin 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 $ $ and run multi and indxr $ domult (uvdisk, uvclass, sauce) uvclass='multi'; uvseq=0; runnx(sauce, uvdisk, uvclass) end $ clrtemp uvclass='multi'; uvseq=0; $ $---------------- # 10, First round of imagr and self-cal -------------- $ 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 $ $ as it's the first round delete any existing CL and SN tables. $ 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); $ $ first round of imagr (always do) $ domx ('I', uv2disk, sauce, uvclass, uvseq, uv2disk, ' ', 0, 0, 1) $ 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 $ $ 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=0; 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. $ $ clip any large Amplitude gains from the SN table $ if (inc > 2) then 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)=100; cparm(6)=2; invers inc; outvers=inc; refant=antref; baddisk 0; go; endof('snsmo'); end $ 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'R',incif,incif,-1) end end if (lpol=1) then for incif=1 to nif $ dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'L',incif,incif) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,sauce,uvclass,uvseq,'SN',inc,plottyp,'L',incif,incif,-1) end end tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_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!!'_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); $HImai 04 Dec 2002 for freqid runcl (sauce, uv2disk, uvclass, inc, inc, inc+1, '2pt', 0, -1); $ $ next round of imagr $ domx ('I', uv2disk, sauce, uvclass, uvseq, uv2disk, ' ', 0, 0, inc+1) $ 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 $ $ 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 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; baselin 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 $ 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 $ startof('imstat'); version =tver; task 'imstat'; innam=sauce; inclass='icl001'; inseq=0; indi=uv2d; blc=0; trc=0; doinvers -1; imstat; endof('imstat') peakflux=pixval startof('imstat'); version =tver; task 'imstat'; innam=sauce; inclass='icl001'; inseq=0; indi=uv2d; blc=0; trc=imsiz(1)/4; doinvers -1; imstat; endof('imstat') rmsflux=pixstd*3 tbfind ('PL', ii); startof('kntr'); version=tver; task 'kntr'; docont 1; dogrey 0; innam=sauce; inclass='icl001'; inseq=0; indi=uv2d; clr2n; blc=0; trc=0; zinc 1; ny 0; xyratio=0; pixrange 0; ltype=4; doalign 1; doblank=-1; docirc=-1; invers 0; ctype 0; stfactor 0; cbplot 1; label 0; dotv -1; tvchan 1; grchan 1; tvcorn 0; plev 0; clev= peakflux; levs 0; levs(1)=0-rmsflux/peakflux; levs(2)=rmsflux/peakflux; 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') tbfind ('PL',jj) if (jj > ii) then doplot (ii+1, jj, filout!!'_'!!sauce!!'_IMAP.ps') doextd ('PL', ii+1, jj) end $ $ 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; refant=0; factor=0; 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; refant=0; factor=0; 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: 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'); $ 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 for incif=1 to nif 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=incif; eif=incif; 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 'INDE'; phslimit 0; bparm 0; bparm(8)=5; polplot ' '; symbol 0; ltype 4; dotv -1; grchan 1; go; endof('vplot'); end $ 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 $ $ 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 $ HImai for single setup Dec 06 2002 if (idfreq <= 0) then startof('tasav');task'tasav' inname=uvnam;indisk=uvdisk;inclass=uvclass;inseq 1; outname=uvnam;outdisk=uvdisk;outclass='tmp';outseq 1; go;endof('tasav') else startof('uvcop');task'uvcop' inname=uvnam;indisk=uvdisk;inclass=uvclass;inseq 1; freqid=idfreq;bif=1;eif=nif; outname=uvnam;outdisk=uvdisk;outclass='tmp';outseq 1; go;endof('uvcop') runnx(uvnam,uvdisk,'tmp') end $ $ 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) $HImai 04 Dec 2002 for freqid runcl (uvnam, uvdisk, 'tmp', 0, 3, 4, '2PT', 0, -1) $ $ 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,'tmp',0,'CL',4,'AMP','R',incif,incif,-1) 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) $HImai 04 Dec 2002 for freqid dosnp (uv2disk,uvnam,'tmp',0,'CL',4,'AMP','L',incif,incif,-1) end end $ 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' 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='OUT:'!!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='OUT:'!!expname!!tasavext go;endof('fittp') $ HImai Dec 10 2002: to save self-cal. sols. $ delete old TASAV. exist (uvdisk, uvnam, 'TASAV', 2, texist); if (texist) then; dozap (uvdisk, uvnam, 'TASAV', 2, 'uv');end startof('tasav');task 'tasav' inname=uvnam;indisk=uvdisk;inclass='tmp';inseq 1; outname=uvnam;outdisk=uvdisk;outclass=' ';outseq 2; go;endof('tasav') $delete unnecessary tables. innam=uvnam; inclass='tasav'; inseq=2;ind=uvdisk; doextd ('FG', 1, 1); doextd ('TY', 1, 1); doextd ('GC', 1, 1); doextd ('BP', 1, 1); doextd ('CL', 2, 3); startof('fittp'); task 'fittp'; inname=uvnam;indisk=uvdisk;inclass='TASAV';inseq 2; doall=-1; intype='UV'; outtape=1; tasavext='_SELFC.FITS outfile='OUT:'!!expname!!tasavext go;endof('fittp') end return; finish $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ proc EVNL evn_precal evn_map evn_save return; finish