$ VLBAPIPE $--------------------------------------------------------------- $! Applies amplitude and phase calibration procs to VLBA data $# RUN POPS VLBI UTILITY CALIBRATION IMAGING $--------------------------------------------------------------- $; Copyright (C) 2025 $; Associated Universities, Inc. Washington DC, USA. $; $; This program is free software; you can redistribute it $; and/or modify it under the terms of the GNU General Public $; License as published by the Free Software Foundation; either $; version 2 of the License, or (at your option) any later $; version. $; $; This program is distributed in the hope that it will be $; useful, but WITHOUT ANY WARRANTY; without even the implied $; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR $; PURPOSE. See the GNU General Public License for more $; details. $; $; You should have received a copy of the GNU General Public $; License along with this program; if not, write to the Free $; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, $; MA 02139, USA. $; $; Correspondence concerning AIPS should be addressed as $; follows: $; Internet email: aipsmail@nrao.edu. $; Postal address: AIPS Project Office $; National Radio Astronomy Observatory $; 520 Edgemont Road $; Charlottesville, VA 22903-2475 USA $--------------------------------------------------------------- $ Based on VLBARUN with a different order of the steps PROCEDURE R_INIT $ $ Define VLBAUTIL and variables for VLBA pipeline docrt 1; dowa true SCALAR R_DISK, R_SQ, R_NUM, R_VER, R_DOHTML, R_DOEMAIL SCALAR R_INVERS, R_CLINT, R_ANTNUM, R_SOLINT, R_TINT, R_BR SCALAR R_MIN, R_MAX, R_SEQ, R_DOSTART, R_DOTIMER, R_NUMCAL SCALAR R_NUMREF, R_FREQUID, R_AP8, R_ERROR, R_DEBUG, R_ROW SCALAR R_FACTOR, R_IFS, R_INSEQ, R_SI, R_IMSEQ, R_LDFILE SCALAR R_ONDISK, R_INDI, R_OBSFQ, R_CHAN, R_NCHAN, R_DOPL SCALAR R_PVER, R_IVER, R_I, R_FOUND, R_NUMANT, R_GU, R_DB SCALAR R_BP, R_NPL, R_USERNO, R_CHKERR, R_DOAPLYD, R_DOFLAG SCALAR R_INTTIM, TYSMOLEV, R_SMOLEV, ELEVLIM, R_ELEV SCALAR SELFCAL, R_BPASS5, R_CHINC, R_DOBAND, BPSOLINT SCALAR R_BPSEQ, R_BPDISK, R_BPMAPS, R_LONG ARRAY R_IMSIZE(2), R_PLCNT(20), r_clcnt(10), R_DOCLIP(2) ARRAY R_CALSCANT(8), R_BADDISKS(10), R_NO_SLFCL(30) ARRAY SMRATES(3) STRING*2 R_REFANT, R_EXT, CHREFANT STRING*4 R_TYP, R_MODE, R_INTERPOL STRING*6 R_CLASS, R_INCL, R_IMCL, R_BPCLAS STRING*8 R_TASK, R_SUBSTR, R_CNVRT, CALTASK, R_CTASK STRING*12 R_EXPNA, R_NA, R_INNA, R_DATE, R_BPNAME STRING*16 R_CALSOURC(30), R_ATARGETS(30), R_PLABEL, R_SRC STRING*48 R_DATAIN, R_DIR, R_EMAIL, R_INFI, R_INTEXT, R_FDIR STRING*66 R_LINE(2), R_OUTDIR, R_SCR, R_OUTTMP $ from input dialog: $--------------------------------------------------------------- R_DATAIN = DATAIN ; R_EXPNA = OUTNAME R_DISK = OUTDISK ; R_INNA = INNAME R_INCL = INCLASS ; R_INSEQ = INSEQ R_INDI = INDISK ; R_MODE = OPTYPE R_CLINT = CLINT ; R_REFANT = CHREFANT R_CALSCANT = TIMERANG ; R_CALSOURC = CALSOUR R_ATARGETS = SOURCES ; R_SOLINT = SOLINT R_IMSIZE = IMSIZE ; R_FACTOR = FACTOR R_DOPL = DOPLOT ; R_DIR = OUTFILE R_EMAIL = OUTTEXT ; R_BADDISKS = BADDISK R_INVERS = INVERS ; R_INFI = INFILE R_DOFLAG = DOFLAG ; R_INTEXT = INTEXT R_DOCLIP = DOCLIP ; R_SMOLEV = TYSMOLEV R_ELEV = ELEVLIM ; R_BPASS5 = BPASS5 R_CTASK = CALTASK ; R_CHINC = CHINC R_DOBAND = DOBAND ; R_BPNAME = IN2NAME R_BPCLAS = IN2CLASS ; R_BPSEQ = IN2SEQ R_BPDISK = IN2DISK ; R_BPMAPS = NMAPS $--- and set to defaults if (r_doband>=0) then; r_doband=max(1,r_doband); end doband = r_doband; bpsolint = max (0, bpsolint) if (smrates(1)>0) then; if (smrates(2)<=0) then; smrates(2)=smrates(1); end if (smrates(3)<=0) then; smrates(3) = 1000; end end tput vlbapipe; vnumber= 36-getpopsn; vput vlbapipe task 'VLBAPIPE'; clr2name; nmaps = 0 $--- R_DOTIMER = 0 ; R_ERROR = 0 ; R_DOHTML = -1 R_LDFILE = -1 ; R_ONDISK = -1 ; R_DOEMAIL = -1 R_SEQ = 1 ; R_FOUND = -1 ; R_NUMANT = 0 R_INTERPOL = '2PT' ; R_OUTDIR = '' ; INVERS = 0 R_CHKERR = 1 ; R_LINE = '' ; R_DOAPLYD = -1 R_CLCNT = -1 ; R_PLCNT = -1 ; R_LONG = 1 $ must be 0 in VLBAUTIL, used in R_GETFQNUM VBA_NFQI = 0; VBA_SX = 0; VBA_9050 = 0 IF ((r_ctask<>'CALIB') & (r_ctask<>'CALIBS')) then r_ctask = 'FRING'; end RETURN; FINISH PROCEDURE R_RESTART *--------------------------------------------------------------- * deletes all PL, BP, SN all but first CL tables *--------------------------------------------------------------- clrstat; inext 'PL'; j = maxtab(inext) if (j>0) then; invers = -1;extdest;end inext 'BP'; j = maxtab(inext); if (j>0) then; invers = -1;extdest;end inext 'FG'; j = maxtab(inext) if (j>1) then; print 'FG tables are not deleted end inext 'CL'; j = maxtab(inext); if (j>1) then;for i = 2:j; invers i; extdest; end; end inext 'TY'; j = maxtab(inext); if (j>1) then;for i = 2:j; invers i; extdest; end; end inext 'SN';j = maxtab(inext) if (j>0) then; invers = -1; extdest; end inext 'NS';j = maxtab(inext) if (j>0) then; invers = -1; extdest; end inext 'TE';j = maxtab(inext) if (j>0) then; invers = -1; extdest; end RETURN; FINISH PROCEDURE R_RESET *--------------------------------------------------------------- * call R_RESTART *--------------------------------------------------------------- r_restart RETURN; FINISH PROCEDURE R_ZAPALL *--------------------------------------------------------------- * deletes all catalog entries matching name parameters * uses adverbs INNAME, INCLASS, INSEQ, INTYPE, INDISK *--------------------------------------------------------------- chkname; if (error<1) then; indisk r_disk for j = 1 to (1-1*error); zap; end end RETURN; FINISH PROCEDURE R_ALLPLOT (R_MIN) *--------------------------------------------------------------- * plots plot files R_MIN to max on the TV *--------------------------------------------------------------- r_min = max (1, r_min); r_max = maxtab('PL') j = r_max - r_min + 1 if (j>0) then; tvinit type char(j) !! ' plot files to show on TV: type 'Versions' !! char(r_min) !! ' TO:' !! char(r_max) for i = r_min:r_max; plver i type 'PLOT #'!!char(i-r_min+1)!!'/'!!char(j)!! type ' -- TYPE A ZERO TO STOP' grchan = 0; grclear; runwait('TVPL'); r_num=1; read r_num if (r_num=0) then; i = r_max+1; end end else; type 'NOTHING TO PLOT - DONE';end RETURN; FINISH PROCEDURE R_INFO (R_TASK) *--------------------------------------------------------------- * if (r_debug) print task name, inputs decide to continue * always print running message *--------------------------------------------------------------- if ((r_debug > 0) & (r_error=0)) then task r_task; type '*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*' inputs; type '*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*' tt = 1; type 'TYPE RETURN TO CONTINUE, ZERO TO STOP'; read tt if (tt = 0) then; r_error = 99 type 'OK, STOPPING AT' r_task; end end; if (r_error=0) then; type 'RUNNING_'!! r_task; end RETURN; FINISH PROCEDURE R_GSTOK *--------------------------------------------------------------- * NOTE: sets stokes (default/undetermined -> stokes = '') * does 'half' if possible *--------------------------------------------------------------- keyvalue 0; keystrng ''; j = 0; stokes = ' ' while ( (j < 8) & (substr(keystrng,1,6) <> 'STOKES') ) j = j + 1; keyword = 'CTYPE' !! char(j); gethead if (substr(keystrng,1,6) = 'STOKES') then keyword = 'NAXIS' !! char(j); gethead; r_i = keyvalue(1) keyword = 'CRVAL' !! char(j); gethead if (keyvalue(1) = -1) then; stokes = 'RR' if (r_i>1) then; stokes='HALF'; end; end if (keyvalue(1) = -2) then; stokes = 'LL'; end if (keyvalue(1) = -5) then; stokes = 'XX' if (r_i>1) then; stokes='HALF'; end; end if (keyvalue(1) = -6) then; stokes = 'YY'; end if (keyvalue(1) = 1) then; stokes = 'I'; end end end RETURN; FINISH PROCEDURE R_GETSTOK *--------------------------------------------------------------- * NOTE: sets stokes (default/undetermined -> stokes = '') *--------------------------------------------------------------- keyvalue 0; keystrng ''; j = 0 while ( (j < 8) & (substr(keystrng,1,6) <> 'STOKES') ) j = j + 1; keyword = 'CTYPE' !! char(j); gethead if (substr(keystrng,1,6) = 'STOKES') then keyword = 'CRVAL' !! char(j); gethead if (keyvalue(1) = -1) then; stokes = 'RR' else if (keyvalue(1) = -2) then; stokes = 'LL' else if (keyvalue(1) = 1) then; stokes = 'I' else; stokes = ' '; end; end; end; end end RETURN; FINISH PROCEDURE R_FQINFO *--------------------------------------------------------------- * Sets the Stokes & frequency information from the header *--------------------------------------------------------------- r_getstok; keyvalue 0; keystrng ''; j = 0 while ((j < 8) & (substr(keystrng,1,4) <> 'FREQ')) j = j + 1; keyword = 'CTYPE' !! char(j); gethead if (substr(keystrng,1,4) = 'FREQ') then keyword = 'CRVAL' !! char(j); gethead r_obsfq = keyvalue(1) $ obs frequency keyword = 'CDELT' !! char(j); gethead r_chan = keyvalue(1) $ channel bandwidth keyword = 'NAXIS' !! char(j); gethead r_nchan = keyvalue(1) $ number channels end if (substr(keystrng,1,2) = 'IF') then keyword = 'NAXIS' !! char(j); gethead r_ifs = keyvalue(1) $ number of IFs end; end $ * * * * find freq -> sefd $ * * * * find mode (typ) -> TBW (assume 2bit) and get $ * * * * #vis for ext=im - not bl RETURN; FINISH PROC R_TVCOLR *--------------------------------------------------------------- * does TVCOLORS with default values *--------------------------------------------------------------- docolor = 1; plcolor=0 plcolor(1,1)~1,1,0, 0.063,1,0, 1,0.671,1, 0,1,1 plcolor(1,9)~1,1,0 RETURN,FINISH PROC R_SNPLOT (R_NA,R_SQ,R_EXT,R_VER,R_TYP,R_MIN,R_MAX,R_NUM) *--------------------------------------------------------------- * Runs SNPLT for catalog file r_na/r_class/r_sq on r_disk * extension r_ext, version r_ver pixrange r_min to r_max * r_num plots/page of parameter r_typ * plot files are made *--------------------------------------------------------------- if (r_error=0) then default 'SNPLT'; inname r_na; inclass r_class; inseq r_sq indisk r_disk; inext r_ext; invers r_ver; nplots r_num pixrange r_min,r_max; optype r_typ * only one (first) stokes needed for dispersive delay if (r_typ = 'DDLY') then; r_getstok; end r_info('SNPLT'); if (r_error = 0) then dotv -1; runwait ('SNPLT') end; timerang r_calscant $ reset altered adverb end RETURN; FINISH PROCEDURE R_UVPLOT (R_NA, R_CLASS, R_SQ) *--------------------------------------------------------------- * Runs UVPLT for catalog file r_na, r_class, r_seq *--------------------------------------------------------------- if (r_error=0) then default 'UVPLT'; inname = r_na; inclass = r_class inseq r_sq; r_gstok; r_info('UVPLT'); if (r_error = 0) then; nchav=4096; dotv=-1; factor=2.5; solint=0.5; bparm=11,0; bparm(10)=1; runwait ('UVPLT') bparm=0; bparm(10)=1; solint=1000; runwait ('UVPLT'); solint=0; factor=1; bparm=0; nchav=0; runwait ('UVPLT') end end RETURN; FINISH PROC R_POSSM (R_NA,R_SQ,R_GU,R_DB,R_BP,R_NPL,R_SI,R_SRC,R_AP8) *--------------------------------------------------------------- * Runs POSSM for catalog file r_na/r_class/r_sq gainuse r_gu * doband r_db, bpver r_bp, nplots n_npl, solint r_si * source r_src, aparm(8) r_ap8 *--------------------------------------------------------------- if (r_error=0) then default 'POSSM'; inname r_na; inclass r_class; inseq r_sq indisk r_disk; docalib 1; gainuse = r_gu; doband = r_db bpver = r_bp; nplots = r_npl; solint = r_si; aparm(9) = 1; source = r_src,''; r_gstok; aparm(8) = r_ap8 if (r_ap8<2) then; baseline refant, 0; aparm(2) = 1 aparm(5)=-180; aparm(6)=180; timerang=r_calscant; end r_info('POSSM'); if (r_error = 0) then dotv -1; runwait ('POSSM') end end RETURN; FINISH PROCEDURE R_VPLOT (R_NA, R_SQ,R_GU,R_DB,R_BP,R_NPL,R_SI, R_SRC) *--------------------------------------------------------------- * Runs VPLOT for catalog file r_na/r_class/r_sq gainuse r_gu * doband r_db, bpver r_bp, nplots n_npl, solint r_si * source r_src * Non-call adverbs: r_class, r_nchan, r_antnum, r_disk *--------------------------------------------------------------- if (r_error=0) then default 'VPLOT'; inname r_na; inclass r_class; inseq r_sq indisk r_disk; docalib 1; gainuse = r_gu; nplots = r_npl * doband = r_db; bpver = r_bp; solint = r_si; r_gstok source = r_src,''; echan = r_nchan; baseline r_antnum, 0 bparm 0, 2, 1, 0, 0,-180, 180; do3col 1 r_info('VPLOT'); if (r_error = 0) then dotv -1; runwait ('VPLOT') end end RETURN; FINISH PROCEDURE R_KNTR (R_NA, R_IMCL, R_CHKERR) *--------------------------------------------------------------- * Runs KNTR: uses nameget to set r_imseq, uses IMEAN for CLEV * Inputs: r_na name, r_imcl class * Output: r_chkerr = seq number of file, < 0 => could not find *--------------------------------------------------------------- default 'IMEAN'; inname r_na; inclass 'ICL001'; intype 'MA' indisk = r_disk; nameget; if (error<1) then; r_imcl = 'ICL001'; r_imseq = inseq else; inclass = 'RCL001'; nameget if (error<1) then; r_imcl = 'RCL001'; r_imseq = inseq else; inclass='LCL001'; nameget if (error<1) then; r_imcl = 'LCL001'; r_imseq = inseq end end end inname r_na; inclass r_imcl; inseq r_imseq; indisk r_disk type 'R_KNTR', inname, inclass, inseq chkname; if (error<1) then nboxes 50; outtext ''; runwait('IMEAN'); nboxes 0 default 'KNTR';dogrey -1; dovect -1; clev = 3*triangle(15) levs = -1.414,-1; tvchan = 0; dodark -1; r_chkerr = -99 for r_i = 3 to 30; levs(r_i) = 2**((r_i-3)/2); end inname r_na; inclass r_imcl; inseq r_imseq; indisk r_disk keyword='naxis3'; gethead; zinc=keyvalue(1)/16 zinc = max(1,zinc); blc(3) = max(1,zinc/2) r_info('KNTR'); if (r_error = 0) then dotv -1; runwait ('KNTR'); r_chkerr = r_imseq; end else type 'ERROR MAKING IMAGE PLOTS, COULD NOT FIND IMAGE FILE' r_chkerr = -error end RETURN; FINISH PROCEDURE R_HTMLPUT (R_LINE) *--------------------------------------------------------------- * pipes contents of r_line to r_outdir file vlbapipe.html *--------------------------------------------------------------- default system; sys2com = r_line, ' >>'; syscom 'echo sys2com(4) = r_outdir; sys2com(5) = 'vlbapipe.html system RETURN; FINISH PROC R_PLOTFILE (R_NA,R_IMCL,R_SQ,R_BR,R_PVER,R_IVER,R_PLABEL) *--------------------------------------------------------------- * for catalog file r_na, r_imcl, r_sq and plot file versions * r_pver through r_iver makes PostScript files then gif files * with name r_outdir plus r_label and plot file number * R_BR controls whether the first plot is to the left or not * Non-call parameters: r_dir, r_outdir, r_disk, r_dohtml *--------------------------------------------------------------- STRING*10 R_SUBST SCALAR R_DOBR r_dobr = r_br; if (r_dobr=0) then; r_dobr=-1; end default 'LWPLA'; inname = r_na; inclass = r_imcl; inseq = r_sq; indisk=r_disk; r_subst = substr(r_plabel,1,10) docolor 1; plcolors 0; plcolors(1,10)~0.88 0.88 0.88 if (r_plabel='RFLAG') then; r_tvcolr; end for r_i = r_pver to r_iver; outfile = r_fdir !! r_subst !! char(r_i) !! '.ps plver=r_i; runwait('LWPLA') if (r_cnvrt<>'') then default system; syscom r_cnvrt sys2com(1) = r_outtmp sys2com(2) = r_subst !! char(r_i) !! '.ps sys2com(3) = r_outdir sys2com(4) = r_subst !! char(r_i) !! '.gif system default system; syscom '\rm sys2com(1) = r_outtmp sys2com(2) = r_subst !! char(r_i) !! '.ps system if (r_dohtml>0) then; r_line(2)='>"' if (r_dobr) then r_line(1)=' "
0) then; VBA_NFQI = VBA_NFQI + 1; end if (VBA_9050 > 0) then; VBA_NFQI = VBA_NFQI + 1; end RETURN; FINISH PROCEDURE R_GETSUROW *--------------------------------------------------------------- * get number of sources in source table * output: r_row *--------------------------------------------------------------- inext 'SU'; invers 0; keyword'NUM ROW'; getthead; r_row = keyvalue(1); RETURN; FINISH PROCEDURE R_EXIT *--------------------------------------------------------------- * Restore initial values before exiting proc *--------------------------------------------------------------- vnumber = 36-getpopsn; vget vlbapipe; dowait -1 RETURN; FINISH PROCEDURE R_GETUVF *--------------------------------------------------------------- * Determine UV file class to work on * Inputs: r_ondisk (=1 -> known, else find) * r_expna, r_disk * proc sets r_class, inclass * also r_expna, r_seq, r_disk when =1 *--------------------------------------------------------------- if (r_ondisk<>1) then inname r_expna; inseq 0; indisk r_disk; intype 'UV'; inclass 'FXPOL'; nameget if (error = 0) then; r_class inclass $ dual polarization, one frequency else; inseq 0 inclass = 'FPOL' !! char(r_frequid); nameget; * dual pols and multi freq with new outclass if (error = 0) then r_class inclass; inclass 'FQ-'!!char(r_frequid); r_zapall; recat else; inseq=0 inclass 'FQ-'!!char(r_frequid); nameget; * polarizations okay, multiple freqs if (error = 0) then; r_class inclass * polarizations okay, single frequency else; r_class 'UVDATA' end end end inclass r_class; inseq 0; nameget; r_seq=inseq if (error) then; r_error = 33; end else r_class = r_incl; r_expna = r_inna; r_seq = r_inseq r_disk = r_indi end RETURN; FINISH PROCEDURE R_WCHSCAN *--------------------------------------------------------------- * Uses BSCAN task with file r_expna, r_incl, r_seq, r_disk * goes through r_numcal list of r_calsourc * Sets: r_calscant *--------------------------------------------------------------- print 'CALLING R_WCHSCAN' r_found = -1; r_i = 1 while ((r_found=-1) & (r_i<=r_numcal)) default BSCAN; inname r_expna; inclass r_incl inseq r_seq; indisk r_disk; docalib 1; invers = r_invers sources(1) = r_calsourc(r_i); runwait('BSCAN') * check return values if (chansel(3,1)=r_numant) then; r_found = r_i; else if(chansel(3,1)<>0) then type r_calsourc(r_i)!!':' r_scr = char(chansel(3,1))!!' OUT OF ' substr(r_scr, length(r_scr)+2, 66) = char(r_numant) type r_scr !! ' ANTENNAS FOUND' end; end r_i=r_i+1 end if (r_found<0) then; r_error = 7 type 'CANNOT FIND GOOD CALIBRATOR SCAN WITH ALL ANTENNAS' type 'PLEASE SET TIMERANG' end if (r_error=0) then; if ((chansel(1,1)-chansel(2,1))>0.0021) then chansel(1,1) = chansel(2,1)-0.0021; end r_calscant(1) = floor (chansel(1,1)) r_calscant(5) = floor (chansel(2,1)) r_calscant(2) = floor ((chansel(1,1)-r_calscant(1))*24) x = chansel(1,1) - (r_calscant(2)/24+r_calscant(1)) r_calscant(3) = floor (x*1440) x = r_calscant(3)/1440 + r_calscant(2)/24 + r_calscant(1) r_calscant(4) = floor ((chansel(1,1)-x) *86400) r_calscant(6) = floor ((chansel(2,1)-r_calscant(5))*24) x = chansel(2,1) - (r_calscant(6)/24 + r_calscant(5)) r_calscant(7) = floor (x*1440) x = r_calscant(7)/1440 + r_calscant(6)/24 + r_calscant(5) r_calscant(8) = floor ((chansel(2,1)-x)*86400) end RETURN; FINISH PROCEDURE R_LOAD *--------------------------------------------------------------- $ Load data and split freq-id's to prepare for VLBA pipeline $ NOTE: proc sets VBA_NFQI *--------------------------------------------------------------- if ((r_ldfile > 0) & (r_error=0)) then $ start loading data douvcomp = -1; doconcat = -1 r_info('VLBALOAD'); if (r_error = 0) then; vlbaload; recat; type 'DONE WITH LOADING THE DATA' * check one freq id, does not check for S/X or 90/50 inext = 'FQ'; invers = 1; keyword = 'NUM ROW'; getthead if (KEYVALUE(1)>1) then; r_error=70; type 'MORE THAN ONE FREQID - QUITTING' type 'SEPARATE FREQIDS (RUN VLBAFIX)' type 'RUN VLBAPIPE ON EACH SEPARATELY else r_info('VLBAFIX'); if (r_error = 0) then; vlbafix; end end; inname=outname; inclass='UVDATA'; inseq 1; indisk outdisk r_inna= inname; r_incl=inclass; r_inseq=inseq; r_indi=indisk end end RETURN; FINISH PROCEDURE R_PRECHECK *--------------------------------------------------------------- * Prepare and check inputs for VLBA pipeline * NOTE: proc sets r_dotimer and r_dostart *--------------------------------------------------------------- * clear messages default clrmsg; clrmsg * check datain or inname if (substr(r_datain,1,1) <> ' ') then; r_ldfile = 1; end if (substr(r_inna,1,1) <> ' ' & r_inseq > 0) then; r_ondisk = 1; end if (r_ondisk = 1 & substr(r_incl,1,1) <> ' ')then r_ondisk = 1 r_disk=r_indi else r_ondisk = -1 end if (r_ldfile = 1 & r_ondisk = 1) then type 'SPECIFY DATAIN OR INNAME NOT BOTH' r_error=1 end if (r_ldfile < 0 & r_ondisk < 0) then type 'NO DATA?: SPECIFY DATAIN OR INNAME' r_error=1 end $ check data file is pristine, only one CL table, no SN tables $ and set the outnames etc because that is how the the script $ was originally written if (r_error=0 & r_ondisk = 1) then if (maxtab('CL')>1) then; r_error=60; end if (maxtab('SN')>0) then; r_error=60; end if (r_error=60) then; type 'PARTIALLY CALIBRATED DATA - STOPPING'; type 'USE R_RESTART TO CLEAR THIS STATUS'; else eprint=3000; getitime; r_inttim=inttime; eprint=0 end end $ check one freq id, does not check for S/X or 90/50 if (r_error=0 & r_ondisk = 1) then inext = 'FQ'; invers = 1; keyword = 'NUM ROW'; getthead if (keyvalue(1)>1) then; r_error=70; type 'MORE THAN ONE FREQID - QUITTING' type 'SEPARATE FREQIDS (RUN VLBAFIX)' type 'RUN VLBAPIPE ON EACH SEPARATELY end end $ check outname, outdisk if (substr(r_expna,1,1)=' ' & substr(r_inna,1,1)<>' ' ) then r_expna = r_inna; else if (substr(r_expna,1,1)=' ' & substr(r_inna,1,1)=' ') then type 'SPECIFY AN UNIQUE OUTNAME OR INNAME' r_error = 4; end end if (r_disk = 0 & r_indi > 0) then; r_disk = r_indi; else if (r_disk = 0 & r_indi = 0) then type 'SPECIFY AN OUTDISK OR INDISK'; r_error = 4; end end r_load $ load file if needed keyword 'USERNO'; gethead; r_userno = keyval(1) $ FUTURE check if outfile already exists - r_restart or bomb?? $ FUTURE check outdisk ? * check invers (Pulse cal file) if (r_invers=0) then; r_invers=1;end * spectral line data or continuum data to be expected? if (r_mode = 'LINE') then; r_mode = 'SPEC'; end; r_fqinfo if (r_mode = '' & r_nchan < 65) then; r_mode='CONT'; end if (r_mode = '' & r_nchan >= 65) then; r_mode='SPEC'; end if (r_error=0) then if (r_mode = 'SPEC') then type 'DOING SPECTRAL LINE PROCEDURE: ' type 'NO PULSE CAL OR FREQUENCY AVERAGING WILL BE DONE' else if (r_mode = 'CONT') then type 'DOING CONTINUUM PROCEDURE:' type 'WITH PULSE CAL AND FREQUENCY AVERAGING' else if (r_mode = 'PSEU') then type 'DOING PSEUDO CONTINUUM PROCEDURE: with'; if (r_invers>0) then type 'PULSE CAL BUT *NO* FREQUENCY AVERAGING' else type 'FRING BUT *NO* FREQUENCY AVERAGING' end else r_error = 1 type 'OBSERVATION MODE NOT KNOWN' type 'FILL IN "OPTYPE" PROPERLY' end end end end $ check if clcor for delzn is wanted if (length(r_infi)>0) then; r_doaplyd = 1; end $ check if html directory and/or e-mail is wanted if (length(r_email) > 0) then; r_doemail = 1; end if (r_doemail>0) then r_email= 'X'!!r_email; substr(r_email,1,1)=' '; end if (length(r_dir) > 0) then; r_dohtml=1; end if (r_dohtml>0) then x = length(r_dir) if (substr(r_dir,x,x)<>':') then if (substr(r_dir,x,x)<>'/') then substr(r_dir,x+1,x+1)='/'; end end if (length(r_dir)>34) then type 'OUTFILE IS TOO LONG, LIMIT IS 34 CHARACTERS' r_error = 13; end r_outdir= 'X' !! r_dir; substr(r_outdir,1,1)=' ' x = length (r_outdir) if (substr(r_outdir,x,x)=':') then r_outdir= 'X$'!!r_dir; substr(r_outdir,1,1)=' '; substr(r_outdir,length(r_outdir),length(r_outdir))='/'; end r_outtmp = r_outdir; format=1; getdate; format 0 r_date=substr(thedate,3,9)!!substr(thedate,11,14)!!'/' clrtemp r_outdir=r_outdir!!r_date if (length(r_outdir)>34) then r_fdir = r_dir; r_long=1 else r_long=-1 r_fdir = r_dir !! r_date; x = length(r_dir); if (substr(r_dir,x,x)=':') then r_outtmp = 'X$' !! substr(r_dir,1,x-1) !! '/' r_outtmp = r_outtmp !! r_date else r_outtmp = 'X'!!r_fdir; end substr(r_outtmp,1,1)=' '; end if (length(r_outdir)>45); then type 'OUTPUT DIRECTORY LIMITED TO 35 CHARACTERS' type '(INCLUDING FINAL /) HINT: IF DESIRED OUTPUT' type 'DIRECTORY PATH LONGER THAN 31 CHAR USE AN type 'ENVIRONMENTAL VARIABLE AND DESIGNATE WITH A ":".' type 'SEE EXPLAIN VLBAPIPE. outdir ends up as type r_outdir r_error = 13;end if (r_error = 0) then default system; syscom 'mkdir sys2com(1) = r_outdir; system if (error > 0) then type 'CANNOT MAKE OUTPUT DIRECTORY FOR PLOTS R_error = 13; end end * check if convert command exists if ((r_dopl > 0) & (r_dopl < 0.5)) then r_cnvrt = ' ' else default system; syscom 'which convert r_cnvrt='convert system; if (error > 0) then * check if magick command exists type 'ERROR: Cannot create plots for output html type 'files because the command convert type 'is not on your computer.. type 'PostScript files will be saved, not in html r_cnvrt = '' end end * check and create html file if (r_error=0) then default system r_line(1) = ' "VLBAPIPE output r_line(2) = '
" r_htmlput(r_line) r_line(1) = ' "

