$ VLBAMPHC $--------------------------------------------------------------- $! Applies VLBARUN calibration to another phase-stopping center $# RUN POPS VLBI UTILITY CALIBRATION IMAGING $--------------------------------------------------------------- $; Copyright (C) 2019, 2023 $; 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 $--------------------------------------------------------------- PROCEDURE C_INIT $ $ Define variables above and beyond VLBARUN $ Assume all of VLBARUN is defined docrt 1; dowa true SCALAR C_DISK, C_SEQ, C_DOUVC STRING*6 C_CLASS STRING*12 C_NAME $ from input dialog: $--------------------------------------------------------------- P_DATAIN = DATAIN ; P_EXPNA = OUTNAME P_DISK = OUTDISK ; P_INNA = INNAME P_INCL = INCLASS ; P_INSEQ = INSEQ P_INDI = INDISK ; P_MODE = OPTYPE C_NAME = IN2NAME ; C_CLASS = IN2CLASS C_SEQ = IN2SEQ ; C_DISK = IN2DISK C_DOUVC = DOUVCOMP ; P_IMSIZE = IMSIZE P_DOPL = DOPLOT ; P_DIR = OUTFILE P_EMAIL = OUTTEXT ; P_BADDISKS = BADDISK P_DOFLAG = DOFLAG ; P_DOCLIP = DOCLIP $--- P_ERROR = 0; P_DOHTML = -1 if (p_imsize(1)=0) then; p_imsize=512; end $--- save inputs 2 places task 'VLBAMPHC'; tput; vnumber=36-getpopsn; vput RETURN; FINISH PROCEDURE C_HTMLPUT (P_LINE) *--------------------------------------------------------------- * pipes contents of p_line to p_outdir file vlbamphc.html *--------------------------------------------------------------- default system; sys2com = p_line, ' >>'; syscom 'echo sys2com(4) = p_outdir; sys2com(5) = 'vlbamphc.html system RETURN; FINISH PROC C_PLOTFILE (P_NA,P_IMCL,P_SQ,P_BR,P_PVER,P_IVER,P_PLABEL) *--------------------------------------------------------------- * for catalog file p_na, p_imcl, p_sq and plot file versions * p_pver through p_iver makes PostScript files then gif files * with name p_outdir plus p_label and plot file number * P_BR controls whether the first plot is to the left or not * Non-call parameters: p_dir, p_outdir, p_disk, p_dohtml *--------------------------------------------------------------- STRING*10 P_SUBST SCALAR P_DOBR p_dobr = p_br; if (p_dobr=0) then; p_dobr=-1; end default 'LWPLA'; inname = p_na; inclass = p_imcl; inseq = p_sq; indisk=p_disk; p_subst = substr(p_plabel,1,10) docolor 1; plcolors 0; plcolors(1,10)~0.88 0.88 0.88 if (p_plabel='RFLAG') then; tvcolors; end for p_i = p_pver to p_iver; outfile = p_dir !! p_subst !! char(p_i) !! '.ps plver=p_i; runwait('LWPLA') default system; syscom p_cnvrt sys2com(1) = p_outtmp sys2com(2) = p_subst !! char(p_i) !! '.ps sys2com(3) = p_outdir sys2com(4) = p_subst !! char(p_i) !! '.gif system default system; syscom '\rm sys2com(1) = p_outtmp sys2com(2) = p_subst !! char(p_i) !! '.ps system if (p_dohtml>0) then; p_line(2)='>"' if (p_dobr) then p_line(1)=' "
' ') then; p_ldfile = 1; end if (substr(p_inna,1,1) <> ' ' & p_inseq > 0) then; p_ondisk = 1; end if (p_ondisk = 1 & substr(p_incl,1,1) <> ' ')then p_ondisk = 1 p_disk=p_indi else p_ondisk = -1 end if (p_ldfile = 1 & p_ondisk = 1) then type 'SPECIFY DATAIN OR INNAME NOT BOTH' p_error=1 end if (p_ldfile < 0 & p_ondisk < 0) then type 'NO DATA?: SPECIFY DATAIN OR INNAME' p_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 (p_error=0 & p_ondisk = 1) then getitime; p_inttim = inttime if (maxtab('CL')>1) then; p_error=60; end if (maxtab('SN')>0) then; p_error=60; end if (p_error=60) then; type 'PARTIALLY CALIBRATED DATA - STOPPING'; end end $ check one freq id, does not check for S/X or 90/50 if (p_error=0 & p_ondisk = 1) then inext = 'FQ'; invers = 1; keyword = 'NUM ROW'; getthead if (keyvalue(1)>1) then; p_error=70; type 'MORE THAN ONE FREQID - QUITTING' type 'SEPARATE FREQIDS (RUN VLBAFIX)' type 'RUN VLBAMPHC ON EACH SEPARATELY end end $ check outname, outdisk if (substr(p_expna,1,1)=' ' & substr(p_inna,1,1)<>' ' ) then p_expna = p_inna; else if (substr(p_expna,1,1)=' ' & substr(p_inna,1,1)=' ') then type 'SPECIFY AN UNIQUE OUTNAME OR INNAME' p_error = 4; end end if (p_disk = 0 & p_indi > 0) then; p_disk = p_indi; else if (p_disk = 0 & p_indi = 0) then type 'SPECIFY AN OUTDISK OR INDISK'; p_error = 4; end end p_load $ load file if needed keyword 'USERNO'; gethead; p_userno = keyval(1) * spectral line data or continuum data to be expected? if (p_mode = 'LINE') then; p_mode = 'SPEC'; end; p_fqinfo if (p_mode = '' & p_nchan < 65) then; p_mode='CONT'; end if (p_mode = '' & p_nchan >= 65) then; p_mode='SPEC'; end $ check if html directory and/or e-mail is wanted if (length(p_email) > 0) then; p_doemail = 1; end if (p_doemail>0) then p_email= 'X'!!p_email; substr(p_email,1,1)=' '; end if (length(p_dir) > 0) then; p_dohtml=1; end if (p_dohtml>0) then x = length(p_dir) if (substr(p_dir,x,x)<>':') then if (substr(p_dir,x,x)<>'/') then substr(p_dir,x+1,x+1)='/'; end end p_outdir= 'X' !! p_dir; substr(p_outdir,1,1)=' ' x = length (p_outdir) if (substr(p_outdir,x,x)=':') then p_outdir= 'X$'!!p_dir; substr(p_outdir,1,1)=' '; substr(p_outdir,length(p_outdir),length(p_outdir))='/'; end p_outtmp = p_outdir; format=1; getdate; format 0 p_date=substr(thedate,3,9)!!substr(thedate,11,14)!!'/' clrtemp p_outdir=p_outdir!!p_date if (length(p_outdir)>63); then type 'OUTPUT DIRECTORY LIMITED TO 37 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 VLBAMPHC. outdir ends up as type p_outdir p_error = 13;end if (p_error = 0) then default system; syscom 'mkdir sys2com(1) = p_outdir; system if (error > 0) then type 'CANNOT MAKE OUTPUT DIRECTORY FOR PLOTS P_error = 13; end end * check if convert command exists default system; syscom 'which convert p_cnvrt='convert system; if (error > 0) then * check if magick command exists p_cnvrt='magick syscom 'which magick system; if (error > 0) then type 'ERROR: Cannot create plots for output html type 'files because the command convert or magick type 'is not on your computer.. type 'Install convert/magick or leave OUTFILE blank p_error=15 end end * check and create html file if (p_error=0) then default system p_line(1) = ' "VLBAMPHC output p_line(2) = '
" c_htmlput(p_line) p_line(1) = ' "

