; Load the SDFITS. filein,"data/TGBT22A_503_02.raw.vegas" ; Check what was observed. summary ; The first two scans, 60 & 61, are part of an OnOff scan, ; the next two, 62 & 63, are part of a Nod scan, and the ; next one is a Track scan using frequency switching. ; The pattern repeats five times, for different sources. ; We'll treat them as one source in this example. ; Lets start with the frequency switched observations. ; By default, the central beam, beam 1, will track the ; source. getfs,64,fdnum=0 ; There are hints of something, lets smooth a bit to bring ; it out from the noise. gsmooth,5,/decimate ; A beautiful detection of ammonia! ; Lets process all the frequency switched scans to increase ; the signal-to-noise ratio. ; We will process all Track scans and put them in the accumulator ; so we can average them latter. ; Freeze the plotter to speed things up. freeze for s=64,84,5 do begin & getfs,s,fdnum=0 & gsmooth,5,/decimate & accum & endfor unfreeze ; Average the accumulated spectra. ave ; Smooth a bit more. gsmooth,5,/decimate ; That looks better, but there is a residual "baseline". ; Select a range around the line and use these channels to ; fit a polynomial and remove the baseline. ; First, lets find out which channels are free of line emission. setxunit,"Channels" chan ; Channels 300 to 750 and 870 to 1290 cover the line free channels ; around the line. nregion,[300,750,870,1290] ; Before proceeding with the fit, copy the spectrum to a different ; data container (10) in case we need to go back. copy,0,10 ; Lets see how different order polynomials would do. nfit,7 bshape ; Not too bad, but maybe it is overfitting (How would we know if ; GBTIDL does not give us something like a Chi squared, or a ; Bayesian Information Criterion ?). nfit,5 bshape ; Maybe a bit better. nfit,3 bshape ; Definitely not. ; Lets use the order 5 polynomial. nfit,5 bshape ; Actually apply the baseline correction. baseline ; Limit the x range so it looks better. setx,300,1200 ; This could go in your fridge door! ; Put it somewhere for latter use. copy,0,10 ; Same but now for the other polarization. ; Clear the accumulator. sclear freeze for s=64,84,5 do begin & getfs,s,fdnum=0,plnum=1 & gsmooth,5,/decimate & accum & endfor unfreeze ave gsmooth,5,/decimate ; Again, the baseline is not flat. ; We do not really need to re-issue all of these commands. setxunit,"Channels" chan nregion,[300,750,870,1290] nfit,5 baseline setx,300,1200 copy,0,11 ; Average the two polarizations. copy,10,0 accum copy,11,0 accum ave ; Save this for later analysis. ; But use velocity instead of channel number. velo write_ascii,"outputs/W3_IF_0.ascii" ; Now, focus on the Nod scans. ; getnod seems to be broken for the KFPA ¯\_(ツ)_/¯ ; We'll have to use getsigref instead. ; For the Nod scans, the nodding was between beams 3 and 7 ; (this is defined during the observations, and I do not know ; if there is an easy way of knowing this by looking at the SDFITS. ; I had to look at the AstrID logs). ; Remember that beam 1 is fdnum=0, so beam 3 is fdnum=2. sclear for s=62,82,5 do begin & getsigref,s,s+1,fdnum=2 & gsmooth,5,/decimate & accum & endfor ave gsmooth,5,/decimate ; That looks way better than the frequency switched one! ; Save it, but to a SDFITS file, just for fun. velo fileout,"outputs/W3_IF_0_Nod.fits",/new keep ; Since in each other Nod scan the source is in beam 7 we can increase the signal-to-noise ; by also adding this data. Notice we flip the scan order. sclear for s=62,82,5 do begin & getsigref,s+1,s,fdnum=6 & gsmooth,5,/decimate & accum & endfor ave gsmooth,5,/decimate keep ; No idea how to close the file :) fileout,"none.fits" ; Now lets look at them together. filein,"outputs/W3_IF_0_Nod.fits" gettp,62 freeze gettp,63 oshow ; The continuum is different, but the line profiles look consistent. ; After you do the same for the rest of the spectral windows, ; you can use your favorite ammonia fitter to figure out the ; source properties. ; For the OnOff scans we can use getps. getps,60,fdnum=0,plnum=0