CBOR: carry the reflection's background variance

var_bkg was added to Reflection and to the HDF5 writer but never to the CBOR reflection map, so it
survived only where rugnux drives the writer in-process. Everything that reaches the writer over the
wire - i.e. every acquisition the broker records - wrote /entry/reflections/*/background_variance as
an array of zeros, presented as a measured quantity, and re-processing such a file fed the merge a
non-signal variance of zero.

Encode and decode it. The key is optional on both sides, so a stream from an older version still
reads and one from this version still reads on an older client.

The round-trip test only checked h, k, l, the predicted position and d - which is why a missing float
was invisible. It now gives every field a distinct value and checks all of them, so the next field
added to Reflection and forgotten here fails immediately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-10 05:52:44 +02:00
co-authored by Claude Opus 5
parent 4869dbd984
commit a7c5d7a89b
4 changed files with 35 additions and 3 deletions
@@ -267,6 +267,7 @@ inline void CBOR_ENC(CborEncoder &encoder, const Reflection& r) {
CBOR_ENC(mapEncoder, "d", r.d);
CBOR_ENC(mapEncoder, "I", r.I);
CBOR_ENC(mapEncoder, "bkg", r.bkg);
CBOR_ENC(mapEncoder, "var_bkg", r.var_bkg);
CBOR_ENC(mapEncoder, "sigma", r.sigma);
CBOR_ENC(mapEncoder, "image", r.image_number);
CBOR_ENC(mapEncoder, "rp", r.dist_ewald);