VLBAMPHC output for: substr(p_line(1),27,66) = p_expna!!'.'!!p_incl!!'.' p_line(2)=char(p_seq)!!'

" c_htmlput(p_line) p_line(1)=' "

User number = p_line(2)=char(p_userno)!!'

" c_htmlput(p_line) p_line(1)=' "

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

" c_htmlput(p_line) p_line(1)=' "

Message log p_line(2)='

" c_htmlput(p_line) p_line(1)=' "See for the message log" c_htmlput(p_line) end end * get source in SU table if (p_error=0) then; inname=p_inna; inclas=p_incl; inseq=p_inseq; indisk=p_indi p_getsurow; inext='SU'; p_numref=p_row for i = 1 to p_row pixxy i 2 1; tabget; p_atargets(i)=keystrng end end if (p_debug > 0) then; type 'C_PRECHECK ERROR = '!!char(p_error); end RETURN; FINISH PROCEDURE C_TABLES *--------------------------------------------------------------- * copies the CL and BP tables and edits them *--------------------------------------------------------------- default tacop; inname=c_name; inclass=c_class; inseq=c_seq indisk=c_disk; ncount=1; outname=p_inna; outclass=p_incl; outseq=p_inseq; outdisk=p_indi; ii = maxtab('BP'); if (ii>0) then inext='BP'; invers=ii; outvers=0; keyword='' baddisk=p_baddisks; p_info('TACOP'); if (p_error=0) then runwait('TACOP'); end else type 'NO BP table found: quitting' p_error = 32 end ii = maxtab('CL'); if ((ii>0) & (p_error=0)) then inext='CL'; invers=ii; outvers=0; keyword='' baddisk=p_baddisks; p_info('TACOP'); if (p_error=0) then runwait('TACOP'); end else type 'NO CL table found: quitting' p_error = 32 end ii = maxtab('FG'); if ((ii>0) & (p_error=0)) then inext='FG'; invers=1; outvers=0; keyword='' baddisk=p_baddisks; p_info('TACOP'); if (p_error=0) then runwait('TACOP'); end end * edit CL table if (p_error=0) then inname=outname; inclass=outclass; inseq=outseq; indisk=outdisk type 'Set source to 0 in CL table ii = maxtab('CL'); if ii > 0 then inext='CL'; invers=ii; keyword'NUM ROW'; getthead; jj = keyvalue(1); keyvalue=0 for ii = 1 to jj; pixxy=ii,3,1; tabput end end type 'Set source to 0 in FG table ii = maxtab('FG'); if ii > 0 then inext='FG'; invers=ii; keyword'NUM ROW'; getthead; jj = keyvalue(1); keyvalue=0 for ii = 1 to jj; pixxy=ii,1,1; tabput end end end RETURN; FINISH PROCEDURE C_RFLAG *--------------------------------------------------------------- * runs RFLAG on MS file one source at a time *--------------------------------------------------------------- default 'rflag'; inname=p_inna; inclas=p_incl; inseq=p_inseq indisk=p_indi; doband 1; docalib 1; stokes 'half'; dotv=-1; if (p_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 (p_inttim>0) then; fparm(2)=p_inttim; end fparm(13) = max (100, p_doflag); fparm(18)=1 if (p_dohtml>0) then p_line(1)=' "

