lentil.radiometry.Spectrum#

class lentil.radiometry.Spectrum(wave, value, waveunit='nm', valueunit=None)[source]#

Class for representing spectral quantities.

Spectrum provides core functionality for defining and interacting with spectral data in lentil. Some basic arithmetic functions are overloaded, so you can add, multiply, and exponentiate Spectrum objects

  • with each other

  • by constants

  • with arrays having the same length as value

Parameters:
  • wave (array_like) – Array of wavelengths.

  • value (array_like) – Array of values corresponding to wavelengths in wave.

  • waveunit (str, optional) – Wavelength units, as accepted by Unit(). Default is nm.

  • valueunit (str or None, optional) – Value units, as accepted by Unit(). Default is None.

Notes

When performing arithmetic operations between two Spectrum objects, the code will behave differently depending on the wave vectors of each Spectrum:

1. If the wave vectors of each Spectrum are the same, the arithmetic operation is directly performed element-wise on the value vectors of each Spectrum.

2. If the wave vectors of each Spectrum are different, the value vectors of each Spectrum are interpolated to the same sampling, and then the arithmetic operation is performed element-wise on the resulting interpolated value vectors. Before interpolating, the wave and value vectors are zero-padded to cover the entire wave range represented by the union of both Spectrum objects. The sampling is determined by the smaller sampling of the two wave vectors.

You can fine tune the sampling, interpolation, and padding methods by interfacing directly with the Spectrum.add() and Spectrum.multiply() methods.

Attributes

Methods

add(other[, sampling, method, fill_value])

Add Spectrum and other, element-wise

append(other[, copy])

Append Spectrum to the end of caller

asarray()

Return wave and value as an array.

bin(wave[, interp_method, ends, ...])

Compute a binned representation of the Spectrum data at a given array of central wavelengths.

copy()

crop(min_wave, max_wave)

Crop a Spectrum object.

divide(other[, sampling, method, fill_value])

Divide Spectrum and other, element-wise

ends([tol])

Locate the indices defining the continuous nonzero portion of the value

from_csv(filename, waveunit, valueunit[, ...])

Create a Spectrum from a csv file.

integrate([start, end, method])

Compute the integrated value between start and end.

multiply(other[, sampling, method, fill_value])

Multiply Spectrum and other, element-wise

pad(ends[, sampling, mode])

Pad a Spectrum

power(other[, sampling, method, fill_value])

Spectrum elements raised to powers from other, element-wise

resample(wave[, method, fill_value, waveunit])

Sample the Spectrum object at a set of desired wavelengths and overwrite the object's wave and value attributes.

sample(wave[, method, fill_value, waveunit])

Sample the Spectrum at a set of desired wavelengths.

subtract(other[, sampling, method, fill_value])

Subtract Spectrum and other, element-wise

to(*args)

Set new wavelength and/or value units.

trim([tol])

Trim the zero or near-zero ends off the Spectrum object.