Schemas reference¶
All configuration and result types are frozen Pydantic v2 models.
Import directly from tldecpy: from tldecpy import PeakSpec, MultiFitResult.
Input schemas¶
tldecpy.schemas.PeakSpec ¶
Bases: PygcdBaseModel
Input specification for one TL peak component.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str | None
|
Human-readable component identifier (e.g. |
model |
str
|
Kinetic model key. Accepted values include canonical keys
( |
init |
dict[str, float]
|
Initial parameter values passed to the optimizer. Required keys depend on the model family:
Missing keys receive model-specific defaults inside the fitter. |
bounds |
(dict[str, tuple[float, float]] | None, optional)
|
Parameter bounds as |
fixed |
(dict[str, float | bool] | None, optional)
|
Parameters held constant during optimisation. Two forms:
|
Examples:
>>> import tldecpy as tl
>>> peak = tl.PeakSpec(
... name="P1",
... model="fo_rq",
... init={"Tm": 450.0, "Im": 5000.0, "E": 1.2},
... bounds={"Tm": (400.0, 500.0), "E": (0.8, 2.0)},
... )
>>> go_peak = tl.PeakSpec(
... model="go_kg",
... init={"Tm": 490.0, "Im": 3000.0, "E": 1.5, "b": 1.8},
... fixed={"b": True}, # hold kinetic order fixed
... )
tldecpy.schemas.BackgroundSpec ¶
Bases: PygcdBaseModel
Input specification for background contribution in TL fits.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
{'linear', 'exponential', 'none'}
|
Background functional form. |
init |
dict[str, float] | None
|
Initial parameter values. |
bounds |
dict[str, tuple[float, float]] | None
|
Optional parameter bounds. |
fixed |
dict[str, float] | None
|
Optional fixed parameter values. |
tldecpy.schemas.RobustOptions ¶
Bases: PygcdBaseModel
Robust loss and weighting options for TL curve fitting.
Attributes:
| Name | Type | Description |
|---|---|---|
loss |
{"linear", "soft_l1", "huber", "cauchy", "arctan", "tukey"}, default="linear"
|
Residual loss function :math:
|
f_scale |
float, default=1.0
|
Residual scale parameter. Residuals with absolute value < |
loss_param |
(float | None, optional)
|
Extra loss parameter used by Tukey biweight (the Tukey constant |
weights |
{"none", "poisson"}, default="none"
|
Residual weighting strategy.
|
multi_start |
int, default=0
|
Number of randomised restarts with ±10 % parameter perturbation.
The best-cost solution is returned. |
ci_bootstrap |
bool, default=False
|
If |
n_bootstrap |
int, default=100
|
Number of bootstrap iterations when |
Examples:
>>> import tldecpy as tl
>>> # Robust fit with Poisson weighting
>>> opts = tl.RobustOptions(
... loss="soft_l1",
... f_scale=5.0,
... weights="poisson",
... )
>>> # Bootstrap confidence intervals
>>> opts_ci = tl.RobustOptions(
... loss="soft_l1",
... f_scale=5.0,
... ci_bootstrap=True,
... n_bootstrap=200,
... )
tldecpy.schemas.FitOptions ¶
Bases: PygcdBaseModel
Solver and uncertainty configuration for multi-peak fitting.
Attributes:
| Name | Type | Description |
|---|---|---|
local_optimizer |
{"trf", "dogbox", "lm"}, default="trf"
|
Local least-squares method passed to
|
max_nfev |
(int | None, optional)
|
Maximum number of objective function evaluations. |
ftol |
float, default=1e-8
|
Relative cost-function reduction tolerance for convergence. |
xtol |
float, default=1e-8
|
Relative parameter-step size tolerance for convergence. |
gtol |
float, default=1e-8
|
Gradient norm tolerance for convergence. |
uncertainty |
(UncertaintyOptions | None, optional)
|
If provided and |
Examples:
>>> import tldecpy as tl
>>> opts = tl.FitOptions(local_optimizer="trf")
>>> opts_uc = tl.FitOptions(
... local_optimizer="trf",
... uncertainty=tl.UncertaintyOptions(
... enabled=True,
... noise_pct=1.0,
... calibration_pct=0.5,
... ),
... )
tldecpy.schemas.UncertaintyOptions ¶
Bases: PygcdBaseModel
Configuration for uncertainty propagation in TL deconvolution.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Enables uncertainty evaluation when |
include_parameter_covariance |
bool
|
Includes covariance from the Jacobian-based local linearization. |
noise_pct |
float
|
Type-A noise contribution as percentage of fitted maximum intensity. |
noise_from_residuals |
bool
|
Uses residual statistics to estimate Type-A noise. |
calibration_pct |
float
|
Type-B calibration contribution in percent. |
heating_rate_pct |
float
|
Relative uncertainty in heating rate :math: |
reader_drift_pct |
float
|
Type-B reader drift contribution in percent. |
uc_metric_min_rel_intensity |
float
|
Minimum relative fitted intensity used to define ROI for |
uc_metric_noise_sigma_factor |
float
|
Residual-noise multiplier used in ROI definition. |
correlations |
dict[str, float]
|
Correlation coefficients keyed as |
export_report |
bool
|
Whether to attach uncertainty report payloads to fit outputs. |
validation_mode |
{'none', 'monte_carlo', 'bootstrap'}
|
Validation mode for uncertainty cross-checking. |
n_validation_samples |
int
|
Number of validation samples/iterations. |
validation_seed |
int | None
|
Random seed for reproducible validation runs. |
threshold_fom |
float
|
Recommended upper bound for figure-of-merit. |
threshold_uc_global |
float
|
Recommended upper bound for global uncertainty criterion. |
threshold_uc_p95 |
float
|
Recommended upper bound for 95th percentile uncertainty criterion. |
tldecpy.schemas.BoundsSpec ¶
Bases: PygcdBaseModel
Bounds definition for a scalar parameter.
Attributes:
| Name | Type | Description |
|---|---|---|
min |
float
|
Lower bound. |
max |
float
|
Upper bound. |
tldecpy.schemas.SimulationOptions ¶
Bases: PygcdBaseModel
ODE simulation options for synthetic TL curve generation.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
str
|
|
rtol |
float
|
Relative integration tolerance. |
atol |
float
|
Absolute integration tolerance. |
points |
int
|
Number of output sample points. |
Result schemas¶
tldecpy.schemas.MultiFitResult ¶
Bases: PygcdImmutableModel
Aggregated output of a multi-peak TL deconvolution.
Attributes:
| Name | Type | Description |
|---|---|---|
peaks |
list[PeakResult]
|
Fitted peak components. |
background |
BGResult | None
|
Optional fitted background component. |
y_obs |
ndarray
|
Observed intensity :math: |
y_hat_total |
ndarray
|
Total fitted intensity :math: |
residuals |
ndarray
|
Residual vector :math: |
metrics |
Metrics
|
Fit-quality and uncertainty metrics. |
converged |
bool
|
Optimizer convergence flag. |
message |
str
|
Optimizer termination message. |
n_iter |
int
|
Number of function evaluations/iterations. |
hit_bounds |
dict[str, bool]
|
Indicates which parameters touched optimization bounds. |
jac_cond |
float
|
Jacobian condition number estimate. |
loss_used |
str
|
Robust loss function effectively used by the solver. |
uc_curve |
ndarray | None
|
Channel-wise combined uncertainty criterion in percent. |
uncertainty_budget |
dict[str, float]
|
Global uncertainty contribution summary. |
uncertainty_report |
dict[str, Any] | None
|
Optional technical uncertainty report payload. |
uncertainty_validation |
dict[str, Any] | None
|
Optional validation diagnostics (MC/bootstrap vs local linearization). |
tldecpy.schemas.Metrics ¶
Bases: PygcdImmutableModel
Goodness-of-fit and uncertainty summary metrics.
Attributes:
| Name | Type | Description |
|---|---|---|
FOM |
float
|
Figure of Merit in percent. |
R2 |
float
|
Coefficient of determination. |
RCS |
float
|
Reduced chi-square surrogate. |
SSR |
float
|
Sum of squared residuals. |
AIC |
float
|
Akaike information criterion. |
BIC |
float
|
Bayesian information criterion. |
uc_global |
float | None
|
Global combined uncertainty criterion in percent. |
uc_max |
float | None
|
Maximum channel-wise combined uncertainty in percent. |
uc_p95 |
float | None
|
95th percentile channel-wise combined uncertainty in percent. |
contrib_E |
float | None
|
Contribution associated with activation-energy parameters. |
contrib_Tm |
float | None
|
Contribution associated with characteristic-temperature parameters. |
contrib_Im |
float | None
|
Contribution associated with characteristic-intensity parameters. |
contrib_bg |
float | None
|
Contribution associated with background parameters. |
tldecpy.schemas.PeakResult ¶
Bases: PygcdImmutableModel
Fitted result for one deconvolved TL peak.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Peak/component label. |
model |
str
|
Kinetic model key used in fitting. |
params |
dict[str, float]
|
Estimated parameter values. |
y_hat |
ndarray
|
Fitted peak contribution :math: |
area |
float
|
Integrated area under the fitted peak. |
ci_95 |
dict[str, tuple[float, float]] | None
|
Optional 95% confidence interval bounds by parameter. |
uncertainties |
dict[str, float]
|
Parameter standard uncertainties. |
tldecpy.schemas.BGResult ¶
Bases: PygcdImmutableModel
Fitted result for the background component.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
Background model type. |
params |
dict[str, float]
|
Estimated background parameters. |
y_hat |
ndarray
|
Fitted background signal. |
uncertainties |
dict[str, float]
|
Standard uncertainties for background parameters. |
tldecpy.schemas.FitResult ¶
Bases: PygcdImmutableModel
Legacy single-peak result schema retained for compatibility.
Attributes:
| Name | Type | Description |
|---|---|---|
params |
dict[str, float]
|
Estimated parameters. |
cov |
ndarray | None
|
Optional covariance matrix. |
metrics |
dict[str, float]
|
Legacy metric payload. |
y_hat |
ndarray
|
Fitted signal. |
residuals |
ndarray
|
Residual signal. |
converged |
bool
|
Convergence flag. |
message |
str
|
Solver termination message. |
model_type |
str
|
Model key used during fitting. |
tldecpy.schemas.SimulationResult ¶
Bases: PygcdImmutableModel
Output schema for ODE-based TL simulations.
Attributes:
| Name | Type | Description |
|---|---|---|
T |
ndarray
|
Temperature grid in kelvin. |
I |
ndarray
|
Simulated intensity signal. |
states |
dict[str, ndarray] | None
|
Optional ODE state trajectories keyed by state name. |
time |
ndarray | None
|
Optional integration-time vector. |
tldecpy.schemas.VersionInfo ¶
Bases: PygcdImmutableModel
Package and API version information.
Attributes:
| Name | Type | Description |
|---|---|---|
version |
str
|
Package version. |
api_version |
str
|
Public API version. |
build |
str | None
|
Optional build tag. |
tldecpy.schemas.ErrorDetail ¶
Bases: PygcdImmutableModel
Serializable error payload for API integrations.
Attributes:
| Name | Type | Description |
|---|---|---|
error_code |
str
|
Stable error identifier. |
message |
str
|
Human-readable error message. |
hint |
str | None
|
Optional remediation hint. |