Skip to content

Commit 1a0c3f2

Browse files
committed
fixed empty gulp nbeams_queue issue and arm detection matching
1 parent 5580c70 commit 1a0c3f2

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

T2/audit.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,13 @@ def _match_rows_for_injection(
229229
ddm = np.full(n, np.inf)
230230

231231
if "ibeam" in tab.colnames:
232-
dbeam0 = np.abs(tab["ibeam"] - inj_beam)
233-
dbeam1 = np.abs(tab["ibeam"] - (inj_beam + 256))
234-
dbeam_min = np.minimum(dbeam0, dbeam1)
235-
which_arm = np.where(dbeam0 <= dbeam1, 0, 1)
232+
base_local = int(inj_beam) % 256 # normalize to 0..255
233+
ew_global = base_local # 0..255
234+
ns_global = base_local + 256 # 256..511
235+
dbeam_ew = np.abs(tab["ibeam"] - ew_global)
236+
dbeam_ns = np.abs(tab["ibeam"] - ns_global)
237+
dbeam_min = np.minimum(dbeam_ew, dbeam_ns)
238+
which_arm = np.where(dbeam_ew <= dbeam_ns, 0, 1) # 0=EW match, 1=NS match
236239
else:
237240
dbeam_min = np.full(n, np.inf)
238241
which_arm = np.zeros(n, dtype=int)
@@ -263,11 +266,9 @@ def _match_rows_for_injection(
263266
best_idx = int(cand_ix[order[0]])
264267

265268
# report arm-corrected beam distance
266-
arm = which_arm[best_idx]
267-
if arm == 0:
268-
dbeam_report = int(np.abs(tab["ibeam"][best_idx] - inj_beam))
269-
else:
270-
dbeam_report = int(np.abs(tab["ibeam"][best_idx] - (inj_beam + 256)))
269+
arm = int(which_arm[best_idx]) # 0=EW, 1=NS
270+
matched_global = ew_global if arm == 0 else ns_global
271+
dbeam_report = int(abs(int(tab["ibeam"][best_idx]) - matched_global))
271272

272273
out = dict(
273274
t1_best_snr=float(tab["snr"][best_idx]) if "snr" in tab.colnames else "",

T2/socket.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,7 @@ def parse_socket(
160160
beam_window=beam_window,
161161
persist_json=bool(audit_dump_json),
162162
)
163-
# try:
164-
# auditor.ingest_legacy_injections(INJECTION_FILE)
165-
# except Exception as e:
166-
# logger.warning(f"AUDIT init: legacy ingestion/mirror failed: {e}")
167-
163+
168164
auditor.attach_injection_source(INJECTION_FILE)
169165
added0 = auditor.refresh_from_source(force=True)
170166
if added0:
@@ -309,6 +305,8 @@ def parse_socket(
309305
if candsfile == "\n" or candsfile == "": # skip empty candsfile
310306
print(f"candsfile is empty. Skipping.")
311307
logger.info(f"candsfile is empty. Skipping.")
308+
# Advance the rolling window for this gulp
309+
nbeams_queue.append(0)
312310
if audit_enabled and auditor is not None:
313311
auditor.update_from_tab(
314312
host=host,

scripts/new_injection_script.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# ================== user knobs ==================
99
# tune only these two to change the population
10-
USER_SNR_MIN = 8.0
10+
USER_SNR_MIN = 10.0
1111
USER_SNR_MAX = 25.0
1212
# =================================================
1313

@@ -42,7 +42,7 @@
4242
_DERIVED_SCALE_MIN = USER_SNR_MIN / K_DEFAULT
4343
_DERIVED_SCALE_MAX = USER_SNR_MAX / K_DEFAULT
4444

45-
# global safety rails if hardware says so
45+
# global safety rails for scale
4646
GLOBAL_SCALE_MIN = 0.01
4747
GLOBAL_SCALE_MAX = 0.5
4848

0 commit comments

Comments
 (0)