prospect.utils¶
prospect.utils.smoothing¶
-
prospect.utils.smoothing.
smoothspec
(wave, spec, resolution=None, outwave=None, smoothtype='vel', fftsmooth=True, min_wave_smooth=0, max_wave_smooth=inf, **kwargs)¶ Parameters: - wave – The wavelength vector of the input spectrum, ndarray. Assumed angstroms.
- spec – The flux vector of the input spectrum, ndarray
- resolution – The smoothing parameter. Units depend on
smoothtype
. - outwave – The output wavelength vector. If
None
then the input wavelength vector will be assumed, though ifmin_wave_smooth
ormax_wave_smooth
are also specified, then the output spectrum may have different length thanspec
orwave
, or the convolution may be strange outside ofmin_wave_smooth
andmax_wave_smooth
. Basically, always setoutwave
to be safe. - smoothtype –
(optional default: “vel”) The type of smoothing to do. One of:
- ”vel” - velocity smoothing,
resolution
units are in km/s (dispersion not FWHM) - ”R” - resolution smoothing,
resolution
is in units of lambda/ sigma(lambda) (where sigma(lambda) is dispersion, not FWHM) - ”lambda” - wavelength smoothing.
resolution
is in units of AA - ”lsf” - line-spread function. Use an aribitrary line spread
function, which can be given as a vector the same length as
wave
that gives the dispersion (in AA) at each wavelength. Alternatively, ifresolution
isNone
then a line-spread function must be present as an additionallsf
keyword. In this case all additional keywords as well as thewave
vector will be passed to thislsf
function.
- ”vel” - velocity smoothing,
- fftsmooth – (optional, default: True) Switch to use FFTs to do the smoothing, usually resulting in massive speedups of all algorithms.
- min_wave_smooth – (optional default: 0)
The minimum wavelength of the input vector to consider when smoothing
the spectrum. If
None
then it is determined from the output wavelength vector and padded by some multiple of the desired resolution. - max_wave_smooth – (optional default: Inf) The maximum wavelength of the input vector to consider when smoothing the spectrum. If None then it is determined from the output wavelength vector and padded by some multiple of the desired resolution.
- inres –
(optional) If given, this parameter specifies the resolution of the input. This resolution is subtracted in quadrature from the target output resolution before the kernel is formed.
In certain cases this can be used to properly switch from resolution that is constant in velocity to one that is constant in wavelength, taking into account the wavelength dependence of the input resolution when defined in terms of lambda. This is possible iff: *
fftsmooth
is False *smoothtype
is"lambda"
* The optionalin_vel
parameter is supplied and True.The units of
inres
should be the same as the units ofresolution
, except in the case of switching from velocity to wavelength resolution, in which case the units ofinres
should be in units of lambda/sigma_lambda. - in_vel – (optional)
If supplied and True, the
inres
parameter is assumed to be in units of lambda/sigma_lambda. This parameter is ignored unless thesmoothtype
is"lambda"
andfftsmooth
is False.
Returns flux: The smoothed spectrum on the outwave grid, ndarray.