"""falltime_organ.py — true fall-time from the sampler surface (the variable the falsified prediction named). For each meditation reading stamped inside the gpu-history window: fall-time = cumulative LOW-UTIL minutes in the sampler rows between the previous full-ask (util >= 50 sample) and the reading's stamp. Classifies the reading by watts against the woken-idle band (sub-floor < 214W vs in-band >= 214W, P-BODY-2 floor surface) and prints the two distributions. Law baked in (pass-165/166): stamps parsed from file bytes; endpoints printed; unit named (low-util MINUTES = samples<10 / 60); timezone: dmon -o DT stamps LOCAL, mktime local; meditation stamps UTC, calendar.timegm. """ import time, calendar, re, glob, sys U = r"C:/Users/user/1f916-contribution" SUB_FLOOR_W = 214.0 # P-BODY-2 woken-idle floor surface def load(): rows = [] for l in open(U + r"\gpu-history.csv"): p = l.split() if len(p) < 14 or p[0].startswith("#"): continue try: ts = time.mktime(time.strptime(p[0] + " " + p[1], "%Y%m%d %H:%M:%S")) w = int(p[3]); sm = int(p[6]) except ValueError: continue rows.append((ts, w, sm)) rows.sort() return rows def readings(): out = [] for f in glob.glob(U + r"\meditations\MEDITATION-*.md"): num = int(re.search(r"MEDITATION-(\d+)", f).group(1)) txt = open(f, encoding="utf-8").read() mm = re.search(r"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})Z", txt) wm = re.search(r"(\d{2,3}\.\d+)W", txt) if not mm: continue t = calendar.timegm(time.strptime(mm.group(1), "%Y-%m-%dT%H:%M:%S")) watts = float(wm.group(1)) if wm else None out.append((num, t, watts)) out.sort(key=lambda x: x[1]) return out def run(): rows = load() if not rows: print("no sampler rows"); return t0, t1 = rows[0][0], rows[-1][0] print("sampler window:", time.strftime("%H:%M:%SZ", time.gmtime(t0)), "->", time.strftime("%H:%M:%SZ", time.gmtime(t1)), f"({round((t1-t0)/60,2)} min, {len(rows)} samples)") rs = [r for r in readings() if r[1] and t0 <= r[1] <= t1] print("readings inside window:", len(rs)) subs, inband = [], [] for num, t, watts in rs: # last full-ask before reading: last sample with util>=50 strictly before t ask = None for ts, w, sm in rows: if ts < t and sm >= 50: ask = ts seg_start = ask if ask is not None else t0 low = sum(1 for ts, w, sm in rows if seg_start <= ts < t and sm < 10) ft = round(low / 60, 2) label = "SUB" if watts is not None and watts < SUB_FLOOR_W else ("INBAND" if watts is not None else "?") line = f" #{num} watts={watts} fall-time={ft} min low-util-samples={low} [{label}]" print(line) if label == "SUB": subs.append(ft) elif label == "INBAND": inband.append(ft) print("SUB n=", len(subs), sorted(subs)) print("INBAND n=", len(inband), sorted(inband)) if __name__ == "__main__": run()