|
|||
NRAO Home > CASA > CASA Cookbook and User Reference Manual |
|
8.3.7 Baseline Fitting
CASA offers a variety of functions for baseline fitting: cubic spline function and sinusoid are now available in addition to polynomial. Also three new parameters are added to all the baseline fitting functions in common. They include getresidual, outlog, and blfile (for detail of these parameters, see below).
The function sd.scantable.poly_baseline carries out a baseline fit, given an mask of channels (if desired):
scans.poly_baseline(msk,order=1)
This will fit a first order polynomial to the selected channels and subtract this polynomial from the full spectrum.
The auto_poly_baseline function can be used to automatically baseline your data without specifying channel ranges for the line-free data. It automatically figures out the line-free emission and fits a polynomial baseline to that data. The user can use masks to fix the range of channels or velocity range for the fit as well as mark the band edge as invalid:
Parameters:
insitu: if False a new scantable is returned.
Otherwise, the scaling is done in-situ
The default is taken from .asaprc (False)
mask: an optional mask retrieved from scantable
order: the order of the polynomial (default is 0)
edge: an optional number of channel to drop at
the edge of spectrum. If only one value is
specified, the same number will be dropped from
both sides of the spectrum. Default is to keep
all channels. Nested tuples represent individual
edge selection for different IFs (a number of spectral
channels can be different)
threshold: the threshold used by line finder. It is better to
keep it large as only strong lines affect the
baseline solution.
chan_avg_limit:
the maximum number of consecutive spectral channels to
average during the search of weak and broad lines.
The default is no averaging (and no search for weak
lines). If such lines can affect the fitted baseline
(e.g. a high order polynomial is fitted), increase this
parameter (usually values up to 8 are reasonable). Most
users of this method should find the default value
sufficient.
plot: plot the fit and the residual. In this each
individual fit has to be approved, by typing ’y’
or ’n’
getresidual:if False, returns best-fit values instead of
residual (default is True)
outlog: Output the coefficients of the best-fit
function to logger (default is False)
blfile: Name of a text file in which the best-fit
parameter values to be written
(default is "": no file/logger output)
Example:
scans.auto_poly_baseline(order=2,threshold=5)
The parameters edge, threshold, and chan_avg_limit can be used in common for all the baseline fitting functions that use linefinder (auto_*_baseline).
It should also be noted that the above two functions now run about 30 times faster than in CASA 3.1.
The functions cspline_baseline and auto_cspline_baseline are for cubic spline fitting with or without using linefinder, respectively. The unique paramters for these are as follows:
clipthresh: Clipping threshold. (default is 3.0, unit: sigma)
clipniter: maximum number of iteration of ’clipthresh’-sigma
clipping (default is 0: no clipping)
The functions sinusoid_baseline and auto_sinusoid_baseline are for sinusoidal fitting with or without using linefinder, respectively. The unique paramters for these are as follows:
of spectral width multiplied by maxwavelength.
The default is 3 (i.e., sinusoids with wave
number of 0(=constant), 1, 2, and 3 are
used for fitting). Also it is possible to
explicitly specify all the wave numbers to
be used, by giving a list including them
(e.g., [0, 1, 2, 15, 16]).
maxwavelength: the longest sonusoidal wavelength. The
default is 1.0 (unit: spectral range)
clipthresh: Clipping threshold. (default is 3.0, unit: sigma)
clipniter: maximum number of iteration of ’clipthresh-sigma
clipping (default is 0: no clipping)
Note that the parameters clipthresh and clipniter can be used both for cubic spline and sinusoid. For polynomial fitting functions, iterative clipping is yet to be available (though you can do the equivalent operation by using cubic spline fitting function with npiece=1).
Also, for cubic spline and sinusoidal fitting, the parameter plot is ignored (always set False) and yet to be available.
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