VLBAPIPE output for: substr(r_line(1),27,66) = r_inna!!'.'!!r_incl!!'.' r_line(2)=char(r_seq)!!'

" r_htmlput(r_line) r_line(1)=' "

User number = r_line(2)=char(r_userno)!!'

" r_htmlput(r_line) r_line(1)=' "

Local time = format = 0; getdate r_line(2) = thedate !! '

" r_htmlput(r_line) r_line(1)=' "

Message log r_line(2)='

" r_htmlput(r_line) r_line(1)=' "See for the message log" r_htmlput(r_line) end end * record inputs if (r_error=0) then invers=r_invers; doprint=-9; inputs vlbapipe default prtmsg; outprint=r_fdir!!'messages.txt filezap outprint $ kill pre-existing one docrt=-3; prtmsg; clrmsg end invers=0; doprint=0 * check reasonable clint -- very loose, default is 0.25 if (r_error=0) then; if (r_clint=0) then; r_clint=0.25; type 'CLINT set to 0.25 end if (r_clint < 0) then; type 'CLINT<0 UNVALID -- STOPPING' r_error=12; end if ((r_obsfq>10.e9) & (r_clint> 2)) then; r_error = 10 type 'CLINT IS TOO LARGE FOR YOUR FREQ' type ' RESET CLINT AND START AGAIN' else if ((r_obsfq<10.e9) & (r_clint> 4)) then; r_error = 10 type 'CLINT IS TOO LARGE FOR YOUR FREQ' type 'RESET CLINT AND START AGAIN' end end clint = r_clint end * check refant $ FUTURE check if refant in array, get number of antennas if (r_error=0) then; r_antnum = antnum (r_refant) if (r_antnum = 0) then; type 'REFANT not set, will try to set a default end if (r_antnum = 0) then; r_antnum = antnum('FD'); end if (r_antnum = 0) then; r_antnum = antnum('PT'); end if (r_antnum = 0) then; r_antnum = antnum('LA'); end if (r_antnum = 0) then; r_antnum = antnum('KP'); end if (r_antnum = 0) then; r_error=11; type 'NO ANTENNA IN THE SOUTHWEST' type 'PLEASE SET REFANT AND START AGAIN' end if (r_error<>11) then type 'REFANT SET TO ANTENNA #', r_antnum end refant = r_antnum end if (r_error=0) then; inext 'AN'; keyword 'NUM ROW'; getthead r_numant = keyval(1) * check timerange and corresp scantime * if no timerang then auto-set i = 1 * if timer(2) or above non-zero, timer is specified (not scan) while (i < 8) i = i + 1; if (r_calscant(i) > 0) then r_dotimer = 1; r_found=1;end end if ((r_dotimer > 0) & (r_error = 0)) then type 'USING SPECIFIED TIMERANGE FOR VLBAPCOR or MPCL' i = r_calscant(5) - r_calscant(1) i = r_calscant(6) - r_calscant(2) + 24 * i i = r_calscant(7) - r_calscant(3) + 60 * i if ((r_calscant(8) - r_calscant(4) + 60 * i) < 1) then type 'ENDING TIME PRECEEDS STARTING TIME - TRY AGAIN r_error = 6 end else if (r_calscant(1) = 0) then r_dotimer=2 else type 'USING SPECIFIED SCAN NUMBER INSTEAD OF TIMERANGE' end end end * check later if in data * count number of sources in calsour, do self-cal ? r_numcal = 0; i = 0; while (i < 30); i = i + 1 if (substr(r_calsourc(i),1,1) <> ' ') then r_numcal = r_numcal + 1 if (substr(r_calsourc(i),1,1) = '-') then j = length(r_calsourc(i)) r_calsourc(i) = substr(r_calsourc(i),2,j) $ if (substr(r_calsourc(i),1,1) = '*') then $ type 'SORRY HAVE TO EXIT: NO SELF CAL ALLOWED' $ type 'FOR CALSOUR = *' $ r_error = 12 $ end $ r_no_slfcl(i) = 0 $ else;r_no_slfcl(i) = 1 end end end * count number of sources targeted (incl its Ph-Ref.) r_numref = 0; i = 0; while (i < 30) ; i=i+1 if (substr(r_atargets(i),1,1)<>' ') then r_numref = r_numref+1; end end * use calsour only (only strong sources, no Ph-Ref) if (r_error=0) then; if (r_numref = 0) then type 'No phase-ref scheme specified type 'Assuming all sources are strong if (r_numcal = 0) then type 'AT LEAST ONE CALSOURCE NEEDED' type 'FOR P-CAL and BANDPASS CALIBRATION' r_error = 8 else if (substr(r_calsourc(2),1,1)='*') then if (r_ctask<>'CALIB') then type 'Will fringe fit all sources that are found else type 'Will CALIB all sources that are found end type 'in the SU table else if (r_ctask<>'CALIB') then type 'Will fringe fit all sources in CALSOUR else type 'Will CALIB all sources in CALSOUR end type 'I.E. :'!!char(r_numcal) end end end * if sources, check if r_numref even (pairs), borrow r_num for * loop. Check later if in data, but here check if odd numbers * are in calsource if (substr(r_atargets(1),1,1) <> ' ') then if (mod(r_numref,2) = 1) then $ odd number of sources type 'ODD NUMBER SOURCES - SPECIFY PHAS-REF *PAIRS* r_error = 8 * check if odd numbered are in calsour, evens not in calsour else for i = 1 to r_numref by 2 r_num = 0 for j = 1 to r_numcal if (r_atargets(i)=r_calsourc(j)) then; r_num = j; end end end if (r_num=0) then type 'CALSOUR DOES NOT, BUT SHOULD, INCLUDE type 'PHASE REF (CAL) SOURCE :'!! r_atargets(i) r_error 9 end for i = 2 to r_numref by 2 r_num = 0 for j = 1 to r_numcal if (r_atargets(i)=r_calsourc(j)) then; r_num = j; end end if (r_num<>0) then type 'CALSOUR DOES, BUT SHOULD NOT, INCLUDE' type 'PHase-REF (target) SOURCE:'!!r_atargets(i) r_error = 9 end end r_numref = r_numref / 2 $ # of pairs if ((r_numref = 1) & (r_atargets(2) = '*')) then type 'Phase-referencing all non-calibrators type 'to :' !! r_atargets(1) end end end * are sources in SU table? if (r_error=0) then; if (r_calsourc(2)<>'*') then jj = r_numcal else jj = 1; end; ii = 0 for i = 1 to jj; r_getsurow; keystrng = '' while ((r_row>0) & (r_calsour(i)<>keystrng)) inext'SU'; pixxy r_row 2 0; tabget if (r_calsour(i) = keystrng) then $ found r_row = -1; r_error = 0 else; r_row = r_row - 1; r_error = 31 end end if (r_error<>0) then r_scr = 'COULD NOT FIND' substr(r_scr,16,66) = r_calsour(i)!!' IN DATA FILE' type r_scr; ii = r_error end end r_error = ii end if ((r_error=0) & (r_numref>0) & (r_atargets(2)<>'*')) then; ii = 0; for i = 1 to r_numref; r_getsurow; keystrng = '' while ((r_row>0) & (r_atargets(2*i)<>keystrng)) inext'SU'; pixxy r_row 2 0; tabget if (r_atargets(2*i)=keystrng) then $ found r_row = -1; r_error = 0 else; r_row = r_row - 1; r_error = 32 end end if (r_error<>0) then r_scr = 'COULD NOT FIND' substr(r_scr,16,66) = r_atargets(2*i)!!' in DATA' type r_scr; ii = r_error end end r_error = ii end * check solint $ FUTURE add check on other valid solints? if (r_error=0) then; if (r_solint<0) then; type 'SOLINT<0 INVALID: STOPPING'; r_error = 10; end if (r_solint=0) then; r_solint=1;end * check map sizes for factor and imsize if (r_factor < 1 & r_imsize(1) >= 0) then; r_factor = 1 type 'WILL NOT DO CALSOUR IMAGES SMALLER THAN 128' else if (r_factor > 64) then; r_factor = 64 type 'CALSOUR IMAGE REQUEST TOO BIG' type 'WILL USE THE MAXIMUM OF 8192 SQUARE'; end end if (substr(r_atargets(1),1,1)<>' ' & r_imsize(1)>=0) then if ( (r_imsize(1) < 512) ! (r_imsize(2) < 512) ) then; r_imsize(1) = max (512, r_imsize(1)) r_imsize(2) = max (512, r_imsize(2)) type 'WILL NOT DO SOURCES IMAGES SMALLER THAN 512' else if ((r_imsize(1) > 8192) ! (r_imsize(2) > 8192)) then r_imsize(1) = min (8192, r_imsize(1)) r_imsize(2) = min (8192, r_imsize(2)) type 'SOURCE IMAGE REQUEST TOO BIG' type 'WILL USE THE MAXIMUM OF 8192 SQUARE' end end end $ include subarray , change into vlbafix ?? r_plcnt(1) = maxtab('PL') * Check there is a scan can be found if timer is left blank r_getuvf end if((r_error = 0) & (r_dotimer = 2)) then; r_wchscan; end if (r_debug > 0) then; type 'R_PRECHECK ERROR = '!!char(r_error);end end RETURN; FINISH PROCEDURE R_BPASS *--------------------------------------------------------------- * Do VLBABPSS (BPASS) *--------------------------------------------------------------- if (r_error=0) then task 'VLBABPSS'; calsour r_calsourc(1),''; solint=bpsolint bpver 1; flux 0; timerang 0; antenna 0; refant = r_antnum calcode ''; invers 0; ncomp 0; nmaps 0; smodel 0; bpass5 = r_bpass5; in2disk=r_bpdisk; nmaps=r_bpmaps in2name = r_bpname; in2class=r_bpclas; in2seq=r_bpseq; r_info('VLBABPSS'); if (r_error = 0) then; vlbabpss; aparm 0 1 .5 1.3,-20 20 0 2 1 0 i = maxtab('SN');j = maxtab('CL') if (r_dopl>0) then r_plcnt(10) = maxtab('PL') r_possm(r_expna,r_seq,j,r_doband,0,6,-1,calsour(1),2) r_plcnt(11) = maxtab('PL'); j = r_plcnt(11); i = r_plcnt(10) if (r_dohtml>0) then r_line(1)=' "

