Skip to content

Make four-point spots and maps part of the record - #19

Merged
PEEKPerformer merged 54 commits into
stack/16-sensorsfrom
stack/17-spots-and-session
Nov 16, 2026
Merged

PEEKPerformer merged 54 commits into
stack/16-sensorsfrom
stack/17-spots-and-session

Conversation

@PEEKPerformer

@PEEKPerformer PEEKPerformer commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

A four-point run carries its spot (index, label, position on a circular or rectangular sample outline) and map id; the file records it with per-spot statistics in the footer; maps are assembled from the run files that share a map id and served at /maps; the PySide6 window sends the spot too. The correction factor is known at any position on a finite sample (calculations_geometry.py, checked against F84 Table 3 and the Smits table), so a spot near an edge is warned about with the error it costs. Design: docs/design/four_point_probe_spots.md.

Woven through it, because they landed the same afternoon in the same files: file names keep their source value; a run can never be written over an existing file; the end-of-run shutdown is one method; a stop during the settle finalizes its file; van der Pauw announces run_started; the session status has a model; sweep compliance is bounded in its own unit.

Stack

Part 17 of 28. Targets stack/16-sensors; PR 18 targets this branch. Merge bottom-up with Rebase and merge so the commits and their messages survive. The stack is phase0/reviewable-baseline cut into reviewable pieces; the last PR's tree is that branch's tree.

PRs 14–21 are the branch's history after f3fd7d9 reordered by topic. Every commit is unchanged in content; only the order differs, and only where the reorder needed no conflict resolution.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Documentation only
  • CI / build / packaging only

Hardware testing

  • Tested against real hardware
  • Tested against software-only path
  • Not applicable

Simulator only. The spot model changes no SCPI.

Test suite

  • QT_QPA_PLATFORM=offscreen pytest tests/ -v passes locally — 2414 passed, 47 skipped, 6 xfailed at this PR's head
  • Added new tests for new behavior, or explained why none are needed

How to verify:

QT_QPA_PLATFORM=offscreen pytest tests/ -v

Reading order

schema/spots.py → calculations_geometry.py → session/spot_stats.py, spot_record.py, spot_map.py → the continuous_run.py hunks → api/routes_maps.py → docs/design/four_point_probe_spots.md §7 for the twelve open questions (defaults were taken; each is a one-line change).

Checklist

  • My changes follow the existing code style
  • I have updated README.md / version history if user-visible — the changelog's Unreleased section covers the whole stack and lands in PR 21
  • I have read the CONTRIBUTING guidelines

A multi-spot four-point measurement exists only in the two UIs: the
data files of the individual placements do not say they belong
together, what the spot was called or where it was, and the
finite-size correction assumes a centred probe without knowing whether
it was. The design makes a spot part of the run's record, derives the
correction factor at any position from the sample's shape (the closed
forms reproduce ASTM F84 Table 3 and the Smits table), and puts an
optional sample picture on top. It lists the questions that need an
answer before the UI work.
The finite-size corrections in calculations.py are table look-ups that
hold for a probe at the centre of the sample, so nothing can say what
a spot near an edge costs. For a thin sheet with insulating edges the
factor has a closed form at any position and orientation: one image at
the inverse point for a disc, an image lattice summed in closed form
along one axis for a rectangle.

At the centre the disc agrees with all 21 rows of ASTM F84 Table 3 to
within 0.0006 and the rectangle agrees with the Smits table to within
0.05 percent, which the tests pin. Three Smits entries disagree with
the series by 0.1 to 1.8 percent and look like transcription errors;
the tests record them and the table is left alone until the original
has been checked.

Pure functions only. Nothing calls them yet.
A four-point-probe characterisation is several placements of the probe
on one sample, and nothing in the settings contract could say where a
placement was or which placements belong together.

SampleGeometry describes the outline the position-aware geometry
functions need: unbounded, circle or rectangle, with exactly the
dimensions that shape has. SpotRequest is one placement: a map id, an
index, a label and an optional position and array angle.

The map id becomes part of a file name and of a URL, so it is limited
to letters, digits, '-' and '_'. The label is written into a header
line, so it may not contain control characters.
The position check of a spot needs to know the sample's outline, and
the two keys that hold one today can only say "circle" or one of three
rectangle aspect ratios.

