# #FitBaseline_demo_feb2011.py: instructions to run FitBaseline # Task. # # v0.0 31/Jan/2011 ACAB: created for Feb 2011 HIFI DWPS IPAC # #For most up-to-date information on baseline removal, see #Chapter 13 in "The HIFI User's Manual". #As described, FitBaseline is the main task to fit #and subtract or divide instrumental baseline structures using #polynomials, but the "sub_base" option on FitHifiFringe #offers an alternative way of doing it. Care should be #taken with the latter as it is a smoothed version of the #line-clipped intensity spectrum. #load band 7B C+ DBS raster map observation #from ~/.hcss/lstore/ #Small offsets are apparent between different sky positions, #which may be instrumental and should be removed before the #map cubes are constructed. obs=getObservation("1342205481",poolName="1342205481_map_dbs_7b") #Click on obs, and on fitBaseline under 'Applicable Tasks'. #For this demo, we will run it in command line mode, however. #The important options are: # #movemasks=1 : transfer line masks between spectra, but not sidebands # #domask=1 : mask lines by clicking # #interactive=True : ask for confirmation before applying polynomial fit. # Most useful if one is not sure about polynomial order # or whether it varies between scans. # #doglue=True : combine sub-bands. Use False if there are sub-bands jumps # or for non-contiguous HRS modules # #order=2 : polynomial order # #basemode="subtract" : for strong continuum source one may used "divide" # #Note the instructions on the console! # #Finish masking for each spectrum by clicking outside of plot box. # #Double-click to remove existing mask # #By default products WBS-H-LSB and WBS-H-USB are both processed. #One only needs to define masks once, as these are the same data. fitBaseline(obs=obs,backends=['WBS-H'],order=2,domask=1,movemasks=1,doglue=True,basemode="subtract",interactive=True,restart=True,smoothResolution=2.0) #Baseline-subtracted spectra are stored in 'obs', replacing the #original spectra. Note the: # #linemask: contains all masks # #fitproduct: contains before/after spectra, masks, and polynomials as well # as polynomial coefficients and uncertainties # #The linemask can be re-used if one decides to re-do the #baseline fitting, e.g. after running a more recent pipeline. #For this, enter previsously basline subtracted obs in the #'obsContext' input parameter. #Suppose that this time we want to divide out the baseline, #instead of subtract. obsnew=getObservation("1342205481",poolName="1342205481_map_dbs_7b") fitBaseline(obs=obsnew,obsContext=obs, backends=['WBS-H'],order=2,domask=1,movemasks=1,doglue=True,basemode="divide",interactive=True,restart=True,smoothResolution=2.0) #to overplot the WBS-H spectra in obs and obsnew: #-double-click on 'obs' #-right-click on WBS-H-USB-->create new variable #-same for 'obsnew' #-double click on obs_level2_WBS_H_LSB #-double click on 'All' twice #-drag obsnew_level2_WBS_H_LSB to plot #-double click on 'All' twice #Example of using FitBaseline on SScan observation #(it is important to remove baselines before applying # doDeconvolution task) #With respect to previous examples, set: # # -movemasks=2: once a line is clicked, an algorithm determines # whether it is in the USB or LSB. Subsequently # the mask is moved between LO settings. This # greatly reduces amount of clicking. # # -interactive=False: reduce interactively, i.e. no # modification of polynomial orders possible. # This reduces amount of clicking. obs=getObservation("1342181161",poolName="1342181161_sscan_dbs_1b_r4") fitBaseline(obs=obs,backends=['WBS-H'],order=2,domask=1,movemasks=2,doglue=True,basemode="subtract",interactive=False,restart=True,smoothResolution=2.0)