CaltechExperimentalGravity / CaltechExperimentalGravity/system_ident
resample_poly destroys the drive's periodicity (53% on the last period) — live in RTSfreerunBackend
- Dominant language
- Python
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
**Stage B5 (spec §3.5).** Present in shipped code today, not just a hazard for the new backend.
[`src/system_ident/backends/rtsfreerun_adapter.py:153`](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/src/system_ident/backends/rtsfreerun_adapter.py#L153) resamples the drive with
`scipy.signal.resample_poly`, and `read()` then tiles the resampled array via `_fit_periodic` /
`np.resize` ([`src/system_ident/backends/rtsfreerun_adapter.py:296`](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/src/system_ident/backends/rtsfreerun_adapter.py#L296)). `resample_poly`'s FIR sees the
**zero-padded array ends**, so the edge periods are corrupted — and tiling makes the corrupt period
recur forever.
Measured on an 8-period tiled multisine, per-period max deviation from the interior period:
```
6.90e-02 0 0 0 0 0 0 5.32e-01
```
The last period is off by **53%**, the first by 6.9%. Resampling *one* period and then tiling is worse
still: a **5.33e-01 seam discontinuity**.
Alternatives, measured against the `resample_poly` interior:
| approach | deviation |
|---|---|
| `scipy.signal.resample` (FFT, exactly periodic) on **one period**, then tile | 8.6e-4 |
| **regenerate the multisine at the target rate** | exactly 0 |
Regeneration is exact and puts the line frequencies on exact bins of both grids.
This is exercised by shipped config: [`src/system_ident/configs/rtsfreerun_hsts.yml`](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/src/system_ident/configs/rtsfreerun_hsts.yml) runs fs 256
against a 16384 Hz model (q = 64). Measured signature there: median `H_err/|H|` rises from 1.0e-9 to
1.8e-4 — so unlike the coherence-blindness issue it *does* self-flag, but it is still wrong.
### Fix
Regenerate at the target rate where the design PSD is available; otherwise `sig.resample` on one period
then tile. **Never `resample_poly`, never resample the tiled array.** Assert the input length is an exact
multiple of the period. Apply at both this site and the new `CDSBackend.inject()`.
### Acceptance
Per-period deviation 5.32e-1 → <1e-9 at the shipped 256/16384 ratio, verified on `MockRTSModel`.
---
**Campaign:** CDS hardware backend · branch [`feat/cds-hardware-backend`](https://github.com/CaltechExperimentalGravity/system_ident/tree/feat/cds-hardware-backend)
· [spec](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/docs/superpowers/specs/2026-08-03-cds-hardware-backend-design.md) · [plan](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/docs/superpowers/plans/2026-08-03-cds-hardware-backend.md) · [handoff](https://github.com/CaltechExperimentalGravity/system_ident/blob/feat/cds-hardware-backend/notes/cds-hardware-bringup-2026-08.md)
*Code is deferred until the plan and issues have been reviewed.*
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/system_ident/backends/rtsfreerun_adapter.py at the resampling site around line 153 and read() around line 296, including _fit_periodic and np.resize. Trace how the shipped 256/16384 configuration reaches MockRTSModel and how the new CDSBackend.inject() should share the behavior. Done means the shipped ratio has per-period deviation below 1e-9 without resampling tiled data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100