Add fpp_sample_shape with its dimensions in millimetres, the array
angle, the warning threshold and the position-correction mode. While
the shape is 'unbounded' the legacy fpp_geometry / fpp_diameter_cm keys
are mapped onto an outline by one pure function, so a profile written
before outlines existed describes the sample it always did.

The per-sample correction is untouched: it still reads the legacy keys
and the tables. When the new outline and the legacy keys describe
different samples the resolver says so as a warning, because the rows
and the position check would otherwise disagree in silence.

Only 'warn' is accepted for fpp_position_correction. Whether 'apply'
should exist is an open question of the design.
A run could not say which placement of the probe it was, so the files
of one characterisation had nothing linking them.

RunRequest gains an optional spot. Any other mode carrying one is a
validation error: the spot and map model is four-point only until a
second mode needs it.
The mean of a spot and its uncertainty were computed twice, once in
each UI, from whatever rows that UI had seen, and written to the data
file by neither.

spot_statistics gives n, mean, sample SD and RSD of Rs, rho and sigma,
with the combined uncertainty from four_point_combined_uncertainty,
called with the inputs the PySide6 panel uses: samples in compliance
record a bound, not a measurement, so they are counted and left out.

A single sample has a mean but no standard deviation; sd and rsd_pct
are NaN there rather than a zero nobody observed.
The geometry functions give the factor at any position, but nothing
turned a run's settings and its spot into the numbers a file should
carry or the decision a run has to make.