Bandpass solutions

r_line(2)='"'; r_htmlput(r_line) r_plotfile (inname,r_class,r_seq,1,i+1,j,'BANDPASS') end end end; nmaps=0; clr2name end RETURN; FINISH PROCEDURE R_UVFLG *--------------------------------------------------------------- * runs UVFLG to absorb INTEXT *--------------------------------------------------------------- print 'INTEXT =' !! r_intext !! 'not blank? default 'UVFLG'; inname=r_expna; inclass=r_class; inseq=r_seq; indisk=r_disk; intext=r_intext; outfgver=1 r_info('UVFLG'); if (r_error = 0) then runwait('UVFLG'); end RETURN; FINISH PROCEDURE R_TYSMO *--------------------------------------------------------------- * Runs TYSMO on the data set *--------------------------------------------------------------- if (r_smolev > 0) then default tysmo; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; dobtween=-1; flagver=0 inext 'ty'; invers=1; aparm(1)=r_smolev/20 aparm(6) = r_smolev; samptype='box'; bparm=15,0 cparm=10,0,0,0,0,r_smolev/10 r_info('TYSMO'); if (r_error=0) then runwait('TYSMO') end end RETURN; FINISH PROCEDURE R_ELEVFG *--------------------------------------------------------------- * Runs UVFLG for elevation *--------------------------------------------------------------- if (r_elev > 0) then default uvflg; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; aparm = 0, r_elev outfgver = maxtab('FG') r_info('UVFLG'); if (r_error=0) then runwait('UVFLG') end end RETURN; FINISH PROCEDURE R_CLIP *--------------------------------------------------------------- * runs CLIP on MS file *--------------------------------------------------------------- if (r_error=0) then default 'clip'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; docalib 1 if (r_doclip(1) > 0) then; doband=r_doband; end aparm = abs(r_doclip(1)),abs(r_doclip(2)),0; aparm(9)=0.3 bparm = 1,0; r_info('CLIP'); if (r_error=0) then runwait('CLIP'); end end RETURN; FINISH PROCEDURE R_LISUN *--------------------------------------------------------------- * Put LISUN data set summary in the output messages *--------------------------------------------------------------- if (r_dohtml>0) then default lisun inname=r_expna; inclass=r_class; inseq=r_seq; indisk=r_disk; docrt=-3; outprint=r_fdir!!'messages.txt r_info('LISUN'); if (r_error = 0) then; go lisun; end end RETURN; FINISH PROCEDURE R_INSTCAL *--------------------------------------------------------------- * Amplitude and instrumental phase calibration per freq-id * NOTE: proc sets VBA_PAIR *--------------------------------------------------------------- if (r_error<>0) then; RETURN; end r_getuvf $ find uvfile to work on inname=r_expna; inclass=r_class; inseq r_seq; indisk=r_disk if (r_error<>0) then; RETURN; end if (tecrfile <> '-') then r_info('VLBATECR'); if (r_error = 0 & r_obsfq<12.e9) then; vlbatecr; r_clcnt(1) = maxtab('CL'); if (tecrfile=' ') then default system; syscom 'rm /tmp/jpl* system default system; syscom 'rm /tmp/emr* system end end end if (r_error<>0) then; RETURN; end if (eopsfile <> '-') then r_info('VLBAEOPS'); if (r_error = 0) then; vlbaeops; r_clcnt(2) = maxtab('CL'); end end r_info ('VLBAPANG'); if (r_error = 0) then vlbapang;clrtemp; j = maxtab('CL'); r_clcnt(3) = j; end if (r_error = 0 & r_intext<>'') then; r_uvflg; end if (r_error = 0 & r_smolev > 0) then; r_tysmo; end if (r_error = 0 & r_elev > 0) then; r_elevfg; end * amplitude cal (Walker method) if (r_error=0) then r_info('VLBACCOR'); if (r_error=0) then vlbaccor; i = maxtab('SN');j = maxtab('CL') r_clcnt(4) = j if (r_dopl>1.5) then r_snplot(r_expna, r_seq, 'SN', i, 'AMP', 0,0, 8) if (r_error=0) then; r_plcnt(2) = maxtab('PL'); if (r_dohtml>0) then; r_line(1)=' "

