Wednesday, March 3, 2010

CVEL bug

I received an email yesterday informing people of a bug in CVEL - that is, if you run CVEL on a data set after SPLIT with an NX table, you are affected! I wanted to post it here in case you're not on the Midnight Job (MNJ) list (which I wasn't). Essentially, CVEL will only shift the first scan to the new velocity axis, while the other scans are not shifted. This bug is explained here. I think the possible fixes are to either run CVEL before SPLIT or to run the midnight job to update your AIPS version and then rerun the new CVEL version on your data.

Read more!

Wednesday, February 17, 2010

CASA guides

Hey! If you're learning CASA, check out this new collection of tips and tutorials that I've been contributing to:
http://casaguides.nrao.edu/

And let me know if you see obvious holes in the documentation there (which is, clearly, still under development).


Read more!

Error in PCAL

Here's a question from Akshaya Rane:

I am doing polarization calibration and while trying to run 'pcal', I have encountered the following error. Does this has to do something with qualifiers?

PCAL 3: TOTAL INTENSITIES MUST BE PROVIDED
PCAL 3: Purports to die of UNNATURAL causes

Any thoughts?

I should add that Eric Greisen says that if you spend an hour trying to figure out something in AIPS, and you can't, you should feel free to email him and ask his help.


Read more!

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.

Update: New and improved as of March 5, 2010:

































































AIPSCASA Purpose
APROPOS taskhelp List tasks with a short description of their purposes
BLCAL blcal Calculate a baseline-based gain calibration solution
BLCHN blcal Calculate a baseline-based bandpass calibration solution
BPASS bandpass Calibrate bandpasses
CALIB gaincal Calibrate gains (amplitudes and phases)
CLCAL applycal Apply calibration to data
COMB immath Combine images
CPASS cpass Calibrate bandpasses by polynomial fitting
DBCON concat Concatenate ''u-v'' datasets
DEFAULT default Load a task with default parameters
FILLM importvla Import old-format VLA data
FITLD importuvfits Import a ''u-v'' dataset which is in FITS format
FITLD importfits Import an image which is in FITS format
FITTP exportuvfits Write a ''u-v'' dataset to FITS format
FITTP exportfits Write an image to FITS format
FRING --- Calibrate group delays and phase rates.
GETJY fluxscale Determine flux densities for other cals
GO go Run a task
HELP help Display the help page for a task
IMAGR clean Image and deconvolve
IMFIT imfit Fit gaussian components to an image
IMHEAD vishead View header for ''u-v'' data
IMHEAD imhead View header for an image
IMLIN imcontsub Subtract continuum in image plane
IMLOD importfits Import a FITS image
IMSTAT imstat Measure statistics on an image
INP inp View task parameters
JMFIT imfit Fit gaussian components to an image
LISTR listobs Print basic data
MCAT ls List image data files
MOMNT immoments Compute moments from an image
OHGEO imregrid Regrids an image onto another image's geometry
PBCOR immath Correct an image for the primary beam
PCAL polcal Calibrate polarization
POSSM plotcal Plot bandpass calibration tables
POSSM plotms Plot spectra
PRTAN listobs Print antenna locations
PRTAN plotants Plot antenna locations
QUACK flagdata Remove first integrations from scans
RENAME mv Rename an image or dataset
SETJY setjy Set flux densities for flux cals
SMOTH imsmooth Smooth an image
SNPLT plotcal Plot gain calibration tables
SPFLG viewer Flag raster image of time v. channel
SPLIT split Write out ''u-v'' files for individual sources
TASK inp Load a task with current parameters
TGET tget Load a task with parameters last used for that task
TVALL viewer Display image
TVFLG viewer Flag raster image of time v. baseline
UCAT ls List ''u-v'' data files
UVFIX fixvis Compute ''u'', ''v'', and ''w'' coordinates
UVFLG flagdata Flag data
UVLIN uvcontsub Subtract continuum from ''u-v'' data
UVLSF uvcontsub Subtract continuum from ''u-v'' data
UVPLT plotms Plot ''u-v'' data
UVSUB uvsub Subtracts model ''u-v'' data from corrected ''u-v'' data
WIPER plotms Plot and flag ''u-v'' data
ZAP rmtables Delete data files



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.

p.s. 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!