! onoff_map.nic ! ! def character comp_mean*20 let comp_mean "0"'scan_list' if (comp_mean.eq."0") then on error continue create dir <"Scan "'name' /pixel 900 300 /size 30 10 on error change dir <"Scan "'name' change win 0 else cl pl set plot land ! on error continue ! create dir <"ONOFF" /pixel 700 700 /size 20 20 ! on error ! change dir <"ONOFF" ! cl dir <"ONOFF" endif ! ! def real box1[4] box2[4] box3[4] box4[4] box5[4] box6[4] box0[4] if (comp_mean.eq."0") then let box1 1. 9 1.2 9.2 ! config let box2 10. 18. 1.2 9.2 ! signal (last scan) let box3 20. 28. 1.2 9.2 ! rms (last scan) else let box0 3.5 25 17 19 ! scan list let box4 3.5 12.5 9 18 ! mean (global) let box1 16. 25. 9 18 ! rms (global) let box5 3.5 13. 1.5 7 ! mean function of integrated scans let box6 16. 25.5 1.5 7 ! rms function of integrated scans endif ! !=================================================== ! Configuration map !=================================================== def int m l l2 def real cos_el sin_el pi let pi 3.1416 let m nrecord|2 LET COS_EL COS(EL[M]*pi|180) let sin_el sin(EL[M]*pi|180) ! let dmax2 onoff_beam**2 /new real def real d1 d2 d3 ! if (comp_mean.eq."0") then def real oa oe /like chan_flag def character filename*20 let filename 'name'".onf" sic search 'filename' if (.not.sic$exist) then say "File "'filename'" not found" return endif col x 2 y 3 /file 'filename' let oa x let oe y if (ref_chan.eq.1.and.nchan.eq.37) then lim -70 70 -70 70 else if (ref_chan.eq.1.and.nchan.eq.19) then lim -50 50 -50 50 else lim /var oa oe endif set box box1[1] box1[2] box1[3] box1[4] set exp 0.6 box set exp 0.6 DRAW TEXT 0.0 -.6 "\gDAz (arcsec)" 2 /BOX 2 DRAW TEXT -.8 1 "\gDEl (arcsec)" 4 90 /BOX 4 set exp 0.5 let w 5 /new int for i 1 to nchan if (.not.chan_flag[i]) then let d1 oa[i]*oa[i]+oe[i]*oe[i] ! ref chan let d2 (oa[i]-wobbler_throw)**2+oe[i]*oe[i] let d3 (oa[i]+wobbler_throw)**2+oe[i]*oe[i] pen 0 if d1.lt.dmax2 then pen 1 endif if d2.lt.dmax2 then pen 1 endif if d3.lt.dmax2 then pen 1 endif ellipse 5.5 /user oa[i] oe[i] draw t oa[i] oe[i] 'i' 5 /user endif next pen /def pen 1 draw r -100 0 5 /user draw l 100 0 5 /user /clip ! pen 3 ellipse 'onoff_beam' /user 0 0 ellipse 'onoff_beam' /user 'wobbler_throw' 0 ellipse 'onoff_beam' /user '-wobbler_throw' 0 pen 0 !======================================================= ! Signal (current scan) !======================================================= set box box2[1] box2[2] box2[3] box2[4] ! ! col z 7 /file 'filename' def real r /like z let r z ! rms col x 4 y 5 z 6 /file 'filename' DEFINE INT N def real xx yy zz rr /like chan_az_off def logi ff /like chan_flag let ff chan_flag ! LET N NXY-NCHAN def int j k sic out tmp.onf for i 1 to nchan let j n+i let xx[i] x[j] let yy[i] y[j] let zz[i] z[j] let rr[i] r[j] if (.not.chan_flag[i]) then if (i.ne.1) then ! say "before test" 'x[j]' 'xx[1]' 'y[j]' 'yy[1]' if ((abs(x[j]-xx[1]).gt.0.01).or.(abs(y[j]-yy[1]).gt.0.01)) then say 'i' 'x[j]' 'y[j]' 'z[j]' 'r[j]' /format i4 e12.4 e12.4 e12.4 e12.4 else let ff[i] yes endif else say 'i' 'x[j]' 'y[j]' 'z[j]' 'r[j]' /format i4 e12.4 e12.4 e12.4 e12.4 endif endif next sic out ! ! Unit system "touch .tmp" col x 1 /file ".tmp" ! just to close 'filename' def char c*1 accept c /col 'filename' /line 6 /format "58x,1a" if (c.ne."J".and.c.ne."s") then say "Cannot retrieve unit in "'filename' say "Unit will be fixed according to jansky_flag" let onoff_unit jansky_flag else let onoff_jy no if (c.eq."J") then let onoff_jy yes endif endif col x 2 y 3 z 4 /file tmp.onf def real maxsignal factor compute maxsignal max z let factor 1 if (maxsignal.lt.0.1.and.onoff_jy) then let factor 1000 let z z*factor let zz zz*factor let rr rr*factor endif if (ref_chan.eq.1.and.nchan.eq.37) then lim 70 -70 -70 70 else if (ref_chan.eq.1.and.nchan.eq.19) then lim 50 -50 -50 50 else lim /rev x endif ran 64 64 /nei 6 plot /scal lin set exp 0.6 box wedge set exp 0.4 for i 1 to nchan if (.not.ff[i]) then ellipse 5.5 /user xx[i] yy[i] draw t xx[i] yy[i] zz[i] 5 /user endif next set exp 0.6 DRAW TEXT 0.0 -.6 "\gD\ga (arcsec)" 2 /BOX 2 DRAW TEXT -.6 1. "\gD\gd (arcsec)" 4 90 /BOX 4 set exp 0.5 ! ! find the equation of line (El=0) in the (ra,dec) system ! Consider 2 channels : the reference channel and another to compute the angle ! of rotation let chan2 0 /new int for i 1 to nchan if chan2.eq.0 then if i.ne.ref_chan then if .not.chan_flag[i] then let chan2 i endif endif endif next col x 2 y 3 /file 'filename' let j n+chan2 let rad sqrt(x[j]**2+y[j]**2) /new real def real alpha1 alpha2 let alpha1 atan2(y[j],-x[j]) let alpha2 atan2(yy[chan2],xx[chan2]) let alpha alpha2-alpha1 /new real let p1 -100*tan(alpha) /new real pen 1 draw r -100 'p1' 5 /user let p1 -p1 draw l 100 'p1' 5 /user /clip pen 3 ellipse 'onoff_beam' /user 0 0 let p1 wobbler_throw*cos(alpha) let p2 wobbler_throw*sin(alpha) /new real ellipse 'onoff_beam' /user 'p1' 'p2' let p1 -p1 let p2 -p2 ellipse 'onoff_beam' /user 'p1' 'p2' pen 0 set exp 1. ! ! !=========================================================== ! rms (current scan) !=========================================================== set box box3[1] box3[2] box3[3] box3[4] ! col x 2 y 3 z 5 /file tmp.onf if (factor.gt.2) then let z z*factor endif ran 64 64 /nei 6 plot /scal lin set exp 0.6 box p n wedge set exp 0.4 for i 1 to nchan if (.not.ff[i]) then ellipse 5.5 /user xx[i] yy[i] draw t xx[i] yy[i] rr[i] 5 /user endif next set exp 0.6 DRAW TEXT 0.0 -.6 "\gD\ga (arcsec)" 2 /BOX 2 !DRAW TEXT -.8 -.6 "\gD\gd (arcsec)" 4 90 /BOX 4 set exp 0.5 ! pen 0.7 ! let p1 -100*tan(alpha) pen 1 draw r -100 'p1' 5 /user let p1 -p1 draw l 100 'p1' 5 /user /clip pen 3 ellipse 'onoff_beam' /user 0 0 let p1 wobbler_throw*cos(alpha) let p2 wobbler_throw*sin(alpha) ellipse 'onoff_beam' /user 'p1' 'p2' let p1 -p1 let p2 -p2 ellipse 'onoff_beam' /user 'p1' 'p2' pen 0 ! set exp 0.7 if (onoff_jy) then if (factor.lt.2) then DRAW TEXT -10 0.1 "Scan "'name'" : Mean signal (Jy)" 8 /BOX 8 DRAW TEXT 0 0.1 "Scan "'name'" : RMS (Jy)" 8 /BOX 8 else DRAW TEXT -10 0.1 "Scan "'name'" : Mean signal (mJy)" 8 /BOX 8 DRAW TEXT 0 0.1 "Scan "'name'" : RMS (mJy)" 8 /BOX 8 endif else DRAW TEXT -10 0.1 "Scan "'name'" : Mean signal (counts)" 8 /BOX 8 DRAW TEXT 0 0.1 "Scan "'name'" : RMS (counts)" 8 /BOX 8 endif let int_elev el[m]+0.5 /new int draw text -19.2 0.1 "Configuration at elevation "'int_elev'"deg" 8 /BOX 8 return ! else ! comp_mean.ne."0" !======================================================================== ! display results of p_onoff-sum !======================================================================== set exp 1 set box box4[1] box4[2] box4[3] box4[4] ! ! compute nchan def character str*5 system "touch .tmp" col x 1 /file ".tmp" ! just to close 'filename' sic out tmp.onf say 'scan_list' sic out col x 1 /file tmp.onf def int iscan let iscan nint(x[1]) get 'iscan' def character filename*20 if (iscan.lt.10) then let filename "000"'iscan'".onf" else if (iscan.lt.100) then let filename "00"'iscan'".onf" else if (iscan.lt.1000) then let filename "0"'iscan'".onf" else let filename 'iscan'".onf" endif def logi ff /like chan_flag def real xx yy zz rr /like chan_az_off let ff chan_flag col x 4 y 5 z 7 /file 'filename' def real r /like x let r z col z 6 /file 'filename' def int nch let nch 1 sic out tmp.onf for i 1 to nchan let xx[i] x[i] let yy[i] y[i] let zz[i] z[i] let rr[i] r[i] if (.not.ff[i]) then if (i.ne.ref_chan) then if ((abs(x[i]-x[ref_chan]).gt.0.01).and.(abs(y[i]-y[ref_chan]).gt.0.01)) then say 'i' 'x[i]' 'y[i]' 'z[i]' 'r[i]' /format i4 e12.4 e12.4 e12.4 e12.4 let nch nch+1 else let ff[i] yes endif else say 'i' 'x[i]' 'y[i]' 'z[i]' 'r[i]' /format i4 e12.4 e12.4 e12.4 e12.4 endif endif next sic out col x 2 y 3 z 4 /file tmp.onf def real maxsignal factor compute maxsignal max mean let factor 1 if (maxsignal.lt.0.1.and.onoff_jy) then let factor 1000 endif def int iz del /var r def real r /like x for i 1 to nchan if (.not.ff[i]) then let iz iz+1 let z[iz] mean[i] let r[iz] sigma_mean[i] endif next if (factor.gt.2) then let z z*factor endif if (blanking[2].lt.0) then set blanking -99999.5 1 endif if (nchan.eq.37) then lim 70 -70 -70 70 else lim 50 -50 -50 50 endif ran 64 64 /nei 6 plot /scal lin set exp 0.6 box wedge set exp 0.4 let iz 0 for i 1 to nchan if (.not.ff[i]) then let iz iz+1 ellipse 5.5 /user xx[i] yy[i] draw t xx[i] yy[i] z[iz] 5 /user endif next set exp 0.8 DRAW TEXT 0 -0.7 "\gD\ga (arcsec)" 2 /BOX 2 DRAW TEXT -1.2 1. "\gD\gd (arcsec)" 4 90 /BOX 4 pen 0 ! !================================================= ! global rms !================================================ set box box1[1] box1[2] box1[3] box1[4] let z r if (factor.gt.2) then let z z*factor endif ran 64 64 /nei 6 plot /scal lin set exp 0.6 box wedge set exp 0.4 let iz 0 for i 1 to nchan if (.not.ff[i]) then let iz iz+1 ellipse 5.5 /user xx[i] yy[i] draw t xx[i] yy[i] z[iz] 5 /user endif next set exp 0.8 DRAW TEXT 0 -0.7 "\gD\ga (arcsec)" 2 /BOX 2 DRAW TEXT -1.2 1. "\gD\gd (arcsec)" 4 90 /BOX 4 set exp 0.8 if (onoff_jy) then if (factor.lt.2) then DRAW TEXT -13 0.1 "Mean signal (Jy)" 8 /BOX 8 DRAW TEXT 0 0.1 "RMS (Jy)" 8 /BOX 8 else DRAW TEXT -13 0.1 "Mean signal (mJy)" 8 /BOX 8 DRAW TEXT 0 0.1 "RMS (mJy)" 8 /BOX 8 endif else DRAW TEXT -13 0.1 "Mean signal (counts)" 8 /BOX 8 DRAW TEXT 0 0.1 "RMS (counts)" 8 /BOX 8 endif ! !====================================== ! scan list pen 0 set exp 1.0 set box box0[1] box0[2] box0[3] box0[4] DRAW TEXT 0 0 "Scan list: "'scan_list' 8 /BOX 8 !================================================= ! Mean (function of integrated time ) !================================================= if (nmax.le.1) then say " " say "Only one scan. Cannot plot mean and RMS fonction of integration time. " return endif set box box5[1] box5[2] box5[3] box5[4] def real x2 y1 y2 tmax tmin let mean_chan mean_chan*factor let y1 1.e32 let y2 0 del /var yy zz def real yy zz for i 1 to nchan if (.not.chan_flag[i].and.(.not.ff[i])) then compute yy min mean_chan[i] compute zz max mean_chan[i] if (yy.lt.y1) then let y1 yy endif if (zz.gt.y2) then let y2 zz endif endif next compute tmax max onoff_time compute tmin min onoff_time if (tmin.gt.100.and.tmax.lt.500) then ! to have some units on log axis ... lim 95 * y1*1.2 y2*1.2 /var onoff_time mean_chan[1] /xlog else if (tmax.lt.1000) lim * 1100 y1*1.2 y2*1.2 /var onoff_time mean_chan[1] /xlog else lim * * y1*1.2 y2*1.2 /var onoff_time mean_chan[1] /xlog endif set exp 0.6 box for i 1 to nchan if (.not.chan_flag[i]) then CONNECT onoff_time MEAN_CHAN[I] endif next pen 1 CONNECT onoff_time MEAN_CHAN[ref_chan] pen 0 set exp 0.8 draw text 0 -0.7 "Integration time (second)" 2 /box 2 if (onoff_jy.and.factor.lt.2) then ! factor =1 (Jy) draw text -1.2 1 "Mean (Jy)" 4 90 /box 4 else if (onoff_jy.and.factor.gt.2) then draw text -1.2 1 "Mean (mJy)" 4 90 /box 4 else draw text -1.2 1 "Mean (counts)" 4 90 /box 4 endif let mean_chan mean_chan|factor !================================================= ! Sigma (function of integrated time ) !================================================= set box box6[1] box6[2] box6[3] box6[4] let sigma_mean_chan sigma_mean_chan*factor let y1 1.e32 let y2 0 for i 1 to nchan if (.not.chan_flag[i].and.(.not.ff[i])) then compute yy min sigma_mean_chan[i] compute zz max sigma_mean_chan[i] if (yy.eq.0) then let ff[i] yes else if (yy.lt.y1) then let y1 yy endif if (zz.eq.0) then let ff[i] yes else if (zz.gt.y2) then let y2 zz endif endif next if (y2|y1.lt.10) then ! to draw unit on log axis (1 or 10 or 100 ...) let y2 9*y1 endif lim = = y1*0.8 y2*1.2 /var onoff_time sigma_mean_chan[1] /xlog /ylog set exp 0.6 box for i 1 to nchan if (.not.chan_flag[i].and.(.not.ff[i])) then CONNECT onoff_time sigma_MEAN_CHAN[i] endif next pen 1 CONNECT onoff_time sigma_MEAN_CHAN[ref_chan] pen 0 set exp 0.8 draw text 0 -0.7 "Integration time (second)" 2 /box 2 if (onoff_jy.and.factor.lt.2) then ! factor =1 (JY) draw text -1.2 1 "RMS (Jy)" 4 90 /box 4 else if (onoff_jy) then draw text -1.2 1 "RMS (mJy)" 4 90 /box 4 else draw text -1.2 1 "RMS (counts)" 4 90 /box 4 endif let sigma_mean_chan sigma_mean_chan|factor endif ! if compute_mean.eq."0" ! set exp 0.9