SN table after ACCOR

r_line(2)='"'; r_htmlput(r_line); i = r_plcnt(1)+1; j = r_plcnt(2) r_plotfile(r_expna,r_class,r_seq,1,i,j,'ACCOR_SN') end end j = maxtab('CL') r_snplot(r_expna, r_seq, 'CL', j, 'AMP', 0,0, 8) if (r_error=0) then r_plcnt(3) = maxtab('PL'); i = r_plcnt(3); j = r_plcnt(2)+1 if (r_dohtml>0) then; r_line(1)=' "

CL table after ACCOR

r_line(2)='"'; r_htmlput(r_line); r_plotfile(r_expna,r_class,r_seq,1,j,i,'ACCOR_CL') end end end if (r_dotimer = 0)then; timerang = scantime(r_calscant(1)); end if (r_dotimer = 1) then; timerang = r_calscant; end if (r_dotimer = 2) then; timerang = r_calscant; end if (r_found > 0) then; calsour r_calsour(r_found),'' else; calsour = ' '; end gainuse 0; docalib 2; doband -1; opcode ''; inext'FQ' invers 1; keyword = 'NO_IF';getthead; * if only 1 IF then no need to align IFs if (keyvalue(1) > 1) then refant = r_antnum; j = maxtab('PC') if ((r_mode = 'SPEC') & (j > 0)) then type 'WEIRD: FOUND A PC TABLE IN MODE SPEC' type 'WILL NOT USE IT ANYWAY' end if ((r_mode<>'SPEC') & (j>0) & (r_invers>-0.5)) then r_info('VLBAPCOR'); if(r_error = 0) then invers=r_invers; vlbapcor; end * spectral-line or pccor not wanted;do manual pcal else r_info('VLBAMPCL'); if (r_error = 0) then vlbampcl; end end i = maxtab('SN'); j = maxtab('CL'); r_clcnt(5) = j; aparm 0, 1, 0, 0, -180, 180, 0 0 3 if ((r_dopl>0) & (r_error=0)) then r_plcnt(4) = maxtab('PL') r_possm(r_expna,r_seq,j,-1,0,9,-1,calsour(1),0) r_plcnt(5) = maxtab('PL') if (r_dohtml>0) then; r_line(1)=' "

Instrumental Phase Cals

