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 (
Noneor ndarray of shape(N_pix_out,)) – The output wavelength vector. IfNonethen the input wavelength vector will be assumed, though ifmin_wave_smoothormax_wave_smoothare also specified, then the output spectrum may have different length thanspecorwave, or the convolution may be strange outside ofmin_wave_smoothandmax_wave_smooth. Basically, always setoutwaveto be safe.smoothtype (string, optional, default: "vel") –
The type of smoothing to perform. One of:
"vel"- velocity smoothing,resolutionunits are in km/s (dispersion not FWHM)"R"- resolution smoothing,resolutionis in units of \(\lambda/ \sigma_\lambda\) (where \(\sigma_\lambda\) is dispersion, not FWHM)"lambda"- wavelength smoothing.resolutionis in units of Angstroms"lsf"- line-spread function. Use an aribitrary line spread function, which can be given as a vector the same length aswavethat gives the dispersion (in AA) at each wavelength. Alternatively, ifresolutionisNonethen a line-spread function must be present as an additionallsfkeyword. In this case all additional keywords as well as thewavevector will be passed to thislsffunction.
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
Nonethen 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: *
fftsmoothis False *smoothtypeis"lambda"* The optionalin_velparameter is supplied and True.The units of
inresshould be the same as the units ofresolution, except in the case of switching from velocity to wavelength resolution, in which case the units ofinresshould be in units of lambda/sigma_lambda.in_vel (float (optional)) – If supplied and True, the
inresparameter is assumed to be in units of lambda/sigma_lambda. This parameter is ignored unless thesmoothtypeis"lambda"andfftsmoothis False.
- Returns:
flux – The smoothed spectrum on the outwave grid, ndarray.
- Return type:
ndarray of shape
(N_pix_out,)