tuskitoo.SpectralExtraction.utils module
- find_signal(data)[source]
Find the most prominent peak in the given data.
Parameters:
- dataarray-like
Input data array in which to find the signal.
Returns:
- int
The index of the most prominent peak in the data.
- guess_picks_image(image, objects_guess=2, plot=False)[source]
Guess the locations of peaks in a 2D image.
Parameters:
- imagearray-like
2D input image.
- objects_guessint, optional, default=2
Number of peaks to guess.
- plotbool, optional, default=False
Whether to plot the intermediate results.
Returns:
- array-like
Indices of the guessed peaks.
- gaussian(x, center, height, sigma)[source]
Gaussian distribution function.
Parameters:
- xarray-like
Input array.
- centerfloat
Center of the Gaussian peak.
- heightfloat
Height of the Gaussian peak.
- sigmafloat
Standard deviation of the Gaussian peak.
Returns:
- array-like
Gaussian distribution evaluated at x.
- integrated_gaussian(center, height, sigma, err_center, err_height, err_sigma)[source]
Compute the integrated area under the Gaussian and propagate errors.
For a Gaussian: A = height * sigma * sqrt(2*pi)
Parameters:
- heightfloat
Height (amplitude) of the Gaussian.
- sigmafloat
Standard deviation of the Gaussian.
- err_heightfloat
Uncertainty in the height.
- err_sigmafloat
Uncertainty in sigma.
Returns:
- Afloat
Integrated area under the Gaussian.
- err_Afloat
Propagated uncertainty in the area.
- gaussian_with_error(x, center, height, sigma, err_center, err_height, err_sigma)[source]
Compute the Gaussian and propagate the errors from the parameters.
Parameters:
- xarray-like
The independent variable.
- centerfloat
Center of the Gaussian.
- heightfloat
Height (amplitude) of the Gaussian.
- sigmafloat
Standard deviation (width) of the Gaussian.
- err_centerfloat
Uncertainty in the center.
- err_heightfloat
Uncertainty in the height.
- err_sigmafloat
Uncertainty in the sigma.
Returns:
- farray-like
The Gaussian function evaluated at x.
- err_farray-like
The propagated uncertainty in f.
- moffat_with_error(x, center, height, alpha, sigma, err_center, err_height, err_alpha, err_sigma)[source]
Compute the Moffat function and propagate the errors from the parameters.
Using the Moffat function:
f(x) = h * [1 + ((x-c)^2/sigma^2)]^(-alpha)
the error on f(x) is computed by standard error propagation:
- δf(x) = sqrt( (∂f/∂h * δh)^2 + (∂f/∂c * δc)^2 +
(∂f/∂α * δα)^2 + (∂f/∂σ * δσ)^2 )
Parameters:
- xarray-like
Independent variable.
- centerfloat
Center of the Moffat peak.
- heightfloat
Height (amplitude) of the Moffat peak.
- alphafloat
Alpha parameter of the Moffat function.
- sigmafloat
Sigma parameter of the Moffat function.
- err_centerfloat
Uncertainty in the center.
- err_heightfloat
Uncertainty in the height.
- err_alphafloat
Uncertainty in alpha.
- err_sigmafloat
Uncertainty in sigma.
Returns:
- farray-like
Moffat function evaluated at x.
- err_farray-like
Propagated uncertainty of f.
- integrated_moffat(center, height, alpha, sigma, err_center, err_height, err_alpha, err_sigma)[source]
Compute the integrated area under the Moffat function and propagate the errors.
For the Moffat function, the integral from -infty to infty is given by:
I = h * sigma * sqrt(pi) * Gamma(alpha - 1/2) / Gamma(alpha)
Note: The center does not affect the area.
Parameters:
- heightfloat
Height (amplitude) of the Moffat function.
- alphafloat
Alpha parameter.
- sigmafloat
Sigma parameter.
- err_heightfloat
Uncertainty in the height.
- err_alphafloat
Uncertainty in alpha.
- err_sigmafloat
Uncertainty in sigma.
Returns:
- Ifloat
Integrated area.
- err_Ifloat
Propagated uncertainty of the area.
- moffat(x, center, height, alpha, sigma)[source]
Moffat distribution function.
Parameters:
- xarray-like
Input array.
- centerfloat
Center of the Moffat peak.
- heightfloat
Height of the Moffat peak.
- alphafloat
Alpha parameter of the Moffat function.
- sigmafloat
Sigma parameter of the Moffat function.
Returns:
- array-like
Moffat distribution evaluated at x.
- smooth_boxcar(y, filtwidth, var=None, verbose=True)[source]
Apply a boxcar smoothing to the spectrum.
Note: This function is not authored by me.
Parameters:
- yarray-like
Input spectrum to be smoothed.
- filtwidthint
Width of the smoothing filter.
- vararray-like or None, optional
Variance spectrum for inverse variance weighting. If None, uniform weighting is used.
- verbosebool, optional, default=True
Whether to print verbose messages.
Returns:
- tuple
Smoothed spectrum and smoothed variance (or None if var is None).