| |
- compress_array(array, compress)
- Compresses an 1-D array by the integer factor "compress".
Temporary fix until the equivalent of IDL's 'rebin' is found.
- expand_array(array, expand, sample=0)
- Expands an 1-D array by the integer factor "expand".
if 'sample' is 1 the new array is created with sampling, if 1 then
the new array is created via interpolation (default)
Temporary fix until the equivalent of IDL's 'rebin' is found.
- fit_gaussian(chans, counts)
- Fits a peak to a Gaussian using a linearizing method
Returns (amplitude, centroid, fwhm).
Inputs:
chans:
An array of x-axis coordinates, typically channel numbers
counts:
An array of y-axis coordinates, typically counts or intensity
Outputs:
Returns a tuple(amplitude, centroid, fwhm)
amplitude:
The peak height of the Gaussian in y-axis units
centroid:
The centroid of the gaussian in x-axis units
fwhm:
The Full Width Half Maximum (FWHM) of the fitted peak
Method:
Takes advantage of the fact that the logarithm of a Gaussian peak is a
parabola. Fits the coefficients of the parabola using linear least
squares. This means that the input Y values (counts) must not be
negative. Any values less than 1 are replaced by 1.
- newton(func, x0, fprime=None, args=(), tol=1.48e-08, maxiter=50)
- newton is taken directly from scipy.optimize.minpack.py.
I have extracted it here so that users of my software don't have to install
scipy. This may change in the future as I use more scipy features, and
scipy will be required
Given a function of a single variable and a starting point,
find a nearby zero using Newton-Raphson.
fprime is the derivative of the function. If not given, the
Secant method is used.
- polyfitw(x, y, w, ndegree, return_fit=0)
- Performs a weighted least-squares polynomial fit with optional error estimates.
Inputs:
x:
The independent variable vector.
y:
The dependent variable vector. This vector should be the same
length as X.
w:
The vector of weights. This vector should be same length as
X and Y.
ndegree:
The degree of polynomial to fit.
Outputs:
If return_fit==0 (the default) then polyfitw returns only C, a vector of
coefficients of length ndegree+1.
If return_fit!=0 then polyfitw returns a tuple (c, yfit, yband, sigma, a)
yfit:
The vector of calculated Y's. Has an error of + or - Yband.
yband:
Error estimate for each point = 1 sigma.
sigma:
The standard deviation in Y units.
a:
Correlation matrix of the coefficients.
Written by: George Lawrence, LASP, University of Colorado,
December, 1981 in IDL.
Weights added, April, 1987, G. Lawrence
Fixed bug with checking number of params, November, 1998,
Mark Rivers.
Python version, May 2002, Mark Rivers
|