## This includes the commands and a function to plot ## bandpass table for separate antennaes ## JEH 12/05/01, modified from a script from gmoellen 01OCT29 ## ================================================ ## REQUIRES "BCAL_TABLENAME" TO BE DEFINED FROM WITHOUT ######################################### include 'table.g' include 'pgplotter.g' t:=table(BCAL_TABLENAME) gain:=t.getcol('GAIN'); # the indicies on the gain array are # [pol1,pol2,spw,channel,antenna] # pol1 and pol2 are 1 or 2, and are # meaningful for B tables only if pol1=pol2 Nchan:=shape(gain)[4] solok:=t.getcol('SOLUTION_OK'); # solok contains a 3D array of booleans # indicating which [spw,channel,antenna] # indicies are ok limits:= [0,Nchan+1,0,max(abs(gain))*1.1] limits:= [0,Nchan+1,0.95,1.05] # create the pgplotter tool mypg:=pgplotter() # Create a control panel frame for plotting to the pgplotter tool fm := frame() la := label(fm, 'Options:') b1 := button(fm, 'Next Antenna') b2 := button(fm, 'Prev Antenna') b3 := button(fm, 'Enter Antenna') b4 := button(fm, 'Change limits') b5 := button(fm, 'Done') # plot bandpass for antenna 1, using default limits i_ant :=0; plot1BP(i_ant+:=1,limits,gain,solok); # Create actions for different buttons whenever b1->press do { plot1BP(i_ant+:=1,limits,gain,solok); print 'plotting BP table for antenna',i_ant; if(i_ant >= 28) {i_ant:=0;} } whenever b2->press do { plot1BP(i_ant-:=1,limits,gain,solok); print 'plotting BP table for antenna',i_ant; if(i_ant <= 1) {i_ant:=29;} } whenever b3->press do { print 'Present Antenna:',i_ant; i_ant:=as_integer(newlimits:=readline('Enter Antenna to Plot>>')); plot1BP(i_ant,limits,gain,solok); } whenever b4->press do { print 'Present limits:',limits[1],limits[2],limits[3],limits[4]; limits:=as_float(split(newlimits:= \ readline('Enter New Limits (space delineated)>>'))); plot1BP(i_ant,limits,gain,solok); } whenever b5->press do { mypg.done(); fm := F; } ## ================================================ function plot1BP(i_ant,xylimits,gaintable,okarray) # assumes pgplot tool mypg has already been created. { Nchan:=shape(gaintable)[4] Npol:=shape(gaintable)[1] mypg.env(xylimits[1],xylimits[2], xylimits[3], xylimits[4], 0,0); if (any(okarray[1,,i_ant])) { for (pol in 1:Npol) { x:=seq(Nchan) # list of channel numbers, from 1..Nchan y:=abs(gain[pol,pol,1,,i_ant]) # mask out the bad channels: x:=x[okarray[1,,i_ant]]; y:=y[okarray[1,,i_ant]]; mypg.sci((i_ant+pol-1)%10+2); # use colors 2-11 mypg.pt(x,y,17); # plot y vs. x with symbol 17 mypg.line(x,y); # connect x-y #make and plot antenna labels: xtxt:= limits[1]+1; ytxt:= limits[4]*0.95+limits[3]*0.05; mypg.ptxt(xtxt,ytxt,0,0,spaste("Antenna ",i_ant)); xtxt:= limits[2]-10; if (pol==2) xtxt:=limits[2]-5; mypg.ptxt(xtxt,ytxt,0,0,spaste("IF=",pol)); } } # reset color to white: mypg.sci(1) }