hqs_nmr.visualization

Visualization module.

Functions

maximum_excluding_region(x, y[, exclude])

Determine the maximum of y excluding a specific region of x values.

plot_spectra(simulated, experimental[, ...])

Plot simulated and experimental spectra in one graph.

plot_spectrum(spectrum[, label, xlabel, ...])

Plot an experimental or simulated spectrum.

hqs_nmr.visualization.maximum_excluding_region(x: ndarray, y: ndarray, exclude: tuple[float, float] | None = None) float

Determine the maximum of y excluding a specific region of x values.

Parameters:
  • x – Values of x.

  • y – Values of y.

  • exclude – Region of x values to exclude. Find the overall maximum of y if set to None.

Returns:

The appropriate maximum value of y.

hqs_nmr.visualization.plot_spectrum(spectrum: NMRExperimentalSpectrum1D | NMRSpectrum1D | NMRGreensFunction1D | NMRResultSpectrum1D | NMRResultGreensFunction1D, label: str | None = None, xlabel: str = '$\\delta$ [ppm]', ylabel: str | None = None, color: str = '#d97815', ax: Axes | None = None) None

Plot an experimental or simulated spectrum.

If a simulated spectrum is provided the spin contributions are added up and in case of Green’s function data the negative of the imaginary part is plotted.

Parameters:
  • spectrum – Object storing the spectrum.

  • label – Label to be attached to the spectrum. Defaults to None.

  • xlabel – Label to be attached to the x-axis. Defaults to “$\delta$ [ppm]”.

  • ylabel – Label to be attached to the y-axis. Defaults to “Intensity [a.u]”.

  • color – Color of the spectrum. Defaults to the HQS orange “#d97815”.

  • ax – Draw spectra in the specified Matplotlib axes.

hqs_nmr.visualization.plot_spectra(simulated: NMRSpectrum1D | NMRGreensFunction1D, experimental: NMRExperimentalSpectrum1D, left: float = 10.0, right: float = 0.0, exclude: tuple[float, float] | None = None, ax: Axes | None = None, scale_experimental: Literal['max-intensity', 'max-intensity-window', 'factor'] = 'max-intensity', scale_experimental_factor: float = 1.0) None

Plot simulated and experimental spectra in one graph.

The simulated spectrum is in orange and upright. The experimental spectrum is in grey and upside down.

Parameters:
  • simulated – Object storing the simulated spectrum.

  • experimental – Object storing the experimental spectrum.

  • left – Left margin of the plot in ppm.

  • right – Right margin of the plot in ppm.

  • exclude – Region to exclude for normalizing the spectrum (for the solvent peak).

  • ax – Draw spectra in the specified Matplotlib axes.

  • scale_experimental – Defines the scaling mode for the experimental spectrum: - “max-intensity” rescales the experimental spectrum so that the largest intensity value is equal to one. - “max-intensity-window” rescales the experimental spectrum so that the largest intensity value within the current viewport (defined by left and right) is equal to one. - “factor” rescales the experimental spectrum with respect to the given scaling factor.

  • scale_experimental_factor – Scaling factor for experimental spectrum that is only applied if the scaling mode (scale_experimental) is chosen to be “factor”.