NRAO Home > CASA > CASA Cookbook and User Reference Manual

8.3.8 Line Fitting

Multi-component Gaussian fitting is done by creating a fitting object, specifying fit parameters and finally fitting the data. Fitting can be done on a scantable selection or an entire scantable using the auto_fit function.

  #spave is an averaged spectrum  
  f=sd.fitter()                           # create fitter object  
  msk=spave.create_mask([3928,4255])      # create mask region around line  
  f.set_function(gauss=1)                 # set a single gaussian component  
  f.set_scan(spave,msk)                   # set the scantable and region  
                                          #  
                                          # Automatically guess start values  
  f.fit()                                 # fit  
  f.plot(residual=True)                   # plot residual  
  f.get_parameters()                      # retrieve fit parameters  
  #   0: peak = 0.786 K , centre = 4091.236 channel, FWHM = 70.586 channel  
  #      area = 59.473 K channel  
  f.store_fit(’orions_hc3n_fit.txt’)      # store fit  
                                          #  
                                          # To specify an initial guess:  
  f.set_function(gauss=1)                 # set a single gaussian component  
  f.set_gauss_parameters(0.4,4100,200\    # set initial guesses for Gaussian  
        ,component=0)                     #   for first component (0)  
                                          #   (peak,center,fwhm)  
                                          #  
                                          # For multiple components set  
                                          # initial guesses for each, e.g.,  
  f.set_function(gauss=2)                 # set two gaussian components  
  f.set_gauss_parameters(0.4,4100,200\    # set initial guesses for Gaussian  
        ,component=0)                     #   for first component (0)  
  f.set_gauss_parameters(0.1,4200,100\    # set initial guesses for Gaussian  
        ,component=1)                     #   for second component (1)  


More information about CASA may be found at the CASA web page

Copyright © 2010 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search