Thursday, February 4, 2010

AIPS to CASA cheat sheet

So, i've been spending the last couple days learning CASA, and I think the most intuitive way to think about it is in terms of what I would be doing in AIPS. Hence the below table. Most tasks in AIPS have a parallel in CASA, although it's not always a one-to-one transfer.





































AIPSCASA Purpose
TASK DEFAULT Load a task with default parameters
INP INP View task parameters
TGET TGET Load a task with parameters last used
GO GO Run a task
APROPOS ??? List tasks relevant to a keyword
FILLM IMPORTVLA Import data
DBCON CONCAT Concatenate uv files
LISTR LISTOBS Print basic data
IMHEAD VISHEAD View header for uv data
IMHEAD IMHEAD View header for an image
PRTAN LISTOBS Print antenna locations
PRTAN PLOTMS(??) Plot antenna locations
UCAT LS List uv data files
MCAT LS List image data files
DELETE RMTABLES Delete data files
QUACK FLAGDATA Remove first integrations from scans
UVFLG FLAGDATA Flag data
UVPLT PLOTMS Plot UV data
WIPER PLOTMS Plot and flag UV data
TVFLG VIEWER Flag raster image of time v. baseline
SPFLG VIEWER Flag raster image of time v. channel
SETJY SETJY Set flux densities for flux cals
GETJY FLUXSCALE Determine flux densities for other cals
CALIB GAINCAL Gain calibrate data
BPASS BANDPASS Bandpass calibrate data
SNPLT PLOTCAL Plot gain calibration tables
POSSM PLOTCAL Plot bandpass calibration tables
POSSM PLOTMS Plot spectra
CLCAL APPLYCAL Apply calibration to data
SPLIT SPLIT Write out uv files for individual sources
IMAGR CLEAN Image and deconvolve
TVALL VIEWER Display image




Do you have a favorite AIPS-to-CASA pair? Disagree with any of the above? Let me know in the comments! I'm still learning and I haven't even started thinking about image analysis yet!

p.s. I guess I'm supposed to be writing CASA documentation for the beginner (e.g., myself), so I doubt this is the last time I will be seeking feedback.

p.p.s. Why is blogger putting this horrific space before my table? I can't get rid of it and it looks fine in the preview. quack. This tip seemed to get rid of it.




Read more!

Plot labels and tick marks

Reader René would like to know about some aesthetic issues in plotting:

I have a question regarding labeling. The LTYPE-parameter (eg. in task 'greys') lets you plot "Label in arcsec or other units from reference pixel". This is just what I need, but it stupidly plots it in degrees instead of arcminutes. Is there a way to change this? (Except transforming the coordinates of the whole image I mean ...)

Also is there a way to adjust the number of ticks to plot? (Add minor and major ticks?)


Read more!

Monday, January 25, 2010

Joining Spectral Line Data with Multiple IFs

Occasionally I've encountered line data that are taken in 4-IF mode - that is, where you have 2 IFs, each tuned to different frequencies, that overlap on their edges. I found these to be a pain to combine the last time I worked with them (in my first Astronomy research project ever!), and they have resurfaced again now.. but I've discovered a much easier solution: UJOIN!

UJOIN takes a data set with 2 IFs tuned to different frequencies (as from 4-IF mode at the VLA), and joined them together. It even deals with re-weighting the overlap regions because now there's more data there! You will want to use UJOIN on data that has already been calibrated (gain AND bandpass).

Here are the inputs:


