Fit 2D time- and energy-resolved spectroscopy data
Project description
trspecfit - 2D Time- and Energy-resolved Spectroscopy Fitting
trspecfit is a Python package for modeling and fitting 1D energy-resolved and 2D time-and-energy-resolved spectroscopy data. It extends lmfit with composable spectral components, parameter-level time dynamics, convolution kernels, and simulation tools so you can build, fit, and validate physically meaningful models in one workflow.
Capabilities
- Modular components (Gaussian, Voigt/GLP/GLS, Doniach-Sunjic, backgrounds, kernels)
- 1D and 2D model construction with time-dependent parameters
- Auxiliary-axis parameter profiles via
add_par_profile(...) - Global fitting via
lmfit, including CI and optional MCMC (lmfit.emcee) - Synthetic data generation (single spectra, 2D datasets, noisy realizations)
- Parameter-sweep simulation for validation and ML training data generation
- Centralized plot configuration via
PlotConfigwith per-plot overrides
Installation
These instructions assume Python 3.12+, pip, and virtual environment support are already installed.
Install from PyPI:
python -m pip install trspecfit
Or install with Jupyter support for the example notebooks:
python -m pip install "trspecfit[lab]"
Install from GitHub:
python -m pip install git+https://github.com/InfinityMonkeyAtWork/time-resolved-spectroscopy-fit.git
Quick Usage
from trspecfit import Project, File
project = Project(path='my_project', name='my_experiment')
file = File(parent_project=project, path='my_dataset',
data=..., energy=..., time=...)
# Define baseline, load model, fit
file.define_baseline(time_start=0, time_stop=3)
file.load_model('models_energy.yaml', 'my_base_model')
file.set_fit_limits(energy_limits=[...], time_limits=[...])
file.fit_baseline('my_base_model')
# Load 2D energy model, add time dependence, fit
file.load_model('models_energy.yaml', 'my_2d_model')
file.add_time_dependence('my_2d_model', 'my_par', 'models_time.yaml', 'my_dynamics')
file.fit_2d('my_2d_model')
# Inspect results
df = file.get_fit_results(fit_type='2d')
For global fits, dynamics, profiles, and advanced workflows see the Quick Start and Examples.
Documentation
Full docs are hosted on Read the Docs: Installation | Quick Start | Examples | Supported Models | API Reference
Citation
If trspecfit contributes to published research, please cite the DOE CODE / OSTI
software record:
Johannes Mahl; Ethan Crumlin. time-resolved spectroscopy fit (trspecfit) v0.01. Lawrence Berkeley National Laboratory, 2025. DOI: 10.11578/dc.20251009.2
Support and Community
- Questions and usage help: Discussions (Q&A)
- Ideas and brainstorming: Discussions (Ideas)
- Reproducible bugs and feature requests: Issues
- Maintainer response target: within 7 days
Development
# Create and activate virtual environment
# Linux / macOS
python3 -m venv .venv
source .venv/bin/activate
# OR Windows (PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate
# [same commands for all platforms from here on]
# Install and setup
pip install -U pip
pip install -e ".[dev]"
python -m pre_commit install --install-hooks
# Quick local test run (same pytest selection used by the pre-commit hook)
pytest
# Full suite, including slow tests (matches CI and release)
pytest -m ""
# Run all configured pre-commit hooks, including the quick pytest hook
python -m pre_commit run --all-files
Repository Layout
src/trspecfit/- package sourcedocs/- Sphinx docs sourceexamples/- notebooks and YAML modelstests/- pytest test suite
Copyright Notice
time-resolved spectroscopy fit (trspecfit) Copyright (c) 2025, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at IPO@lbl.gov.
NOTICE. This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit others to do so.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trspecfit-0.8.0.tar.gz.
File metadata
- Download URL: trspecfit-0.8.0.tar.gz
- Upload date:
- Size: 239.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4014fb845e0ca71dc1ea4b76538bff8813b0903be16b6fc2c602bd184a3f532
|
|
| MD5 |
b10de54b3695546bf99dfef1e5be5f17
|
|
| BLAKE2b-256 |
ac21ee366026dce2c547079acf13f9dffb0a463465f81aa16580e7c2f20483a1
|
Provenance
The following attestation bundles were made for trspecfit-0.8.0.tar.gz:
Publisher:
release.yaml on InfinityMonkeyAtWork/time-resolved-spectroscopy-fit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trspecfit-0.8.0.tar.gz -
Subject digest:
a4014fb845e0ca71dc1ea4b76538bff8813b0903be16b6fc2c602bd184a3f532 - Sigstore transparency entry: 1367790033
- Sigstore integration time:
-
Permalink:
InfinityMonkeyAtWork/time-resolved-spectroscopy-fit@5f8487a307984f515e27f36ebfe6a65bd74ed2ce -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/InfinityMonkeyAtWork
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5f8487a307984f515e27f36ebfe6a65bd74ed2ce -
Trigger Event:
push
-
Statement type:
File details
Details for the file trspecfit-0.8.0-py3-none-any.whl.
File metadata
- Download URL: trspecfit-0.8.0-py3-none-any.whl
- Upload date:
- Size: 170.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39daf484ba95f6c0540a496f6cd698d742390cd905b70d474ef2dee708f12896
|
|
| MD5 |
1021cda12d284779b086c60faafb64aa
|
|
| BLAKE2b-256 |
905c52858013499ee29a2f722a1ab52d6c8eb47f0550245b9a26c6f03a715881
|
Provenance
The following attestation bundles were made for trspecfit-0.8.0-py3-none-any.whl:
Publisher:
release.yaml on InfinityMonkeyAtWork/time-resolved-spectroscopy-fit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trspecfit-0.8.0-py3-none-any.whl -
Subject digest:
39daf484ba95f6c0540a496f6cd698d742390cd905b70d474ef2dee708f12896 - Sigstore transparency entry: 1367790084
- Sigstore integration time:
-
Permalink:
InfinityMonkeyAtWork/time-resolved-spectroscopy-fit@5f8487a307984f515e27f36ebfe6a65bd74ed2ce -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/InfinityMonkeyAtWork
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5f8487a307984f515e27f36ebfe6a65bd74ed2ce -
Trigger Event:
push
-
Statement type: