* * CALBK - set of procedures to semi-automatically reduce polarization * calibration data for the VLA for dataset: * 05-16-2005 2030-0000 LST SMyers POLCA program * * Version STM-05-25-05 for running on SANDROCK USER 1553 Disks 1 and 2 * Use 1999.2 flux scale * THIS ASSUMES THE 31DEC01 VERSION OF AIPS OR LATER! * * NOTE: The session-specific variables are defined in procedure SETIT. * This script should be useable for any run if these are changed * appropriately. * * This script assumes the UV data and ICLN models are on Disk 1, and * Disk 2 is available for temporary map storage. * * Because the primary calibrator is 1331+305 (3C286) or 0137+331 (3C84) * which are resolved, a CC model is preferred. However, the following * procedure will sort of work with a point model by skipping step 2. * * Calibrators are broken into lists: * * abscal = primary flux and EVPA calibrator * polcal = polarization leakage calibrator(s) * * srclist = all calibrators except abscal * | * strongcal = bright calibrators from callist (shorter solutions) * medcal = normal calibrators from callist * weacal = weak calbirators from callist (longer solution intervals) * * Fill your data using FILLM * We suggest you use default antenna gain curves and no opacity correction * if you have Tip Curve data available for opacities (see step 3): * BPARM = -1,0; * and set DOOPAC 1; DOGAIN -1 in SETIT. If no opacities, use default * BPARM = 0; * and set DOOPAC -1; DOGAIN -1 in SETIT. * * Steps to run, with data in SLOT I: * * 1. SETIT -- define the session specific variables (IMPORTANT!!!!) * * Before starting be sure to quack off the first 10 sec (to zap the * pointing scans and bad data at start), and examine the data in * TVFLG for obvious problems (use AMPL DIFF and PHA DIFF with 3.3sec * records). * * If you read in the data with 1min default CL entries: * Delete default CL 1 and run * REINDXR(I) -- INDXR with CPARM(3) 10/60 to make CL 1 with 10sec entries * * 2. Various pre-calibration issues: * * If you are starting with a previous calibration, reset this with * RESETIT(I) -- reset SU fluxes and clear SN and CL tables back to 1 * * Normally, at this point, you would split off the data for the cal * and map it in SCMAP or DIFMAP to produce a ICLN with CC=1. For * D-configuration (and probably C) a point model is sufficient. * * 3. CALDATA(I) -- gain calibration, using the model, produces CL 3 and * CL 4 which is the one to be applied in following steps. You can * examine the output in file *.CALIB to check the process. * * Controlled by parameters in SETIT. * Note that DOOPAC, DOGAIN, and DOBASE control pre-gain corrections: * * If data was filled with BPARM(1)=-1 (no opacity correction) * DOOPAC=1 -- apply known zenith optical depth correction (w/airmass) * works from either CL 1 or 2 and will write CL table 2 * (Default: DOOPAC=-1 if no TIP Curve, else DOGAIN=1) * * If data was not filled with BPARM(2)=0 (gain curve applied) * DOGAIN=1 -- This will do gain and opacity calibration, works from * either CL 1 or 2 and will write CL 2. * (Default: DOGAIN=-1) * * If data need baseline corrections * DOBASE=1 -- This will do gain and opacity calibration, works from * either CL 1 or 2 and will write CL 2. Put baseline * corrections in CALBASE procedure. * (Default: DOBASE=-1) * * 4. LISTCAL(I) -- examine calibrators with LISTR OPTYP='MATX' * * 5. CALPOL(I) -- runs PCAL and does a LISTR OPTYP='MATX' on cross-pols * for calibrator (RL and LR). * * 6. Examine LISTR output files *.PCAL and *.POLC * * 7. OUTPOL(I) -- runs IMAGR and then IMSTAT/IMVAL on the maps * * 8. Examine LISTR output files *.TXT and produce summary by, for example * grep 'IF=' *.TXT * The lines at the end of the .TXT files contain the angles we want, * and can be extracted by * grep 'PHASE' *.TXT * * Remember, if you need to redo things, proc RESETIT(I) will reset to * the beginning, and to redo steps 5 or 7 just requires blasting the listr * output files. * Proc Setit * Procedure to define global pseudoverbs, arrays and strings * as well as to define the calibrator names and number for later use * scalar angle, angle1, angle2, polang1, polang2, corang1, corang2 scalar phdiff, flxtot1, flxtot2, fpol1, fpol2, spol1, spol2 * string*16 abscal, absnam, srccal, absnot, srclist(30) string*16 polcal(30), medcal(30), weacal(30), strongcal(30) string*12 absmod, predir string*6 iclass, bclass, uclass, qclass, vclass, aclass string*2 prefix string*1 fqband scalar opacity, abcell, absref, absang, numbox, calimode, sjparm scalar numsrcs, nummed, numweak, numstrong scalar absint, absamp, medint, medamp, strint, stramp, weaint, weaamp scalar polint, usecell scalar dogain, doopac, dobase array absflx(2), absant(50), notant(50), absuvr(2), getant(50) array absbox(4), rmsbox(4), antlist(50) array useant(50), useuvr(2), usetap(2) * * Set up some class suffixes for the appropriate version of AIPS * type 'Setting up for AIPS TST' iclass 'ICL001'; bclass 'IBM001'; uclass 'UCL001'; qclass 'QCL001'; vclass 'VCL001'; * * Calibrate weights (DOCALIB=2) * calimode 2; * * NOTE: These values are specific to this session * type 'Using setup values for B-config K-Band POLCA run' * * AN13, 14, 16, 18 for EVLA; AN6, 27 BAD antlist 0 * predir 'PWD:'; type 'PREDIR =',predir * *** --------------------------------- * CHANGE PREFIXES WITH CONFIG/BAND: prefix 'BK'; type 'PREFIX =',prefix fqband 'K'; type 'FQBAND =',fqband *** --------------------------------- * *** ------------------------------------------------------------------------ * CHANGE THIS WITH PRIMARY CALIBRATOR: *** ------------------------------------------------------------------------ * 3C48: * abscal '0137+331'; type 'ABSCAL =',abscal; absnot ''; absnam '3C48'; type 'ABSNAM =',absnam * Use new Amy model absmod '3C48_K'; aclass 'MODEL'; type 'ABSMOD =',absmod,'.',aclass * 3C48 K-band R-L phase diff 1999.2 = -146 deg absang -146; type 'ABSANG =',absang * setjy calc 1999.2 absflx 0; sjparm 0; type 'ABSFLX =',absflx * 3C48 K-band A-config: recommended 0-80 klam and 1 station/arm (w/o model) * 3C48 K-band B-config: recommended 0-80 klam and 5 stations/arm (w/o model) * 3C48 K-band C-config: recommended 0-80 klam and all stations (w/o model) * 3C48 K-band D-config: recommended 0-80 klam and all stations (w/o model) * --------------------------------------------------------------- * 3C48 K-band A-config: use all uvr and all stations (with model) * 3C48 K-band B-config: use all uvr and all stations (with model) * 3C48 K-band C-config: use all uvr and all stations (with model) * 3C48 K-band D-config: use all uvr and all stations (with model) *** ------------------------------------------------------------------------ * 3C286: * * abscal '1331+305'; type 'ABSCAL =',abscal; absnot ''; * absnam '3C286'; type 'ABSNAM =',absnam * Use new Amy model * absmod '3C286_K'; aclass 'MODEL'; type 'ABSMOD =',absmod,'.',aclass * 3C286 K-band R-L phase diff 1999.2 X-band = 66 deg * absang 66; type 'ABSANG =',absang * setjy calc 1999.2 * absflx 0; sjparm 0; type 'ABSFLX =',absflx * 3C286 K-band A-config: 50-300 klam and 3 stations/arm, reduce 1% (w/o model) * 3C286 K-band B-config: 50-300 klam and 7 stations/arm, reduce 1% (w/o model) * 3C286 K-band C-config: 50-300 klam and all stations, reduce 1% (w/o model) * 3C286 K-band D-config: recommended 0-15 klam and all stations (w/o model) * ---------------------------------------------------------------- * 3C286 K-band A-config: use all uvr and all stations (with model) * 3C286 K-band B-config: use all uvr and all stations (with model) * 3C286 K-band C-config: use all uvr and all stations (with model) * 3C286 K-band D-config: use all uvr and all stations (with model) *** ------------------------------------------------------------------------ * absuvr 0 0; type 'ABSUVR =',absuvr absant 0 notant 0 type 'ABSANT =',absant * antennas for getjy, all stations getant 0 * solution interval for phase and amp+phase absint 20/60; absamp 0 type 'ABSINT =',absint,absamp * *** ------------------------------------------------------- * CHANGE REFANT AS APPROPRIATE FOR DATE OF OBSERVING: absref 15; type 'ABSREF =',absref *** ------------------------------------------------------- * numbox 0; type 'NUMBOX =',numbox absbox 0, 0, 0, 0; type 'ABSBOX =',absbox rmsbox 32, 32, 96, 96; type 'RMSBOX =',absbox * K-band A-config: abcell 0.02 * K-band B-config: abcell 0.06 * K-band C-config: abcell 0.20 * K-band D-config: abcell 0.70 abcell 0.06; type 'ABCELL =',abcell * * May put limit on antennas to use in phasecal and mapping of 3C48 * Useful in A config K/Q band (taper 500kl => cell 0.05") * Otherwise set to zero and usecell same as abcell useuvr 0 0; usetap 0 0; useant 0 usecell abcell * * Full list of sources (excluding primary calibrator) numsrcs 8; type 'NUMSRCS =',numsrcs * NOTE: LOST 2136+006, 2253+161 srclist '1743-038','1751+096','1924-292','2202+422','2355+498','0136+478',''; srclist(7) '0238+166'; srclist(8) '0359+509'; * Normal flux-density sources nummed 4 medcal '1743-038','1751+096','2202+422','0136+478','' type 'MEDCAL =',medcal medint 20/60; medamp 0 * High flux-density sources numstrong 2 strongcal '1924-292','0359+509',''; type 'STRONGCAL =',strongcal strint 10/60; stramp 0 * Low flux-density sources numweak 2 weacal '2355+498','0238+166',''; type 'WEACAL =',weacal weaint 20/60; weaamp 0 * Polarization D-term calibrator polcal '2202+422',''; type 'POLCAL =',polcal polint 2 srccal ' ' * * Opacity correction (if not done in FILLM): doopac 1; * TIP curve opacity 0.095; type 'OPACITY = ',opacity * * Gain-elevation correction (if not done in FILLM): dogain -1; * * Baseline correction (if after move): dobase -1; * Finish * * Proc Resetit(i) * Reset dataset I for redo-ing of all procedures * getn i task 'setjy' optyp 'rejy' source abscal,'' bif 1; eif 2; zerosp 0 freqid 1 go setjy; wait setjy source srclist go setjy; wait setjy * inext 'sn';inver -1;extd * inext 'cl';inver 0; extd * imh type 'There should now be no SN tables and 1 CL table' type 'May have to repeat EXTD if CL tables remain' * Finish * * Proc Reindxr(i) * Create new CL table with 10 sec entries * Run after deleting CL 1 * NOTE: This will use current BPARMs (same as FILLM). Choices: * BPARM = -1,0,... Do not set opacity, set gains (default) * BPARM = 0,... Set both opacities and gains (no OPAC available) * getn i task 'indxr' infile ''; prtlev 0 cparm 0, 0, 10/60, 0 go indxr; wait indxr imh type 'There should now be 1 CL table with 10sec entries' * Finish * * Proc Mapem * Specialized procedure to run IMAGR with stokes I,Q, and U * sets, and map them. * tget imagr for j=1 to 2; outn sour(1) bif j; eif j outseq (j+6) clr2n; in2di indi; outdi 2 niter 200 stokes 'i'; outcl iclass wait imagr; go imagr niter 200 stokes 'q'; outcl qclass wait imagr; go imagr stokes 'u'; outcl uclass wait imagr; go imagr stokes 'v'; outcl vclass wait imagr; go imagr end wait imagr * now make polc and pola maps for j=1 to 2; indi 2; in2di 2; outdi 2 innam outn blc 0; trc 0 inseq (j+6); outseq inseq incl qclass in2name innam in2seq inseq in2cl uclass opcode 'polc' outcl opcode aparm 0 blc 70 30; trc 140 94; tvlod; imstat bparm 0 0 1 bparm(1)=pixstd incl uclass blc 70 30; trc 140 94; tvlod; imstat bparm(2)=pixstd incl qclass; blc 0; trc 0 go comb; wait comb opcode 'pola' outcl opcode go comb; wait comb end type 'finished MAPEM' Finish * * * FIXKGAIN.001 v08feb2002 - S.T. Myers (NRAO) runfile to load procedure Proc FIXKGAIN(i,j) * Usage: FIXKGAIN( CATNO, CLVER ) * I = catalog number of file; J = version number of CL table to correct * Procedure to put in polynomial gain coefficients * Compiled by B.Butler 2002-02-08 from Perley-Butler run 2001-11-10 * Same curves as in VLA.GAINS applied in FILLM * * Normalization close to 1 at maximum * * Back-propagate to June 2001, since that is the point at * which the subreflector rotation v. elevation was turned on * Use average gain curve for AN 4 * type 'Applying K band gain curves from Perley-Butler 2001-11-10' type 'Version BButler/SMyers 2002-02-08' type 'Gain curves IF and Pol averaged' task 'clcor' getn i gainver 0 gainuse j opcode 'gain' source '' * * AVERAGE COEFF = 1.0429E+00, -2.8623E-03, 3.9044E-05, 0 * ANTEN 1 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0225E+00, -2.4650E-03, 4.2225E-05, 0; GO CLCOR; ANTEN 2 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.5400E-01, 2.3688E-04, 2.2775E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 3 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0850E+00, -4.1050E-03, 4.1700E-05, 0; WAIT CLCOR; GO CLCOR; * AN4 was in barn during run, use average curve ANTEN 4 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0429E+00, -2.8623E-03, 3.9044E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 5 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0425E+00, -2.6525E-03, 3.5075E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 6 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0375E+00, -2.7100E-03, 3.7450E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 7 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0900E+00, -4.1675E-03, 3.8625E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 8 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0700E+00, -3.8175E-03, 4.3300E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 9 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0350E+00, -2.5700E-03, 3.7550E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 10 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0700E+00, -3.6375E-03, 3.9600E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 11 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.8800E-01, -1.0907E-03, 3.2150E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 12 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.1325E+00, -6.1375E-03, 5.6625E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 13 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0550E+00, -2.9950E-03, 3.7325E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 14 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0975E+00, -4.6775E-03, 4.6750E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 15 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0400E+00, -4.0575E-03, 6.7950E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 16 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.1125E+00, -5.2850E-03, 5.0975E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 17 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0600E+00, -3.1500E-03, 3.3675E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 18 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.6675E-01, -3.8510E-04, 2.8925E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 19 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0375E+00, -2.7425E-03, 3.9650E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 20 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0425E+00, -3.0425E-03, 4.2000E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 21 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.6275E-01, -1.2383E-04, 2.3875E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 22 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0800E+00, -4.1275E-03, 4.5425E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 23 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0125E+00, -1.7350E-03, 3.1000E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 24 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.8500E-01, -6.5701E-05, 1.2300E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 25 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0650E+00, -3.0625E-03, 3.1125E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 26 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 9.9300E-01, -1.0235E-03, 3.4800E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 27 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0875E+00, -4.6600E-03, 5.1800E-05, 0; WAIT CLCOR; GO CLCOR; ANTEN 28 0; STOKES = 'RL'; BIF=1; EIF=2; CLCOR 1.0350E+00, -3.0325E-03, 4.9525E-05, 0; WAIT CLCOR; GO CLCOR; WAIT CLCOR; * Finish * * Proc calopac(i) * * Specialized procedure to calibrate antennas for gain curve * * task 'clcor' if opacity>0.0 then opcode 'opac'; type ' Correcting for opacity: tau = ', opacity; clcor opacity,0; gainver 0; gainuse 2; stokes ''; source ''; go clcor; wait clcor; end * type ' Completed CALOPAC ' * Finish * * * * Proc calgain(i) * * Specialized procedure to calibrate antennas for gain curve * if fqband='K' then fixkgain(i,2); end * type ' Completed CALGAIN ' * Finish * * Proc calbase(i) * * Apply baseline corrections to data * APPLY TO CL 2 * type 'Apply Baseline corrections' * task 'clcor' indi 1; getn i opcode 'ANTP'; clcorprm 0; gainver 0; gainuse 2; stokes ''; source ''; bif 0; eif 0; * * antenn 0, 0; clcor 0.0000,0.0000,0.0000,0,0,0,1; go clcor; wait clcor; * type ' Completed baseline corrections with CLCOR ' * Finish * * Proc caldata(i) * * Specialized procedure to calibrate data, possibly with ICLN model. * First do short (typically 10s) phase solutions followed by longer * (~1min) full gain solutions. * clrtemp prtas ''; clrmsg * * Start by making CL 2 from CL 1 * task 'tacop' getn i inext 'cl' outdi indi geto i inver 1 outver 2; ncount 1 keyword ''; keyval 0 go tacop; wait tacop * if doopac > 0 then calopac(i); end if dogain > 0 then calgain(i); end if dobase > 0 then calbase(i); end * task 'setjy' indisk 1; getn i optyp '' aparm 0 if absflx(1) = 0.0 then optyp 'calc'; aparm(2) sjparm; end source abscal,'' bif 1; eif 1; zerosp absflx(1) 0 freqid 1 go setjy; wait setjy bif 2; eif 2; zerosp absflx(2) 0 freqid 1 go setjy; wait setjy * * First pass - phase-only * task 'calib' if absmod <> '' then in2n absmod; * Use CC 1 model attached to ABSMOD on Disk 1 type 'Phase calibration using Clean model - restricted data' in2cl aclass; in2seq 1; in2d 1; cmodel 'comp'; cmethod 'dft'; invers 1; flux 0; ncomp 0; nmaps 1; uvr 0; anten 0; basel anten else in2n ''; type 'Phase calibration using Point model - restricted data' in2cl ''; in2seq 0; in2d 0; cmodel ''; cmethod ''; invers 0; flux 0; ncomp 0; nmaps 0; smodel 0; uvr absuvr; anten absant; basel anten end calsour abscal,'' flagver 0; gainuse 0; docalib calimode; refant absref aparm 4 0 cparm 0 0 10 10 0 * * Main calibrator - initial phase-only * solmode 'p'; solint absint snver 1 go calib; wait calib * * Normal sources - initial phase-only * if nummed > 0 then calsour medcal; uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'p'; solint medint snver 1 go calib; wait calib end * * Strong sources - initial phase-only * if numstrong > 0 then calsour strongcal; calsour strongcal uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'p'; solint strint snver 1 go calib; wait calib end * * Weaker sources - initial phase-only * if numweak > 0 then calsour weacal; uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'p'; solint weaint snver 1 go calib; wait calib end * * Apply each source to itself * task 'clcal' type 'Applying Self Calibration for ',abscal source abscal,'' calsour source opcode ' ' interp 'simp' gainver 2 gainuse 3 go clcal; wait clcal * for i = 1 to numsrcs; srccal = srclist(i) type 'Applying Self Calibration for ',srccal task 'clcal' source srccal,'' calsour source opcode ' ' interp 'simp' gainver 2 gainuse 3 go clcal; wait clcal end * * Second pass - full gain (amplitude) solutions on longer timescales * task 'calib' if absmod <> '' then in2n absmod; * Use CC 1 model attached to ABSMOD on Disk 1 type 'Amplitude calibration using Clean model - restricted data' in2cl aclass; in2seq 1; in2d 1; cmodel 'comp'; cmethod 'dft'; invers 1; flux 0; ncomp 0; nmaps 1; uvr 0; anten 0; basel anten else in2n ''; type 'Amplitude calibration using Point model - very restricted data' in2cl ''; in2seq 0; in2d 0; cmodel ''; cmethod ''; invers 0; flux 0; ncomp 0; nmaps 0; smodel 0; uvr absuvr; anten absant; basel anten end calsour abscal,'' flagver 0; gainuse 0; docalib calimode refant absref aparm 4 0 cparm 0 0 10 10 0 * * Primary calibrator - amp cal * solmode 'a&p'; solint absamp snver 2 go calib; wait calib * * Normal calibrators - amp cal * if nummed > 0 then calsour medcal; calsour medcal uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'a&p'; solint medamp snver 2 go calib; wait calib end * * Strong calibrators - amp cal * if numstrong > 0 then calsour strongcal; uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'a&p'; solint stramp snver 2 go calib; wait calib end * * Weak calibrators - amp cal * if numweak > 0 then calsour weacal; uvr 0 0; anten 0; basel 0 clr2n; invers 0; flux 0; ncomp 0; nmaps 0 solmode 'a&p'; solint weaamp snver 2 go calib; wait calib end * * Get fluxes from amplitude solutions * task 'getjy' source srclist calsour abscal,'' anten getant bif 1; eif 2 go getjy anten 0 * * Apply each source to itself * task 'clcal' source abscal,'' if absmod <> '' then calsour source; type 'Applying Self Calibration for ',abscal opcode ' ' anten 0 interp 'simp' gainver 3 gainuse 4 go clcal; wait clcal else calsour source; type 'Applying Self Calibration for ',abscal opcode ' ' anten absant interp 'simp' gainver 3 gainuse 4 go clcal; wait clcal if absnot <> '' then calsour absnot,''; type 'Applying External Calibration for ',abscal anten notant go clcal; wait clcal end anten 0 end * for i = 1 to numsrcs; srccal = srclist(i) type 'Applying Self Calibration for ',srccal task 'clcal' source srccal,'' calsour source opcode ' ' anten 0 interp 'simp' gainver 3 gainuse 4 go clcal; wait clcal end * prtas '' outprint predir!!prefix!!'.CALIB' docrt -1 prtmsg docrt 1 * type ' Completed CALDATA ' * Finish * * Proc listcal(i) * * use LISTR 'GAIN' to output amplitude solutions * task 'listr' getn i sources '' optyp 'gain' inext 'sn';inver 2 docalib 1; gainuse 0; dopol -1 dparm 0 0 5 0 docrt -1 antenn antlist; basel antenn * bif 1; eif 1; stokes 'r' outpr predir!!prefix!!'-1R.AMPL' go listr; wait listr * bif 1; eif 1; stokes 'l' outpr predir!!prefix!!'-1L.AMPL' go listr; wait listr * bif 2; eif 2; stokes 'r' outpr predir!!prefix!!'-2R.AMPL' go listr; wait listr * bif 2; eif 2; stokes 'l' outpr predir!!prefix!!'-2L.AMPL' go listr; wait listr * docrt 1; outpr ''; inext ''; inver 0 * * use LISTR 'MATX' to examine gain calibration * task 'listr' getn i sources '' stokes 'half' optyp 'matx' docalib 1; gainuse 0; dopol -1 dparm 5,0 docrt 1 * bif 1; eif 1; go listr; wait listr * bif 2; eif 2; go listr; wait listr * bif 1; eif 2; antenn 0; basel 0 * type ' Completed LISTCAL ' * Finish * * Proc calpol(i) clrtemp * indisk 1 getn i task 'pcal' calsour polcal bif 1; eif 2 docalib 1; gainuse 0 solint polint refant absref anten 0 soltyp ''; bparm 0; cparm 0 prtas ''; clrmsg go pcal; wait pcal prtas 'pcal' outprint predir!!prefix!!'.PCAL' docrt -1 prtms docrt 1 * task 'listr' sour abscal,'' uvr absuvr; anten absant; basel anten docalib 1; gainuse 0 dopol 1 optyp 'matx' stokes 'polc' dparm 5 0 docrt -1 outprint predir!!prefix!!'-'!!absnam!!'.POLC' bif 1 go listr; wait listr bif 2 go listr; wait listr docrt 1 uvr 0 0; anten 0; basel anten; stokes ' '; optyp ' ' * clrtemp getn i task 'listr' sour srclist uvra 0 0 docalib 1; gainuse 0 dopol 1 optyp 'matx' stokes 'polc' dparm 5 0 docrt -1 outprint predir!!prefix!!'-ALLCAL.POLC' bif 1 go listr; wait listr bif 2 go listr; wait listr docrt 1 * type ' Completed CALPOL ' * Finish * * Proc outrms * * short proc to use IMSTAT for current image to output the off-source * statistics for I,Q,U images in IF 1 and 2 for the current source name * SOURCE(1). * * Expects BLC,TRC for off-source window stored in RMSBOX clrtemp inna source(1) blc rmsbox(1), rmsbox(2), 0; trc rmsbox(3), rmsbox(4), 0 * * IF 1 data, INSEQ=7 * inseq 7; type 'IF 1 Off-source image statistics for source '!!inna incl iclass; imstat; type inna!!' IF=1 I RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl qclass; imstat; type inna!!' IF=1 Q RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl uclass; imstat; type inna!!' IF=1 U RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl vclass; imstat; type inna!!' IF=1 V RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' * * IF 2 data, INSEQ=8 * inseq 8; type 'IF 2 Off-source image statistics for source '!!inna incl iclass; imstat; type inna!!' IF=2 I RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl qclass; imstat; type inna!!' IF=2 Q RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl uclass; imstat; type inna!!' IF=2 U RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' incl vclass; imstat; type inna!!' IF=2 V RMS: FLUX = '!!CHAR(pixstd*1000.0)!!' milliJy ' * Finish * * Proc setang (angle) * * Set vector angle into -180 to 180 deg range of validity * if angle < -180.0 then angle = angle + 360.0; end if angle > 180.0 then angle = angle - 360.0; end * Finish * * Proc outstat (angle1,angle2) * * short proc to use IMSTAT for current image to output the polarization * angles for IF 1 and 2 for the current source name SOURCE(1) * Should have already set BLC,TRC for window (or 0,0 for whole map) * * NOTE: Polarization angles output by COMB are 1/2 the R/L phase difference * and thus run from -90 to +90 degrees * clrtemp inna source(1); * * IF 1 data, INSEQ=7 * type 'IF 1 On-source image statistics for source '!!inna incl iclass; inseq 7; imstat; type inna!!' IF=1 I Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' type inna!!' IF=1 I Max: at ('!!CHAR(pixxy(1))!!','!!CHAR(pixxy(2))!!')' flxtot1 = pixval*1000.0 * incl qclass; imval; type inna!!' IF=1 Q Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl uclass; imval; type inna!!' IF=1 U Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl vclass; imval; type inna!!' IF=1 V Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl 'POLC'; imval; type inna!!' IF=1 P Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' fpol1 = pixval*1000.0 incl 'POLC N'; imval; type inna!!' IF=1 P Max: Noise = '!!CHAR(pixval*1000.0)!!' milliJy ' spol1 = pixval*1000.0 incl 'POLA'; imval; type inna!!' IF=1 P Max: Angle = '!!CHAR(pixval)!!' Deg ' angle1 = pixval incl 'POLA N'; imval; type inna!!' IF=1 P Max: Error = '!!CHAR(pixval)!!' Deg ' * type inna!!' IF=1 Poln Flux = '!!CHAR(fpol1)!!' +/- '!!CHAR(spol1)!!' mJy ' type inna!!' IF=1 Frac Poln = '!!CHAR(100.0*fpol1/flxtot1)!!' % ' * * IF 2 data, INSEQ=8 * inna source(1); type 'IF 2 On-source image statistics for source '!!inna incl iclass; inseq 8; imstat; type inna!!' IF=2 I Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' type inna!!' IF=2 I Max: at ('!!CHAR(pixxy(1))!!','!!CHAR(pixxy(2))!!')' flxtot2 = pixval*1000.0 * incl qclass; imval; type inna!!' IF=2 Q Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl uclass; imval; type inna!!' IF=2 U Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl vclass; imval; type inna!!' IF=2 V Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' incl 'POLC'; imval; type inna!!' IF=2 P Max: Flux = '!!CHAR(pixval*1000.0)!!' milliJy ' fpol2 = pixval*1000.0 incl 'POLC N'; imval; type inna!!' IF=2 P Max: Noise = '!!CHAR(pixval*1000.0)!!' milliJy ' spol2 = pixval*1000.0 incl 'POLA'; imval; type inna!!' IF=2 P Max: Angle = '!!CHAR(pixval)!!' Deg ' angle2 = pixval * incl 'POLA N'; imval; type inna!!' IF=2 P Max: Error = '!!CHAR(pixval)!!' Deg ' * type inna!!' IF=2 Poln Flux = '!!CHAR(fpol2)!!' +/- '!!CHAR(spol2)!!' mJy ' type inna!!' IF=2 Frac Poln = '!!CHAR(100.0*fpol2/flxtot2)!!' % ' * * Compute phase diff between IF 1 and 2 phdiff = 2.0*(angle1 - angle2); setang( phdiff ) type inna!!' IF=1-2 RL Phase Difference = '!!CHAR(phdiff)!!' Deg ' * Finish * * Proc outpol(i) * * Maps sources, calculates polarizations and angles and writes them out * clrtemp task 'imagr' indi 1 getn i docalib 1; gainuse 0; dopol 1 *** This has to change for different configs and bands imsize 256; cell abcell *** No need to clean the entire map either nbox numbox; clbox absbox, 0 *** uvwtfn ' ' cmethod ''; flagver 0; bchan 1; echan 0; subar 0; clr2n; nfield 1 bmaj 0; bmin 0; bpa 0; cparm 0 dotv false baddis 2 0 * * Do ABSCAL first to establish angle setting source abscal,'' * use restricted antennas and possibly uvrange uvra useuvr; anten useant; basel anten; cell usecell uvtaper usetap; zerosp 0 outver 0 tput imagr prtas ''; clrmsg mapem indi 2 outrms blc absbox(1), absbox(2), 0; trc absbox(3), absbox(4), 0 outstat(angle1, angle2) * These angles are 1/2*RL phase diff * At X band the RL phase of ABSCAL is ABSANG deg corang1 = absang - 2.0*angle1; setang( corang1 ) corang2 = absang - 2.0*angle2; setang( corang2 ) polang1 = 2.0*angle1 + corang1; setang( polang1 ) polang2 = 2.0*angle2 + corang2; setang( polang2 ) * These correction factors are the instrumental R/L phase difference * correction factors ANGLE(TRUE) - ANGLE(OBS) * so we can just add these to the observed R/L angles for the sources type source(1)!!' IF=1 RL Phase Angle = '!!CHAR(absang)!!' Deg ' type source(1)!!' IF=2 RL Phase Angle = '!!CHAR(absang)!!' Deg ' type source(1)!!' IF=1 RL Phase Correction = '!!CHAR(corang1)!!' Deg ' type source(1)!!' IF=2 RL Phase Correction = '!!CHAR(corang2)!!' Deg ' type source(1)!!' IF=1 RL Computed Phase = '!!CHAR(polang1)!!' Deg ' type source(1)!!' IF=2 RL Computed Phase = '!!CHAR(polang2)!!' Deg ' outprint predir!!source(1)!!'-'!!prefix!!'.TXT' docrt -1; prtmsg; docrt 1; outprint '' for j=1 to 24; getn j; zap; end * * Loop over other calibrators * for i = 1 to numsrcs; * clrtemp tget imagr srccal = srclist(i) * type 'Imaging data from source ',srccal * source srccal,'' indi 1 uvra 0 0; anten 0; basel 0; cell abcell uvtaper 0 0; tput imagr prtas ''; clrmsg mapem indi 2 outrms blc absbox(1), absbox(2), 0; trc absbox(3), absbox(4), 0 outstat(angle1, angle2) polang1 = 2.0*angle1 + corang1; setang( polang1 ) polang2 = 2.0*angle2 + corang2; setang( polang2 ) type source(1)!!' IF=1 RL Phase Angle = '!!CHAR(polang1)!!' Deg ' type source(1)!!' IF=2 RL Phase Angle = '!!CHAR(polang2)!!' Deg ' outprint predir!!source(1)!!'-'!!prefix!!'.TXT' docrt -1; prtmsg; docrt 1; outprint '' for j=1 to 24; getn j; zap; end * end * type ' Completed Polarization Calibration Run ' type ' Results can be found in *'!!prefix!!'.TXT files ' * Finish