pueoAnalysisTools
Loading...
Searching...
No Matches
LoadManyEvents.py
1import ROOT
2import re
3import numpy as np
4import polars as pl
5from pathlib import Path
6from initialise import load_pueoEvent_Dataset
7import calibration
8from calibration import generate_antenna_phase_center_pairs_with_placeholders, load_dataset_and_measure_time_delays
9from calibration import retrieve_relevant_antennas_from_all_pairs, compute_time_delay_residuals
10import os
11from scipy.optimize import minimize
12import matplotlib.pyplot as plt
13import matplotlib
14matplotlib.use("Agg")
15
16if __name__ == "__main__":
17 import os
18 from scipy.optimize import minimize
19 import matplotlib.pyplot as plt
20 import matplotlib
21 matplotlib.use("Agg")
22 ant_type='LF'
23 MC=False
24 run = 800
25
26 # load event list
27 #eventlist_data = np.loadtxt("LFRun797.txt", delimiter=',')
28 #event_list = eventlist_data[:,1].astype(int).tolist()
29 data = np.genfromtxt(
30 "gndcal_pass3_corrected.csv",
31 delimiter=",",
32 names=True, # use header
33 dtype=None, # auto-detect types
34 encoding="utf-8"
35 )
36
37 mask = (
38 (data["run"] == run) &
39 (data["source"] == "TD") &
40 (data["pol"] == "H")
41 )
42 # in this list H and V are flipped.
43 event_list = data["event_number"][mask].tolist()
44
45 print("event_list=", event_list)
46 CHUNK_SIZE = 50
47
48 # which chunk am I?
49 task_id = int(os.environ.get("SLURM_ARRAY_TASK_ID", 0))
50
51 start_idx = task_id * CHUNK_SIZE
52 end_idx = start_idx + CHUNK_SIZE
53
54 chunk = event_list[start_idx:end_idx]
55
56 if len(chunk) == 0:
57 print(f"No events for task {task_id}")
58 exit()
59
60 start = chunk[0]
61 end = chunk[-1]
62
63 print(f"Processing events {start} -> {end}")
64
65 event_list=chunk
66
67
68
69 if ant_type=='MI':
70 j26: Path = os.environ.get("PUEO_UTIL_INSTALL_DIR") / Path("share/pueo/geometry/jan26/qrh.dat")
71 offset_inSIM: Path = os.environ.get("PUEO_UTIL_INSTALL_DIR") / Path("share/pueo/geometry/jun25/phase_center_offset_MI.dat")
72 elif ant_type=='LF':
73 j26: Path = os.environ.get("PUEO_UTIL_INSTALL_DIR") / Path("share/pueo/geometry/jan26/lf.dat")
74 offset_inSIM: Path = os.environ.get("PUEO_UTIL_INSTALL_DIR") / Path("share/pueo/geometry/jan26/phase_center_offset_LF.dat")
75 else:
76 print("Ant type doesn't exist!")
77
78 nominal_pairs = generate_antenna_phase_center_pairs_with_placeholders(qrh_dot_dat=j26, offset_inSIM=offset_inSIM, ant_type=ant_type)
79 ds: ROOT.pueo.Dataset = load_pueoEvent_Dataset(run_number = run, MC=MC)
80
81 pulser_directions_and_pairwise_time_delays = (
82 load_dataset_and_measure_time_delays(dataset=ds, phase_center_pairs=nominal_pairs, MC=MC, AntType=ant_type, singlerun=run, event_list=event_list, UPSAMPLE=10)
83 )
84
85
86 pulser_directions_and_pairwise_time_delays.write_ipc(f"feather_data/pulser_directions_and_pairwise_time_delays_run{run}_{start}_{end}.feather")
87
88