Tuesday, May 12, 2009

Super Resolution

When people say they have 'super-resolved' their source-- say, by having a 0.75" beam for VLA 20 cm A config observations-- what do they mean? Did they just ask CLEAN to give them a 0.75" restoring beam? This makes me feel very nervous. What do you guys think? Is it a good idea in some cases?



Read more!

Wednesday, April 15, 2009

AIPS Scripting Example Sans Commentary

For your viewing pleasure, here's an example AIPS script. What the script does is calibrate a VLA continuum data set (including polarization). Note that this script is NOT guaranteed to work for YOUR data! DO NOT USE THIS SCRIPT BLINDLY. I am posting this as an example of AIPS scripting, not as an example of how to reduce data.

See below the cut for the code.





*
* REDUCE.099
*
* Purpose: a set of routines designed to aid in the calibration process. Note that
* these procedures use stuff in VLAPROCS. RUN VLAPROCS before running
* routines in this file.
*
* NOTES on Run Files with AIPS:
*
* AIPS is stupid, so indenting stuff with tab characters causes AIPS to
* barf on a run file.
*
* To run a RUNFILE, create an environment variable in your shell with the
* directory where the runfile is. Name the runfile with something short
* ending in .099 (user number in hex; use EHEX in AIPS to find). In AIPS,
* change your version to version='myvlar080705'. Caution: you don't want
* any of your routine names or values to be the same as something already
* in AIPS. For example, naming a routine CLCAL will cause AIPS to use your
* CLCAL routine rather than the actual CLCAL routine. You read in your
* runfile with 'RUN reduce.099'. Changed the file and need to run again?
* Then just do RUN reduce.099 again. Note that AIPS doesn't get rid of
* the first instance of RUN reduce.099 in memory, so you need to use
* COMPRESS periodically to get rid of old reduce.099 stuff. COMPRESS also
* helps when you have issues after redefining variables etc. To nuke a
* procedure from the procedures list (help procs to see), use scratch.
* The procedure still takes up memory however until you run a compress. I
* haven't figured out how to get rid of old adverbs.
*
* Getting errors that say 'AIPS: SYMBOL?' means that POPS (the scripting
* language) doesn't recognize the command. Try help popsym to get a list
* of the commands available to you.
*
* 'TXTMAT: NO MEMBER NAME GIVEN' means that you should make sure there's
* procedure in the memory of AIPS.
*
* Note that the read command expects single quotes about whatever you
* enter on the keyboard. Respond 'Y' rather than Y to any prompts.
*
* Make sure that the last line of the file is empty otherwise the last
* line of the program will not be read.
*
*
* Date Programmer Description of Changes
* ----------------------------------------------------------------------
* 3/21/06 A.A. Kepley Original Code
* 3/23/06 A.A. Kepley Modified for new 12/05/05 dataset
* 9/12/06 A.A. Kepley Modified for use with AM694 dataset
* 2/09/06 A.A. Kepley Modified for use with AM643 dataset
* ======================================================================
*
proc dreduceme
*
* Purpose: dummy procedure to create variables used later
*
* Inputs: none
*
* Outputs: none
*
* Method: none
*
* Date Programmer Description of Changes
* ----------------------------------------------------------------------
* 3/21/06 A.A. Kepley Original Code
* 3/23/06 A.A. Kepley Modified for new 12/05/05 dataset
*
string*8 pri_cal $ name of primary calibrator.
string*8 sec_cal $ name of secondary calibrator. Also
$ used to calibrate the instrumental
$ polarization response.
string*8 obj_name(15) $ name of object (maybe more than 1).
scalar nobj $ number of objects
string*50 myoutname $ name of output file for various
$ tasks.
string*15 dataprefix $ what data set I'm reducing.
scalar myrefant $ reference antenna (1-29).
string*8 myprompt $ prompt value.
scalar polangle $ polarization angle
array pri_uvr(2) $ set uvrange for primary calibrator
array sec_uvr(2) $ set uvrange for secondary calibrators
scalar mysolint $ set my solution interval
scalar mypsolint $ set my solution interval for my polarization
*
return;finish
*
* ======================================================================
*
proc reduceme
*
* Purpose: Main calibration routine. This routine pretty thoroughly clobbers
* your AIPS environment you might want to do a save at the command
* line so you can go back to the way things were (using get)
*
* Inputs: The user needs to change the values for INNAME, INCLASS, INSEQ,
* INDISK, PRI_CAL, SEC_CAL, OBJ_NAME, DATAPREFIX, and MYREFANT for
* each data set. .
*
* Outputs: calibrated data set with final calibration table in CL 3 and
* gain and phase calibration table in CL 2. This task also produces a
* number of files in order to check on the calibration in your main home
* directory. If you run reduceme several times, the information from the
* later runs will be appended to the files. The files also include the
* task input parameters used to run the tasks. The files are named with
* the data set you are reducing, the object name, and the task which was
* run.
*
* Method: This calibration routine is for single channel continuum calibration
* including polarization calibration. It follows the procedures in
* Chapter 4 of the 31DEC05 version of the AIPS Cookbook closely.
* It uses the old method of calibrating the primary flux calibrator
* uv limits rather than a model of the source.
*
* REMEMBER TO CHECK ALL OUTPUT TO MAKE SURE THE REDUCTION WENT WELL AND
* THAT THE ROUTINE IS DOING WHAT YOU THINK IT SHOULD BE DOING.
*
* Date Programmer Description of Changes
* ----------------------------------------------------------------------
* 3/21/06 A.A. Kepley Original Code
* 3/23/06 A.A. Kepley Modified for new 12/05/05 dataset
* 9/12/06 A.A. Kepley Modified for AM694_1 dataset
* 2/09/07 A.A. Kepley Modified for AM643_1 dataset

