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.
Stage |
Module |
Entry Point(s) |
|---|---|---|
load |
|
|
process |
|
|
plot |
|
|
analyse |
|
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:
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.
Field |
Shape / Type |
Meaning |
|---|---|---|
|
\(N_{\text{pump}} \times N_{\text{probe}} \times N_{t_2}\) |
2D signal cube (in \(\text{mOD}\)) |
|
\(N_{\text{pump}}\) |
Pump (excitation) axis \(\omega_1\) |
|
\(N_{\text{probe}}\) |
Probe (detection) axis \(\omega_3\) |
|
\(N_{t_2}\) |
Population waiting times \(t_2\) |
|
|
Unit labels and metadata dictionary |
|
\(N_{t_1/\text{pump}} \times N_{\text{probe}} \times N_{t_2} \times N_s\) |
Per-scan raw signal tensor (when |
|
|
Slow-modulation / polarisation state cubes |
|
|
Per-state single-scan tensors |
|
|
Total number of individual scans \(N_s\) |
|
|
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())
Format Token |
Instrument / Origin |
Description |
|---|---|---|
|
PyMORGAN standard |
Comma-separated processed signal cube ( |
|
PyMORGAN FAIR HDF5 |
Gzip-compressed FAIR 2D HDF5 archive ( |
|
MESS 2D |
Multi-file directory with raw/signal states, count, probe, and ref files |
|
Univ. of Sheffield |
Sheffield 2D-IR directories ( |
|
STFC / Central Laser Facility |
Raw Ultra/LIFEtime 2D-IR interferograms with multi-detector ( |
|
STFC / Central Laser Facility |
Processed Ultra/LIFEtime 2D-IR delay slices with multi-detector channel switching |
|
PyMESS HDF5 |
Unified PyMESS 2D HDF5 datasets ( |
|
PhaseTech Spectroscopy |
QuickControl 2D ASCII datasets ( |
The P2DAT format: The first row is
0, 0, t2^(1), t2^(2), ...(the population waiting times); each subsequent row ispump, probe, S(t2^(1)), .... The flat pump/probe ordering is reshaped with zero-copy Fortran order directly into theZ[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 concatenatedCombined (DET1+DET2)) are loaded with independent calibrated probe vectors. Switching the active detector viaset_active_detector()(or the top Detector selector in the GUI) updatesprobe,Z, and processing history with full Undo/Redo support.FAIR 2D HDF5 (
HDF5_2D):Dataset2D.to_hdf5()andpymorgan.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_scanscompanions are loaded intostates_dataandstates_signal_ss. DerivedMagic AngleandAnisotropystates automatically inherit per-scan tensors computed from the parallel and perpendicular states, and switching states viaset_active_state()preservesactive_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
101points 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:
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\):
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:
Evaluating the unwrapped phase difference across a symmetric window \([k_{\max} - \Delta k/2, k_{\max} + \Delta k/2]\) around the carrier peak gives:
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:
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:
When Pump correction is enabled, the signal is normalised by the excitation spectrum profile:
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 ifbkg_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-basedscan_indices, updatingraw_signal,raw_interferogram,Z_R, andactive_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:
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.
Axis units and the \(10^3\) rule: Pump and probe axes can be displayed in any of the units below via
twoD_freq_unitorfreq_unit=, pivoting through wavelength \(\lambda\,[\mathrm{nm}] = P_{\text{in}} / x_{\text{in}}\):
Token |
Quantity |
\(P\) (\(\text{unit}\cdot\text{nm}\)) |
Typical Mid-IR Value |
|---|---|---|---|
|
Wavenumber |
\(10^{7}\) |
|
|
Wavenumber |
\(2.54 \times 10^{7}\) |
|
|
Wavelength |
— |
|
|
Frequency |
\(2.99792458 \times 10^{5}\) |
|
|
Energy |
\(1239.841984\) |
|
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:
Cubic spline upsampling onto a grid
sd_interpolation_factortimes finer.Local least-squares peak fitting (
quadratic,cubic,quartic,gaussian, orlorentzian) 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):
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}\)):
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 andL-BFGS-Bsolvers. 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:
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
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.