Skip to content

feat(trend): normalize the trend to a fixed spectrum - #23

Merged
mrcsin merged 1 commit into
masterfrom
trend-normalization
Nov 16, 2026
Merged

mrcsin merged 1 commit into
masterfrom
trend-normalization

Conversation

@mrcsin

@mrcsin mrcsin commented Nov 16, 2026

Copy link
Copy Markdown
Member

Problem

The client asked to normalize the intensity trend: on a press, fix the current values in the measurement window, then show each later value as the mean of every pixel divided by its own fixed pixel, times 100 or 1000. Only the trend is normalized, and a change of wavelength or window resets it.

Change

  • A switch over the trend, "Нормировка: Выкл | ×100 | ×1000", in Semi's ButtonRadioButton look, 22 px to fit the top margin. It replaces two toggle buttons after a designer review: Off is visible, and the checked state is quieter.
  • IntensityCache.StartNormalization and StopNormalization fix and drop the reference under the cache lock, recompute the recent spectra, and raise a re-read that carries the reference. The stored day is re-read normalized from the raw pixels (SpectrumHistory.IntensityPointsAsync), and the stored data does not change.
  • QueryWindows.NormalizedMeanOf is the one home of the formula: it divides each pixel by its own reference pixel and then averages. A zero reference pixel is skipped. A point of the other spectrometer is NaN, because both firmware tables cover 898-1028 nm.
  • A key change ends normalization and adds an Info line. A dark reference is refused with a Warning. Every change clears a held Y range. The state line and the Y label name the factor.
  • The factor segments need a fresh live spectrum, and their tooltip says so. Off stays enabled, so a stale link never locks normalization on. MirroredRadioButton never checks itself, so a refused press leaves the switch as it was. A transparent strip stops a press on a disabled segment from reaching the plot.
  • Docs: overview.md (Normalization), docs/architecture/README.md (Trend row), readme.md, and the plan. This is PR 2 of 3; .NET 11 follows.

Verification

  • dotnet build -c Release: 0 warnings. dotnet format --verify-no-changes and terse over every SemiSpec/*.cs: exit 0.
  • dotnet test: 1133 passed. The new tests cover:
    • the order of operations: a reference of [100, 200] and pixels of [100, 100] give 75, not 66.7; this is checked on the cache path and on the store path
    • zero reference pixels
    • the other device
    • the dark refusal
    • a start or stop racing key changes on two threads
    • the feed passing the reference to the store read
    • the switch's states, enablement and tooltip
    • a refused click
    • a click on a disabled segment
    • the text fit at the minimum width
  • Known flake, not caused by this branch: AppLifecycleTrendTests.TheTrendShowsTheStoredPointsAfterARestart and CompositionRootTests.TheAppBuildsTheMainWindowFromTheProvider fail now and then on master and on the commit before feat(ui): add display toggles and trend dots #22.
  • The operator ran the app against the board emulator and approved the behaviour and the switch.
Per-task commits before collapse
23a7710 feat(trend): normalize the trend to a fixed spectrum

🤖 Generated with Claude Code

The client asked for normalization of the intensity trend: fix the
current window pixels on a press, then show every later value as the
mean of each pixel divided by its own fixed pixel, times 100 or 1000,
without touching the full spectrum, and drop it on a change of
wavelength or window.

A switch over the trend, Off | x100 | x1000, starts, switches and stops
it. The cache fixes the newest live spectrum under its lock, normalizes
the recent spectra, and re-reads the stored day normalized from the raw
pixels, so raw and normalized points never share one axis. A key change
ends it with an Info line, a dark reference is refused with a Warning,
and a point of the other spectrometer is NaN, since both firmware tables
cover 898-1028 nm. The factor segments need a fresh live spectrum; Off
stays enabled so a stale link never locks normalization on. The switch
replaces two toggle buttons after a designer review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mrcsin
mrcsin marked this pull request as ready for review November 16, 2026 14:54
@mrcsin
mrcsin merged commit ce73832 into master Nov 16, 2026
1 check passed
@mrcsin
mrcsin deleted the trend-normalization branch November 16, 2026 14:58
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.

1 participant