r_line(2)='"'; r_htmlput(r_line); i = r_plcnt(4)+1 j = r_plcnt(5) r_plotfile(r_expna,r_class,r_seq,1,i,j,'INSTRCAL') end end end if (r_doclip(1)<0) then; r_clip; end $ outseq r_frequid;outclass '';runwait('TASAV') end end r_plcnt(6) = maxtab('PL'); RETURN; FINISH PROCEDURE R_BPAMP *--------------------------------------------------------------- * adds BPASS, ACSCL, APCAL corrections *--------------------------------------------------------------- $ ??????? if (r_doband >= 0) then; r_bpass; end r_info('VLBAAMP'); if (r_error = 0) then vlbaamp; ii = maxtab('SN'); jj = maxtab('CL') r_clcnt(8) = jj; r_clcnt(7) = jj-1 if (r_dopl>1.5) then r_snplot(r_expna,r_seq,'SN',ii-1,'AMP', 0, 0, 8) if (r_error=0) then r_plcnt(12) = maxtab('PL'); if (r_dohtml>0) then r_line(1)=' "

SN table after ACSCL

r_line(2)='"'; r_htmlput(r_line); i = r_plcnt(11)+1; j = r_plcnt(12) r_plotfile(r_expna,r_class,r_seq,1,i,j,'ACSCL_SN') end end r_snplot (r_expna,r_seq,'SN',ii,'AMP',0,0,8) if (r_error=0) then r_plcnt(13) = maxtab('PL'); if (r_dohtml>0) then; r_line(1)=' "

SN table after APCAL

r_line(2)='"'; r_htmlput(r_line); i = r_plcnt(12)+1; j = r_plcnt(13) r_plotfile(r_expna,r_class,r_seq,1,i,j,'APCAL_SN') end end end if ((r_dopl>0) & (r_error=0)) then r_plcnt(13) = maxtab('PL') $ in case r_dopl=1 r_snplot(r_expna, r_seq, 'CL', jj-1, 'AMP', 0, 0, 8) if (r_error=0) then r_plcnt(14) = maxtab('PL'); if (r_dohtml>0) then r_line(1) = ' "

CL table after ACSCL

r_line(2) = '"'; r_htmlput(r_line); i = r_plcnt(13)+1; j = r_plcnt(14) r_plotfile (r_expna,r_class,r_seq,1,i,j,'ACSCL_CL') end end r_snplot(r_expna, r_seq, 'CL', jj, 'AMP', 0, 0, 8) if (r_error=0) then r_plcnt(15) = maxtab('PL'); if (r_dohtml>0) then r_line(1) = ' "

CL table after APCAL

r_line(2) = '"'; r_htmlput(r_line); i = r_plcnt(14)+1; j = r_plcnt(15) r_plotfile(r_expna,r_class,r_seq,1,i,j,'APCAL_CL') end end end end RETURN; FINISH PROCEDURE R_APPLYD *--------------------------------------------------------------- * adds DELZN corrections with CLCOR *--------------------------------------------------------------- source ''; stokes ''; timer 0; gainv = 0; gainu = 0 opcode 'ATMO'; clcorprm 0; infile = r_infi; r_info('CLCOR'); if (r_error = 0) then runwait('CLCOR') r_clcnt(9) = maxtab('CL') type 'CL #'!!char(r_clcnt(9)) !! ' adds DELZN corrections end return;finish PROC R_VLBAFRNG *--------------------------------------------------------------- * fringe fit a dataset using FRING and then apply the * corrections using CLCAL. * Input adverbs: * INNAME file name * INCLASS file class * INSEQ file sequence number * INDISK disk number * CALSOUR calibrator source * TIMERANG time range * BCHAN lowest channel * ECHAN highest channel * GAINUSE CL table to use * REFANT reference antenna * SEARCH prioritized reference antenna list * SOLINT solution interval * DPARM FRING DPARMS * SOURCES sources to calibrate in CLCAL * INTERPOL interpolation method to use * BADDISK bad disk *--------------------------------------------------------------- SCALAR VBA_OK, VBA_CL, VBA_NMS vba_nms = 0; vba_ok = 1; vnumber = 36-getpopsn; vput vlbafrng if (gainuse=0) then; gainuse = maxtab('cl'); end vput vlbafrng for i = 1 to 30 if (source(i)<>'') then vba_nms = vba_nms + 1 end end if (vba_ok>=0) then type 'run fring'; clrtemp default 'fring'; vget vlbafrng; task = 'fring' clrtemp if (search(1)<>0) then aparm(9) = 1; end clrtemp $ aparm(6) = 1 if (maxtab('bp')>0) then; doband = r_doband; bpver = maxtab('bp'); end chinc = min(r_chinc, 1); if (chinc<0) then chinc=findchin; end docalib 2; runwait('FRING') chinc = r_chinc * SNSMO the result rates if ((smrates(1)) & (r_error=0)) then default 'snsmo'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; dobtween=-1 samptype='box'; bparm=0,0,smrates(1); smotype='vlbi' cparm=0; cparm(3)=smrates(2); cparm(8)=smrates(3); invers=maxtab('sn'); r_info('SNSMO'); if r_error = 0 then runwait('SNSMO'); end end if (r_error=0) then type 'RUN CLCAL'; default 'clcal'; vget vlbafrng task 'clcal'; vba_cl = maxtab('cl')+1 if ((interpol='self') ! (sources(1) = '')) then gainver gainuse; gainuse=vba_cl; snver=maxtab('SN') runwait('CLCAL') else $$$ manual self for i = 1 to vba_nms vget vlbafrng; task 'clcal'; gainver gainuse; gainuse vba_cl; calsour = source(i), '' source = source(i),''; snver = maxtab('SN') runwait('CLCAL') end end vba_clas = 'SN #' !! char(snver) type vba_clas!!' contains fringe solns for sources in calsour vba_clas = 'CL #' !! char(vba_cl) type vba_clas !! ' adds fringe solns for sources in sources vnumber=36-getpopsn; vget vlbafrng; vput vlbafrng end end return; finish PROCEDURE R_FRING *--------------------------------------------------------------- * Runs FRING on cal sourses, CLCAL on phase ref sources * First do all clcals on calsources, then the pairs *--------------------------------------------------------------- * all sources if (substr(r_calsourc(2),1,1)='*') then calsour ''; sources ''; r_getsurow; r_numcal = r_row * includes phase-refs, not targets else calsour r_calsourc; sources r_calsourc end * search = 0 $ better make sure solutions exist search = antnum('PT'),antnum('LA'),antnum('KP'),antnum('FD') search(5)~antnum('OV'), antnum('NL'), antnum('BR') search(8)~antnum('NH'), antnum('SC'), antnum('MK') bchan 0; interpol r_interpol; aparm(6) 1; aparm(9) 1 baddisk r_baddisks; solint = r_solint; dparm(8) 0; if (r_inttim>0) then; dparm(4)=r_inttim; end refant = r_antnum; timer=0 r_info('VLBAFRNG'); if (r_error = 0) then r_vlbafrng; gainuse = maxtab('CL') vnumber= 36-getpopsn; vput clcal $ -- for phase-ref * sources not empty, not all if ((r_numref>0) & (r_atargets(2)<>'*') & (r_error=0)) then * vlbafrng did all cals, now do the pairs * print messes with the for loop * this statement needed and the separation print 'Doing phase reference targets for i = 1 to r_numref * pair observed in this freq-ID vget clcal; interpol r_interpol; sources r_atargets(2*i), '' calsour r_atargets(2*i-1), '' if (r_error=0) then r_info('CLCAL'); if (r_error = 0) then runwait('CLCAL'); vput clcal end end end for i = 1 to r_numref sources r_atargets(2*i), '' calsour r_atargets(2*i-1), '' r_scr = '**' !! calsour(1) r_scr = r_scr !!': used to phase-reference : type r_scr !! source(1) !!'**' end end if ((r_atargets(2) = '*') & (r_error=0)) then vget clcal; interpol r_interpol calsour r_atargets(1), '' for i = 1:r_numcal; sources(i) = '-'!!r_calsourc(i); end r_info('CLCAL'); if (r_error = 0) then runwait('CLCAL') r_scr = '** ALL NON-CALIBRATORS PHASE-REFERENCED' type r_scr !! ' TO :'!!calsour(1)!!'**' end end ii = maxtab('SN'); jj = maxtab('CL'); r_clcnt(6) = jj if ((r_dopl>1.5) & (r_error=0)) then r_snplot(inname, r_seq, 'SN', ii, 'PHAS', -180, 180, 8) r_snplot(inname, r_seq, 'SN', ii, 'DELA', 0, 0, 8) r_snplot(inname, r_seq, 'SN', ii, 'RATE', 0, 0, 8) r_snplot(inname, r_seq, 'SN', ii, 'SNR', 0, 0, 8) if (r_error=0) then r_plcnt(7) = maxtab('PL'); if (r_dohtml>0) then; r_scr = ' "

Phase, delay, rate, snr in SN table r_line(1) = r_scr !! ' after r_line(2) =' FRING

"'; r_htmlput(r_line) i = r_plcnt(6)+1; j = r_plcnt(7) r_plotfile (r_expna,r_class,r_seq,1,i,j,'FRING_SN') end end r_snplot(inname, r_seq, 'CL', jj, 'AMP', 0, 0, 8) if (r_error=0) then r_plcnt(8) = maxtab('PL'); if (r_dohtml>0) then; r_line(1) = ' "

Amplitude in CL table after r_line(2) = ' FRING

"'; r_htmlput(r_line) i = r_plcnt(7)+1; j = r_plcnt(8) r_plotfile(r_expna,r_class,r_seq,1,i,j,'FRAMr_CL') end end end if ((r_dopl>0) & (r_error=0)) then r_plcnt(8) = maxtab('PL') $ in case r_dopl=1 r_snplot(inname, r_seq, 'CL', jj, 'PHAS', -180, 180, 8) r_snplot(inname, r_seq, 'CL', jj, 'DELA', 0, 0, 8) r_snplot(inname, r_seq, 'CL', jj, 'RATE', 0, 0, 8) if (r_error=0) then r_plcnt(9) = maxtab('PL'); if (r_dohtml>0 )then; r_scr = ' "

Phase, delay, rate in CL table r_line(1) = r_scr!!' after FRING

r_line(2) = '"'; r_htmlput(r_line) i = r_plcnt(8)+1; j = r_plcnt(9) r_plotfile (r_expna,r_class,r_seq,1,i,j,'FRING_CL') end end for i=1 to r_numref by 2; j = maxtab ('CL') r_vplot(r_expna,r_seq,j,r_doband,0, 9, 0.5, r_atarget(i)) end if (r_error=0) then r_plcnt(10) = maxtab('PL') if (r_dohtml>0)then; r_line(1)=' "

Phases of phase calibrator(s) with r_line(2)=' last CL table applied

" r_htmlput(r_line); i = r_plcnt(9)+1; j = r_plcnt(10) r_plotfile (r_expna,r_class,r_seq,1,i,j,'PHASECAL') end end end end RETURN; FINISH PROCEDURE R_CALIB *--------------------------------------------------------------- * Runs CALIB on cal sourses, CLCAL on phase ref sources * First do all clcals on calsources, then the pairs *--------------------------------------------------------------- default calib; r_getuvf $ find uvfile to work on inname=r_expna; inclass=r_class; inseq r_seq; indisk=r_disk * all sources if (substr(r_calsourc(2),1,1)='*') then calsour ''; sources ''; r_getsurow; r_numcal = r_row * includes phase-refs, not targets else calsour r_calsourc; sources r_calsourc end docalib=1; doband=r_doband; bchan 0; interpol r_interpol baddisk=r_baddisks; solint=r_solint; refant=r_antnum; solmode='p'; aparm(6) 1; r_info('CALIB'); if (r_error = 0) then runwait('CALIB'); gainuse = maxtab('CL') type 'RUN CLCAL'; default 'clcal'; vget calib task 'clcal'; vba_cl = maxtab('cl')+1 gainver maxtab('cl'); gainuse=vba_cl; snver=maxtab('SN') r_info('CLCAL'); if (r_error=0) then; runwait('CLCAL') vba_clas = 'SN #' !! char(snver) type vba_clas!!' contains CALIB solns vba_clas = 'CL #' !! char(vba_cl) type vba_clas !! ' adds CALIB solns ii = maxtab('SN'); jj = maxtab('CL'); r_clcnt(6) = jj end if ((r_dopl>1.5) & (r_error=0)) then r_snplot(inname, r_seq, 'SN', ii, 'PHAS', -180, 180, 8) if (r_error=0) then r_plcnt(7) = maxtab('PL'); if (r_dohtml>0) then; r_scr = ' "

