hqs_nmr.analysis.multiplet_finder

Tools to analyze calculated or experimental NMR spectra.

Functions

identify_multiplets(omegas, intensity[, ...])

Identifies multiplets within an NMR spectrum.

identify_multiplets_via_equal_area_partitioning(...)

Identifies multiplets in a spectrum through an equal area partitioning of the frequencies.

identify_multiplets_via_spin_contributions(...)

Identifies multiplets and corresponding spin contributions in an NMR spectrum.

hqs_nmr.analysis.multiplet_finder.identify_multiplets_via_equal_area_partitioning(omegas: np.ndarray, intensity: np.ndarray, number_omegas: int = 400, frequency_window: tuple[float, float] | None = None, frequency_window_width_threshold: float = 1e-10, split_threshold: float = 1.5, minimum_integral_threshold: float = 0.7, result_spectrum: NMRResultSpectrum1D | None = None, recursive_iterations: int = 1) list[NMRMultiplet]

Identifies multiplets in a spectrum through an equal area partitioning of the frequencies.

Parameters:
  • omegas – Frequencies at which the spectrum is defined.

  • intensity – Intensity values of the spectrum.

  • number_omegas – Should be chosen proportional to the number of spins in the molecule. We recommend 50 frequency points per spin, but at least a total of 100. Defaults to 400.

  • frequency_window – If set, only multiplets in the window will be analyzed. Defaults to None.

  • frequency_window_width_threshold – If the width of the frequency window is below this threshold times the width of the overall frequency range, the full frequency range is taken into account. Defaults to 1e-10.

  • split_threshold – Identified multiplets with an integral smaller than this threshold are not attempted to be split again. Defaults to 1.5.

  • minimum_integral_threshold – If an integral of a multiplet is below this threshold the code increases the multiplet bounds until the value is larger than this threshold. Defaults to 0.7.

  • result_spectrum – If a simulated spectrum is given, it is used to refine the search for multiplets. Defaults to None.

  • recursive_iterations – Maximum number of recursive attempts to split multiplets. Defaults to 1.

Returns:

A list of objects containing the frequency bounds and integrals of each multiplet.

hqs_nmr.analysis.multiplet_finder.identify_multiplets(omegas: ndarray, intensity: ndarray, threshold: float | None = None, buffer: float = 0.01, shift: float | None = None, minimum_integral: float = 0.7) list[NMRMultiplet]

Identifies multiplets within an NMR spectrum.

Parameters:
  • omegas – Frequencies for which the spectrum was evaluated.

  • intensity – Intensity values of the spectrum.

  • threshold – Intensities larger than this threshold are declared to be part of a multiplet. If None, 1% of the maximum intensity is chosen as threshold. Defaults to None.

  • buffer – If the intensity is smaller than the threshold, but within a radius of size buffer there is intensity larger than it, the intensity is still declared part of the multiplet. Should be chosen in the same unit as omegas. Defaults to 0.01.

  • shift – If not None, only the multiplet located around the shift is added to the result list. Defaults to None.

  • minimum_integral – The function tries to optimize the found multiplets, such that all multiplet integrals are larger than this value. Defaults to 0.7.

Returns:

List of multiplets.

hqs_nmr.analysis.multiplet_finder._encode_multiplets_in_vector(omegas: ndarray, intensity: ndarray, threshold: float | None, buffer: float) ndarray

Creates a vector with ones where there are multiplets and zeros otherwise.

Parameters:
  • omegas – Frequencies for which the spectrum was evaluated.

  • intensity – Intensity values of the spectrum.

  • threshold – Intensities larger than this threshold are declared to be part of a multiplet. If None, 1% of the maximum intensity is chosen as threshold.

  • buffer – If the intensity is smaller than the threshold, but within a radius of size buffer there is intensity larger than it, the intensity is still declared part of the multiplet. Should be chosen in the same unit as omegas.

Returns:

Vector with zeros and ones encoding where there are multiplets.

hqs_nmr.analysis.multiplet_finder._extract_multiplets_from_vector(multiplet_vector: ndarray, omegas_ppm: ndarray, intensity: ndarray, shift: float | None = None) list[NMRMultiplet]

Get multiplets from vector.

Method is based on results from identify_multiplets_in_spectrum and extracts from it the multiplet bounds and then calculates the integrals.

Parameters:
  • multiplet_vector – Array with zeros and ones, where ones encode where there are multiplets.

  • omegas_ppm – Array of frequencies in ppm.

  • intensity – Array of the intensity values of the spectrum.

  • shift – If None, all multiplets are identified. If not None, only the multiplet located around the shift is added to the result list. Defaults to None.

Returns:

List with the multiplets as encoded in the multiplet_vector.

hqs_nmr.analysis.multiplet_finder._ensure_multiplets_larger_minimum(omegas_ppm: ndarray, intensity: ndarray, minimum_integral: float, multiplet_list: list[NMRMultiplet]) list[NMRMultiplet]

Join adjacent multiplets with integrals smaller than a defined minimum value.

Parameters:
  • omegas_ppm – Array of frequencies in ppm.

  • intensity – Array of the intensity values of the spectrum.

  • minimum_integral – The function tries to optimize the found multiplets, such that all multiplet integrals are larger than this value.

  • multiplet_list – Original list with multiplets which can include multiplets with integrals smaller than minimum_integral.

Returns:

List with the optimized multiplets.

hqs_nmr.analysis.multiplet_finder.identify_multiplets_via_spin_contributions(result_nmr_spectrum: NMRResultSpectrum1D, threshold_array: np.ndarray | None = None, buffer: float = 0.01) list[NMRJoinedMultiplet]

Identifies multiplets and corresponding spin contributions in an NMR spectrum.

Parameters:
  • result_nmr_spectrum – Result of an NMR spectrum calculation.

  • threshold_array – Defines spin-dependent intensity thresholds, where values of the spin contribution larger than the corresponding threshold are declared to be part of a multiplet. Has to be in the same order as the spin_contributions attribute. If None, 1% of the maximum intensity is chosen as threshold. Defaults to None.

  • buffer – If the intensity is smaller than the threshold, but within a radius of size buffer there is intensity larger than it, the intensity is still declared part of the multiplet. Should be chosen in the same unit as omegas. Defaults to 0.01.

Returns:

List of multiplets with information on the underlying spin contributions.

hqs_nmr.analysis.multiplet_finder._join_multiplets(spectrum: NMRSpectrum1D, spin_dependent_multiplet_vector: ndarray, multiplet_list: list[NMRMultiplet | None]) list[NMRJoinedMultiplet]

Identify which multiplets overlap and correspond to a joined multiplet.

Method is based on intermediate results of identify_multiplets_via_spin_contributions_v2 and combines the identified multiplets of individual spin contributions into joined multiplets if their bounds overlap.

Parameters:
  • spectrum – A calculated NMR spectrum.

  • spin_dependent_multiplet_vector – Array with zeros and ones encoding where the multiplets are in the individual spin contributions.

  • multiplet_list – List with the multiplets associated with the individual spin contributions.

Returns:

List of joined multiplets.