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 (ndarray of shape
(N_pix,)
) – The wavelength vector of the input spectrum. Assumed Angstroms.spec (ndarray of shape
(N_pix,)
) – The flux vector of the input spectrum.resolution (float) – The smoothing parameter. Units depend on
smoothtype
.outwave (
None
or ndarray of shape(N_pix_out,)
) – The output wavelength vector. IfNone
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 (string, optional, default: "vel") –
The type of smoothing to perform. 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 Angstroms"lsf"
- line-spread function. Use an aribitrary line spread function, which can be given as a vector the same length aswave
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.
fftsmooth (bool, optional, default: True) – Switch to use FFTs to do the smoothing, usually resulting in massive speedups of all algorithms. However, edge effects may be present.
min_wave_smooth (float, 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 (float, 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 (float, 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 (float (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.
- Return type:
ndarray of shape
(N_pix_out,)