Skip to content

Fix Planckian/exponential fits on physical units; add fit formulas - #75

Merged
PierreRaybaut merged 3 commits into
developfrom
fix/planck-fit-and-domain-coordinates
Oct 20, 2026
Merged

PierreRaybaut merged 3 commits into
developfrom
fix/planck-fit-and-domain-coordinates

Conversation

@PierreRaybaut

@PierreRaybaut PierreRaybaut commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #74

Several problems reported by DataLab 1.3.0 users about the blackbody signal, curve fitting and synthetic images.

Bug fixes

  • Automatic Planckian fit: on data in physical units (e.g. a blackbody curve with wavelengths in meters), planckian_fit returned its initial guess unchanged. The fitted peak came out exactly exp(5) - 1 (about 147) times too low, with no warning. The initial guess now matches the data peak, and the fit runs on normalized data, so it converges whatever the units. With the default blackbody signal, the fit gives back T = 293 K and an emissivity of 1, to better than 1e-6 relative error.
  • Exponential fit: the rate b was bounded to [-10, 10] whatever the X unit, so a 1 ms time constant with X in seconds could not be fitted. The bound now scales with 1/Δx, and evaluate clips the exponent b·x instead of b itself.

New features

  • FitComputer.FORMULA and get_formula() give the rich-text formula of every fit model (single source of truth for SigimaX, DataLab and DataLab-Web).
  • PlanckParam now has default axis titles and units: wavelength in m, spectral radiance in W·sr⁻¹·m⁻³. Its docstring had the wrong unit.
  • Gaussian, 2D ramp, sinusoidal grating, ring, Siemens star and 2D sinc images now derive from DomainImageParam. Its "Physical coordinates" option (enabled by default) uses the [xmin, xmax] × [ymin, ymax] domain as the image coordinates. Parameters serialized without this option (creation metadata, workspaces, history) are deserialized with it disabled, so recreating an older image keeps its pixel coordinates.

Not changed

The 4-parameter Planck model and the fit_params schema are unchanged. The model is still over-parameterized (#43 stays open); the docstring now explains how to derive peak wavelength, temperature and emissivity from the fitted parameters.

Companion PRs (merge order: Sigima → SigimaX → DataLab)

Validation

  • Full test suite: 2191 passed, 34 skipped.
  • New regression tests cover:
    • Planckian fit over several temperatures, with X in m, µm and nm, with noise and a baseline;
    • exponential fit with a 1 ms time constant;
    • a FORMULA for every fit type;
    • physical coordinates for each of the 6 image types, with the option on and off, plus legacy deserialization;
    • Planck axis labels.
  • Ruff and Pylint (10/10) pass on the changed modules.

#74)

The automatic Planckian fit returned its initial guess (peak exp(5) - 1
times too low) on physically scaled data such as wavelengths in meters:
the amplitude seed ignored the model peak value and curve_fit stopped at
its first iteration. The seed now matches the data peak and the fit runs
on normalized data. The docstring explains how to derive the peak
wavelength, temperature and emissivity from the fitted parameters.

The exponential fit bounded the rate to [-10, 10] whatever the X unit and
clipped the rate itself when evaluating the model: the rate bound now
scales with the X range and only the exponent is clipped.

Every fit computer now exposes its model formula (FORMULA attribute and
get_formula() method) for interactive fit dialogs.

Assisted-by: Claude Opus 5.5
…fo (#74)

Gaussian, 2D ramp, sinusoidal grating, ring pattern, Siemens star and 2D
sinc images are computed over a [xmin, xmax] x [ymin, ymax] domain which
was ignored by the image coordinates. These parameter classes now derive
from DomainImageParam, whose "Physical coordinates" option (enabled by
default) applies the domain to the image uniform coordinates.

The blackbody signal gets default axis labels and units (wavelength in m,
spectral radiance in W·sr⁻¹·m⁻³).

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants