Two-Dimensional Spectroscopy (2D-IR, 2D-ES, 2D-EV & 2D-VE)#

Pipeline Overview & Supported 2D Modalities#

The two-dimensional branch follows the same load → process → plot → analyse pipeline as the one-dimensional branch, built around a single Dataset2D object. PyMORGAN is designed for general two-dimensional optical correlation spectroscopy across both homonuclear and cross-regime heteronuclear experiments:

  • 2D-IR (Two-Dimensional Infrared Spectroscopy): Vibrational excitation (\(\omega_1\) in the mid-IR) and vibrational detection (\(\omega_3\) in the mid-IR).

  • 2D-ES (Two-Dimensional Electronic Spectroscopy): Electronic excitation (\(\omega_1\) in the UV/Vis/NIR) and electronic detection (\(\omega_3\) in the UV/Vis/NIR).

  • 2D-EV (Two-Dimensional Electronic–Vibrational Spectroscopy): Electronic excitation (\(\omega_1\) in the UV/Vis) coupled to vibrational detection (\(\omega_3\) in the mid-IR).

  • 2D-VE (Two-Dimensional Vibrational–Electronic Spectroscopy): Vibrational excitation (\(\omega_1\) in the mid-IR) coupled to electronic detection (\(\omega_3\) in the UV/Vis/NIR).

Because Dataset2D stores the pump (\(\omega_1\)) and probe (\(\omega_3\)) axes independently, cross-regime experiments (2D-EV and 2D-VE) where the excitation and detection axes span disjoint spectral regions work seamlessly without special casing.

The 2D Pipeline Stages and Where They Live#

Stage

Module

Entry Point(s)

load

pymorgan.twoD.load

pymorgan.load_2D(), Dataset2D.from_file

process

pymorgan.twoD.process

Dataset2D.process, Dataset2D.background_correct, Dataset2D.recalc_average, Dataset2D.set_active_state

plot

pymorgan.twoD.plot

Dataset2D.plot_map, Dataset2D.plot_surface, Dataset2D.plot_scan_maps

analyse

pymorgan.twoD.analyse, pymorgan.twoD.kubo_fit

Dataset2D.slice_at, diagonal, center_line_slope, nodal_line_slope, fit_2d_gaussian_map, fit_2d_gaussian_global, run_kubo_fit

Data Model#

A two-dimensional measurement is a stack of 2D frequency–frequency correlation maps, one per population waiting time \(t_2\). The signal is stored as a three-dimensional cube:

\[Z \in \mathbb{R}^{N_{\text{pump}} \times N_{\text{probe}} \times N_{t_2}}\]

indexed by pump frequency \(\omega_1\), probe frequency \(\omega_3\), and population time \(t_2\). When single-scan loading (load_single_scans=True) or slow-modulation state datasets are present, Dataset2D also tracks the per-scan and per-state tensors.

Fields Stored on Dataset2D#

Field

Shape / Type

Meaning

Z

\(N_{\text{pump}} \times N_{\text{probe}} \times N_{t_2}\)

2D signal cube (in \(\text{mOD}\))

pump

\(N_{\text{pump}}\)

Pump (excitation) axis \(\omega_1\)

probe

\(N_{\text{probe}}\)

Probe (detection) axis \(\omega_3\)

delays

\(N_{t_2}\)

Population waiting times \(t_2\)

units

dict

Unit labels and metadata dictionary

raw_signal_ss

\(N_{t_1/\text{pump}} \times N_{\text{probe}} \times N_{t_2} \times N_s\)

Per-scan raw signal tensor (when load_single_scans=True)

states_data

dict[str, ndarray]

Slow-modulation / polarisation state cubes

states_signal_ss

dict[str, ndarray]

Per-state single-scan tensors

nscans

int

Total number of individual scans \(N_s\)

active_scan_indices

list[int]

0-based indices of scans included in the active average

Loading and the Loader Registry#

As in 1D, formats are resolved through a registry (pymorgan.twoD.load). Calling pymorgan.available_map_loaders() lists all registered 2D readers:

import pymorgan as pm

data = pm.load_2D("scan.p2dat", data_type="P2DAT")
print(pm.available_map_loaders())
Supported Two-Dimensional Data Formats in PyMORGAN#

Format Token

Instrument / Origin

Description

P2DAT

PyMORGAN standard

Comma-separated processed signal cube (.p2dat)

HDF5_2D

PyMORGAN FAIR HDF5

Gzip-compressed FAIR 2D HDF5 archive (.h5 / .hdf5) storing cubes, detectors, phasing parameters, and provenance history

MESS_2DIR

MESS 2D

Multi-file directory with raw/signal states, count, probe, and ref files

UoS_2DIR

Univ. of Sheffield

Sheffield 2D-IR directories (.2D + .DT / .LG / CalibratedProbe.csv / w0.csv) with dual-detector switching

RAL_RAW

STFC / Central Laser Facility

Raw Ultra/LIFEtime 2D-IR interferograms with multi-detector (DET1 / DET2 / combined) switching

RAL_Proc

STFC / Central Laser Facility

Processed Ultra/LIFEtime 2D-IR delay slices with multi-detector channel switching

PyMESS_2D

PyMESS HDF5

Unified PyMESS 2D HDF5 datasets (.h5, alias PyMESS_2DIR)

QuickControl_2D

PhaseTech Spectroscopy

QuickControl 2D ASCII datasets (.info + .scan + .wts), supporting time-domain shaper and frequency-domain maps

  • The P2DAT format: The first row is 0, 0, t2^(1), t2^(2), ... (the population waiting times); each subsequent row is pump, probe, S(t2^(1)), .... The flat pump/probe ordering is reshaped with zero-copy Fortran order directly into the Z[pump, probe, t2] cube in \(\text{mOD}\).

  • UoS & RAL multi-detector 2D-IR (UoS_2DIR, RAL_RAW, RAL_Proc): Paired dual-array detectors (DET1, DET2, and concatenated Combined (DET1+DET2)) are loaded with independent calibrated probe vectors. Switching the active detector via set_active_detector() (or the top Detector selector in the GUI) updates probe, Z, and processing history with full Undo/Redo support.

  • FAIR 2D HDF5 (HDF5_2D): Dataset2D.to_hdf5() and pymorgan.twoD.load.load_2D_hdf5() persist raw/processed cubes, detector channels, active detector/state, shot rotation, and JSON processing history (history_json).

  • The MESS 2DIR & PyMESS_2D formats: Automatically detect wobbler and chopper modulation modes, perform interferogram normalisation (\(I / \text{counts}\)), and compute optical density \(\Delta\mathrm{OD} = -1000 \log_{10}(I_{\text{probe}} / I_{\text{ref}})\). For PyMESS 2D HDF5 files, slow-modulated state datasets under /data/slow_modulation/state_XX_<name> (with or without /data/interferograms_raw) and their *_individual_scans companions are loaded into states_data and states_signal_ss. Derived Magic Angle and Anisotropy states automatically inherit per-scan tensors computed from the parallel and perpendicular states, and switching states via set_active_state() preserves active_scan_indices.

Interferogram Processing, Phasing, and Fourier Transformation#

For raw time-domain 2D measurements (interferometer- or pulse-shaper-based acquisitions), the data must be baseline-corrected, windowed, Fourier-transformed along the coherence time axis \(t_1 \to \omega_1\), and phased to produce pure absorptive 2D correlation maps via Dataset2D.process or the Phasing/FT GUI sub-tab.

Baseline Correction and Preprocessing#

  • Pulse-shaper data: Mean subtraction across the time-domain points removes DC offsets:

    \[S_{\text{corr}}(t_1, \omega_3, t_2) = S(t_1, \omega_3, t_2) - \langle S(t_1, \omega_3, t_2) \rangle_{t_1}\]
  • Interferometer data: A running median filter with an odd kernel size of 101 points is applied along \(t_1\) to both the reference interferogram and the transient signal, isolating the oscillatory fringe signal from slow baseline curvature.

Rotating-Frame Parameters#

In rotating-frame acquisitions (such as AOTF or pulse-shaper spectrometers), the experimental time step \(\Delta t_1\) and rotating-frame carrier frequency \(\omega_0\) (in \(\text{cm}^{-1}\)) define the spectral frequency axis:

