Repository navigation
Planckian and exponential fits depend on data units; Planck signal and domain-based images lack axis information #74
Description
Context
Several issues reported by DataLab 1.3.0 users, all rooted in Sigima, concern the blackbody (Planck) signal, the Planckian fit, and synthetic images. An exponential fit defect found while investigating is included as well.
1. Automatic Planckian fit returns its initial guess (bug)
With the default Planck signal (500 points, wavelengths in meters), planckian_fit returns a curve whose peak is 147.4 times lower than the data, without any warning:
import sigima.objects as so
from sigima.tools.signal import fitting
s = so.create_signal_from_param(so.PlanckParam.create(T=296.0))
y_fit, params = fitting.planckian_fit(s.x, s.y)
print(s.y.max() / y_fit.max()) # 147.41... = exp(5) - 1Root cause: PlanckianFitComputer.compute_initial_params seeds amp with the data range, but with sigma = 1 and x0 = x_peak the model peaks at amp / (exp(5) - 1). With x ~ 1e-5 and amp ~ 1e7, curve_fit stops on xtol at the first iteration and returns p0 unchanged. The amp bounds ([0.01, 100] × dy) do not even contain the solution for sigma = 1. The fit converges as soon as x is expressed in µm, which confirms a conditioning/initial-guess problem rather than a model error.
2. Exponential fit fails for short time constants (bug)
import numpy as np
from sigima.tools.signal import fitting
x = np.linspace(0, 5e-3, 500) # seconds
y = 2.0 * np.exp(-x / 1e-3) + 0.1 # tau = 1 ms
y_fit, params = fitting.exponential_fit(x, y)
# UserWarning: Optimization failed: Initial guess is outside of provided bounds
# relative RMS residual: 0.72The bounds on b are hard-coded to [-10, 10] and evaluate clips b itself to ±50, so the fit depends on the X unit.
3. Planck signal has no axis labels or units (enhancement)
PlanckParam computes a spectral radiance as a function of wavelength in meters, but leaves X/Y labels and units empty (periodic signals, by contrast, default to xunit = "s"). The func docstring also gives a wrong unit (W m⁻² sr⁻¹ Hz⁻¹ instead of W sr⁻¹ m⁻³ for B_λ).
4. Domain-based synthetic images are displayed in pixel coordinates (enhancement)
Gaussian, 2D ramp, sinusoidal grating, ring pattern, Siemens star and 2D sinc images are computed over [xmin, xmax] × [ymin, ymax], but create_image_from_param does not set the image coordinates (x0 = y0 = 0, dx = dy = 1). Center, width and frequency parameters are therefore expressed in a different scale than the displayed axes: e.g. a grating with fx = 0.1 over [0, 100] on 1024 pixels shows 10 periods across axes labelled 0–1023.
5. Fit model formulas are not available programmatically (enhancement)
The interactive fit dialogs cannot show which formula is used. Users have to read the source code to find it.
Proposed changes
PlanckianFitComputer: initial guess consistent with the model (x0 = x_peak · W / 5,amp = dy · (exp(W) − 1) · (W/5)⁵with W ≈ 4.965, Wien's constant), bounds centered on it, and fit performed on normalized x/y then mapped back. Document the derived quantities (peak ≈ 1.007 · x0 / sigma; for x in meters, T = h c sigma / (5 k_B x0)). The 4-parameter model and thefit_paramsschema are unchanged (the degeneracy remains tracked in Planckian fit is exactly non-identifiable: x0 and sigma cannot be determined separately #43).ExponentialFitComputer: clip the exponentb · x(overflow protection) instead ofb, and scale thebbounds with1 / Δx.FitComputer.FORMULA: rich-text model formula on every fit computer (single source of truth for SigimaX, DataLab and DataLab-Web).PlanckParam: default labels and units (Wavelength [m], Spectral radiance [W·sr⁻¹·m⁻³]); fix thefuncdocstring.- Domain-based image parameters: new "Physical coordinates" option (default on) applying the domain to the image coordinates; test data helpers keep pixel coordinates.
- Regression tests and French translations.
Related
- Planckian fit is exactly non-identifiable: x0 and sigma cannot be determined separately #43 (Planckian model degeneracy, out of scope here)
- Interactive fit dialogs: show the model formula and evaluate models through Sigima SigimaX#9, Wrong automatic Planckian fit, missing Planck axis information and synthetic images shown in pixels DataLab#400, Interactive fit dialog: show the model formula web#56
Activity
PierreRaybaut commentedon Oct 20, 2026
Fix proposed in #75, DataLab-Platform/SigimaX#10 and DataLab-Platform/DataLab#401 (merge order: Sigima, then SigimaX, then DataLab). The PRs target
develop, so this issue will not be closed automatically on merge.fix(fitting): Planckian and exponential fits independent of data units (
feat(objects): physical coordinates for domain images, Planck axis in…
docs: release notes and French translations for DataLab-Platform#74