Phase in SN table r_line(1) = r_scr !! ' after r_line(2) =' CALIB

"'; r_htmlput(r_line) i = r_plcnt(6)+1; j = r_plcnt(7) r_plotfile (r_expna,r_class,r_seq,1,i,j,'FRING_SN') end end r_snplot(inname, r_seq, 'CL', jj, 'AMP', 0, 0, 8) if (r_error=0) then r_plcnt(8) = maxtab('PL'); if (r_dohtml>0) then; r_line(1) = ' "

Amplitude in CL table after r_line(2) = ' CALIB

"'; r_htmlput(r_line) i = r_plcnt(7)+1; j = r_plcnt(8) r_plotfile(r_expna,r_class,r_seq,1,i,j,'FRAMr_CL') end end end if ((r_dopl>0) & (r_error=0)) then r_plcnt(8) = maxtab('PL') $ in case r_dopl=1 r_snplot(inname, r_seq, 'CL', jj, 'PHAS', -180, 180, 8) if (r_error=0) then r_plcnt(9) = maxtab('PL'); if (r_dohtml>0 )then; r_scr = ' "

Phase in CL table r_line(1) = r_scr!!' after FRING

r_line(2) = '"'; r_htmlput(r_line) i = r_plcnt(8)+1; j = r_plcnt(9) r_plotfile (r_expna,r_class,r_seq,1,i,j,'FRING_CL') end end for i=1 to r_numref by 2; if (r_error=0) then j = maxtab ('CL') r_vplot(r_expna,r_seq,j,r_doband,0, 9, 0.5, r_atarget(i)) end end if (r_error=0) then r_plcnt(10) = maxtab('PL') if (r_dohtml>0)then; r_line(1)=' "

Phases of phase calibrator(s) with r_line(2)=' last CL table applied

" r_htmlput(r_line); i = r_plcnt(9)+1; j = r_plcnt(10) r_plotfile (r_expna,r_class,r_seq,1,i,j,'PHASECAL') end end end end RETURN; FINISH PROCEDURE R_RFLAG *--------------------------------------------------------------- * runs RFLAG on MS file one source at a time *--------------------------------------------------------------- STRING*1 R_CALS, R_TARGS SCALAR R_RFL default 'rflag'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; doband r_doband; docalib 1; r_gstok; dotv=-1; if (r_mode<>'SPEC') then avgchan 11; fparm=3,1,-1,-1,0,1; fparm(17)=0.3; j=12 else avgchan = 0; fparm=3,1,-1,0,0,1; fparm(17)=0.8; j = 4 end if (r_inttim>0) then; fparm(2)=r_inttim; end fparm(18)=1; r_cals = substr(r_calsourc(2),1,1) r_targs = substr(r_atargets(2),1,1) if (r_dohtml>0) then r_line(1)=' "

RFLAG plots

r_line(2)='"'; r_htmlput(r_line); end * all sources in SU if ((r_cals='*') ! (r_targs='*')) then r_getsurow; inext='SU' for r_rfl = 1 to r_row pixxy = r_rfl, 2 0; tabget; source=keystrng,'' doplot = J; if (r_error = 0) then ii = maxtab('PL') + 1; type 'SOURCE :'!!source(1)!!' BEING RFLAGed NOW r_info('RFLAG'); if (r_error=0) then runwait('RFLAG'); doplot=-J; runwait('RFLAG') if ((r_dopl>0) & (r_dohtml>0)) then; jj = maxtab('PL'); r_plcnt(16)=jj r_plotfile (inname,inclass,inseq,1,ii,jj,'RFLAG') end end end end * one at a time else avgchan 11; fparm=3,1,-1,-1,0,1; fparm(17)=0.3; j=12 fparm(18)=1 ; ii = maxtab('PL') + 1; if (r_inttim>0) then; fparm(2)=r_inttim; end for r_rfl = 1 to r_numcal source=r_calsourc(r_rfl),''; doplot=J if (r_error=0) then type 'SOURCE :'!!source(1)!!' BEING RFLAGed NOW r_info('RFLAG'); if (r_error=0) then runwait('RFLAG'); doplot=-J; runwait('RFLAG') end end end if (r_mode='SPEC') then avgchan = 0; fparm=3,1,-1,0,0,1; fparm(17)=0.8; j = 4 end fparm(18)=1 if (r_inttim>0) then; fparm(2)=r_inttim; end if (r_numref > 0) then for r_rfl = 1 to r_numref source=r_atargets(2*r_rfl),''; doplot=J if (r_error=0) then type 'SOURCE :'!!source(1)!!' BEING RFLAGed NOW r_info('RFLAG'); if (r_error=0) then runwait('RFLAG'); doplot=-J; runwait('RFLAG') end end end end if ((r_dopl>0) & (r_dohtml>0) & (r_error=0)) then; jj = maxtab('PL'); r_plcnt(16)=jj r_plotfile (inname,inclass,inseq,1,ii,jj,'RFLAG') end end RETURN; FINISH PROCEDURE R_SPLIT *--------------------------------------------------------------- * Split data for this frequency ID *--------------------------------------------------------------- task 'SPLIT'; outdisk indisk; sources''; doband r_doband bpver=maxtab('BP'); gainuse 0; douvcomp=-1; stokes='' timerang 0; outseq = r_frequid; outclass substr(r_expna,1,6) keyword'NAXIS3'; gethead; bchan 1; echan keyvalue(1); nchav 0 * pseudo cont or spectral line, no freq averaging r_scr = 'VERAGED IN SINGLE SOURCE DATA' if (r_mode <> 'CONT') then aparm 0; type char(echan)!!' CHANNELS KEPT UNA' !! r_scr else $ continuum, grab all together aparm 2 0; type char(echan)!!' CHANNELS A' !! r_scr end aparm(6)=1; chinc=1; r_info('SPLIT'); if (r_error=0) then; runwait('SPLIT');end; RETURN; FINISH PROCEDURE R_SETCELL (R_TYP) *--------------------------------------------------------------- * NOTE: sets cellsize, bchan, echan and nchav for imagr *--------------------------------------------------------------- SCALAR R_FRQ inext'FQ'; invers 1; r_frq = 0 keyword='NO_IF'; getthead; r_ifs=keyv(1) for x=1:r_ifs pixxy = 1,2,x; tabget; r_frq=max(r_frq,keyvalue(1)) end keyword'CRVAL3'; gethead; r_frq=r_frq+keyvalue(1) cellsize 2.25e6 / r_frq bchan 1; echan 1; nchav 1 if (r_typ <> 'CONT') then $ spec cube or otf-avg channels keyword'NAXIS3'; gethead; echan = keyvalue(1); if (r_typ = 'PSEU') then; bchan = ceil(echan/12); echan = echan+1-bchan; nchav = echan-bchan+1; chinc = nchav else $ skip few channels if (r_typ = 'SPEC') then bchan = ceil(echan/12); echan = echan+1-bchan; if (bchan = 1) then; bchan = 2; end else type 'CANNOT DETERMINE IMAGE PARAMETERS' r_error = 15 end end end; RETURN; FINISH PROCEDURE R_SCMAP(J) *--------------------------------------------------------------- * run IMAGR (NOT SCMAP) on calibrators *--------------------------------------------------------------- default 'IMAGR'; imsize 128*r_factor; niter 1500; flux 1e-4 uvwtfn'NA'; imagrp(10) 1; inseq r_frequid; outseq r_frequid outdisk r_disk; intype'UV'; stokes 'I'; im2parm 1,0 overlap 2 for i = 1 to r_numcal if (substr(r_calsourc(2),1,1)='*') then r_getuvf; inname=r_expna; inclass=r_class; inseq r_seq indisk=r_disk inext'SU';pixxy i 2 0; tabget; inname keystrng else; inname r_calsourc(i);end inclass substr(r_expna,1,6); INSEQ 0; clrtemp intype 'uv'; chkname; stokes 'I' * always continuum image of strong sources (if > 10 vis) if ((r_error=0) & (error < 1)) then r_setcell('PSEU'); timerang 0; keyword'GCOUNT'; gethead if ((keyvalue(1) > 10) & (r_error = 0)) then type 'CALIBRATOR :'!!inname!!' BEING IMAGED NOW' r_info('IMAGR'); if r_error = 0 then runwait('IMAGR'); end kk = 0; bb=0 if ((r_dopl > 0) & (r_error=0)) then; r_uvplot(inname, inclass, inseq) imsize 128*r_factor; kk = maxtab('PL'); r_plcnt(17) = max(0,r_plcnt(17))+kk r_kntr (inname,r_imcl,r_chkerr); inclass=r_imcl inseq = r_chkerr if (r_chkerr>0) then bb=maxtab('PL'); r_plcnt(18)=max(0,r_plcnt(18))+bb;end end if (r_dohtml>0 & kk>0 & r_error=0) then; if (i=1) then r_line(1)=' "

Final UVPLTs and Images

