Metadata-Version: 2.4
Name: tldecpy
Version: 1.0.0
Summary: TLDecPy core library for thermoluminescence glow-curve deconvolution.
Project-URL: Homepage, https://github.com/HideOnParadise/TLDecPy
Project-URL: Documentation, https://hideonparadise.github.io/TLDecPy/
Project-URL: Bug Tracker, https://github.com/HideOnParadise/TLDecPy/issues
Project-URL: Source, https://github.com/HideOnParadise/TLDecPy
Project-URL: Changelog, https://github.com/HideOnParadise/TLDecPy/blob/main/CHANGELOG.md
Project-URL: Citation, https://github.com/HideOnParadise/TLDecPy#citation
Author-email: Cesar Romero <csronun@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2026, Cesar Romero
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: deconvolution,dosimetry,fitting,physics,radiation,science,thermoluminescence
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy>=1.20
Requires-Dist: pandas>=1.3
Requires-Dist: pydantic>=2.0.0
Requires-Dist: scipy>=1.7
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: matplotlib; extra == 'dev'
Requires-Dist: mkdocs; extra == 'dev'
Requires-Dist: mkdocs-material; extra == 'dev'
Requires-Dist: mkdocstrings[python]; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: numpydoc; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs; extra == 'docs'
Requires-Dist: mkdocs-material; extra == 'docs'
Requires-Dist: mkdocstrings[python]; extra == 'docs'
Requires-Dist: numpydoc; extra == 'docs'
Provides-Extra: perf
Requires-Dist: numba; extra == 'perf'
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

# TLDecPy: Thermoluminescence Glow-Curve Deconvolution in Python

[![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Python](https://img.shields.io/badge/Python-3.10%20%7C%203.11%20%7C%203.12-3776AB?logo=python&logoColor=white)](https://www.python.org/)
[![CI](https://github.com/HideOnParadise/TLDecPy/actions/workflows/ci.yml/badge.svg)](https://github.com/HideOnParadise/TLDecPy/actions/workflows/ci.yml)

`tldecpy` is an open-source scientific Python library for thermoluminescence (TL) glow-curve analysis, nonlinear deconvolution, and kinetic-model benchmarking.

The project is designed for reproducible research workflows in radiation dosimetry and TL materials analysis, with typed APIs and physically motivated models.

## Supported Kinetic Models

TLDecPy includes single-peak and multi-peak deconvolution with:

- First-order (FO): `fo_rq`, `fo_ka`, `fo_wp`, `fo_rb`
- Second-order (SO): `so_ks`, `so_la`
- General-order (GO): `go_kg`, `go_rq`, `go_ge`
- One-Trap One-Recombination center (OTOR): `otor_lw` (Lambert W), `otor_wo` (Wright Omega)
- Mixed-order families: `mo_kitis`, `mo_quad`, `mo_vej`
- Continuous trap-distribution models (Gaussian and Exponential forms)

## Highlights

- Multi-component deconvolution with robust losses and optional Poisson weighting
- Automatic initialization helpers (`autoinit_multi`, peak detection, preprocessing)
- Uncertainty metrics and diagnostics in fit outputs
- Synthetic data generation utilities for method validation
- Bundled Refglow benchmark datasets (`x001` to `x010`)
- Typed models and results (`py.typed`, Pydantic v2 schemas)

## Installation

### From source

```bash
git clone https://github.com/HideOnParadise/TLDecPy.git
cd TLDecPy
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
```

### Planned PyPI install

```bash
pip install tldecpy
```

## Quickstart

```python
import tldecpy as tl

# 1) Load a reference glow curve (Refglow)
T, I = tl.load_refglow("x001")

# 2) Automatic initialization of peaks and optional background
peaks, bg = tl.autoinit_multi(
    T,
    I,
    max_peaks=3,
    allow_models=("fo_rq", "go_kg", "otor_lw"),
    bg_mode="auto",
)

# 3) Run deconvolution
result = tl.fit_multi(
    T,
    I,
    peaks=peaks,
    bg=bg,
    beta=1.0,
    robust=tl.RobustOptions(loss="soft_l1", f_scale=2.0, weights="poisson"),
    options=tl.FitOptions(local_optimizer="trf"),
)

print("Converged:", result.converged)
print("R2:", f"{result.metrics.R2:.4f}", "FOM:", f"{result.metrics.FOM:.3f}%")
for peak in result.peaks:
    print(peak.name, peak.model, peak.params)
```

For an end-to-end OTOR demonstration, see:

- `examples/example_otor_fit.py`
- `examples/example_refglow002_manual_fit.py` (manual Refglow x002 deconvolution)

## Development Quality Checks

```bash
make lint
make typecheck
make test
make qa
```

## Citation

If TLDecPy contributes to your research, please cite the software archive (Zenodo DOI once released).

Suggested BibTeX entry:

```bibtex
@software{romero2026tldecpy,
  title   = {TLDecPy},
  author  = {Romero, Cesar},
  year    = {2026},
  url     = {https://github.com/HideOnParadise/TLDecPy},
  note    = {Zenodo DOI to be added after first release}
}
```

## License

This project is distributed under the BSD 3-Clause License. See [LICENSE](LICENSE).
