From gmoellen@cv3.cv.nrao.edu Mon Oct 29 14:10:20 2001 Date: Mon, 29 Oct 2001 13:41:15 -0700 (MST) From: George Moellenbrock To: aips2-naug@cv3.cv.nrao.edu Subject: Glish to plot from gain table Hi gang, Here is the long-awaited script that will help you plot values from the gain table. Really, this is a short lesson in plotting data from any aips++ table. The main point to be made here is that the convention for storing data in a table (see aips++ Note 240 in the "Learn More" section of the aips++ webpage for the cal table definition, and Note 229 for the MS defn) must be known so that you can extract what you want from a multi-dimensional column. In the case in question, the GAIN column of a bandpass calibration table is 5D: it is a list of 2D Jones matrices indexed for row (a list of antennas and potentially times), channel, and spectral_window. The example below makes use of a 'B' cal table generated for the ngc5921 test dataset. One bandpass solution for each antenna for the whole observation was obtained. The following script won't necessarily be appropriate for every 'B' table, e.g., if there is more than one row per antenna (several solution times). Also, I only label the antennas on the plot in a very primitive way. Please consult the Glish Ref Manual for tips on how to index the gain array according to values in the ants array, and for how to use pgplot thru glish. Above all, have fun tinkering in glish! It only takes an hour or two to get the hang of this sort of generic processing and plotting, and I (for one) have found it very useful. (The recipes page will be updated later this week with a number of similar generic scripts, as well as the standard reduction scripts.) Of course, this level of effort to plot bandpass solutions is not expected of users; I am fixing up plotcal this week. The point is that you can use the generic capability to plot what you want and how you want it. Cheers, George # script to plot amplitudes from 'B' cal table # (gmoellen 01OCT29) include 'table.g' include 'pgplotter.g' # make table tool on cal table: t:=table('ngc5921.bcal') # Extract useful columns (correcting index columns for zero-based # counting): ants:=t.getcol('ANTENNA1') + 1; gain:=t.getcol('GAIN'); solok:=t.getcol('SOLUTION_OK'); # The indices on the gain array are [pol1,pol2,spw,ch,row], where pol1 and # pol2 are 1 or 2, and are meaningful for B tables only if pol1=pol2. # solok now contains a 3D array of booleans indicating which spw,ch,row # indices are ok. # List the ants (one for every antenna in the ANTENNA table, even if # there is no data for some of them): print ants; # the number of ants is the length of the unique(ants) array: nrow:=shape(ants) # List the shape of the gain array: print shape(gain); # make a pgplotter tool: mypg:=pgplotter() # set axes and make an empty plot # max x value is nchan+1: xmax:=shape(gain)[4]+1; # max y value is max amp gain x 1.1: ymax:=max(abs(gain))*1.1; mypg.env(0.0,xmax, 0.0,ymax, 0,0); # for each row plot the channel amplitudes: # ( you may want to choose only rows for specific antennas ) for (i in 1:nrow) { if (any(solok[1,,i])) { # any ch in this row ok? for (pol in 1:2) { x:=seq(shape(gain)[4]) # list of channel numbers y:=abs(gain[pol,pol,1,,i]) # mask out the bad channels: x:=x[solok[1,,i]]; y:=y[solok[1,,i]]; mypg.sci((i+pol-1)%10+2) # use colors 2-11 mypg.pt(x,y,17) # plot y vs. x with symbol 17 xtxt:= (i/nrow)*xmax; ytxt:= ymax*0.95; if (pol==2) ytxt:=ymax*0.9; mypg.ptxt(xtxt,ytxt,0,0,spaste(ants[i])); } } } # reset color to white: mypg.sci(1)