r_line(2)='"'; r_htmlput(r_line); end inclass substr(r_expna,1,6); inseq=0 if (i<10) then r_scr = 'UVPCAL0'!!char(i); ii=kk r_plotfile (inname,inclass,inseq,1,1,ii,r_scr) if (bb>0) then r_scr = 'IMACAL0'!!char(i); ii=bb r_plotfile(inname,'ICL001',r_chkerr,0,1,ii,r_scr) end else inseq=0 r_scr = 'UVPCAL'!!char(i); ii=kk r_plotfile (inname,inclass,inseq,1,1,ii,r_scr) if (bb>0) then r_scr = 'IMACAL'!!char(i); ii=bb r_plotfile(inname,'ICL001',r_chkerr,0,1,ii,r_scr) end end end end end end clrtemp; for i = 1 to r_numcal if (substr(r_calsourc(2),1,1)<>'*') then inname r_calsourc(i);inclass'SCMAP'; r_zapall inclass'IBM001'; inseq 0; indisk r_disk; intype'MA' r_zapall inclass'RBM001'; r_zapall; inclass'LBM001'; r_zapall else inseq 0; inext 'SU'; r_getuvf; inname=r_expna inclass=r_class; inseq r_seq; indisk=r_disk pixxy i 2 0; tabget; inname keystrng inclass'IBM001'; inseq 0; intype'MA'; indisk r_disk r_zapall inclass'RBM001'; r_zapall; inclass'LBM001'; r_zapall end intype'UV' end clrtemp; recat RETURN; FINISH PROCEDURE R_IMAGR *--------------------------------------------------------------- * images phase ref targets *--------------------------------------------------------------- imsize r_imsize; outc''; doband=-1; im2parm 1,0; nbox 0 boxfile ''; oboxfi ''; outvers 0 if (r_numref > 0) then if (substr(r_atargets(2),1,1)='*') then inname r_expna; inclass 'UVDATA'; r_getsurow r_numref = r_row-r_numcal; r_sq=1 end for i = 1 to r_numref if (substr(r_atargets(2),1,1)='*') then j = 0; r_getuvf; inname=r_expna inclass=r_class; inseq r_seq; indisk=r_disk inext'SU' while ((r_sq<=r_row) & (j<>17)) pixxy r_sq 2 0; tabget; r_num = 1; j = length(keystrng) $ max 12 while ((j<17) & (r_num<=r_numcal)) if (r_calsourc(r_num)=keystrng) then j = 17; r_sq = r_sq + 1 $ found else r_num = r_num + 1;end end if (j <> 17) then; inname keystrng; j = 17 r_sq = r_sq + 1; end end else inname r_atargets(2*i) end inseq r_frequid; outseq r_frequid; intype 'uv' inclass substr(r_expna,1,6); chkname if ((r_error=0) & (error < 1)) then r_setcell(r_mode); timerang 0; keyword'GCOUNT' gethead; stokes 'I'; channel 0 if ((keyvalue(1) > 10) & (r_error = 0)) then type 'TARGET :'!!inname!!' BEING IMAGED NOW' if ((nchav<>1) ! (echan=1)) then r_info('IMAGR'); if r_error=0 then runwait('IMAGR'); end kk = 0; bb=0 if ((r_error=0) & (r_dopl > 0)) then; r_uvplot (inname, inclass, inseq) imsize r_imsize; kk = maxtab('PL') r_plcnt(19)=max(0,r_plcnt(19))+kk r_kntr(inname, inclass,r_chkerr) inclass=r_imcl; inseq=r_chkerr if (r_chkerr>0) then; bb=maxtab('PL'); r_plcnt(20)=max(0,r_plcnt(20))+bb; end if (r_dohtml>0 & kk>0) then; inclass substr(r_expna,1,6) if (i<10) then r_scr = 'UVPTAR0'!!char(i) j = kk; inseq 0 r_plotfile(inname,inclass,inseq,1,1,j,r_scr) if (bb>0) then r_scr = 'IMATAR0'!!char(i) j = bb r_plotfile(inname,'ICL001',r_chkerr,0,1,j,r_scr) end else r_scr = 'UVPTAR'!!char(i) j = kk; inseq 0 r_plotfile(inname,inclass,inseq,1,1,j,r_scr) if (bb>0) then r_scr = 'IMATAR'!!char(i) j = bb r_plotfile(inname,'ICL001',r_chkerr,0,1,j,r_scr) end end end end else if ((r_error=0) & (r_dopl > 0)) then r_uvplot (inname, inclass, inseq) imsize r_imsize; kk=maxtab('PL'); r_plcnt(19)=r_plcnt(19)+kk if (r_dohtml>0 & kk>0) then; inclass substr(r_expna,1,6) if (i<10) then r_scr = 'UVPTAR0'!!char(i) else r_scr = 'UVPTAR'!!char(i) end j=kk; inseq 0 r_plotfile(inname,inclass,inseq,1,1,j,r_scr) end end niter 1000; flux 1e-3; stokes='I'; bb = -1 for bif=1 to r_ifs inclass substr(r_expna,1,6) inseq 0; eif=bif; r_info('IMAGR'); if (r_error=0) then runwait('IMAGR'); end if ((r_error=0) & (r_dopl > 0)) then r_kntr(inname, inclass, r_chkerr) if (r_chkerr>0) then; bb=maxtab('PL') r_plcnt(20)=r_plcnt(20)+bb; end if (r_dohtml>0 & bb>0) then; if (i<10) then r_scr = 'IMATAR0'!!char(i) else r_scr = 'IMATAR'!!char(i) end r_scr = r_scr !! char(bif) j = bb r_plotfile(inname,'ICL001',r_chkerr,bb,1,j,r_scr) end end end if (r_dopl>0) then inclass=r_imcl; inseq=r_chkerr; end end end end end inseq = 0; intype = 'MA'; indisk outdisk for i = 1 to r_numref inname r_atargets(2*i); inclass'?BM001'; r_zapall * inclass'RBM001'; r_zapall; inclass'LBM001';r_zapall end recat end RETURN; FINISH PROCEDURE R_SELFCAL *--------------------------------------------------------------- * runs IMAGR to image calibration sources * then runs FRING to slef-cal each cal source * then SNSMO to limit rates * finally CLCAL *--------------------------------------------------------------- default 'imagr'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; doband r_doband; docalib 1; imsize 128*r_factor; niter 1500; flux 1e-4 uvwtfn'NA'; imagrp(10) 1; outdisk r_disk; intype'UV'; stokes 'I'; im2parm 1,0; overlap 2 * image the cals for i = 1 to r_numcal if (substr(r_calsourc(2),1,1)='*') then r_getuvf; inname=r_expna inclass=r_class; inseq r_seq; indisk=r_disk inext'SU';pixxy i 2 0; tabget; srcname keystrng else; srcname r_calsourc(i);end r_setcell('PSEU'); outname = srcname type 'CALIBRATOR : '!!srcname!!' BEING IMAGED NOW' r_info('IMAGR'); if r_error = 0 then runwait('IMAGR'); end end * fringe the cals if (r_ctask='FRING') then; default 'fring'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; search = antnum('PT'),antnum('LA'),antnum('KP') search(4)~antnum('FD'),antnum('OV'),antnum('NL') search(7)~antnum('BR'),antnum('NH'), antnum('SC') search(10)=antnum('MK'); aparm(9)=1 else; default 'calib'; solmode='p'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; end doband r_doband; docal 1; bchan 0; interpol r_interpol; aparm(6) 1; baddisk r_baddisks; solint = r_solint; dparm(8) 0; if (r_inttim>0) then; dparm(4)=r_inttim; end refant = r_antnum; snver = maxtab('sn')+1 nmaps 1; in2class 'icl001'; in2disk r_disk; chinc = min(r_chinc, 1); if (chinc<0) then chinc=findchin; end for i = 1 to r_numcal if (substr(r_calsourc(2),1,1)='*') then r_getuvf; inname=r_expna inclass=r_class; inseq r_seq; indisk=r_disk inext'SU';pixxy i 2 0; tabget; calsour keystrng,'' else; calsour r_calsourc(i),'';end in2name=calsour(1) if (r_ctask='FRING') then type 'CALIBRATOR : '!!in2name!!' BEING FRINGed NOW r_info('FRING'); if r_error = 0 then runwait('FRING'); end else type 'CALIBRATOR : '!!in2name!!' BEING CALIBed NOW r_info('CALIB'); if r_error = 0 then runwait('CALIB'); end end end; chinc = r_chinc * SNSMO the result rates if ((smrates(1)) & (r_ctask='FRING')) then default 'snsmo'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; dobtween=-1 samptype='box'; bparm=0,0,smrates(1); smotype='vlbi' cparm=0; cparm(3)=smrates(2); cparm(8)=smrates(3); invers=maxtab('sn'); r_info('SNSMO'); if r_error = 0 then runwait('SNSMO'); end end * CLCAL the cals default 'clcal'; inname=r_inna; inclass=r_incl; inseq=r_inseq; indisk=r_indi; interpol = r_interpol snver = maxtab('SN'); gainver=maxtab('CL'); gainuse=gainver+1 r_clcnt(10) = gainuse * all sources if (substr(r_calsourc(2),1,1)='*') then calsour ''; sources ''; r_getsurow; r_numcal = r_row * includes phase-refs, not targets else calsour r_calsourc; sources r_calsourc end vput vlbafrng; vba_nms=0 for i = 1 to 30 if (sources(i)<>'') then vba_nms = vba_nms + 1 end end if ((interpol='self') ! (sources(1) = '')) then r_info('CLCAL'); if r_error = 0 then runwait('CLCAL'); end else $$$ manual self for i = 1 to vba_nms vget vlbafrng; task 'clcal'; calsour = source(i), '' source = source(i),''; snver = maxtab('SN') r_info('CLCAL'); if r_error = 0 then runwait('CLCAL'); end end end * CLCAL the targets gainuse = maxtab('CL') vnumber= 36-getpopsn; vput clcal $ -- for phase-ref * sources not empty, not all if ((r_numref>0) & (r_atargets(2)<>'*')) then * vlbafrng did all cals, now do the pairs * print messes with the for loop * this statement needed and the separation print 'Doing phase reference targets for i = 1 to r_numref * pair observed in this freq-ID vget clcal; interpol r_interpol; sources r_atargets(2*i), '' calsour r_atargets(2*i-1), '' r_info('CLCAL'); if (r_error = 0) then runwait('CLCAL'); vput clcal end end end if (r_atargets(2) = '*') then vget clcal; interpol r_interpol calsour r_atargets(1), '' for i = 1:r_numcal; sources(i) = '-'!!r_calsourc(i); end r_info('CLCAL'); if (r_error = 0) then runwait('CLCAL') r_scr = '** ALL NON-CALIBRATORS PHASE-REFERENCED' type r_scr !! ' TO :'!!calsour(1)!!'**' end end RETURN; FINISH PROCEDURE R_REPORT *--------------------------------------------------------------- * Report on tables and plots made *--------------------------------------------------------------- if (r_dohtml>0) then r_line(1)=' "

Summary of the CL tables produced by *--------------------------------------------------------------- r_line(2)=' vlbapipe:

" r_htmlput(r_line) r_line(1)=' "CL#1: Input CL table r_line(2)='
" r_htmlput(r_line); r_line(2) = ' correction added
" if (r_clcnt(1) > 0) then r_line(1) =' "CL#'!!char(r_clcnt(1))!!': Ionospheric r_htmlput(r_line); end if (r_clcnt(2) > 0) then r_line(1)=' "CL#'!!char(r_clcnt(2))!!': EOP r_htmlput(r_line); end if (r_clcnt(3) > 0) then r_scr = char(r_clcnt(3)) r_line(1)=' "CL#'!!r_scr!!': Parallactic angle r_htmlput(r_line); end if (r_clcnt(4) > 0) then r_line(1)=' "CL#'!!char(r_clcnt(4))!!': Sampler r_htmlput(r_line); end; if (r_clcnt(5) > 0) then r_line(1)=' "CL#'!!char(r_clcnt(5))!!': Instr Phase-cal r_htmlput(r_line); end; r_line(2) = ' added
" if (r_clcnt(6) > 0) then if (r_ctask<>'CALIB') then r_line(1) = ' "CL#'!!char(r_clcnt(6))!!': Fringe fit else r_line(1) = ' "CL#'!!char(r_clcnt(6))!!': CALIB end r_htmlput(r_line); end if (r_clcnt(7) > 0) then r_scr = char(r_clcnt(7)) r_line(1)=' "CL#'!!r_scr!!': Post-BPASS sampler r_htmlput(r_line); end if (r_clcnt(8) > 0) then r_line(1)=' "CL#'!!char(r_clcnt(8))!!': Gain amplitude r_htmlput(r_line); end if (r_clcnt(9) > 0) then r_line(1)=' "CL#'!!char(r_clcnt(9))!!': DELZN r_htmlput(r_line); end if (r_clcnt(10) > 0) then if (r_ctask<>'FRING') then r_line(1) = ' "CL#'!!char(r_clcnt(10))!!': CALIB else r_line(1) = ' "CL#'!!char(r_clcnt(10))!!': Fringe fit end r_line(2) = ' self-cal added (final table)
" r_htmlput(r_line); end end clrtemp if ((r_dohtml>0) & (r_dopl > 0)) then r_line(1)=' "

Summary of the PL tables produced by r_line(2)=' vlbapipe:

