prospect.utils

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. If None then the input wavelength vector will be assumed, though if min_wave_smooth or max_wave_smooth are also specified, then the output spectrum may have different length than spec or wave, or the convolution may be strange outside of min_wave_smooth and max_wave_smooth. Basically, always set outwave 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 as wave that gives the dispersion (in AA) at each wavelength. Alternatively, if resolution is None then a line-spread function must be present as an additional lsf keyword. In this case all additional keywords as well as the wave vector will be passed to this lsf 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 optional in_vel parameter is supplied and True.

    The units of inres should be the same as the units of resolution, except in the case of switching from velocity to wavelength resolution, in which case the units of inres 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 the smoothtype is "lambda" and fftsmooth is False.

Returns:

flux – The smoothed spectrum on the outwave grid, ndarray.

Return type:

ndarray of shape (N_pix_out,)