lumispy.signals.common_luminescence module

Signal class for luminescence data (BaseSignal class)

class lumispy.signals.common_luminescence.CommonLumi

Bases: object

General luminescence signal class (dimensionless)

_convert_data(newaxis, factor, inplace, jacobian, data2, var2)

Utility function to perform the data and variance conversion for signal unit transformations.

_reset_variance_linear_model()

Reset the variance linear model parameters to their default values, as they are not applicable any longer after a Jacobian transformation.

_signal_math(ref, op, inplace=False)

Utility function to perform a mathematical operation on the signal data with a reference spectrum, where the signal axes can differ in range and pixel density.

E.g. for spectral response correction and calculate spectral response, where the operation would differ.

Parameters:
  • ref (Signal 1D object) – Reference spectrum to be used for the operation.

  • op (operator) – The operation to be performed on the signal.

  • inplace (boolean, optional) – If False (default), a new signal object is created and returned. Otherwise, the operation is performed on the original signal object.

Return type:

Signal object

calculate_spectral_response(ref, inplace=False)

Calculate the spectral response by dividing the signal by a reference spectrum.

Parameters:
  • ref (Signal 1D object) – Reference spectrum to be used for calculation.

  • inplace (boolean, optional) – If False (default), a new signal object is created and returned. Otherwise, the operation is performed on the original signal object.

Return type:

Signal object

crop_edges(crop_range=None, crop_px=None, rebin_nav=False, **kwargs)

Crop edges along the navigation axes of the signal object.

Crop the amount of pixels from the four edges of the scanning region, from the edges inwards.

Cropping can happen uniformly on all sides or by specifying the cropping range for each axis or each side independently.

If the shape of the navigation axes differs between the signals, all signals can be rebinned to match the shape of the first signal in the list.

Parameters:
  • crop_range ({int | float | str} or tuple of {ints | floats | strs}) – If int the values are taken as indices. If float the values are converted to indices. If str, HyperSpy fancy indexing is used (e.g. rel0.1 will crop 10% on each side, or 100 nm will crop 100 nm on each side). If a number or a tuple of size 1 is passed, all sides are cropped by the same amount. If a tuple of size 2 is passed (crop_x, crop_y), a different amount is cropped from the x and y directions, respectively. If a tuple of size 4 is passed (crop_left, crop_bottom, crop_right, crop_top), a different amount is cropped from each edge individually.

  • rebin_nav (bool) – If the shape of the navigation axes differs between the signals, all signals can be be rebinned to match the shape of the first signal in the list. Note this does not take into account the calibration values of the navigation axes.

  • kwargs – To account for the deprecated crop_px parameter.

normalize(pos=nan, element_wise=False, inplace=False)

Normalize data to value at pos along signal axis, defaults to maximum value.

Can be helpful for e.g. plotting, but does not make sense to use on signals that will be used as input for further calculations!

Parameters:
  • pos (float, int) – If ‘nan’ (default), spectra are normalized to the maximum. If float, position along signal axis in calibrated units at which to normalize the spectra. If int, index along signal axis at which to normalize the spectra.

  • element_wise (boolean) – If False (default), a spectrum image is normalized by a common factor. If True, each spectrum is normalized individually.

  • inplace (boolean) – If False (default), a new signal object is created and returned. If True, the operation is performed on the existing signal object.

Notes

Sets metadata.Signal.normalized to True. If metadata.Signal.quantity contains the word ‘Intensity’, replaces this field with ‘Normalized intensity’.

remove_negative(basevalue=1, inplace=False)

Set all negative values to ‘basevalue’, e.g. for logarithmic scale plots.

Parameters:
  • basevalue (float) – Value by which negative values are replaced (default = 1).

  • inplace (boolean) – If False (default), a new signal object is created and returned. Otherwise, the operation is performed on the existing signal object.

Notes

Sets metadata.Signal.negative_removed to True.

scale_by_exposure(integration_time=None, inplace=False, **kwargs)

Scale data in spectrum by integration time / exposure, (e.g. convert counts to counts/s).

Parameters:
  • integration_time (float) – Integration time (exposure) in s. If not given, the function tries to use the ‘metadata.Acqusition_instrument.Detector.integration_time’ field or alternatively find any ‘integration_time’, ‘exposure’ or ‘dwell_time’ fields in the original_metadata.

  • inplace (boolean) – If False (default), a new signal object is created and returned. If True, the operation is performed on the existing signal object.

Notes

Sets metadata.Signal.scaled to True. If intensity units is ‘counts’, replaces them by ‘counts/s’.

Deprecated since version 0.2: The exposure argument was renamed integration_time, and it will be removed in LumiSpy 1.0.

spectral_response_correction(ref, inplace=False)

Correct the spectral response of the signal by multiplying with a reference spectrum. For example applying grating, detector or system spectral response curves.

Parameters:
  • ref (Signal 1D object) – Reference spectrum to be used for correction.

  • inplace (boolean, optional) – If False (default), a new signal object is created and returned. Otherwise, the operation is performed on the original signal object.

Return type:

Signal object

to_eV(inplace=True, jacobian=True)

Convert signal axis of 1D signal to non-linear energy axis (eV).

Uses wavelength dependent refractive index of air. Assumes wavelength in units of nm unless the axis units are specifically set to µm.