spot_record_from_settings resolves the spot against the sample outline:
the array angle (the spot's own, else the setting), the edge clearance
in units of s, the factor at the spot and at the centre, and the
relative error of assuming the centre. From those it answers the two
questions a run asks -- is a tip off the sample, and is the error above
the operator's threshold -- and builds the header block.

The position effect is reported only. The per-sample numbers keep
coming from the table look-up.
A client could describe a spot but had no way to hand it to a run.

POST /session/start and MeasurementSession.start accept a spot. It is
validated before anything is opened and rides in the run settings as
settings['spot'], beside the sections the profile provides, so the run
procedure reads it the same way whether the session or the PySide6
worker started the run. A run without one has no such key.

The rule for which modes may carry a spot moves into one function that
the request model and the session both call.
The finite-size correction assumes the probe is at the centre, and
nothing told the operator when a placement made that assumption cost
several percent -- or when the position entered was not on the sample
at all.

A four-point run that carries a spot with a position now checks it
before anything is opened. A tip on or beyond the edge ends the run
with a geometry_warning event, an error and run_ended 'spot_refused';
the instrument is never touched, so no output can turn on under a probe
that is not where the run thinks it is. A relative error above
fpp_edge_warn_pct emits geometry_warning and the run goes on: the
measurement is valid, and no position correction is applied.

Runs without a spot, and every other mode, take the path they took
before.
The data files of the runs that make up one four-point map did not say
that they belong together, what each placement was called or where on
the sample it was.

A four-point run that carries a spot now writes a 'spot' block into the
v2 header: map id, index, label, position, the array angle in force,
the sample outline, the position-correction mode and threshold, and --
for a position on a bounded sample -- the factor there, the factor at
the centre, the relative error and the edge clearance in units of s.
CSV and HDF5 get it through the same metadata dict.

A run without a spot writes the header it wrote before.
The mean of a placement, its spread and its combined uncertainty could
not be reproduced from the archive: only the PySide6 panel computed
them, and only the separate Save Summary export wrote them down.

Every four-point run now ends its file with a spot_stats block -- n,
the samples left out for compliance, and n, mean, sample SD, RSD,
u_stat, u_inst and u_total for Rs, rho and sigma -- and emits
spot_complete with the same numbers and the run's spot, so a client
shows the backend's statistics rather than its own. CSV and HDF5 get
the block through the existing end metadata.

The acquisition loop gains one call, after a row is written, that
keeps the row's values for the statistics. Nothing about when a sample
is taken, what is sent to the instrument or what a row holds changes,
and a failure to compute the block is a warning, not a lost file.

For a run without a spot the header is unchanged and the footer gains
only this block; a test pins both key sets. Other modes are untouched.
parse_metadata coerces every header value back to a Python literal,
which cannot tell an identifier from the number it resembles: a map id
of '12_3' comes back as the integer 123 and a label of 'true' as a
bool. A reader that matches files by id would miss its own files.

text_keys names the values to return exactly as written. The default
is empty, so every existing caller gets what it got before.
A spot is a run, so a map is whatever the files that share a map_id
say it is, and nothing read them together.

session/spot_map.py reads the headers and footers of the four-point
runs in one directory, keeps the newest run of each spot index and
returns the spots with the inter-spot mean, sample SD and RSD of Rs,
rho and sigma. A run that never finished or has no sample outside
compliance is listed as skipped and does not displace a good earlier
run of the same index; older runs of an index are listed as superseded.
CSV, gzipped CSV and HDF5 runs are read; only files with the four-point
tag in their name are opened, because reading a gzipped footer means
decompressing the whole file.

write_map_summary writes <map_id>_map.json beside the runs through a
temporary file and a rename. The run files are only ever read and
nothing is deleted.

SpotMap is exported as contracts/maps.schema.json, with generated
TypeScript types beside the other two contracts.
The map existed only while something assembled it, so the archive held
the runs of a map but not the map.

A four-point run that carries a spot now refreshes <map_id>_map.json
beside its data file once that file is finalized. The summary is
derived from the run files and can be rebuilt from them, so failing to
write it is a warning and never the run's failure; a run without a
spot writes nothing.

The simulator test runs three spots and a repeat of the second through
the session and checks the whole record: the spot block in every
header, footer statistics against the rows, spot_complete against the
footer, the newer run standing for spot 2, and the inter-spot RSD
against a hand calculation.
The desktop UI keeps its spots in a browser-side store that is gone on
reload, because the backend had nothing to ask.

GET /maps lists the map ids an operator's four-point runs name and
GET /maps/{map_id} returns the assembled SpotMap, 404 when no run names
it. Both need the bearer token like every other route and neither
writes anything.

The directory is <data_directory>/<username> from the operator's own
profile, the place a run by that operator writes into, with the
username through the same sanitizer the run's directory name went
through. The map id is matched against the plain-token pattern before
it gets near a path.
The header block, the footer statistics and the map were only checked
end to end against CSV. Run one spot through the session with the HDF5
exporter and read all three back. Skipped where h5py is not installed.
Steps 1 to 4 are in: geometry math, schema, the spot in the file and
the events, and the map with its API. Say so in the status line and
beside each step, with the two things a reader of the code would
otherwise have to discover: the new outline keys feed only the position
check, and 'apply' is not accepted until question 1 is answered.
Instrument locks live in one directory per machine so that two
ResistaMet processes exclude each other. Two test suites running at
once are not that: they refused each other's simulated GPIB0::24 and
failed with "in use by another process". Each test now takes its locks
in a directory of its own, and the tests of the shared location patch
it themselves as before.

The sidecar tests started the backend in the checkout, so every run
left a data file under measurement_data/. The sidecar now gets a home
and a working directory under tmp_path.
The design's table gave 1 - F_here/F_centre while the code and the
files record F_centre/F_here - 1, the fraction by which the reported
sheet resistance is too high. Near an edge the two differ (25 vs 33
percent at one spacing), so the table now uses the recorded quantity.
A run's base name ends in its source value, which has a decimal point:
..._4PP_0.10mA, ..._VSRC_0.500V, ..._sweep_0.0to1.0. The exporters
built the output name with Path.with_suffix, which takes everything
after the last dot for a suffix and replaces it, so those runs were
written as ..._4PP_0.csv, ..._VSRC_0.csv and ..._sweep_0.0to1.csv. The
value the name exists to carry was lost, and two runs at 0.10 mA and
0.25 mA in the same second shared one path.

The extension is now appended to the name instead, in the CSV, gzipped
CSV, HDF5 and legacy CSV+JSON exporters (the checkpoint file included).
Nothing reads a value back out of a file name: the results routes and
the PySide6 viewer match on the extension, and the spot map matches
"_4PP_" anywhere in the name.
Review found two faults in the image sum. For a sample more than about
5.6 times wider than long, sin() overflowed in the far image rows and
the run that asked for the factor died outside its error handling.
For a long strip the sum had not converged: forty rows left an error
of 0.1 percent at L/W = 200, because the rows converge at a rate set
by the shorter side over the longer one and the comment had the ratio
upside down.

The closed-form sum now runs along the shorter side, which makes eight
rows exact for any shape, and ln|sin u| switches to its asymptote far
from the real axis.

The agreement with the tables was also overstated. Twenty of the 21
F84 rows round to the printed value (S/D = 0.085 gives 4.2656 against
4.265), and the Smits table agrees to within 0.05 percent, not to four
digits. The docstring, the design and the tests now say that.
The stamp at the front of a run's file name has one-second resolution,
and the exporters opened their files with 'w'. Two runs of the same
sample inside the same second -- a scripted client, or a stop and an
immediate restart -- asked for the same path, and the second run
replaced the first run's data without a word.

Each exporter now takes base, base-2, base-3, ... -- the first name for
which none of the files it will write exists (.csv and .csv.gz; .h5;
.csv, .json and the .json.tmp checkpoint of a crashed run) -- and
creates its files in exclusive mode. A name taken by another process
between the check and the open is therefore an error for the new run,
never an overwrite of the old one.

The choice is made inside the exporter because only it knows which
extensions it writes; the runs already report the path the exporter
ended up with, so file_opened, file_finalized and the worker's
filename follow without change.
Output off, the file footer, spot statistics and the closing log line
sat inline at the bottom of ContinuousRun.execute, reachable only by
falling out of the sampling loop. The next commit needs to reach them
from a second place.

Pure move: the block is unchanged apart from its indentation, and the
three locals it read become arguments. Review with

    git show --color-moved=dimmed-zebra \
        --color-moved-ws=allow-indentation-change
A run stopped during the settling wait left a file with a header and no
footer, and the log went from "Stopping measurement..." straight to
"Instrument disconnected." with no "Output turned OFF." and no "Data
saved to:". In Results the orphan looked like any completed run.

The stop interrupts the wait by raising RunStopped, which unwound past
the shutdown at the end of the try block; its handler did nothing, and
only _cleanup ran, which closes the file without end metadata and says
nothing. The same held for a stop inside a delta-mode polarity settle or
a read-retry backoff, where a four-point run spends most of its time.

The handler now runs the same shutdown as every other stop: output off
with its log line, the footer (zero samples is a valid count),
file_finalized, the closing "completed" line and acquisition_finished.
The sampling loop is untouched.
Every continuous run and sweep opens its event stream with run_started,
which carries the mode, the sample, the operator and the settings the
run will use. A van der Pauw run sent nothing until its first log line,
so a client could not tell from the stream which mode had begun or what
it was configured with, and had to infer a new run from an unfamiliar
run id.

VdpRun now emits it at the same point in the lifecycle as ContinuousRun
-- first thing, before the instrument lock and the safety prompt -- with
the same payload. The PySide6 adapter ignores the event, as it does for
the other modes.
Cancelling the touch-safety prompt ended the run with "cancelled" and
wrote nothing to the log: its last line was still the previous run's,
so there was no record that a run had been asked for and refused, or
why.

Both run procedures now log one line (code safety_declined) naming the
sample, the quantity that tripped the warning, its value and the
threshold, whenever the prompt ends without an acknowledgement. A
timeout keeps its own warning. Info level: the operator chose this.
An up-then-down sweep that wrote 82 rows logged "Sweep complete: 41
points acquired": the message took the length of the forward leg only.
The file footer and the event stream were right; the log disagreed with
both.

The line now gives the total and, for a two-way sweep, the split:
"82 points acquired (41 forward, 41 reverse)". The opening line had the
same ambiguity and now says "41 points each way" for a two-way sweep.
One-way sweeps log exactly what they did before.
The log is read at the bench, and it spoke in internals: "Measurement
(source_v) completed!", "Configuring instrument for four_point mode...",
a warning-sign emoji in front of the power and compliance warnings, and
"Ohm/sq", "Ohm.cm", "Ohms" where both UIs write the symbols.

Messages now name a mode the way the PySide6 tabs and the desktop rail
do, through one table (constants.MODE_DISPLAY_NAMES). The emoji become
the "Warning:" prefix the other warnings already use, which the PySide6
log also colours. Units are written as the symbols.

Only message text changes. Log codes, event payloads, settings keys and
file metadata keep the internal keys; no test or client matched on the
changed text (the PySide6 colouring looks for "error", "warn" and
"compliance", all still present where they were).
The four-point power messages formatted every threshold as whole
milliwatts, so a 0.1 mW hard stop read "0 mW" and the message refuted
itself: "worst-case power 0.5 mW exceeds the probe-safety hard stop
0 mW". The runtime warning did the same with a 0.5 mW warn threshold.

One helper, format_power, picks the SI prefix and gives three figures
(100 µW, 500 µW, 2 mW, 1.5 W). The pre-run validation issue, the
configure-time refusal and warning, and the runtime warning and hard
stop all use it, so a threshold reads the same before and during a run.
It lives in a small Qt-free module because the schema and the session
both need it.
With the sense leads open the voltmeter floats, and a four-point run
recorded a sheet resistance of about -43 kΩ/sq on screen and in the
file: no compliance, no error, nothing in the log. Swapped sense leads
give the same sign. A passive sample cannot do that, so the first such
sample now logs one warning (code fpp_negative_ratio) saying the sense
leads are probably open or swapped.

It is a warning and nothing else. The sample, the row, the statistics
and the run's end are untouched, and it is said once per run, not once
per sample. Delta mode is left out: its reading is the half-difference
of two polarities, where an offset cancels by design. Samples in
compliance are left out because they already have their own warning.
A file written through the API records the backend's version and
nothing else, so output from the desktop app cannot be told from the
PySide6 app's, in the file or in the Results metadata panel.

POST /session/start (and RunRequest, its contract) accepts an optional
client: {name, version}. Both are short tokens -- letters, digits,
space and . _ + - , at most 64 characters -- because they are written
onto one line of a CSV header and must not be able to start another.
The session carries it as settings['client'], the way a spot travels,
and build_metadata writes client.name and client.version into the v2
header of every mode, van der Pauw included. software_version stays
the backend's own.

With no client in the request, and on the PySide6 path, the header is
exactly what it was. Contract and generated desktop types regenerated.
GET /session and every session command answer with a dict whose shape
lived only in MeasurementSession.status(), so the desktop client typed
it by hand and nothing would notice the two drifting apart.

SessionStatus (session/status.py) describes that reply field for field;
every field is required, nullable where there may be nothing to report.
status() builds its dict through the model, so the reply and the
contract are the same thing, and still returns a plain dict with the
same keys and values as before. tools/export_contracts.py writes it to
contracts/session.schema.json and the desktop's generator turns that
into src/generated/session.ts; the drift test covers the new file.

The pending prompt gets its own model rather than reusing the prompt
event's payload: that one has defaults, which the generator renders as
optional fields, and the status always sends all five.
A client learns which SourceMeter is on the bus from the
instrument_connected event, or from its own Identify. After a reload
both are gone: the desktop's header said "No instrument" until the next
run connected, while Settings showed the model and its limits.

The session now remembers the instrument as last seen -- the data of a
run's instrument_connected event, or a successful identify, whichever
is newer -- and reports it as status.instrument (null until either has
happened). A failed identify leaves the previous sighting in place.
Contract and generated types regenerated.
test_settings_bounds compares each model field's bounds with the
PySide6 widget's and already has a list for fields whose lower bound is
deliberately looser than the widget's, with the reason. The next commit
needs the same for an upper bound, so the mechanism is added here, with
an empty list: every field is still held to its widget's maximum, and
no assertion changes for any of them.
A sweep's compliance limits what is measured, so its unit follows the
source: amperes on a voltage-sourced sweep, volts on a current-sourced
one. The schema bounded it at 3 whatever the unit, so a current-sourced
sweep could not be given more than 3 V of compliance.

The bound now follows sweep_source: at most 3.15 A when sourcing
voltage (the 3 A class's compliance ceiling) and 210 V when sourcing
current (the 2400's 200 V range). The field's own "le" is the larger of
the two and a field validator applies the tighter one, so the issue is
keyed to sweep_compliance and 60 is refused as a current limit exactly
as before. These are the family's envelope: ModelSpec is reported at
connect but not enforced, as for the other modes' 200 V bounds, and an
instrument rejects a limit it cannot set.

Raising a voltage bound past 30 V touches the touch-safety prompt. It
already reads a current-sourced sweep's compliance as the voltage on
the leads (safety.is_potentially_hazardous); what was missing was any
way to reach it, since the old bound refused such a request first. The
tests here pin it end to end: 60 V of compliance on a current-sourced
sweep raises the same prompt, field for field, as a 60 V source, before
the instrument is opened; cancel ends the run; 21 V asks nothing; and a
voltage-sourced sweep's current limit is never read as volts.

The PySide6 spin box still stops at 3 in either unit; the bounds test
records that divergence with its reason.
GET /results lists .json files, for the legacy CSV+JSON pair, and so it
also listed every <map_id>_map.json a four-point map writes beside its
runs: in the desktop's Results view a map summary appeared as if it were
a run, and could not be previewed.

Names ending in _map.json are now skipped. The summary is derived data
with its own routes under /maps, and no run's name can end that way (a
run's name ends in its source value). The suffix is one constant in
spot_map.py, used by the writer and by the listing.
Giving every test a private lock directory also hid the real location
from the one test that checks it, which then failed. That test now
opts out with a marker.
The spot check runs after run_started and outside execute()'s main
try, with the instrument lock held, and it caught only ValueError. Any
other exception -- an overflow in the geometry series, float(None)
from a null fpp_edge_warn_pct in hand-built settings, a payload the
event model rejects -- left run_started with no run_ended and the lock
held until the process died.

The whole check is now inside the guard, and any exception is the
refusal it should always have been: error 'spot_invalid' with the
exception's text, the lock released, run_ended 'spot_refused' as the
last event.
The PySide6 window has a spot name field, a spot counter and two
buttons, but no map, so it has nothing to put in the spot block a
four-point run can now carry. Its files still do not say which spot
they are or that they belong together.

Add the rule that turns those widgets into a spot, where it can be
tested without Qt. A mapping session is the runs one user makes on one
sample name between two resets; a run for another user or sample, the
first run of the process, and the first run after a reset each start a
new map. When in doubt the runs go to a new map, because two maps can
be merged from their files and one map of two samples cannot be split.

The window validates nothing through pydantic when a run starts, so
the label and the sample name are reduced here to what SpotRequest
accepts: no line breaks, at most 80 characters, "Spot N" when nothing
is left, and a map id that is a plain token with a random suffix so
two maps minted in the same second differ.
SpotSamples.add claimed it could not raise and could: a derived value
of None has no .get, and a column could be appended before a later
conversion failed, leaving the columns with different lengths. It was
also called inside the try around the CSV write, where a raise would
have been counted as a write failure -- three of which stop a run.

add now converts every value first and appends afterwards, and treats
a derived value that is not a dict as a sample with no derived values.
The loop calls it through _keep_for_statistics, after the write and
under its own guard, which warns once per run. It still counts only
rows that reached the file.
A map is rebuilt from whatever is in the data directory, and two things
in one file could take the whole map down: a header value of the wrong
type ('spot.x_mm: abc') raised outside the guard, making GET /maps/{id}
a 500 and failing the summary write; and started_at values with and
without a UTC offset cannot be compared as datetimes.

Every value read from a file is now validated inside the guard, and a
run that fails goes under 'skipped' with the reason. Files that cannot
be read at all are listed too -- 'h5py not installed' for HDF5 runs on
a machine without it -- instead of vanishing behind a debug line; they
cannot say which map they belong to, so every map of the directory
reports them.

Newest is decided by the Unix stamp at the front of the file name,
which is UTC and so survives a daylight-saving change and two PCs with
different zones; then started_at as a timestamp; then the -N the
exporter appends to a taken name, as a number; then the name.

Map ids are checked with fullmatch: '$' alone accepts a trailing
newline.
The schema accepts only 'warn', but the PySide6 path hands the run
settings no schema has seen, and the spot block wrote whatever the key
held. A hand-edited 'apply' would have been recorded as in force in a
file whose numbers had no correction applied.

The record now always says 'warn', the only thing implemented, and the
run logs a warning naming the value it ignored.
A label of only spaces passed validation and was written to the file
header, whose reader strips values: it read back empty. A label with
outer spaces read back as a different string from the one the event
carried.

The label is stripped before it is validated, so what is accepted is
what every reader will see.
With fpp_spacing_cm missing or zero the per-sample calculation falls
back to 0.1016 cm and the run measures, but the spot check passed the
zero on and the geometry functions refused it: a run the rows would
have computed was refused as 'spot_invalid'. The spot check now uses
the same fallback.
A four-point run records its spot in the file header, the statistics
footer and the map summary when its settings carry one, but the
PySide6 window never set it: a spot there was a row in a table, and
the files of one afternoon's placements still could not be told to
belong together without the operator's memory.

Add the spot where the window starts a run, from the widgets it
already has: the label is the Spot name field as Start is pressed, the
index is the spot counter, and the map id comes from the mapping
session rule in schema.map_session. Clear All ends the map. The run is
started for the current spot and Save Spot then archives it and moves
the counter on, so the index in the file is the row the spot gets in
the table; starting again without saving repeats the index, and the
newer file stands for the spot.

The gather step is left as the goldens describe it, no widget, text
or layout changes, and Save Spot, the bar chart and the summary export
do what they did. The spot is built inside the existing settings try
block, so a spot that could not be described would stop the start with
the settings dialog rather than an exception in a slot.
Say what the window sends and which rule decides when a map ends, so
the open question about map identity is read against what the shipping
application does today rather than against nothing.
The spot block's relative_error compares the factor at the spot with
the closed-form centre of the fpp_sample_* outline. The rows do not use
that factor: they use the table look-up on fpp_geometry and
fpp_diameter_cm, or K*alpha when no diameter is entered. When the two
describe different samples the header understated the error in the
file's own Rs -- a 20 s square measured with the unbounded 4.532 is
1.8 % off at its centre, where relative_error says 0.

The block now also records spot.factor_rows, the lateral factor the
rows apply, and spot.relative_error_rows = factor_rows / factor_here
- 1. The factor is asked of build_row with one made-up reading, once
per run before the instrument is opened, so which correction path a run
takes is still decided in one place; the F84 thickness term F(w/S) is
divided out, since the other factors are thin-sheet and lateral only.

The edge warning is judged on relative_error_rows whenever the rows
have a finite Rs, and geometry_warning says which comparison it made
(compared_with, and in the message). The map's spots carry the new
error too.
Two ways out of execute() left an open data file to the silent backstop
in _cleanup: the return when the output would not turn on, and the
handler for an unexpected error. The file was closed but had no footer,
no file_finalized or acquisition_finished event, and the log never said
the output was off or where the data went -- what the settle-stop fix
cured for a stop.

Both now leave through _shut_down. It runs once per run, so a fault
inside the shutdown cannot send the run round it again. Nothing sent to
the instrument changes: the output-off in _shut_down is the one the
normal end already sends, ahead of the one in _cleanup.
spot_complete was emitted inside the try around the file's finalize, so
a failure to build or send it was logged as 'finalize_failed' --
"Error finalizing export" -- about a file that had just been finalized
and was whole.

It now has a guard and a code of its own, 'spot_complete_failed', and
the message says the data file is complete. A finalize that really
failed announces no spot.
The map summary was written from the shutdown, in the run thread,
before _cleanup: with the instrument still open and its lock still
held. Assembling a map reads every four-point file in the directory,
and the directory may be a slow network share, so a second process
waiting for the instrument waited on the share too.

The shutdown now only notes the map id. The summary is written after
_cleanup has closed the instrument and released the lock, and before
run_ended: run_ended is promised to be the last event of a run, and
the map_summary log line is an event. spot_complete still comes before
run_ended, as the tests pin. The session is not idle until the write
returns, but nothing else is held while it does.
The instrument's relative accuracy floor depends on V and I only, yet
it was computed three times per spot, once each for Rs, rho and sigma,
walking every reading through the accuracy tables each time. A
four-point run with no sample target can hold a great many readings.

The floor now comes from one call per spot. It is still obtained from
four_point_combined_uncertainty, so which readings count stays that
function's business, and a test holds u_stat, u_inst and u_total equal,
bit for bit, to calling it with the readings.

The docstring now says where sd and rsd_pct deliberately differ from
that function's: NaN rather than 0 for a single value, and |mean|
rather than the signed mean in the RSD.
A map takes the newest run of each spot index, and nothing in a file
said whether that run measured its full count of samples or was stopped
after two. The footer's spot_stats block now carries end_reason, the
same value run_ended reports, so it reaches spot_complete and the map's
spots as well.

Nothing acts on it yet: whether a run that was stopped early should
displace a complete earlier one is left to be decided, and newest-wins
is unchanged.
The design said "keep the newest run per spot index" without saying
what newest means or what happens to a run that cannot be read, and did
not know about end_reason or which error the edge warning is judged on.
Say each where a reader of the design will look for it, and name the
one question the code leaves open: whether a run that was cut short
should displace a complete earlier one.
Building and reviewing steps 2 to 5 raised questions the design did
not have: what to do when the sample outline and the legacy geometry
keys disagree, whether a run cut short should displace a complete one,
where maps are looked for, three behaviours of the PySide6 spot
controls, and the naming of map files. They join the list the UI work
waits on.
@PEEKPerformer
PEEKPerformer force-pushed the stack/17-spots-and-session branch from e480985 to dd1fe3d Compare November 16, 2026 18:33
@PEEKPerformer
PEEKPerformer merged commit 956b517 into stack/16-sensors Nov 16, 2026
4 checks passed
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