* cleaning things up.
clrmsg
dowait true
default getjy
default setjy
default calib
default clcal
default listr
default pcal
default rldif
default clcor

* input file to calibrate
INNAME 'AM643_1 ' $ Input image name (name)
INCLASS 'X BAND' $ Input image name (class)
INSEQ 1 $ Input image name (seq. #)
INDISK 1 $ Input image disk unit #

* primary, secondary calibrator, and object to calibrate
pri_cal = '0521+166'
sec_cal = '0244+624'
obj_name = 'N1569',''

* Other defaults for calibration
nobj = 1
dataprefix = 'AM643_1.'
myrefant = 5
flagver 1
pri_uvr = 0,45 $ since the data are all less than 20 klamdba
sec_uvr = 0,0 $ this isn't too important
polangle = -20
mysolint = 0.0
mypsolint = 1.0

* Run setjy to find the flux value for the primary calibrator
prtask 'SETJY' $ clearing out the results
clrmsg $ of previous runs of setjy.
task 'SETJY'
sources pri_cal,''
optype 'calc'
calcode ''
freqid 1
aparm 0
go
* Save the results of the setjy run
myoutname dataprefix !! pri_cal !! '.SETJY'
docrt false
outprint myoutname
prtask 'AIPS'
clrmsg
inputs setjy $ printing out the setjy inputs
prtmsg
prtask 'setjy' $ printing out the setjy results
prtmsg

* Run VLACALIB on the primary calibrator
* calsour pri_cal,''
* calcode ''
* uvrange pri_uvr
* refant myrefant
* snver 1
* minamper 10
* minphser 10
* docalib false
* gainuse 0
* doprint 1
* myoutname dataprefix !! pri_cal !! '.CALIB'
* outprint myoutname
* vlacalib

* Run VLACALIB on the secondary calibrator
* calsour sec_cal,''
* calcode ''
* uvrange sec_uvr
* refant myrefant
* snver 1
* minamper 10
* minphser 10
* doprint 1
* myoutname dataprefix !! sec_cal !! '.CALIB'
* outprint myoutname
* vlacalib

* Run CALIB on the primary calibrator
prtask 'CALIB'
clrmsg
task 'CALIB'
calsour pri_cal,''
calcode ''
bchan 1
echan 0
antennas 0
uvrange pri_uvr
weightit 0
snver 1
minamper 10
minphser 10
docalib false
clr2name
clroname
refant myrefant
gainuse 0
dopol false
doband false
solint mysolint
solsub 0
solmin 0
soltype ''
aparm 4,0
aparm(6) 2
solmode 'A&P'
cparm 0, 0, minamper/10, minphser/10, 1, 0
go
* Save results of CALIB run
myoutname dataprefix !! pri_cal !! '.CALIB'
docrt false
outprint myoutname
prtask 'AIPS'
clrmsg
inputs calib
prtmsg
prtask 'calib'
prtmsg

* Run CALIB on the secondary calibrator
prtask 'CALIB'
clrmsg
task 'CALIB'
calsour sec_cal,''
calcode ''
bchan 1
echan 0
antennas 0
uvrange sec_uvr
weightit 0
snver 1
minamper 10
minphser 10
docalib false
clr2name
clroname
refant myrefant
gainuse 0
dopol false
doband false
solint mysolint
solsub 0
solmin 0
soltype ''
aparm 4,0
aparm(6) 2
solmode 'A&P'
cparm 0, 0, minamper/10, minphser/10, 1, 0
go
* Save results of CALIB run
myoutname dataprefix !! sec_cal !! '.CALIB'
docrt false
outprint myoutname
prtask 'AIPS'
clrmsg
inputs calib
prtmsg
prtask 'calib'
prtmsg

* Transfering the flux density scale determined by the primary calibrator
* to the secondary calibrator and the polarization angle calibrator
prtask 'getjy'
clrmsg
task 'getjy'
sources sec_cal,''
soucode ''
calsour pri_cal,''
calcode ''
bif 1; eif 2
freqid 1
snver 1
go
* Save the results of the setjy run
myoutname dataprefix !! sec_cal !! '.GETJY'
docrt false
outprint myoutname
prtask 'aips'
clrmsg
inputs getjy
prtmsg
prtask 'getjy'
prtmsg

* Applying the gain and phase solutions from the secondary calibrator to the data
prtask 'clcal'
clrmsg
task 'clcal'
sources sec_cal, obj_name, ''
soucode ''
calsour sec_cal,''
calcode ''
opcode 'cali'
interpol '2pt'
doblank 1
dobtween 0
snver 1
gainver 1
gainuse 2
refant myrefant
go
* Save the results of the calib run
myoutname dataprefix !! sec_cal !! '.CLCAL'
docrt false
outprint myoutname
prtask 'aips'
clrmsg
inputs clcal
prtmsg
prtask 'clcal'
prtmsg

* Applying the gain and phase solutions from the primary calibrator to the
* primary calibrator
prtask 'clcal'
clrmsg
task 'clcal'
sources pri_cal,''
soucode ''
calsour pri_cal,''
calcode ''
opcode 'cali'
interpol '2pt'
doblank 1
dobtween 0
snver 1
gainver 1
gainuse 2
refant myrefant
go
* Save the results of the calib run
myoutname dataprefix !! pri_cal !! '.CLCAL'
docrt false
outprint myoutname
prtask 'aips'
clrmsg
inputs clcal
prtmsg
prtask 'clcal'
prtmsg

* looking at the results of the gain and phase calibration
task 'listr'
optype 'matx'
sources pri_cal,''
uvrange pri_uvr
calcode ''
stokes ''
freqid 1
bif 1; eif 1
docalib 2
gainuse 2
dparm 5, 1, 0 $ plot scalar averaged amp+phase
docrt false
myoutname dataprefix !! pri_cal !! '.GPCALRES'
outprint myoutname
go
bif 2; eif 2
go

task 'listr'
optype 'matx'
sources sec_cal,''
uvrange sec_uvr
calcode ''
stokes ''
freqid 1
bif 1; eif 1
docalib 2
gainuse 2
dparm 5, 1, 0 $ plot scalar averaged amp+phase
docrt false
myoutname dataprefix !! sec_cal !! '.GPCALRES'
outprint myoutname
go
bif 2; eif 2
go

bif 1; eif 2

* prompting to see if I want to do polarization calibration
print 'Do polarization calibration (Y/N)?'
read myprompt
if myprompt = 'N' then
return
end

* Calibrating the instrumental polarization
prtask 'pcal'
clrmsg
task 'pcal'
calsour sec_cal,''
docalib 2
gainuse 2
solint mypsolint
soltype 'appr'
prtlev 1
bparm 0
cparm 0
go
* Save the results of the pcal run
myoutname dataprefix !! sec_cal !! '.PCAL'
docrt false
outprint myoutname
prtask 'aips'
clrmsg
inputs pcal
prtmsg
prtask 'pcal'
prtmsg

* calibrate the absolute phase angle using either 3C286 (1331+305) or
* 3C138 (0521+166)
prtask 'rldif'
clrmsg
task 'rldif'
sources pri_cal,''
uvrange pri_uvr
docalib 2
gainuse 2
dopol true
docrt false
myoutname dataprefix !! pri_cal !! '.RLDIF'
outprint myoutname
go

* changing RLdif output to a phase offset correction
* I've changed the following (9/12/06) so that the polarization angle is set
* earlier in the program depending on what polarization angle source is used.
for i = 1:2
clcorprm(i) = polangle - clcorprm(i)
end

print 'finish clcorprm'

* applying the polarization corrections to the data
prtask 'clcor'
clrmsg
task 'clcor'
sources ''
stokes 'L'
gainver 2
gainuse 3
opcode 'polr'
go
* saving the results of the clcor run
myoutname dataprefix !! obj_name(1) !! '.CLCOR'
docrt false
outprint myoutname
prtask 'aips'
clrmsg
inputs clcor
prtmsg
prtask 'clcor'
prtmsg

* checking the polarization calibration
task 'rldif'
sources pri_cal, sec_cal,''
uvrange pri_uvr
freqid 1
bif 1; eif 2
docalib 2
gainuse 3
dopol 1
docrt false
myoutname dataprefix !! pri_cal !! '.PCALRES'
outprint myoutname
go

return;finish
*
* ======================================================================
*
proc killcal
*
* Purpose: clean up old calibration to run new calibration.
*
* Inputs: none
*
* Outputs: deletes all CL tables except CL 1 and all SN tables.
*
* Method: none
*
* Date Programmer Description of Changes
* ----------------------------------------------------------------------
* 3/21/06 A.A. Kepley Original Code
*
*
vlareset
inext 'sn'
invers -1
extdest

return; finish
*
* ======================================================================
*
proc test
*
* Purpose: test stuff
*
print 'Y or N'
read myprompt
print myprompt
if myprompt = 'Y' then
print 'Yay for Yes!'
return
else
print 'Boo for no!'
end

print 'hello world'

return; finish
*
* ======================================================================
*


Read more!

AIPS Scripting: Progress Update

From reader Bruce:

This scripting stuff is very useful, but I can't find scripting AIPS #3 and etc. Is it out there?

I have lots of files to input, run sdgrid on, then write out. I have no idea how I could go about making sure stuff gets in the right slot to work for any given task.

The short answer is that I haven't gotten around to writing it yet. (thesis) I'll put it on my to-do list for my observing run next month. It's a good task for 2 in the morning. I'll post an example script without commentary, in case some one would find it useful.

The slightly longer answer is that you don't need to worry about catalog slots. Instead of dealing with stuff through the getn mechanism, i.e., getn 209, you want to use the actual name of the file (INNAME, INCLASS, INSEQ, INDISK, etc.). That way you know you have the file you want, and don't have to depend on the catalog number always being the same.




Read more!

Saturday, March 7, 2009

More Missing Flux Cals

I'm reducing archival data, and a flux calibrator was unfortunately not taken at the beginning and the end of the observation. It was only taken at the beginning, and when I read the data in with FILLM, FILLM says that the antennas moved between my flux cal and my phase cal/data. FILLM then puts the flux cal in a different UV file from the data/phase cal.

I'm thinking the antennas couldn't have moved THAT much over 15 minutes (and all i want is a flux anyway), so I'd still like to use the flux cal (also there are no appropriate recent fluxes for the phase cal in any of the NRAO databases that Claudia suggested.) Is there a way to
a) apply a flux calibration solution from another uv file?
or
b) relax FILLM's requirements so that it will not be so sensitive to moving antennas and put everything in one file?
or
c) append a source to another UV file? I know uvglu appends in frequency, but i don't think it appends sources.

