trspecfit examples

trspecfit examples#

trspecfit fits multi-component spectral models to 1D energy-resolved and 2D time- and energy-resolved spectroscopy data: modular lineshapes, time dynamics, convolution kernels, parameter profiles, and lmfit-based fitting with confidence intervals and MCMC.

The pages here are the package’s example notebooks, executed end to end, so you can read the plots, fit reports and tables without installing anything. They were run with trspecfit 0.20.0 (git ref v0.20.0) on 2026-10-03. Every page has a download button for the executed notebook.

To run them yourself:

python -m pip install "trspecfit[lab]"

Source on GitHub · Documentation · PyPI

Pick the notebook that matches what you are trying to do; each one is self-contained. The fitting workflows are numbered in blocks: 0x single-file fitting skills, 1x post-fit work, 2x multi-file workflows.

Fitting workflows#

Notebook

What you learn

01 basic fitting

Load data, define a model, fit baseline + 2D, visualize results.

02 dependent parameters

Link parameters with expressions and physical constraints.

03 multi cycle dynamics

Multi-cycle dynamics with subcycles and frequency.

04 parameter profiles

Depth-dependent parameters via profile functions (with optional time-dependence).

10 model comparison

Compare two models on the same file (baseline / SbS / 2D).

11 save load export

FitResults HDF5 round-trip, CSV/PNG export, “ship just the winners”.

12 uncertainty mcmc

Declare the noise model, then three tiers of parameter uncertainty — stderr, profiled CIs, and MCMC — checked against truth and the Cramér-Rao bound.

13 missing noise model

What the unknown default does to stderr, profiled CIs and MCMC on the same data as 12, and the Gaussian fallback.

20 multi file independent fit

Multi-file workspace, per-file independent fits (bridge to shared-parameter fitting).

21 multi file shared fit

Multi-file workspace, shared-parameter fits across files.

Synthetic data#

Notebook

What you learn

01 simulator

Generate synthetic noisy data from a known ground truth.

02 ml training data

Sweep parameter space for ML training datasets.

Data generators#

Some examples ship synthetic data made by a notebook in their data/ directory from truth model files, which those pages show. The build re-runs the generators and checks that the regenerated data matches what the examples were fitted to.