The intensity is converted from counts/nm (counts/µm) to counts/meV by doing a Jacobian transformation, see e.g. Mooney and Kambhampati, J. Phys. Chem. Lett. 4, 3316 (2013), doi:10.1021/jz401508t, which ensures that integrated signals are correct also in the energy domain. If the variance of the signal is known, i.e. metadata.Signal.Noise_properties.variance is a signal representing the variance, a squared renormalization of the variance is performed. Note that if the variance is a number (not a signal instance), it is converted to a signal if the Jacobian transformation is performed

Parameters:
  • inplace (boolean) – If False, a new signal object is created and returned. Otherwise (default) the operation is performed on the existing signal object.

  • jacobian (boolean) – The default is to do the Jacobian transformation (recommended at least for luminescence signals), but the transformation can be suppressed by setting this option to False.

Examples

>>> import numpy as np
>>> from lumispy import LumiSpectrum
>>> S1 = LumiSpectrum(np.ones(20), DataAxis(axis = np.arange(200,400,10)), ))
>>> S1.to_eV()
to_invcm(inplace=True, jacobian=True)

Convert signal axis of 1D signal to non-linear wavenumber axis (cm^-1).

Assumes wavelength in units of nm unless the axis units are specifically set to µm.

The intensity is converted from counts/nm (counts/µm) to counts/cm^-1 by doing a Jacobian transformation, see e.g. Mooney and Kambhampati, J. Phys. Chem. Lett. 4, 3316 (2013), doi:10.1021/jz401508t, which ensures that integrated signals are correct also in the wavenumber domain. If the variance of the signal is known, i.e. metadata.Signal.Noise_properties.variance is a signal representing the variance, a squared renormalization of the variance is performed. Note that if the variance is a number (not a signal instance), it is converted to a signal if the Jacobian transformation is performed

Parameters:

inplace (boolean) –

If False, a new signal object is created and returned. Otherwise (default) the operation is performed on the existing signal object.

jacobianboolean

The default is to do the Jacobian transformation (recommended at least for luminescence signals), but the transformation can be suppressed by setting this option to False.

Examples

>>> import numpy as np
>>> from lumispy import LumiSpectrum
>>> S1 = LumiSpectrum(np.ones(20), DataAxis(axis = np.arange(200,400,10)), ))
>>> S1.to_invcm()
to_invcm_relative(laser=None, inplace=True, jacobian=False)

Convert signal axis of 1D signal to Raman/Stokes shift.

The non-linear wavenumber axis (cm^-1) relative to the exciting laser wavelength (Raman/Stokes shift). Assumes wavelength in units of nm unless the axis units are specifically set to µm.

The intensity is converted from counts/nm (counts/µm) to counts/cm^-1 by doing a Jacobian transformation, see e.g. Mooney and Kambhampati, J. Phys. Chem. Lett. 4, 3316 (2013), doi:10.1021/jz401508t, which ensures that integrated signals are correct also in the wavenumber domain. If the variance of the signal is known, i.e. metadata.Signal.Noise_properties.variance is a signal representing the variance, a squared renormalization of the variance is performed. Note that if the variance is a number (not a signal instance), it is converted to a signal if the Jacobian transformation is performed

Parameters:

inplace (boolean) –

If False, a new signal object is created and returned. Otherwise (default) the operation is performed on the existing signal object.

laser: float or None

Laser wavelength in the same units as the signal axis. If None (default), checks if it is stored in metadata.Acquisition_instrument.Laser.wavelength.

jacobianboolean

The default is not to do the Jacobian transformation for Raman shifts, but the transformation can be activated by setting this option to True.

Examples

>>> import numpy as np
>>> from lumispy import LumiSpectrum
>>> S1 = LumiSpectrum(np.ones(20), DataAxis(axis = np.arange(200,400,10)), ))
>>> S1.to_invcm(laser=325)
to_raman_shift(laser=None, inplace=True, jacobian=False)

Convert signal axis of 1D signal to Raman/Stokes shift.

The non-linear wavenumber axis (cm^-1) relative to the exciting laser wavelength (Raman/Stokes shift). Assumes wavelength in units of nm unless the axis units are specifically set to µm.

The intensity is converted from counts/nm (counts/µm) to counts/cm^-1 by doing a Jacobian transformation, see e.g. Mooney and Kambhampati, J. Phys. Chem. Lett. 4, 3316 (2013), doi:10.1021/jz401508t, which ensures that integrated signals are correct also in the wavenumber domain. If the variance of the signal is known, i.e. metadata.Signal.Noise_properties.variance is a signal representing the variance, a squared renormalization of the variance is performed. Note that if the variance is a number (not a signal instance), it is converted to a signal if the Jacobian transformation is performed

Parameters:

inplace (boolean) –

If False, a new signal object is created and returned. Otherwise (default) the operation is performed on the existing signal object.

laser: float or None

Laser wavelength in the same units as the signal axis. If None (default), checks if it is stored in metadata.Acquisition_instrument.Laser.wavelength.

jacobianboolean

The default is not to do the Jacobian transformation for Raman shifts, but the transformation can be activated by setting this option to True.

Examples

>>> import numpy as np
>>> from lumispy import LumiSpectrum
>>> S1 = LumiSpectrum(np.ones(20), DataAxis(axis = np.arange(200,400,10)), ))
>>> S1.to_invcm(laser=325)