half_period_to_hz assumes 1024 sps: histogram frequencies 2x/4x low at 2048/4096 sps (latent) #50

Closed
opened 2026-10-26 19:07:44 -04:00 by serversdown · 1 comment
Owner

Summary

minimateplus.histogram_codec.half_period_to_hz (and _FREQ_NUMERATOR = 512) assumes a histogram sampled at 1,024 sps: freq = 512 / half-period. Frequency is really (sample rate / 2) / half-period. So the helper is 2x low at 2,048 sps and 4x low at 4,096 sps.

Measured (2026-10-26, BE9441)

  • K441LTOK.QZ0, whose export says "Sample Rate : 2048 sps": 66/66 frequencies match its export with 1024/hp. With 512/hp they're half.
  • K441LTON.900, "Sample Rate : 4096 sps": 3,398/3,398 intervals match with 2048/hp (decoded with the #47/#49 reader).
  • The archive's 13,089 histograms with exports: exact using each file's own rate / 2.

Impact today: none found (latent)

git grep on dev finds no production caller. Histogram frequencies shown by SFM, the sidecar and the PDF come from Blastware's paired report (zc_freq_hz), not from the half-periods. The helper is used by its own tests, and analysis_idf/idfh_decode.py and the micromate/idf_file.py docs also say 512/hp; those are worth checking for Thor's own rates.

Fix

Take the sample rate as a parameter, read from the file's setup or the decoded event, rather than a constant. It must be done before anything computes frequencies from half-periods, e.g. a histogram download with no paired report, which is what SFM's own MiniMate download produces.

## Summary `minimateplus.histogram_codec.half_period_to_hz` (and `_FREQ_NUMERATOR = 512`) assumes a histogram sampled at **1,024 sps**: freq = 512 / half-period. Frequency is really **(sample rate / 2) / half-period**. So the helper is 2x low at 2,048 sps and **4x low at 4,096 sps**. ## Measured (2026-10-26, BE9441) - `K441LTOK.QZ0`, whose export says "Sample Rate : 2048 sps": 66/66 frequencies match its export with 1024/hp. With 512/hp they're half. - `K441LTON.900`, "Sample Rate : 4096 sps": 3,398/3,398 intervals match with 2048/hp (decoded with the #47/#49 reader). - The archive's 13,089 histograms with exports: exact using each file's own rate / 2. ## Impact today: none found (latent) `git grep` on `dev` finds no production caller. Histogram frequencies shown by SFM, the sidecar and the PDF come from Blastware's paired report (`zc_freq_hz`), not from the half-periods. The helper is used by its own tests, and `analysis_idf/idfh_decode.py` and the `micromate/idf_file.py` docs also say 512/hp; those are worth checking for Thor's own rates. ## Fix Take the sample rate as a parameter, read from the file's setup or the decoded event, rather than a constant. It must be done before anything computes frequencies from half-periods, e.g. a histogram download with no paired report, which is what SFM's own MiniMate download produces.
serversdown added the Kind/Bug
Priority
Low
4
labels 2026-10-26 19:07:44 -04:00
Author
Owner

Fixed on dev (merge 31231d7, fix 2b698e7). Ships in the next release.

  • half_period_to_hz(halfp, sample_rate=1024) now computes (sample_rate / 2) / halfp. The fixed 512 was correct at 1024 sps only.
  • Measured against Blastware's _XML.XML reports on DL2: 527,915 / 527,915 frequency cells at 1024 sps and 1,725 / 1,725 at 2048 sps.
  • Blastware's words, measured on ~3.1 M cells:
    • N/A for a half-period of 0
    • >100 (>200 at 2048) at 5 samples or fewer
    • <1.0 below 1 Hz
  • Decode checker: all four channels' per-interval frequencies now match every DL2 histogram, with 0 regressions.
  • SFM now also stores each interval's half-periods in the .h5 (/intervals/half_period/<ch>), so frequencies can be recomputed at any sample rate.

Protocol reference: Appendix D.6.9.

**Fixed on `dev`** (merge `31231d7`, fix `2b698e7`). Ships in the next release. - `half_period_to_hz(halfp, sample_rate=1024)` now computes `(sample_rate / 2) / halfp`. The fixed 512 was correct at 1024 sps only. - **Measured against Blastware's `_XML.XML` reports on DL2:** 527,915 / 527,915 frequency cells at 1024 sps and 1,725 / 1,725 at 2048 sps. - **Blastware's words, measured on ~3.1 M cells:** - `N/A` for a half-period of 0 - `>100` (`>200` at 2048) at 5 samples or fewer - `<1.0` below 1 Hz - **Decode checker:** all four channels' per-interval frequencies now match every DL2 histogram, with 0 regressions. - SFM now also stores each interval's half-periods in the `.h5` (`/intervals/half_period/<ch>`), so frequencies can be recomputed at any sample rate. Protocol reference: Appendix D.6.9.
Sign in to join this conversation.