# Coordinator's second look, own code: is the 0.2676-d signal on the nova before the outburst? Aperture with a plain annulus median sky; 1-day running-median high-pass; amplitude against nearby control frequencies. import sys, math, os import numpy as np src = open(sys.argv[1], encoding="utf-8").read().split("path = sys.argv[1]")[0] ns = {}; exec(compile(src, "nova_spot_funcs", "exec"), ns) load, aperture = ns["load"], ns["aperture"] OFF = (19.48, 40.03) for sec in sys.argv[3:]: h1, h2, col = load(os.path.join(sys.argv[2], f"cut-s{sec}.zip")) t, q, F = col["TIME"], col["QUALITY"], col["FLUX"] g = (q == 0) & np.isfinite(t) & np.isfinite(F).all(axis=(1, 2)); t, F = t[g], F[g] cd = np.array([[h2.get("CD1_1", 0), h2.get("CD1_2", 0)], [h2.get("CD2_1", 0), h2.get("CD2_2", 0)]]) if not cd.any(): cd = np.array([[h2.get("PC1_1", 1)*h2.get("CDELT1", 0), h2.get("PC1_2", 0)*h2.get("CDELT1", 0)], [h2.get("PC2_1", 0)*h2.get("CDELT2", 0), h2.get("PC2_2", 1)*h2.get("CDELT2", 0)]]) if not cd.any(): nx, ny = (F.shape[2]-1)/2, (F.shape[1]-1)/2 inv = np.linalg.pinv(cd) ra0, de0 = h2["RA_OBJ"], h2["DEC_OBJ"] if cd.any(): dp = inv @ np.array([(ra0-h2["CRVAL1"])*math.cos(math.radians(de0)), de0-h2["CRVAL2"]]) nx, ny = h2["CRPIX1"]-1+dp[0], h2["CRPIX2"]-1+dp[1] print("sector", sec, "nova pixel", round(float(nx), 2), round(float(ny), 2), "wcs keys", [k for k in ("CD1_1","PC1_1","CDELT1","1CRV4P","WCSAXES") if k in h2]) for r in (1.0, 1.5): lc = aperture(F, nx, ny, r) # 1-day running median high-pass, fast version on a coarse step y = lc.copy(); step = max(1, len(t)//4000) idx = np.searchsorted(t, t-0.5), np.searchsorted(t, t+0.5) med = np.array([np.median(lc[a:b]) for a, b in zip(*idx)]) y = lc - med s = np.std(y); keep = np.abs(y) < 6*s; tt, yy = t[keep], y[keep]-y[keep].mean() def amp(f): c, sn = np.cos(2*np.pi*f*tt), np.sin(2*np.pi*f*tt) A = np.vstack([c, sn]).T; co, *_ = np.linalg.lstsq(A, yy, rcond=None) return float(np.hypot(*co)) f0 = 1/0.26760 a0 = amp(f0) ctrl = np.array([amp(f0+df) for df in np.arange(-1.5, 1.5, 0.05) if abs(df) > 0.3]) print(f"sector {sec} r={r}: frames {len(tt)} A(0.26760 d)={a0:.3f} e/s | controls median {np.median(ctrl):.3f} max {ctrl.max():.3f} | rank above {int((ctrl < a0).sum())} of {len(ctrl)}")