\[\omega_1(k) = k \cdot \Delta\nu + \omega_0, \qquad \Delta\nu = \frac{1}{N_{\text{FT}} \Delta t_1 c_0}\]

where \(c_0 = 2.99792458\times 10^{-5}\text{ cm/fs}\) is the speed of light and \(N_{\text{FT}}\) is the total number of Fourier transform points. For interferometer systems, \(\omega_0 = 0\) and \(\Delta t_1 = 2.11079\text{ fs}\) (the HeNe laser interference fringe period).

Interferogram Time-Zero (\(t_1 = 0\), Bin-Zero) via the Fourier Shift Theorem#

Determining the exact zero-path-difference position (\(t_1 = 0\), or “binzero” \(b_0\)) is essential for obtaining pure absorptive spectra without phase distortion. Physically, placing the time origin at \(t_1 = 0\) requires that the phase spectrum \(\phi(\omega) = \arg(\mathcal{F}\{I\})(\omega)\) have zero first derivative across the optical carrier frequency \(\omega_0\):

\[\left.\frac{\mathrm{d}\phi}{\mathrm{d}\omega}\right|_{\omega_0} = 0\]

Rather than iteratively rolling the time-domain signal and computing hundreds of redundant FFTs, PyMORGAN determines \(b_0\) analytically using the Discrete Fourier Shift Theorem. Circularly shifting a discrete sequence of length \(N\) by \(b\) bins, \(I'(t_1) = \operatorname{roll}(I, -b)\), corresponds to an exact linear phase ramp in the frequency domain:

\[\mathcal{F}\{\operatorname{roll}(I, -b)\}[k] = X[k] \cdot \exp\!\left(+i \frac{2\pi k}{N} b\right)\]

Evaluating the unwrapped phase difference across a symmetric window \([k_{\max} - \Delta k/2, k_{\max} + \Delta k/2]\) around the carrier peak gives:

\[\Delta\phi(b) = \phi_b[k_2] - \phi_b[k_1] = \underbrace{(\phi_0[k_2] - \phi_0[k_1])}_{\Delta\phi_0} + \underbrace{\left(\frac{2\pi \Delta k}{N}\right)}_{m} \cdot b\]

Because \(\Delta\phi(b)\) is strictly linear in \(b\), the exact binzero position \(b_0\) where \(\Delta\phi(b_0) \equiv 0 \pmod{2\pi}\) is solved in closed form in under \(1\,\mu\text{s}\) per delay:

\[b_0 = \operatorname{round}\!\left( \frac{2\pi m_{\text{wrap}} - \Delta\phi_0}{m} \right), \qquad m_{\text{wrap}} = \operatorname{round}\!\left(\frac{\Delta\phi_0 + m \cdot b_{\max}}{2\pi}\right)\]

Apodisation Window Functions & Zero-Padding#

To eliminate truncation ripples (sinc sidelobes) arising from the finite \(t_1\) acquisition window, PyMORGAN applies an apodisation window \(w(v)\) centred at binzero \(b_0\) for \(v = |q - (b_0 + 1)| \le M = N_{\text{bins}} - b_0 - 1\):

  • Box: \(w(v) = 1.0\)

  • Cosine (Cos, default): \(w(v) = \cos\!\left(\frac{\pi v}{2 M}\right)\)

  • Cos²: \(w(v) = \cos^2\!\left(\frac{\pi v}{2 M}\right)\)

  • Cos³: \(w(v) = \cos^3\!\left(\frac{\pi v}{2 M}\right)\)

  • Hanning: \(w(v) = 0.5 + 0.5 \cos\!\left(\frac{\pi v}{M}\right)\)

  • Hamming: \(w(v) = 0.54 + 0.46 \cos\!\left(\frac{\pi v}{M}\right)\)

Zero-padding supports integer multiplication factors (\(1\times\), \(2\times\), \(4\times\)) and automatic padding to the next power of two (\(2^k\)).

IRLS Phasing Models, Pump Correction & Scatter Subtraction#

The frequency-dependent phase error \(\phi(\omega_1)\) is modelled by fitting a Constant, Linear, Quadratic, or Cubic polynomial by iteratively reweighted least squares (IRLS) over a window of \(\pm N\) points around the carrier peak:

\[S_{\text{phased}}(\omega_1, \omega_3, t_2) = \operatorname{Re}\!\left( S_{\text{raw}}(\omega_1, \omega_3, t_2) \cdot e^{-i \phi(\omega_1)} \right)\]

When Pump correction is enabled, the signal is normalised by the excitation spectrum profile:

\[S_{\text{norm}}(\omega_1, \omega_3, t_2) = \frac{S_{\text{phased}}(\omega_1, \omega_3, t_2)}{|I_{\text{pump}}(\omega_1)| / \max |I_{\text{pump}}|}\]

Background \(t_2\) map subtraction is performed via:

data.background_correct(reference=-1)      # by t2 index
data.background_correct(t2=50)             # by nearest t2 value
data.background_correct(do_correct=False)  # passthrough

2D Single-Scan Contour Array Explorer & Scan Recombination#

When load_single_scans=True is enabled in Settings, multi-scan 2D datasets (MESS_2DIR, PyMESS_2D, UoS_2DIR, and RAL_RAW) retain their individual scan tensors in raw_signal_ss (shape \(N_{t_1/\text{pump}} \times N_{\text{probe}} \times N_{t_2} \times N_s\)) and optional per-scan interferograms raw_interferogram_ss.

  • Slice-level per-scan map evaluation (compute_scan_maps_at_t2()): Computes 2D frequency-domain maps (label, scan_indices_0based, Z_map) at a chosen \(t_2\) delay for each individual scan or group of \(N\) consecutive binned scans (bin_size). For time-domain shaper/interferometer datasets, only the requested \(t_2\) slice (plus the scatter-subtraction reference slice if bkg_sub=True) is Fourier-transformed and phased per scan/bin.

  • Multi-panel contour array (plot_scan_maps() / plot_scan_map_array()): Renders a grid of 2D contour maps across all individual or binned scans alongside an Average comparison panel on a shared colour scale.

  • Scan recombination (recalc_average()): Recomputes the averaged 2D dataset across any selected 0-based scan_indices, updating raw_signal, raw_interferogram, Z_R, and active_scan_indices.

pm.update_settings(load_single_scans=True)
d2 = pm.load_2D("scan_folder", data_type="MESS_2DIR")

# Plot a multi-panel grid of 2D contour maps at t2 = 0.5 ps (binning 2 scans per panel)
fig, axes, panels = d2.plot_scan_maps(0.5, bin_size=2, include_average=True)

# Recompute the dataset average excluding outlier scan index 3 (0-based)
keep = [i for i in range(d2.nscans) if i != 3]
d2.recalc_average(keep).process(apodise_method="1", phase_method="Linear")

In pymorgan-gui, the Single Scans box appears in the 2D tab whenever a dataset with multiple scans is loaded:

  • Bin Scans sets the number of consecutive scans averaged into each subplot panel.

  • Plot Scan Contours opens an interactive multi-panel figure where clicking any scan panel toggles its [Excluded] status (highlighted in red), and clicking the embedded Recalc. Avg. (Exclude Selected) button recomputes the dataset average and refreshes the main 2D GUI in place.

  • Recalc. Avg. opens a dialog to enter custom 1-based scan ranges (e.g. 1-4, 6-10).

Plotting, Cross-Regime Diagonal Handling & Unit Conversions#

plot_map() renders the map nearest a requested \(t_2\) as a pump-vs-probe contour and returns a Map2DAxes(ax, top, cbar) named tuple:

out = data.plot_map(0.5)                                  # single t2 map
ftir = pm.load_spectrum("sample_FTIR.csv", kind="absorption")
data.plot_map(0.5, top_spectrum=ftir, top_label="FTIR")   # with top reference panel

Two behaviours are specific to 2D plotting:

  1. Diagonal handling across 2D-IR, 2D-ES, 2D-EV, and 2D-VE: The \(\omega_1 = \omega_3\) diagonal line is drawn only where the pump and probe axes overlap; when their ranges are disjoint (as in 2D-EV and 2D-VE), no diagonal is drawn.

  2. Axis units and the \(10^3\) rule: Pump and probe axes can be displayed in any of the units below via twoD_freq_unit or freq_unit=, pivoting through wavelength \(\lambda\,[\mathrm{nm}] = P_{\text{in}} / x_{\text{in}}\):

Display Units of the 2D Spectral Axes#

Token

Quantity

\(P\) (\(\text{unit}\cdot\text{nm}\))

Typical Mid-IR Value

cm-1

Wavenumber

\(10^{7}\)

2000

in-1

Wavenumber

\(2.54 \times 10^{7}\)

5080

nm

Wavelength

—

5000

THz

Frequency

\(2.99792458 \times 10^{5}\)

60

eV

Energy

\(1239.841984\)

0.25

Whenever an axis exceeds \(5 \times 10^{3}\) in the display unit (e.g. UV/Vis wavenumbers in 2D-ES, 2D-EV, or 2D-VE), its tick labels are divided by \(1000\) and the axis label gains a \(10^3\) prefix (e.g. \(\omega_1\;(10^3\;\mathrm{cm}^{-1})\)).

Spectral Diffusion Analysis (CLS, IvCLS, NLS)#

pymorgan.twoD.analyse extracts Centre-Line Slope (CLS), Inverse CLS (IvCLS), and Nodal-Line Slope (NLS) across \(t_2\) waiting times using Huber-loss linear regression and two-stage sub-pixel extremum refinement:

  1. Cubic spline upsampling onto a grid sd_interpolation_factor times finer.

  2. Local least-squares peak fitting (quadratic, cubic, quartic, gaussian, or lorentzian) to the measured samples around the coarse extremum.

pump, probe, m = data.slice_at(0.5)          # 2D map at t2 = 0.5 ps
freq, sig      = data.diagonal(0.5)          # signal along omega_1 = omega_3

cls  = data.center_line_slope()              # [t2, slope]
both = data.center_line_slope(both=True)     # [t2, CLS, IvCLS]
nls  = data.nodal_line_slope()               # [t2, slope]

Advanced 2D Analysis Dialogs & Tools#

Direct Kubo Lineshape & Generalized FFCF Fitting#

The Kubo Fit… dialog (kubo_dialog.py, backed by pymorgan.twoD.kubo_fit) performs full third-order response-function simulation and multi-core non-linear least-squares fitting of 2D spectra using generalized Frequency Fluctuation Correlation Functions (FFCFs):

\[C(t) = \Delta_0^2 + \sum_{m=1}^{M} \Delta_m^2 e^{-t/\tau_{c,m}}\]

The dephasing lineshape function \(g(t)\) combines pure homogeneous dephasing (\(\Delta\omega_{T_2}\), with \(1/T_2^* = \pi c_0 \Delta\omega_{T_2}\)), static inhomogeneous broadening (\(\Delta_0\)), and an arbitrary number of Kubo exponential decay terms (\(\Delta_m\), correlation time \(\tau_{c,m}\)):

\[g(t) = \pi c_0 \Delta\omega_{T_2}\, t + \frac{1}{2}\sigma_0^2 t^2 + \sum_{m=1}^{M} \sigma_m^2 \tau_{c,m}^2 \left( e^{-t/\tau_{c,m}} + \frac{t}{\tau_{c,m}} - 1 \right), \qquad \sigma_i = \frac{2\pi c_0 \, \Delta_i}{2\sqrt{2\ln 2}}\]
  • Shared or per-band independent FFCF groups: Multiple FFCF groups can be defined and assigned independently to the excitation (\(\omega_1\), ffcf_id) and detection (\(\omega_3\), ffcf_id_w3) coordinates of each oscillator band.

  • Diagonal and cross-peak bands with bath correlation: Supports both diagonal oscillators (\(\omega_1 = \omega_3\)) and off-diagonal cross-peaks (\(\omega_1 \ne \omega_3\)) with parameter linking (link_w1, link_w3, link_anharm) and a tunable cross-peak bath correlation factor \(\eta_{AB} \in [-1, 1]\).

  • Variable Projection (VarPro) & multi-core parallelisation: Uses Trust-Region Reflective (scipy.optimize.least_squares) with analytical Variable Projection to solve the linear GSB and ESA pathway amplitudes (\(A_{\text{GSB}}, A_{\text{ESA}}\)) at each step, alongside full-parameter TRF and L-BFGS-B solvers. Time-domain evaluation uses separable 1D outer products, batched 2D FFTs, separable 2D rectilinear interpolation, and multi-core parallel execution across \(t_2\) delays (ProcessPool / ThreadPool) with parallel Jacobian column evaluation.

  • Joint 2D + 1st-order FTIR fitting & diagnostics: Simultaneously fits 2D correlation maps across selected \(t_2\) delays and the analytical 1st-order steady-state FTIR spectrum (weighted by kubo_ftir_weight), with live FFCF \(C(t)\) and \(g(t)\) diagnostic plots and JSON/TOML model preset import/export.

Interactive 2D Gaussian Peak Fitting & Cross-Peak Generator#

The 2D Gaussian Fit… dialog (twoD_gaussian_dialog.py, backed by fit_2d_gaussian_map() and fit_2d_gaussian_global()) fits a sum of 2D correlated elliptical Gaussian peaks to diagonal and cross-peak features:

\[G(\omega_1, \omega_3) = A \exp\!\left( -\frac{1}{2(1-\rho^2)} \left[ \frac{(\omega_1 - \omega_{1,0})^2}{\sigma_1^2} + \frac{(\omega_3 - \omega_{3,0})^2}{\sigma_3^2} - \frac{2\rho(\omega_1 - \omega_{1,0})(\omega_3 - \omega_{3,0})}{\sigma_1 \sigma_3} \right] \right)\]

Users can click directly on the 2D contour map to seed peaks, automatically generate linked cross-peak pairs from diagonal modes via the CrossPeakGeneratorDialog, link centres and anharmonicities across peaks, and fit either single \(t_2\) slices or globally across the entire \(t_2\) stack.

2D ROI Volume Integration & Dynamics#

The 2D Integral Dynamics… dialog (twoD_integral_dialog.py) provides interactive rectangular region-of-interest (ROI) selection on the \((\omega_1, \omega_3)\) map using a draggable RectangleSelector. It integrates the 2D signal volume

\[I(t_2) = \iint_{\mathrm{ROI}} Z(\omega_1, \omega_3, t_2)\,\mathrm{d}\omega_1\,\mathrm{d}\omega_3\]

across all population waiting times \(t_2\), plots the resulting kinetic trace, and fits it with single- or multi-exponential decay models.

2D Spectrum Subtraction#

The Subtract 2D Spectra… dialog (twoD_subtraction_dialog.py) loads a reference 2D dataset (such as pure solvent or buffer), interpolates it onto the sample dataset’s \((\omega_1, \omega_3, t_2)\) grid, and performs scaled subtraction \(Z_{\mathrm{corr}} = Z_{\mathrm{sample}} - k \, Z_{\mathrm{ref}}\) with a live three-panel preview (Sample, Scaled Reference, and Difference Map).

Graphical Interface Sub-Tabs & Movie Export#

  • Phasing/FT Sub-Tab: Controls Apodisation (Box, Cos, Cos^2, Cos^3, Hanning, Hamming, None), Phase fit order (Constant, Linear, Quadratic, Cubic), Phase range (\(\pm N\)), Zero-padding, and Pump correction, displaying the fitted polynomial phase coefficients live.

  • Other plt. Sub-Tab (TD / PH / CAL + Pop button): Displays the time-domain interferogram (TD), Fourier amplitude + Gaussian fit + unwrapped phase & fit on a twin axis (PH), or the calibrated probe axis (CAL), with a Pop button to detach a synchronised resizable window.

  • Movie / GIF / WebP / APNG Export (Make Movie...): Exports animated GIF, WebP, or APNG videos (via Pillow) stepping through \(t_2\) population times with configurable delay range, frame rate, figure dimensions, and fixed or per-frame normalised \(Z\)-scale.