tesliper.glassware.spectra

Objects representing spectra.

Classes

SingleSpectrum(genre, values, abscissa[, ...])

Represents a single spectrum: experimental, averaged from set of conformers, or calculated for only one conformer.

Spectra(genre, filenames, values, abscissa)

Represents a collection of spectra calculated for a number of conformers.

class tesliper.glassware.spectra.SingleSpectrum(genre: str, values: Sequence[float], abscissa: Sequence[float], width: float = 0.0, fitting: str = 'n/a', scaling: float = 1.0, offset: float = 0.0, filenames: Optional[Sequence[str]] = None, averaged_by: Optional[str] = None)[source]

Represents a single spectrum: experimental, averaged from set of conformers, or calculated for only one conformer.

Notes

Calling len() on this class’ instance will show a number of data points in the spectrum.

Parameters
  • genre (str) – Name of data genre that this object represents.

  • values (Sequence[float]) – List of intensity values for each point on the x-axis.

  • abscissa (Sequence[float]) – List of x-axis values.

  • width (float, optional) – Full width at half maximum used to calculate spectrum, if applies. Provided for the record only, by default 0.0.

  • fitting (str, optional) – Name of the fitting function used to calculate spectrum, if applies. Provided for the record only, by default “n/a”.

  • scaling (float, optional) – Multiplyier for correction of signal intensity, by default 1.0.

  • offset (float, optional) – Correction of the spectrum’s shift. Positive value indicates a bathochromic shift, negative value indicates a hypsochromic shift. By default 0.0.

  • filenames (Optional[Sequence[str]], optional) – List of identifiers of conformers that were used to calculate average spectrum, if applies.

  • averaged_by (Optional[str], optional) – Energies genre used to calculate average spectrum, if applies.

property spectra_type

‘vibrational’, ‘electronic’, or ‘scattering’.

Type

Returns type of spectra

property units: Dict[str, str]

Units in which spectral data is stored. It provides a unit for width, start, stop, step, x, and y. abscissa and values are stored in the same units as x and y respectively.

property scaling: Union[int, float]

A factor for correcting the scale of spectra. Setting it to new value changes the y attribute as well. It should be an int or float.

property offset: Union[int, float]

A factor for correcting the shift of spectra. Positive value indicates a bathochromic shift, negative value indicates a hypsochromic shift. Setting it to new value changes the x attribute as well. It should be an int or float.

property x: numpy.ndarray

Spectra’s x-values corrected by adding its offset to abscissa.

property y: numpy.ndarray

Spectra’s y-values corrected by multiplying its values by scaling.

scale_to(spectrum: tesliper.glassware.spectra.SingleSpectrum) None[source]

Establishes a scaling factor to best match a scale of the spectrum values.

Parameters

spectrum (SingleSpectrum) – This spectrum’s y-axis values will be treated as a reference. If spectrum has its own scaling factor, it will be taken into account.

shift_to(spectrum: tesliper.glassware.spectra.SingleSpectrum) None[source]

Establishes an offset factor to best match given spectrum.

Parameters

spectrum (SingleSpectrum) – This spectrum will be treated as a reference. If spectrum has its own offset factor, it will be taken into account.

class tesliper.glassware.spectra.Spectra(genre: str, filenames: Sequence[str], values: Sequence[Sequence[float]], abscissa: Sequence[float], width: float = 0.0, fitting: str = 'n/a', scaling: float = 1.0, offset: float = 0.0, allow_data_inconsistency: bool = False)[source]

Represents a collection of spectra calculated for a number of conformers.

Changed in version 0.9.1: Corrected len() behavior.

Notes

Calling len() on this class’ instance will show how many conformers’ spectra it contains.

Parameters
  • genre (str) – Name of data genre that this object represents.

  • filenames (Optional[Sequence[str]], optional) – List of conformers’ identifiers that were used to calculate spectra.

  • values (Sequence[float]) – List of intensity values for each point on the x-axis.

  • abscissa (Sequence[float]) – List of x-axis values.

  • width (float, optional) – Full width at half maximum used to calculate spectra. Provided for the record only, by default 0.0.

  • fitting (str, optional) – Name of the fitting function used to calculate spectra. Provided for the record only, by default “n/a”.

  • scaling (float, optional) – Multiplyier for correction of signal intensity, by default 1.0.

  • offset (float, optional) – Correction of the spectra’s shift. Positive value indicates a bathochromic shift, negative value indicates a hypsochromic shift. By default 0.0.

  • allow_data_inconsistency (bool, optional) – Flag signalizing if instance should allow data inconsistency (see ArrayPropety for details).

property offset: Union[int, float]

A factor for correcting the shift of spectra. Positive value indicates a bathochromic shift, negative value indicates a hypsochromic shift. Setting it to new value changes the x attribute as well. It should be an int or float.

property scaling: Union[int, float]

A factor for correcting the scale of spectra. Setting it to new value changes the y attribute as well. It should be an int or float.

property spectra_type

‘vibrational’, ‘electronic’, or ‘scattering’.

Type

Returns type of spectra

property units: Dict[str, str]

Units in which spectral data is stored. It provides a unit for width, start, stop, step, x, and y. abscissa and values are stored in the same units as x and y respectively.

property x: numpy.ndarray

Spectra’s x-values corrected by adding its offset to abscissa.

property y: numpy.ndarray

Spectra’s y-values corrected by multiplying its values by scaling.

average(energies: tesliper.glassware.arrays.Energies) tesliper.glassware.spectra.SingleSpectrum[source]

A method for averaging spectra by population of conformers. If this object is empty, averaged spectrum will be a flat line at 0.0 intensity.

Parameters

energies (Energies) – Object with populations and genre attributes containing respectively: list of populations values as numpy.ndarray and string specifying energy genre.

Returns

Averaged spectrum.

Return type

SingleSpectrum

scale_to(spectrum: tesliper.glassware.spectra.SingleSpectrum, average_by: Optional[tesliper.glassware.arrays.Energies] = None) None[source]

Establishes a scaling factor to best match a scale of the spectrum values. An average spectrum is calculated prior to calculating the factor. If average_by is given, it is used to average by population of each conformer. Otherwise an arithmetic average of spectra is calculated, which may lead to inaccurate results.

Parameters
  • spectrum (SingleSpectrum) – This spectrum’s y-axis values will be treated as a reference. If spectrum has its own scaling factor, it will be taken into account.

  • average_by (Energies, optional) – Energies object, used to calculate average spectrum prior to calculating the factor. If not given, a simple arithmetic average of the spectra will be calculated.

shift_to(spectrum: tesliper.glassware.spectra.SingleSpectrum, average_by: Optional[tesliper.glassware.arrays.Energies] = None) None[source]

Establishes an offset factor to best match given spectrum. An average spectrum is calculated prior to calculating the factor. If average_by is given, it is used to average by population of each conformer. Otherwise an arithmetic average of spectra is calculated, which may lead to inaccurate results.

Parameters
  • spectrum (SingleSpectrum) – This spectrum will be treated as a reference. If spectrum has its own offset factor, it will be taken into account.

  • average_by (Energies, optional) – Energies object, used to calculate average spectrum prior to calculating the factor. If not given, a simple arithmetic average of the spectra will be calculated.