integrate_wavelength¶
- nsb2.core.spectral.integrate_wavelength(flux, wavelength, axis=-1)[source]¶
Integrate a spectral quantity over wavelength.
Composite Simpson’s rule is applied to the plain numerical values, and the unit of the result is reconstructed as
flux.unit * wavelength.unit.- Parameters:
flux (astropy.units.Quantity) – Spectral quantity to integrate. The wavelength axis is given by
axis; all other axes are integrated independently.wavelength (astropy.units.Quantity) – Wavelength grid, of the same length as
fluxalongaxis. Need not be equidistant, but must be strictly monotonic.axis (int, optional) – Axis of
fluxholding the wavelength samples. Default is the last axis.
- Returns:
Integral of
fluxover wavelength, withaxisremoved and unitflux.unit * wavelength.unit.- Return type:
- Raises:
TypeError – If either argument is not a ~astropy.units.Quantity.
Examples
>>> import numpy as np, astropy.units as u >>> wvl = np.linspace(400, 500, 11) * u.nm >>> flx = np.ones(11) * u.erg / u.s / u.cm**2 / u.nm >>> integrate_wavelength(flx, wvl) <Quantity 100. erg / (s cm2)>