" r_htmlput(r_line) if (r_dopl > 1.5) then r_line(1) = ' "'!! char(r_plcnt(1)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(2)) r_line(2) = ' Sampler corrections in SN
" r_htmlput(r_line); r_line(1) =' "'!! char(r_plcnt(2)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(3)) r_line(2) = ' Sampler corrections added to CL
" r_htmlput(r_line); end r_line(1) = ' "' !! char(r_plcnt(4)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(5)) r_line(2) = ' (Manual?) P-cal
" r_htmlput(r_line); if (r_dopl > 1.5) then r_line(1) =' "'!! char(r_plcnt(6)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(7)) if (r_ctask<>'CALIB') then r_line(2) = ' Fringe-fit solutions in SN
" else r_line(2) = ' CALIB solutions in SN
" end r_htmlput(r_line); r_line(1) =' "'!! char(r_plcnt(7)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(8)) r_line(2) = ' Amp in CL table
" r_htmlput(r_line); end r_line(1) =' "'!!char(r_plcnt(8)+1)!!'-'!!char(r_plcnt(9)) r_line(2) = ' CL table before bandpass
" r_htmlput(r_line); r_line(1) =' "' !! char(r_plcnt(9)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(10)) r_line(2) = ' Phase after cal
" r_htmlput(r_line); r_line(1) = ' "' !! char(r_plcnt(10)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(11)) r_line(2) = ' Bandpass corrections
" r_htmlput(r_line); if (r_dopl > 1.5) then r_line(1) =' "' !! char(r_plcnt(11)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(12)) r_line(2) = ' post-BPASS sampler corr in SN
" r_htmlput(r_line); r_line(1) = ' "' !! char(r_plcnt(12)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(13)) r_line(2) = ' Gain corrections in SN
" r_htmlput(r_line); end r_line(1) = ' "' !! char(r_plcnt(13)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(14)) r_line(2) = ' Post-BPASS samp corr in CL
" r_htmlput(r_line); r_line(1) = ' "' !! char(r_plcnt(14)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(15)) r_line(2) = ' Gain correction added to CL
" r_htmlput(r_line); if (r_doflag>0) then r_line(1) = ' "' !! char(r_plcnt(15)+1)!!'-' r_line(1) = r_line(1) !! char(r_plcnt(16)) r_line(2) = ' RFLAG before and after plots
" r_htmlput(r_line); end r_line(2) = '
" if (r_plcnt(17)>0) then r_line(1) = ' "' !! char(r_plcnt(17)) r_line(1) = r_line(1)!!' Calibrator UV file plots r_htmlput(r_line); r_line(1) = ' "' !! char(r_plcnt(18)) r_line(1)=r_line(1)!!' Calibrator image file plots r_htmlput(r_line); end if (r_plcnt(19)>0) then r_line(1) = ' "' !! char(r_plcnt(19)) r_line(1) = r_line(1) !! ' Target UV file plots r_htmlput(r_line); r_line(1) = ' "' !! char(r_plcnt(20)) r_line(1) = r_line(1) !! ' Target image file plots r_htmlput(r_line); end end type ' ' type 'SUMMARY OF THE CL-TABLES PRODUCED FOR THIS DATA:' type ' ' type 'CL-1 : Input CL table if (r_clcnt(1) > 0) then r_scr = char(r_clcnt(1)) type 'CL-'!!r_scr!!' : Ionospheric correction added end if (r_clcnt(2) > 0) then r_scr = char(r_clcnt(2)) type 'CL-'!!r_scr!!' : EOP correction added end if (r_clcnt(3) > 0) then r_scr = char(r_clcnt(3)) type 'CL-'!!r_scr!!' : Parallactic angle correction added end if (r_clcnt(4) > 0) then r_scr = char(r_clcnt(4)) type 'CL-'!!r_scr!!' : Sampler corrections added end if (r_clcnt(5) > 0) then r_scr = char(r_clcnt(5)) type 'CL-'!!r_scr!!' : Instr. Phase-cal added end if (r_clcnt(6) > 0) then r_scr = char(r_clcnt(6)) if (r_ctask<>'CALIB') then type 'CL-'!!r_scr!!' : Fringe fit added else type 'CL-'!!r_scr!!' : CALIB solution added end end if (r_clcnt(7) > 0) then r_scr = char(r_clcnt(7)) type 'CL-'!!r_scr!!' : Post-BPASS sampler cor added end if (r_clcnt(8) > 0) then r_scr = char(r_clcnt(8)) type 'CL-'!!r_scr!!' : Gain corrections added end if (r_clcnt(9) > 0) then r_scr = char(r_clcnt(9)) type 'CL-'!!r_scr!!' : DELZN corrections added end if (r_clcnt(10) > 0) then r_scr = char(r_clcnt(10)) if (r_ctask<>'FRING') then type 'CL-'!!r_scr!!' : Fringe self-cal added - final CL table else type 'CL-'!!r_scr!!' : CALIB self-cal added - final CL table end end type ' ' if (r_dopl > 0) then $ report about plots made type 'Plots have been produced for this frequency-ID: type ' ' if (r_dopl > 1.5) then r_scr = char(r_plcnt(1)+1)!!'-'!!char(r_plcnt(2)) type r_scr!!' Sampler corrections in SN r_scr = char(r_plcnt(2)+1)!!'-'!!char(r_plcnt(3)) type r_scr !!' Sampler corrections added to CL end r_scr = char(r_plcnt(4)+1)!!'-'!!char(r_plcnt(5)) type r_scr!!' (Manual?) P-cal if (r_dopl > 1.5) then r_scr = char(r_plcnt(6)+1)!!'-'!!char(r_plcnt(7)) if (r_ctask<>'CALIB') then type r_scr!!' Fringe-fit solutions in SN else type r_scr!!' CALIB solutions in SN end r_scr = char(r_plcnt(7)+1)!!'-'!!char(r_plcnt(8)) type r_scr!!' Amp in CL table end r_scr = char(r_plcnt(8)+1)!!'-'!!char(r_plcnt(9)) type r_scr!!' CL table before bandpass r_scr = char(r_plcnt(9)+1)!!'-'!!char(r_plcnt(10)) type r_scr!!' Phases after cal r_scr = char(r_plcnt(10)+1)!!'-'!!char(r_plcnt(11)) type r_scr!!' Bandpass corrections if (r_dopl > 1.5) then r_scr = char(r_plcnt(11)+1)!!'-'!!char(r_plcnt(12)) type r_scr!!' post-BPASS sampler corr in SN r_scr = char(r_plcnt(12)+1)!!'-'!!char(r_plcnt(13)) type r_scr!!' Gain corrections in SN end r_scr = char(r_plcnt(13)+1)!!'-'!!char(r_plcnt(14)) type r_scr!!' Post-BPASS samp corr in CL r_scr = char(r_plcnt(14)+1)!!'-'!!char(r_plcnt(15)) type r_scr!!' Gain correction added to CL if (r_doflag>0) then r_scr = char(r_plcnt(15)+1)!!'-'!!char(r_plcnt(16)) type r_scr!!' RFLAG before and after plots end if (r_plcnt(17)>0) then r_scr = char(r_plcnt(17))!!' Calibrator UV file plots r_scr = char(r_plcnt(18))!!' Calibrator image file plots end if (r_plcnt(19)>0) then r_scr = char(r_plcnt(19))!!' Target UV file plots r_scr = char(r_plcnt(20))!!' Target image file plots end type ' ' end RETURN; FINISH PROCEDURE VLBAPIPE *--------------------------------------------------------------- $ $ Do whole VLBA pipeline *--------------------------------------------------------------- * inputs vlbapipe type '======================================================= r_init; r_precheck; type '-------------------------' if (r_error = 0) then; r_lisun; end if (r_error = 0) then; r_instcal; end if (r_error = 0 & r_doaplyd > 0) then; r_applyd; end if (r_error = 0) then; if (r_ctask='CALIB') then; r_calib else; r_fring; end end if (r_error = 0) then; r_bpamp; end if (r_error = 0 & r_doclip(1) > 0) then; r_clip; end if (r_error = 0 & r_doflag > 0) then; r_rflag; end if (r_doflag <= 0 ! r_doflag >= 10) then if (r_error = 0 & selfcal > 0) then; r_selfcal; end if (r_error = 0) then; r_split; end if (r_error = 0 & r_factor>0) then; r_scmap(1); end if (r_error = 0 & r_imsize(1)>0) then; r_imagr; end end if (r_error = 0) then; r_report; end if (r_error = 0) then if (r_dohtml>0) then r_line(2)=''; r_line(1)=' "" r_htmlput(r_line) if (r_doemail>0) then default system; sysout= '/tmp/r_tempmail syscom 'echo "From: sys2com(1) = r_email ; sys2com(2) = '"'; system; syscom 'echo "To: sys2com(1) = r_email; system; syscom 'echo "Subject: sys2com(1) = ' VLBAPIPE DONE : sys2com(2) = 'X'!!r_expna!!'.'!!r_incl!!'.' sys2com(2) = sys2com(2)!!char(r_seq)!!'"' substr(sys2com(2),1,1) = ' ' ; system; syscom 'echo "X-Mailer: AIPS VLBAPIPE report" sys2com = ''; system syscom= 'echo "VLBAPIPE is done, please review your sys2com(1) = ' plots at jj = length(r_dir) if (substr(r_dir,jj,jj)=':') then sys2com(2)='"'; system syscom 'echo "file://" sys2com(1)=substr(r_outdir,2,length(r_outdir)) sys2com(2) ='"vlbapipe.html" else sys2com(1)= ' plots at file:// sys2com(2)= substr(r_dir,1,jj)!!r_date sys2com(3)= 'vlbapipe.html" end system; default system syscom= 'cat /tmp/r_tempmail | sendmail -f daip@nrao.edu sys2com(1) = r_email; system; sys2com = '' syscom= '\rm /tmp/r_tempmail system end * print messages default prtmsg; outprint=r_fdir!!'messages.txt docrt=-3; prtmsg; if (r_long) then; default system; syscom='mv sys2com(1) = r_outtmp!!'messages.txt sys2com(2) = r_outdir system end end if (r_doemail>0 & r_dohtml<0) then default system; sysout= '/tmp/r_tempmail syscom 'echo "From: sys2com(1) = r_email ; sys2com(2) = '"'; system; syscom 'echo "To: sys2com(1) = r_email; system; syscom 'echo "Subject: sys2com(1) = ' VLBAPIPE done : sys2com(2) = 'X'!!r_expna!!'.'!!r_incl!!'.' sys2com(2) = sys2com(2)!!char(r_seq)!!'"' substr(sys2com(2),1,1) = ' ' ; system; syscom 'echo "X-Mailer: AIPS VLBAPIPE report" sys2com = ''; system syscom = 'echo " sys2com(1) = 'VLBAPIPE finished okay but sys2com(2) = ' " system syscom = 'echo " sys2com(1) = 'OUTFILE not set so there is no html system syscom 'echo " " sys2com = ' ' system; sysout='' syscom= 'cat /tmp/r_tempmail | sendmail -f daip@nrao.edu sys2com(1) = r_email system;sys2com = '' syscom= '\rm /tmp/r_tempmail system end * type '' type 'USE R_ALLPLOT(X) TO PLOT FROM PL-VERSION X ON TV' type '' r_scr = 'PROCEDURE DONE, THANK YOU FOR CHOOSING' type r_scr!!' AIPS FOR YOUR BUSINESS' * send e-mail saying procedure has failed else if (r_doemail>0) then default system; sysout= '/tmp/r_tempmail syscom 'echo "From: sys2com(1) = r_email ; sys2com(2) = '"'; system; syscom 'echo "To: sys2com(1) = r_email; system; syscom 'echo "Subject: sys2com(1) = ' VLBAPIPE FAILED : sys2com(2) = 'X'!!r_expna!!'.'!!r_incl!!'.' sys2com(2) = sys2com(2)!!char(r_seq)!!'"' substr(sys2com(2),1,1) = ' ' ; system; syscom 'echo "X-Mailer: AIPS VLBAPIPE error report" sys2com = ''; system syscom = 'echo " sys2com(1) = 'Error # '!! char(r_error) !!' occurred sys2com(2) = ' " system syscom = 'echo " sys2com(1) = 'Please review your inputs and try again system syscom 'echo " " sys2com = ' ' system; sysout='' syscom= 'cat /tmp/r_tempmail | sendmail -f daip@nrao.edu sys2com(1) = r_email system;sys2com = '' syscom= '\rm /tmp/r_tempmail system end type 'ERROR #'!! char(r_error) !!' OCCURRED' type 'PLEASE REVIEW YOUR INPUTS AND TRY AGAIN' end; type '======================================================= vget vlbapipe; r_exit RETURN; FINISH *--------------------------------------------------------------- * revision EWG October 31, 2025 * Use R_RESTART to initialize the data file R_DEBUG = 0 $ can be set to true in the interactive AIPS window