Monday, June 4, 2007

WBR Step 6L: Calibration

Calibration is usually a somewhat iterative process. I will lightly flag my calibrator, then calibrate the calibrator, then see if any new funky looking data points have appeared. If they have, I will flag again and calibrate again. Wash, rinse, repeat until no funky data points show up.

So how do you calibrate your data anyway?


Assuming you've lightly flagged your phase and flux calibrators, according to Step 5, now we're ready to run SETJY. SETJY basically just writes to your data the most accurate flux for your flux calibrator. Important parameters to consider here:
--SOURCES '1331+305', '0137+331', or '0542+498' (whichever one you used. sometimes you will have two different flux calibrators, and you can enter them both here.
--OPTYPE 'CALC'


AIPS 1: SETJY Task to enter source info into source (SU) table.
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: INNAME 'AC825_FQ1' Input image name (name)
AIPS 1: INCLASS 'CH 0' Input image name (class)
AIPS 1: INSEQ 1 Input image name (seq. #)
AIPS 1: INDISK 1 Input image disk unit #
AIPS 1: SOURCES '1331+305' Sources to modify.
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Source qualifier -1=>all
AIPS 1: BIF 0 Low IF # for flux density
AIPS 1: EIF 0 High IF # for flux density
AIPS 1: ZEROSP *all 0 I,Q,U,V flux density (Jy)
AIPS 1: OPTYPE 'CALC' ' ' => use other adverbs
AIPS 1: for required operation
AIPS 1: 'CALC' => determine
AIPS 1: 3C286/3C48/1934 fluxes from
AIPS 1: standard formulae
AIPS 1: 'REJY' => reset source
AIPS 1: fluxes to zero.
AIPS 1: 'REVL' => reset velocity
AIPS 1: to zero
AIPS 1: 'RESE' => reset fluxes &
AIPS 1: velocities to zero.
AIPS 1: CALCODE ' ' New calibrator code:
AIPS 1: '----' => change to blank
AIPS 1: SYSVEL 0 Velocity of source (km/s)
AIPS 1: RESTFREQ 0 0 Line rest frequency (Hz)
AIPS 1: VELTYP ' ' Velocity type 'LSR,'HELIO'
AIPS 1: VELDEF ' ' Velocity definition 'RADIO',
AIPS 1: 'OPTICAL'
AIPS 1: FREQID 0 FQ table entry to use for
AIPS 1: velocity information and
AIPS 1: 'CALC' option
AIPS 1: APARM *all 0 (1): Pixel to which SYSVEL
AIPS 1: refers ( 0=>1)
AIPS 1: (2): Only for 'CALC' option:
AIPS 1: <= 0 => use latest VLA
AIPS 1: values (1999.2) or,
AIPS 1: for 1934-638, the
AIPS 1: ATCA value of 30Jul94.
AIPS 1: 1 => use Baars values
AIPS 1: or old ATCA/PKS values
AIPS 1: for 1934-638
AIPS 1: 2 => use VLA 1995.2
AIPS 1: values or for 1934-638
AIPS 1: the ATCA value of
AIPS 1: 30Jul94.
AIPS 1: >= 3 => use oldest VLA
AIPS 1: values (1990) or,
AIPS 1: for 1934-638, the
AIPS 1: ATCA value of 30Jul94.
AIPS 1: (3): Only for 'CALC' option:
AIPS 1: multiply the calculated
AIPS 1: fluxes by APARM(3) with
AIPS 1: 0 -> 1


Now it's time to run calib!
(I wouldn't use VLACALIB (like the AIPS cookbook tells you too) because some parts of VLACALIB are a bit of a black box, and can set certain parameters quite mysteriously (I've had it use SOLINT = 400 before, for no good reason).

Run calib on your flux calibrator first. Here are some parameters you should definitely worry about and set:
CALSOUR '1331+305' (name of flux calibrator)
UVRANGE (find this in the VLA calibrator manual. the best calibrators are ones where you don't have to set this.)
DOCALIB 2 (apply weights)
REFANT 6 (you chose a refant in step 3, use it!)
SOLINT 1 (this is how often to solve for a calibration solution. 1 seems to work well often.)
SOLMODE 'A&P' (calibrate amplitudes and phases)

AIPS 1: CALIB: Task to determine calibration for data.
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: Input uv data.
AIPS 1: INNAME 'AC825_FQ1' UV file name (name)
AIPS 1: INCLASS 'CH 0' UV file name (class)
AIPS 1: INSEQ 1 UV file name (seq. #)
AIPS 1: INDISK 1 UV file disk drive #
AIPS 1: Data selection (multisource):
AIPS 1: CALSOUR '1331+305' Calibrator sources
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Calibrator qualifier -1=>all
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: SELBAND -1 Bandwidth to select (kHz)
AIPS 1: SELFREQ -1 Frequency to select (MHz)
AIPS 1: FREQID 1 Freq. ID to select.
AIPS 1: TIMERANG *all 0 Time range to use.
AIPS 1: BCHAN 0 Lowest channel number 0=>all
AIPS 1: ECHAN 0 Highest channel number
AIPS 1: ANTENNAS *all 0 Antennas to select. 0=all
AIPS 1: DOFIT *all 0 Subset of ANTENNAS list for
AIPS 1: which solns are desired.
AIPS 1: ANTUSE *all 0 Mean gain is calculated
AIPS 1: (CPARM(2)>0) using only the
AIPS 1: listed antennas. See explain.
AIPS 1: SUBARRAY 0 Subarray, 0=>all
AIPS 1: UVRANGE 0 0 Range of uv distance for full
AIPS 1: weight
AIPS 1: WTUV 0 Weight outside UVRANGE 0=0.
AIPS 1: WEIGHTIT 0 Modify data weights function
AIPS 1: Cal. info for input:
AIPS 1: DOCALIB 2 If >0 calibrate data
AIPS 1: = 2 calibrate weights
AIPS 1: GAINUSE 0 CL table to apply.
AIPS 1: DOPOL -1 If >0 correct polarization.
AIPS 1: BLVER -1 BL table to apply.
AIPS 1: FLAGVER 1 Flag table version
AIPS 1: DOBAND -1 If >0 apply bandpass cal.
AIPS 1: Method used depends on value
AIPS 1: of DOBAND (see HELP file).
AIPS 1: BPVER 1 Bandpass table version
AIPS 1: SMOOTH *all 0 Smoothing function. See
AIPS 1: HELP SMOOTH for details.
AIPS 1:
AIPS 1: CLEAN map. See HELP.
AIPS 1: IN2NAME ' ' Cleaned map name (name)
AIPS 1: IN2CLASS ' ' Cleaned map name (class)
AIPS 1: IN2SEQ 0 Cleaned map name (seq. #)
AIPS 1: IN2DISK 0 Cleaned map disk unit #
AIPS 1: INVERS 0 CC file version #.
AIPS 1: NCOMP *all 0 # comps to use for model.
AIPS 1: 1 value per field
AIPS 1: FLUX 0 Lowest CC component used.
AIPS 1: NMAPS 0 No. Clean map files
AIPS 1: CMETHOD ' ' Modeling method:
AIPS 1: 'DFT','GRID',' '
AIPS 1: CMODEL ' ' Model type: 'COMP','IMAG'
AIPS 1: SMODEL *all 0 Source model, 1=flux,2=x,3=y
AIPS 1: See HELP SMODEL for models.
AIPS 1:
AIPS 1: Output uv data file.
AIPS 1: OUTNAME ' ' UV file name (name)
AIPS 1: OUTCLASS ' ' UV file name (class)
AIPS 1: OUTSEQ 0 UV file name (seq. #)
AIPS 1: OUTDISK 0 UV file disk drive #
AIPS 1:
AIPS 1: Solution control adverbs:
AIPS 1: REFANT 6 Reference antenna
AIPS 1: SOLINT 1 Solution interval (min)
AIPS 1: SOLSUB 0 Solution subinterval
AIPS 1: SOLMIN 0 Min solution interval
AIPS 1: APARM *all 0 General parameters
AIPS 1: 1=min. no. antennas
AIPS 1: 2 > 0 => data divided
AIPS 1: 3 > 0 => avg. RR,LL
AIPS 1: 5 > 0 => avg. IFs.
AIPS 1: 6=print level, 1=good,
AIPS 1: 2 closure, 3 SNR
AIPS 1: 7=SNR cutoff (0=>5)
AIPS 1: 8=max. ant. # (no AN)
AIPS 1: 9 > 0 => pass failed soln
AIPS 1: Phase-amplitude Parameters:
AIPS 1: DOFLAG 0 Flag on closure error?
AIPS 1: SOLTYPE ' ' Soln type,' ','L1','GCON',
AIPS 1: 'R', 'L1R', 'GCOR'
AIPS 1: SOLMODE 'A&P' Soln. mode: 'A&P','P','P!A',
AIPS 1: 'GCON',
AIPS 1: SOLCON 0 Gain constraint factor.
AIPS 1: MINAMPER 0 Amplitude closure error
AIPS 1: regarded as excessive in %
AIPS 1: MINPHSER 0 Phase closure error regarded
AIPS 1: as excessive in degrees
AIPS 1: CPARM *all 0 Phase-amp. parameters
AIPS 1: 1 = Min el for gain
AIPS 1: normalization (deg)
AIPS 1: 2 >0 => normalize gain
AIPS 1: 3 avg. amp. closure err
AIPS 1: 4 avg. ph. closure err
AIPS 1: 5 >0 => scalar average
AIPS 1: 6 limit clipping in robust
AIPS 1: SNVER 0 Output SN table, 0=>new table
AIPS 1: ANTWT *all 0 Ant. weights (0=>1.0)
AIPS 1: GAINERR *all 0 Std. Dev. of antenna gains.
AIPS 1: BADDISK *all 0 Disk no. not to use for
AIPS 1: scratch files.

You will get some output that looks like this:

localh> CALIB1: Writing SN table 1
localh> CALIB1: RPOL, IF= 1 The average gain over these antennas is 3.080E+00
localh> CALIB1: RPOL, IF= 2 The average gain over these antennas is 3.088E+00
localh> CALIB1: LPOL, IF= 1 The average gain over these antennas is 3.033E+00
localh> CALIB1: LPOL, IF= 2 The average gain over these antennas is 3.086E+00
localh> CALIB1: Found 2321 good solutions
localh> CALIB1: Failed on 7 solutions

Some ways to tell if your data is really acting up is if you have tons of bad solutions (if you do, you might want to consider increasing your solint). Additionally, for some telescopes (not really for the VLA), if you have lots of bad solutions, you might have to tell CALIB to accept points of lower quality.
aparm(1) = 4 (CALIB default is a minimum of 6 antennas for a good solution, you could decrease it to 4.)
aparm(7) = 3 (CALIB default is a signal-to-noise in your solutions of 5. This is a bit high for some telescopes, and can reasonably be decreased to 3.)
soltype = 'L1' (this should be a more robust method for finding solutions (robust against outlying points). However, AIPS wants you to know that you will "lose some statistical efficiency". You could try other robust soltypes, too, but be warned they might be slow.)

Additionally, in my experience, it's a good thing that those 4 numbers (one for each polarization and IF) are all about the same (around 3.08). If one is really different than the others, than it might imply that their is bad data in that if/polarization.

All CALIB does is spit out a 'SN' table. The way we have it right now (SNVER = 0), every time you run CALIB it will spit out a new SN table. If you set SNVER = 1, every time you run CALIB, it would just append new information to this table.

Let's see if this calibration brought up any new bad data that needs to be flagged. If we want to apply calibration to our data in tasks like UVPLT and TVFLG, the calibration needs to be in a 'CL' table, not a "SN' table (yeah, stupid AIPS rule). To copy our 'SN' table to a 'CL' table, use VLACLCAL. First, you will need to type:

run vlaprocs

to load up the task VLACLCAL. Then set three important parameters. In this case, we'll use:
SOURCES = '1331+305' (the name of your flux cal)
CALSOUR = '1331+305' (the name of your flux cal)
REFANT = 6 (your reference antenna)

AIPS 1: VLACLCAL Procedure to run CLCAL and LISTR for VLA data.
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: Use RUN VLAPROCS first
AIPS 1: INNAME 'AC825_FQ1' Input UV file name (name)
AIPS 1: INCLASS 'CH 0' Input UV file name (class)
AIPS 1: INSEQ 1 Input UV file name (seq. #)
AIPS 1: INDISK 1 Input UV file disk unit #
AIPS 1: SOURCES '1331+305' Source list to calibrate
AIPS 1: *rest ' '
AIPS 1: SOUCODE ' ' Source "Cal codes"
AIPS 1: CALSOUR '1331+305' Cal sources for calibration
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Source qualifier -1=>all
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: FREQID 1 Unique frequency code
AIPS 1: TIMERANG *all 0 Time range to calibrate
AIPS 1: SUBARRAY 0 Subarray, 0=>all
AIPS 1: INTERPOL ' ' Interpolation function
AIPS 1: SAMPTYPE ' ' Smoothing function
AIPS 1: DOBLANK 0 Blanked value interpolation
AIPS 1: DOBTWEEN 1 > 0 -> smooth all sources
AIPS 1: together; else separate them
AIPS 1: SMOTYPE ' ' Data to smooth
AIPS 1: BPARM *all 0 Smoothing parameters
AIPS 1: ICUT .1 Cutoff for functional forms
AIPS 1: GAINVER 0 Input Cal table 0=>1
AIPS 1: GAINUSE 0 Output CAL table 0=>2
AIPS 1: REFANT 6 Reference antenna 0=>pick.
AIPS 1: DOPRINT 1 >0 Print messages to a file
AIPS 1: or to the printer.
AIPS 1: OUTPRINT *all ' ' Printer disk file to save
AIPS 1: BADDISK *all 0 Disks to avoid for scratch

This should write out a CL table 2. If you want to apply this caibration in, say, TVFLG, you would just use
DOCAL = 2
GAINUSE = 2
and that applies the CL table 2.

At this point, I also like to flag on phase. I've had a few data sets where amplitudes looks ok for the calibrators, but there are still some quite aberrant points in phase. In general, any points with phases > +/-10 degrees are probably bad (for your calibrators, which are point sources!!! unfortunately, you won't be able to flag on phase at all for your target source, because your target source will not be a point source and will therefore have phases running the whole gamut from -180 to +180 degrees.)

If you want to 'undo' the calibration (let's say because you flagged some data, and now you want to do a new and improved calibration and no longer need your old one), just delete your SN tables, and all CL tables which are greater than 1. BUT DON'T DELETE CL TABLE 1!!! This has important basic information in it.

When you think you have the very best calibration for your flux calibrator, I like to then repeat this same process for my phase calibrator. Iterate by running CALIB and VLACLCAL on your phase calibrator, and then flagging it until in uvplt there are very no aberrant points left in amplitude or phase. (Make sure you check each IF and each polarization!)

Now, when you trust your calibration/flagging for both your calibrators, Delete your SN tables and CL table #2. Let's do final runs of CALIB. At this point I set SNVER = 1 so that CALIB will write out solutions for both calibrators to the same SN table.
--Run CALIB on your flux calibrator.
--Run CALIB on your phase calibrator.

Now, run GETJY to get a flux for your phase calibrator. Parametrs to set:
SOURCES = your phase calibrator
CALSOUR = your flux calibrator

AIPS 1: GETJY Task to determine source flux densities.
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: INNAME 'AC825' Input UV file name (name)
AIPS 1: INCLASS 'CH 0' Input UV file name (class)
AIPS 1: INSEQ 1 Input UV file name (seq. #)
AIPS 1: INDISK 1 Input UV file disk unit #
AIPS 1: SOURCES '1033+395' Source list to find fluxes
AIPS 1: *rest ' '
AIPS 1: SOUCODE ' ' Source "Cal codes"
AIPS 1: CALSOUR '1331+305' Cal sources for calibration
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Source qualifier -1=>all
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: BIF 0 Lowest IF number 0=1
AIPS 1: EIF 0 Highest IF number
AIPS 1: TIMERANG *all 0 Time range of solutions.
AIPS 1: ANTENNAS *all 0 Antennas to use
AIPS 1: SUBARRAY 0 Subarray, 0=>all
AIPS 1: SELBAND -1 Bandwidth to select (kHz)
AIPS 1: SELFREQ -1 Frequency to select (MHz)
AIPS 1: FREQID 2 Freq. ID to select.
AIPS 1: SNVER 2 Input SN table, 0=>all.

You will get some output that looks like this:

localh> GETJY1: Task GETJY (release of 31DEC05) begins
localh> GETJY1: Source:Qual CALCODE IF Flux (Jy)
localh> GETJY1: 1033+395 : 0 A 1 .40437 +/- .00091
localh> GETJY1: 2 .39109 +/- .00074
localh> GETJY1: Appears to have ended successfully
localh> GETJY1: localhost 31DEC05 TST: Cpu= .0 Real= 0

At this point, what you want to worry about is the errors in the fluxes determined for your phase cal. If they are big, something has gone awry. What you do NOT need to worry about is if the fluxes are significantly different from those in the VLA calibrator manual. Remember that these calibrators are AGN-- they vary in flux!! Flux calibrators have been chosen because their fluxes are hopefully quite steady, but phase calibrators have only been chosen to be pointy. Their fluxes may vary. That's why you are comparing them with the flux calibrator, to get the best flux determination for them at the time of your observations!

A fun exercise is to look up your phase calibrator using this Java applet. It will show you how the flux of your calibrator has changed over time (their are only data points here when someone has actually used your phase calibrator for their VLA observations).

Finally, do final runs of VLACLCAL.
Do one run with
SOURCES = your phase cal, your target sources
CALSOUR = your phase cal
Do one more run with
SOURCES = your flux cal
CALSOUR = your flux cal
The defaults on VLACLCAL are smart enough to always output to CL table #2 (even if it already exists).

A good way to do a final check of your calibration (although it should be quite good if you have done it the iterative way I suggest!) is to run LISTR in 'MATX' mode.
OPTYPE = 'MATX'
SOURCES = your phase cal
DOCAL = 2
GAINUSE = 2
DPARM(1) = 5
DOCRT = -1
OUTPRINT = a file name

AIPS 1: LISTR: Task to print UV data and calibration tables.
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: USERID 0 User number.
AIPS 1: INNAME 'AC825' UV data (name).
AIPS 1: INCLASS 'CH 0' UV data (class).
AIPS 1: INSEQ 1 UV data (seq. #). 0 => high
AIPS 1: INDISK 1 Disk unit #. 0 => any
AIPS 1: OPTYPE 'MATX' List type:
AIPS 1: 'MATX','LIST','GAIN','SCAN'
AIPS 1: INEXT 'CL' CL, SN or TY table for 'GAIN'
AIPS 1: INVER 0 CL, Sn or TY table version
AIPS 1: SOURCES '1033+395' Source list
AIPS 1: *rest ' '
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: TIMERANG *all 0 Time range to list
AIPS 1: STOKES ' ' Stokes type to list.
AIPS 1: SELBAND -1 Bandwidth to select (kHz)
AIPS 1: SELFREQ -1 Frequency to select (MHz)
AIPS 1: FREQID 0 Freq. ID to select.
AIPS 1: None selected => 1.
AIPS 1: BIF 1 Lowest IF number 0=1
AIPS 1: EIF 1 Highest IF number
AIPS 1: BCHAN 1 Low channel number 0=>1
AIPS 1: ECHAN 0 High channel number
AIPS 1: ANTENNAS *all 0 Antennas to list
AIPS 1: BASELINE *all 0 Baselines with ANTENNAS
AIPS 1: UVRANGE 0 0 UV range in kilolambda
AIPS 1: SUBARRAY 0 Subarray, 0=>1
AIPS 1: Cal. info for input:
AIPS 1: DOCALIB 2 If >0 calibrate data
AIPS 1: = 2 calibrate weights
AIPS 1: GAINUSE 2 CAL (CL or SN) table to apply
AIPS 1: DOPOL -1 If >0 correct polarization.
AIPS 1: BLVER -1 BL table to apply.
AIPS 1: FLAGVER 0 Flag table version
AIPS 1: DOBAND -1 If >0 apply bandpass cal.
AIPS 1: Method used depends on value
AIPS 1: of DOBAND (see HELP file).
AIPS 1: BPVER -1 Bandpass table version
AIPS 1: SMOOTH *all 0 Smoothing function. See
AIPS 1: HELP SMOOTH for details.
AIPS 1: DPARM 5 1 Control info:
AIPS 1: *rest 0 (1) 0=amp, 1=phase, 2=rms
AIPS 1: 3=amp+rms, 4=phase+rms
AIPS 1: 5=amp+phase, 6=delay,
AIPS 1: 7=rate, 8=SNR, 9=par. ang
AIPS 1: 10 = Tsys, 11=elev,
AIPS 1: 12 = multiband delay
AIPS 1: 13 = Tant 14 = weights
AIPS 1: N.B. Options 3 and 4 only
AIPS 1: valid for OPTYPE = 'MATX'
AIPS 1: (2) 0=vec avg, 1=scalar
AIPS 1: (3) No. col (4-10) def=4.
AIPS 1: (4) avg. time min (MATX,LIST)
AIPS 1: *** significant
AIPS 1: (5) Type of gain listings:
AIPS 1: 0 => all with same scale
AIPS 1: like DEC-10 listings;
AIPS 1: 1 => scan/source info at
AIPS 1: source/scan boundaries.
AIPS 1: (6) Matrix scaling control:
AIPS 1: 0 => plot amp & rms
AIPS 1: matrices with same scale;
AIPS 1: 1 => self-scale each
AIPS 1: separately.
AIPS 1: (7) > 0 self-scale phase
AIPS 1: displays, else degrees.
AIPS 1: DOACOR -1 > 0 include autocorrelations
AIPS 1: FACTOR 0 When DPARM(5)=0 Multiply
AIPS 1: gain listings by FACTOR,
AIPS 1: 0=> use scale factor from
AIPS 1: first record printed.
AIPS 1: DOCRT -1 > 0 -> use the terminal,
AIPS 1: else use the line printer
AIPS 1: > 72 => terminal width
AIPS 1: OUTPRINT 'MATX_CAL1'
AIPS 1: Printer disk file to save
AIPS 1: BADDISK *all 0 Disk to avoid for scratch.

When you look at this list of numbers, amplitudes should be near constant between baselines and in time. Phases should be around zero. Lots of 0's and 1's are good! Teens and 20's are bad! If you have nice phases that are mostly small numbers, then...

Congratulations! You have calibrated your data!!!

No comments: