eradiate.spectral.BandSRF

class eradiate.spectral.BandSRF(wavelengths, values, name=None)

Bases: SpectralResponseFunction

The spectral response function for a single band of an instrument.

Parameters:
  • wavelengths (quantity) – Wavelengths defining the interpolation grid. Values must be monotonically increasing.

  • values (array-like) – Spectrum values. If a quantity is passed, units are checked for consistency. If a unitless array is passed, it is automatically converted to appropriate default configuration units, depending on the value of the quantity field. If no quantity is specified, this field can be a unitless value.

  • name (str, optional) – Name of this SRF.

Fields:
  • wavelengths (quantity) – Wavelengths defining the interpolation grid.

  • values (quantity) – Spectrum values.

  • name (str or None) – Name of this SRF.

central_wavelength()

Return central wavelength.

Returns:

pint.Quantity

static convert(value)

Converter for the Measure.srf field.

Notes

Supported conversion protocols:

  • dict: Dispatch to subclass based on ‘type’ entry, then pass dictionary to constructor as keyword arguments.

  • Dataset, DataArray: Call BandSRF.from_dataarray().

  • Path-like: Attempt loading a dataset from the hard drive, then call BandSRF.from_dataarray().

  • str: Perform a NetCDF file lookup in the SRF database and load it.

Anything else will pass through this converter without modification.

eval(w)

Evaluate the spectral response function for one or several wavelengths. Evaluation is vectorized.

Parameters:

w (array-like) – One or several wavelengths at which the SRF is evaluated.

Returns:

quantity – The returned value as the same shape as w.

classmethod gaussian(wl_center, fwhm, cutoff=3.0, wl=None, wl_res=1.0, pad=False, normalize=True)

Generate a Gaussian spectral response function dataset from central wavelength and full width at half maximum values.

Parameters:
  • wl_center (quantity or float) – Central wavelength of the Gaussian distribution. If passed as a float, the value is interpreted as being given in nm.

  • fwhm (quantity or float) – Full width at half maximum of the Gaussian distribution. If passed as a float, the value is interpreted as being given in nm.

  • cutoff (float, default: 3.0) – Cut-off, in multiples of the standard deviation σ.

  • wl (quantity or array-like, optional) – Mesh used to evaluate the discretized distribution. If unset, a regular mesh with spacing given by wl_res is used. If passed as an array, the value is interpreted as being given in nm.

  • wl_res (quantity or float, optional) – Resolution of the automatic spectral mesh if relevant. If passed as a float, the value is interpreted as being given in nm.

  • pad (bool, default: False) – If True, pad SRF data with leading and trailing zeros.

  • normalize (bool, default: True) – If True, the generated SRF data is normalized to have a maximum equal to 1.

Returns:

Dataset – A dataset compliant with the Eradiate SRF format. The uncertainty variable is set to NaN.

integrate(wmin, wmax)

Return the integral of the SRF on the specified interval, using the trapezoid rule.

Parameters:

wmin, wmax (float or quantity) – Lower and upper bounds of the integration domain. Floats are interpreted as being specified in default configuration units.

Returns:

integral (quantity) – Integral as a scalar quantity.

integrate_cumulative(w)

Return the cumulative integral of the SRF on the specified mesh, using the trapezoid rule.

Parameters:

w (array-like) – Nodes of the spectral integration mesh. If a dimensionless array is passed, it is interpreted as being specified in default configuration units.

Returns:

integral (quantity) – Cumulative integral as an array of shape (N-1,), where wavelength has shape (N,).

support()

Return the interval in which the SRF is nonzero.

Returns:

quantity

Note

This method does not actually compute the support: it assumes that any leading and trailing zeros are already removed.

to_dataset()
Returns:

Dataset – A dataset compliant with the Eradiate SRF format. The uncertainty variable is set to NaN.