Thanks!


Read more!

Thursday, March 5, 2009

WBR Step 7C: Apply Your Calibration

After you have calibrated your calibrators, you are going to want to apply this calibration to your source data-- the object you actually care about imaging.

First, you need to make a CL table that interpolates the amplitude/phase solutions found every ~30 minutes for the phase calibrator to your source data. You can use CLCAL or VLACLCAL to do this. Let's say your sources are "PHS_CAL' and 'COOL_GAL', and you have a lovely SN table for 'PHS_CAL' which you determined using the steps in Section 6. Then your inputs to CLCAL will look like this:


AIPS 1: CLCAL Task to manage SN and CL calibration tables
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: INNAME 'NICE_DATA' Input UV file name (name)
AIPS 1: INCLASS 'L BAND' Input UV file name (class)
AIPS 1: INSEQ 2 Input UV file name (seq. #)
AIPS 1: INDISK 1 Input UV file disk unit #
AIPS 1: SOURCES 'PHS_CAL' Source list to calibrate
AIPS 1: 'COOL_GAL' *rest ' '
AIPS 1: SOUCODE ' ' Source "Cal codes"
AIPS 1: CALSOUR 'PHS_CAL' Cal sources for calibration
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Source qualifier -1=>all
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: TIMERANG *all 0 Time range to calibrate
AIPS 1: SUBARRAY 0 Subarray, 0=>all,
AIPS 1: ANTENNAS *all 0 Antennas selected, 0=> 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: OPCODE ' ' Operation 'MERG','CALI',
AIPS 1: 'CALP'; ' ' => 'CALI'
AIPS 1: INTERPOL '2PT' Interpolation function,
AIPS 1: choices are: '2PT','SIMP',
AIPS 1: 'AMBG','CUBE','SELF','POLY',
AIPS 1: 'SELN'; see HELP for details
AIPS 1: CUTOFF 0 Interpolation limit in
AIPS 1: time (min); 0=> no limit.
AIPS 1: SAMPTYPE ' ' Smoothing function
AIPS 1: BPARM *all 0 Smoothing parameters
AIPS 1: ICUT 0.1 Cutoff for functional forms
AIPS 1: DOBLANK 0 Blanked value interpolation
AIPS 1: DOBTWEEN 0 > 0 -> smooth all sources
AIPS 1: together; else separate them
AIPS 1: SMOTYPE ' ' Data to smooth
AIPS 1: SNVER 0 Input SN table, 0=>all.
AIPS 1: INVERS 0 Upper SN table vers in a
AIPS 1: range. 0=>SNVER
AIPS 1: GAINVER 1 Input Cal table 0=>high
AIPS 1: GAINUSE 2 Output CAL table 0=>high+1
AIPS 1: REFANT 8 Reference antenna 0=>pick.
AIPS 1: BADDISK *all 0 Disks to avoid for scratch

Now CL table #2 has all the info you need to calibrate your data!

Next, you want to apply this calibration and split your 'COOL_GAL' data off into a single source file. For this, use SPLIT.

AIPS 1: SPLIT Task to split multi-source uv data to single source
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: also works on single files.
AIPS 1: INNAME 'NICE_DATA' Input UV file name (name)
AIPS 1: INCLASS 'L BAND' Input UV file name (class)
AIPS 1: INSEQ 2 Input UV file name (seq. #)
AIPS 1: INDISK 1 Input UV file disk unit #
AIPS 1: SOURCES 'COOL_GAL' Source list
AIPS 1: *rest ' '
AIPS 1: QUAL -1 Source qualifier -1=>all
AIPS 1: CALCODE ' ' Calibrator code ' '=>all
AIPS 1: TIMERANG *all 0 Time range to copy
AIPS 1: STOKES ' ' Stokes type to pass.
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: BIF 0 Lowest IF number 0=>all
AIPS 1: EIF 0 Highest IF number 0=>all
AIPS 1: BCHAN 0 Lowest channel number 0=>all
AIPS 1: ECHAN 0 Highest channel number
AIPS 1: SUBARRAY 0 Subarray, 0=>all
AIPS 1: DOCALIB 2 > 0 calibrate data & weights
AIPS 1: > 99 do NOT calibrate weights
AIPS 1: GAINUSE 2 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: OUTCLASS 'SPLIT' Output UV file name (class)
AIPS 1: OUTSEQ 0 Output UV file name (seq. #)
AIPS 1: OUTDISK 0 Output UV file disk unit #.
AIPS 1: DOUVCOMP -1 1 (T) => compressed data
AIPS 1: APARM *all 0 Control information:
AIPS 1: 1 = 1 => avg. freq. in IF
AIPS 1: multi-channel out
AIPS 1: = 2 => avg. freq. in IF
AIPS 1: single channel out
AIPS 1: = 3 => avg IF's also
AIPS 1: 2 = Input avg. time (sec)
AIPS 1: 3 > 0 => Drop subarrays
AIPS 1: 4 > 0 => calibrate weights
AIPS 1: 5 = 0 pass only xc data
AIPS 1: = 1 pass xc and ac data
AIPS 1: = 2 pass only ac data
AIPS 1: 6 > 0 add full source name
AIPS 1: to header
AIPS 1: NCHAV 0 Number of chan. to average.
AIPS 1: (used if APARM(1) = 1)
AIPS 1: <= 0 -> ALL
AIPS 1: CHINC 0 Channel incr. between output
AIPS 1: channels (used if APARM(1)=1)
AIPS 1: ICHANSEL *all 0 Array of channel start, stop,
AIPS 1: and increment numbers and IF
AIPS 1: number to be used when
AIPS 1: averaging in frequency.
AIPS 1: (used if APARM(1) = 2, 3)
AIPS 1: BADDISK *all 0 Disks to avoid for scratch

The most important things to have set here are DOCAL = 2 and GAINUSE=2. If you have done other fancy things like a baseline-dependent calibration or a bandpass calibration, you can also apply those here.

SPLIT will make a file with just the calibrated data for your source of interest. You'll need to flag this single-source file, and then you'll be ready to image!



Read more!

Imaging with AIPS

Reader Elena has a question:

Could some of you indicate me a tutorial for imaging with AIPS ?
I would need something with examples, and possibly considering both point-like and extended sources.
So far I found this :
http://www-astro.physics.ox.ac.uk/~hrk/AIPS_TUTORIAL/HRK_AIPS_1.html#24.
It's not focused on imaging, but there are some useful images as examples. Besides, it doesn't consider the case when one can not self-calibrate (e.g. looking for all Stokes parameters), that would be very interesting for me.

My response is below.



Elena, I would suggest that you read the AIPS COOKBOOK section on imaging and check out the synthesis imaging summer school book on imaging as well. I also encourage you to play around with IMAGR and see how changing the different parameters changes the image.

Read more!

Wednesday, March 4, 2009

Why is imaging quick sometimes and slloooow others?

I have 6 sources, each with 2-3 hours of continuum L-band data on them. For five of them, imaging and self-calibration are really quite quick, but one of the sources takes a factor of 5-6 longer to image/calibrate than the others! Its correlator setup is not different, it was taken only one day previous to the other sources, and it has a similar amount of time on source. Any ideas about why imagr seems to choke for this source? Thanks!


Read more!