RFLAG plots

p_line(2)='"'; c_htmlput(p_line); end * all sources in SU p_getsurow; inext='SU' for gg = 1 to p_row pixxy = gg 2 1; tabget; source=keystrng,'' doplot = J; if (p_error = 0) then ii = maxtab('PL') + 1; p_info('RFLAG'); if (p_error=0) then runwait('RFLAG'); doplot=-J; runwait('RFLAG') if ((p_dopl>0) & (p_dohtml>0)) then; jj = maxtab('PL') c_plotfile (inname,inclass,inseq,1,ii,jj,'RFLAG') end end end end RETURN; FINISH PROCEDURE C_SPLIT *--------------------------------------------------------------- * Split data for this frequency ID *--------------------------------------------------------------- default 'SPLIT'; inname=p_inna; inclas=p_incl; inseq=p_inseq indisk=p_indi; doband 1; docalib 1; outdisk indisk; bpver=maxtab('BP'); gainuse 0; douvcomp=-1; stokes='' outseq = p_frequid; outclass substr(p_expna,1,6) keyword'NAXIS3'; gethead; bchan 1; echan keyvalue(1); nchav 0 * pseudo cont or spectral line, no freq averaging p_scr = 'VERAGED IN SINGLE SOURCE DATA' if (p_mode <> 'CONT') then aparm 0; type char(echan)!!' CHANNELS KEPT UNA' !! p_scr else $ continuum, grab all together aparm 2 0; type char(echan)!!' CHANNELS A' !! p_scr end aparm(6)=1; p_info('SPLIT'); if (p_error=0) then; runwait('SPLIT');end; RETURN; FINISH PROCEDURE C_IMAGR *--------------------------------------------------------------- * images secondary phase stopping source *--------------------------------------------------------------- DEFAULT 'IMAGR'; imsize p_imsize; im2parm 2 5 7 0.5 niter 1500; flux 1e-4; uvwtfn'NA'; imagrp(10) 1 stokes 'I'; intype 'uv'; overlap 2; dotv=-1; outdisk=p_disk for i = 1 to p_numref inname p_atargets(i); inseq p_frequid; outseq p_frequid inclass substr(p_expna,1,6); chkname; srcname = inname if (error < 1) then p_setcell(p_mode); timerang 0; keyword'GCOUNT' gethead; stokes 'I'; channel 0 if ((keyvalue(1) > 10) & (p_error = 0)) then type 'TARGET :'!!inname!!' BEING IMAGED NOW' if ((nchav<>1) ! (echan=1)) then runwait('IMAGR'); if (p_dopl > 0) then; p_uvplot (inname, inclass, inseq) p_plcnt(16) = maxtab('PL'); p_kntr(inname, inclass,p_chkerr) inclass=p_imcl; inseq=p_chkerr if (p_chkerr>0) then; p_plcnt(17)=maxtab('PL'); end if (p_dohtml>0 & p_plcnt(16)>0) then; inclass substr(p_expna,1,6) if (i<10) then p_scr = 'UVPTAR0'!!char(i) j = p_plcnt(16); inseq 0 c_plotfile(inname,inclass,inseq,1,1,j,p_scr) if (p_plcnt(17)>0) then p_scr = 'IMATAR0'!!char(i) j = p_plcnt(17) c_plotfile(inname,'ICL001',p_chkerr,0,1,j,p_scr) end else p_scr = 'UVPTAR'!!char(i) j = p_plcnt(16); inseq 0 c_plotfile(inname,inclass,inseq,1,1,j,p_scr) if (p_plcnt(17)>0) then p_scr = 'IMATAR'!!char(i) j = p_plcnt(17) c_plotfile(inname,'ICL001',p_chkerr,0,1,j,p_scr) end end end end else if (p_dopl > 0) then p_uvplot (inname, inclass, inseq) p_plcnt(16) = maxtab('PL'); if (p_dohtml>0 & p_plcnt(16)>0) then; inclass substr(p_expna,1,6) if (i<10) then p_scr = 'UVPTAR0'!!char(i) else p_scr = 'UVPTAR'!!char(i) end j=p_plcnt(16); inseq 0 c_plotfile(inname,inclass,inseq,1,1,j,p_scr) end end niter 1000; flux 1e-3; stokes='I'; bb = -1 for bif=1 to p_ifs inclass substr(p_expna,1,6) inseq 0; eif=bif; runwait('IMAGR') if (p_dopl > 0) then p_kntr(inname, inclass, p_chkerr) if (p_chkerr>0) then; p_plcnt(17)=maxtab('PL'); end if (p_dohtml>0 & p_plcnt(17)>0) then; if (i<10) then p_scr = 'IMATAR0'!!char(i) else p_scr = 'IMATAR'!!char(i) end p_scr = p_scr !! char(bif) j = p_plcnt(17) c_plotfile(inname,'ICL001',p_chkerr,bb,1,j,p_scr) end end end if (p_dopl>0) then inclass=p_imcl; inseq=p_chkerr; end end end end end inseq = 0; intype = 'MA'; indisk outdisk for i = 1 to p_numref inname p_atargets(i); inclass'?BM001'; p_zapall * inclass'RBM001'; p_zapall; inclass'LBM001';p_zapall end recat RETURN; FINISH PROCEDURE VLBAMPHC *--------------------------------------------------------------- * Do whole cal/image the secondary phase stopping source *--------------------------------------------------------------- * inputs vlbamphc type '======================================================= c_init; c_precheck; type '-------------------------' if (p_error = 0) then; c_tables; end if (p_error = 0 & p_doclip(1) > 0) then; p_clip; end if (p_error = 0 & p_doflag > 0) then; c_rflag; end if (p_error = 0) then; c_split; end if (p_error = 0 & p_imsize(1)>0) then; c_imagr; end if (p_error = 0) then if (p_dohtml>0) then p_line(2)=''; p_line(1)=' "" c_htmlput(p_line) if (p_doemail>0) then default system; sysout '/tmp/p_tempmail syscom= 'echo "VLBAMPHC is done, please review your sys2com(1) = ' plots at jj = length(p_dir) if (substr(p_dir,jj,jj)=':') then sys2com(2)='"'; system syscom 'echo "file://" sys2com(1)=substr(p_outdir,2,length(p_outdir)) sys2com(2) ='"vlbamphc.html" else sys2com(1)= ' plots at file:// sys2com(2)= substr(p_dir,1,jj)!!p_date sys2com(3)= 'vlbamphc.html" end system; default system syscom= 'cat /tmp/p_tempmail | mail -s sys2com(1) = ' "VLBAMPHC DONE sys2com(2) = 'X'!!p_expna!!'.'!!p_incl!!'.' sys2com(2) = sys2com(2)!!char(p_seq)!!'"' substr(sys2com(2),1,1) = ' ' sys2com(3)= p_email system; sys2com = '' syscom= '\rm /tmp/p_tempmail system end * print messages default prtmsg; outprint=p_dir!!'messages.txt docrt=-1; prtmsg; default system; syscom='mv sys2com(1) = p_outtmp!!'messages.txt sys2com(2) = p_outdir system end if (p_doemail>0 & p_dohtml<0) then default system syscom= 'echo "VLBAMPHC is done." sysout= '/tmp/p_tempmail system; default system syscom= 'cat /tmp/p_tempmail | mail -s sys2com(1) = ' "VLBAMPHC DONE : sys2com(2) = 'X'!!p_expna!!'.'!!p_incl!!'.' sys2com(2) = sys2com(2)!!char(p_seq)!!'"' substr(sys2com(2),1,1) = ' ' sys2com(3)= p_email system;sys2com = '' syscom= '\rm /tmp/p_tempmail system end * type '' type 'USE P_ALLPLOT(X) TO PLOT FROM PL-VERSION X ON TV' type '' p_scr = 'PROCEDURE DONE, THANK YOU FOR CHOOSING' type p_scr!!' AIPS FOR YOUR BUSINESS' * send e-mail saying procedure has failed else if (p_doemail>0) then default system syscom= 'echo "VLBAMPHC failed, please review your sys2com(1) = ' inputs and try again." sysout= '/tmp/p_tempmail system; sysout ='' syscom= 'cat /tmp/p_tempmail | mail -s sys2com(1) = ' "VLBAMPHC FAILED : sys2com(2) = 'X'!!p_expna!!'.'!!p_incl!!'.' sys2com(2) = sys2com(2)!!char(p_seq)!!'"' substr(sys2com(2),1,1) = ' ' sys2com(3)= p_email system;sys2com = '' syscom= '\rm /tmp/p_tempmail system end type 'ERROR#'!! char(p_error) !!' OCCURRED' type 'PLEASE REVIEW YOUR INPUTS AND TRY AGAIN' end; type '======================================================= tget vlbamphc; c_exit RETURN; FINISH