Files
aimsight-optimizer/sessions/LENZSPITZE_2026-10-23T2355_2026-11-01T1140_20261118T1049Z/tools/drop_steady.py
T

22 lines
1.3 KiB
Python
Raw Normal View History

"""Removes the Kendall-tau (STEADY) condition of the slow drift from a displacement.py and its thresholds.md line. Args: <detectors folder>"""
import sys
from pathlib import Path
root = Path(sys.argv[1])
p = root / "scripts" / "displacement.py"
s = p.read_text()
for old, new in [
("at least SIZE median daily amplitudes, |Kendall tau| ≥ STEADY, and\n# no step", "at least SIZE median daily amplitudes, and no\n# step"),
("amplitudes, with\n# the same tau and step conditions;", "amplitudes, with\n# the same step condition;"),
("STEADY = 0.6 # D-055\n", ""),
(" tau = sum((lv[j] > lv[i]) - (lv[j] < lv[i]) for i, j in pairs) / len(pairs)\n", ""),
("SIZE * ampl and abs(tau) >= STEADY and step", "SIZE * ampl and step"),
(" signs = step = 0\n", " step = 0\n"),
(" signs += sum((lv[j] > lv[k]) - (lv[j] < lv[k]) for k in range(i, j)) # Kendall tau, step by step\n", ""),
("step <= abs(d) / 2 \\\n and signs * (1 if d > 0 else -1) >= STEADY * n * (n - 1) / 2:", "step <= abs(d) / 2:"),
]:
assert s.count(old) == 1, old
s = s.replace(old, new)
p.write_text(s)
t = root / "thresholds.md"
lines = [x for x in t.read_text().splitlines(keepends=True) if not x.startswith("| | `STEADY` |")]
t.write_text("".join(lines))