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()

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

crop_edges(crop_px)

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

Parameters:

crop_px (int) – Amount of pixels to be cropped on each side individually.

Returns:

signal_cropped – A smaller cropped CL signal object. If inplace is True, the original object is modified and no LumiSpectrum is returned.

Return type:

CommonLuminescence

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

Normalizes 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)

Sets 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.

to_eV(inplace=True, jacobian=True)

Converts signal axis of 1D signal to non-linear energy axis (eV) using 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)

Converts 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.

  • 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_invcm()
to_invcm_relative(laser=None, inplace=True, jacobian=False)

Converts signal axis of 1D signal to 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.

  • jacobian (boolean) – 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)

Converts signal axis of 1D signal to 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.

  • jacobian (boolean) – 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)