AIPS 1: UJOIN Converts IFs to additional spectral channels
AIPS 1: Adverbs Values Comments
AIPS 1: ----------------------------------------------------------------
AIPS 1: INNAME ' ' Input UV file name (name)
AIPS 1: INCLASS ' ' Input UV file name (class)
AIPS 1: INSEQ 0 Input UV file name (seq. #)
AIPS 1: INDISK 0 Input UV file disk unit #
AIPS 1: OUTNAME ' ' Output UV file name (name)
AIPS 1: OUTCLASS ' ' Output UV file name (class)
AIPS 1: OUTSEQ 0 Output UV file name (seq. #)
AIPS 1: OUTDISK 1 Output UV file disk unit #.
AIPS 1: CHANSEL *all 0 Begin, end input channels,
AIPS 1: begin output channel each IF
AIPS 1: OPCODE ' ' 'DIFF' to output the vis
AIPS 1: difference in the overlap
AIPS 1: DOWEIGHT 1 0 => delete spectrum if any
AIPS 1: IF or channel is flagged
AIPS 1: < -0.5 => keep data even if
AIPS 1: one of the IFs is flagged
AIPS 1: > 0.5 => delete channel if
AIPS 1: one of the IFs is flagged


The main thing to set is CHANSEL. This is a 6-element array:

chansel(1) - first channel to use from IF 1
chansel(2) - last channel to use from IF 1
chansel(3) - output channel that corresponds to 1st input channel from IF 1 (ugh)
chansel(4) - first channel to use from IF 2
chansel(5) - last channel to use from IF 2
chansel(6) - output channel that corresponds to 1st input channel from IF 2 (ugh again)


The AIPS help file on UJOIN has some helpful information on how to set these values properly, but I will reproduce what I did to set these - it's not completely straightforward.

Using UJOIN on your own data
First, you should apply all your calibrations in SPLIT. Make sure that when you SPLIT off your science source, you keep BIF and EIF set to 0 - this will create a single source file with both IFs.

Then, you will need to figure out the frequency and reference pixel of each of your observations (f_1, p_1, f_2, p_2). I did this by SPLITting each IF off separately from the LINE data and then running IMHEAD on each. You should also record delta_f (from IMHEAD again - this should be the same for each IF). In my case, f_2 was bigger than f_1 - if this is different for you, you'll have some sign differences somewhere and CHANSEL will be in a different order.

Next, figure out if any of the channels in your IFs are on the edges of the bandpass. You will not want to keep these channels as they will add noise into the final, combined UV data. Typically, look at the region where the bandpass is flat-ish, and use that. To find these, you will want to use POSSM to take a quick look at your bandpass solutions for each antenna:


default possm
aparm = 0, 1, 0.7, 1.3, -180, 180, 0, 2, 0, 0
source [bpass calibrator]
solint -1
nplots 9
dotv 1
bpver 0


Find the first and last channels of the flat-ish region for each IF (n_first,1; n_last,1; n_first,2; n_last,2).

Now you can start setting CHANSEL with the first and last channels for IF 1:


chansel(1) = n_first,1 # first channel from flat-ish part of bpass, if 1
chansel(2) = n_last,1 # last channel from flat-ish part of bpass, if 1
chansel(3) = 1 # ichansel(1) goes into output channel 1
chansel(4) = n_first,2 # first channel from flat-ish part of bpass, if 2
chansel(5) = n_last,2 # last channel from flat-ish part of bpass, if 2


Now we move on to chansel(6), which is not nearly as easy as the above part was. Here you have to figure out which output channel corresponds to chansel(4). You'll have to take into consideration all the other ichansel values. Here is the equation I came up with for ichansel(6):



You can find the derivation at the end of this post if you're interested or getting incorrect answers. (As Martha Haynes once said, "You get what you pay for and this is free!")



As a reminder, here's what all of the variables stand for:

n = this is the value for ichansel(6)
f_1,0 = reference frequency of IF 1
f_2,0 = reference frequency of IF 2
delta_f = frequency steps between channels
n_first,1 = first channel of IF 1 used in output
n_first,2 = first channel of IF 2 used in output
p_1 = reference channel of IF 1
p_2 = reference channel of IF 2


Testing that UJOIN did the right thing
You'll probably want to check that this actually worked correctly. The UJOIN help recommends that you use POSSM to check that the spectrum of the phase calibrator is flat.

- First, SPLIT off the phase calibrator separately.

- Next, run UJOIN on this phase calibrator file with the same inputs as for the galaxy.

- Check that the spectrum of the UJOIN data is flat in POSSM:

default possm
aparm 0
solint 0
nplots 0
source [phase calibrator]


This should plot the phase calibrator spectrum with data from all antennas averaged together.


My derivation of the ichansel(6) equation:
To figure this out, I wrote some equations to find the frequency at a given channel (f1, f2):



These tell you the frequency (f_1, f_2) at an arbitrary channel (n_1, n_2) for each IF. f_1,0 tells you the frequency at reference pixel p_1 for IF 1. f_2,0 tells you the frequency at reference pixel p_2, for IF 2. delta_f is the frequency steps between each channel.

Now we can write an equation to for the frequency of the output channels:


We can sub in for f_out,0 because we know what channel we're setting as the first output channel (ichansel 1!), and we know its frequency from the above equation for f_1 (n_1) for IF 1:



Now we want to know what output channel (n) corresponds to the first channel of IF 2 (n_first,2). Where does this occur in f_out?




Now just rearrange that for n!



Read more!

Tuesday, January 19, 2010

TV suddenly red?

Is your TV suddenly mis-behaving and showing everything in red rather than in black and white? Make sure that TVCHAN=1.


Read more!

Friday, January 8, 2010

IBLED error (related to the TV?)

Reader Ruta asks:

hi, i have come across an error message copied below while running task 'ibled' on a single source datafile. whats happening and why am i getting this error..? thanks in advance.
localh> IBLED1: Loading data for baseline 1 - 2
localh> IBLED1: Loading data from ***/12:00:53 to ***/11:54:54
localh> IBLED1: There are 25 valid vis. points on this baseline
localh> IBLED1: Loading AMPLITUDE
localh> IBLED1: with Stokes I chs 1- 1 IFs 1- 1
localh> IBLED1: Displaying pixels 1 to 35
localh> IBLED1: Data range 1.092369E+04 1.093816E+04
localh> IBLED1: VISLAB: ERROR 2 RETURNED FROM IMVECT
localh> IBLED1: IBFOAD: ERROR 2 FROM VISLAB
localh> IBLED1: LOADING ERROR 2 FROM IBFOAD
localh> IBLED1: TELEVISION I/O ERROR 2 FROM SETFRM
localh> IBLED1: Temporary master file to be destroyed
localh> IBLED1: Destroyed 1 extension files of type FC
localh> IBLED1: Destroyed UV image file: catno= 540 disk= 3
localh> IBLED1: Purports to die of UNNATURAL causes
localh> IBLED1: voodoo 31DEC09 TST: Cpu= 1.8 Real= 3 IO= 17

Does anyone have any ideas other than double-checking the parameters to make sure that they are correct?


Read more!

Tuesday, November 10, 2009

Heads Up! Inverted Axes for EVLA-VLA data..

I recently encountered an issue with one spectral line data set observed during the EVLA-VLA transition (like all my other data sets). So far, only this data set in particular is affected, but it could possibly apply to others if you notice this behavior. If you notice rotation that should not be there compared to other images, this may affect you!

Here are the weird things about this data set:

  1. The velocity axis appears to be backwards, but the header seems normal (is, the cdelt3 value in the header is not of the opposite sign).
  2. Compared to other observations of the same galaxy taken in different configurations, the map is rotated by 180 degrees on the plane of the sky, but again, the header seems normal (cdelt1/2 are both normal).
I spent a lot of time trying to figure out the cause of this and originally chalked it up to user error - i.e., something went wrong in the calibration, which gave the phases the opposite sign. Or so I thought.

Well! Turns out it was a bona fide problem with the EVLA transition, which inverted the velocity axis and gave the phase an incorrect sign. This has mostly been corrected in the archive, but is apparently still present in a few, lingering data sets. The fix for this is to use the task "FLOPM" on the data (after SPLIT) with opcode "VLAE".

Voila! Problem solved. Now if I could only get back the three weeks I spent banging my head against the proverbial AIPS wall.

Read more!

IMERG SECRETS

IMERG is a program that combines single dish and interferometer data (see Stanimirovic (2002) for details on the algorithm). In short, this algorithm (also referred to as "feathering") fourier transforms both the single dish and the interferometer data, uses the overlap region in uv space between the interferometer and single dish data to determine a scaling factor for the single dish data, adds the interferometer image and the scaled single dish image in fourier space, and then fourier transforms it back.

IMERG has a couple of extra caveats that the user should be aware of before running:

  • Both images need to be square and the dimensions a power of two.
  • Make very sure there are no blanks in either image. Use REMAG to replace any blanks with zero. Note that OHGEO will blank any region in the transformed image that is outside the boundaries of the original image. One of the signs that you may have some blanks in your image is really small scaling factors (~1e-8).
  • Make sure that the single dish image is big enough, i.e., make sure the galaxy is much smaller than the entire image.

Edit (11/13/09): As far as I can tell, IMERG does absolutely no checking that the two images have the same axes, so beware and double check that both images are the same. Also the beam that gets put in the resulting image is the single dish beam, not the interferometer beam. Use ADDBEAM to change.


Read more!