mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 01:53:31 +01:00
ZH: restructure reconstruction script
This commit is contained in:
parent
8fa0f268db
commit
0405ddb1c7
1 changed files with 47 additions and 40 deletions
|
@ -24,6 +24,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
####
|
####
|
||||||
fname_dir = path.dirname(fname)
|
fname_dir = path.dirname(fname)
|
||||||
|
max_clock_offset = None
|
||||||
if True: # use the original files
|
if True: # use the original files
|
||||||
ev = REvent(fname)
|
ev = REvent(fname)
|
||||||
|
|
||||||
|
@ -33,47 +34,61 @@ if __name__ == "__main__":
|
||||||
rng = np.random.default_rng(seed)
|
rng = np.random.default_rng(seed)
|
||||||
|
|
||||||
dirname += f'rand{max_clock_offset}ns'
|
dirname += f'rand{max_clock_offset}ns'
|
||||||
|
else:
|
||||||
|
raise NotImplementedError
|
||||||
|
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||||
|
|
||||||
# Full reconstruction?
|
if not path.isfile(antennas_fname):
|
||||||
if False:
|
print("Antenna file cannot be found, did you try generating a beacon?")
|
||||||
print("Full reconstruction")
|
sys.exit(1)
|
||||||
|
|
||||||
if max_clock_offset:
|
# Full reconstruction?
|
||||||
print(f"Randomising timing: {max_clock_offset}")
|
if False:
|
||||||
clock_offsets = max_clock_offset * (2*rng.uniform(size=len(ev.antennas)) - 1)
|
print("Full reconstruction")
|
||||||
for i, ant in enumerate(ev.antennas):
|
|
||||||
ant.t -= clock_offsets[i]
|
|
||||||
else:
|
|
||||||
print(f"Not randomising timing")
|
|
||||||
|
|
||||||
with open(dirname + '/res.pkl', 'wb') as fp:
|
if max_clock_offset:
|
||||||
res = rit.reconstruction(ev, outfile=dirname+'/fig.pdf', slice_outdir=dirname+'/', Xlow=100, N_X=15, Xhigh=800)
|
print(f"Randomising timing: {max_clock_offset}")
|
||||||
|
clock_offsets = max_clock_offset * (2*rng.uniform(size=len(ev.antennas)) - 1)
|
||||||
|
for i, ant in enumerate(ev.antennas):
|
||||||
|
ev.antennas[i].t += clock_offsets[i]
|
||||||
|
else:
|
||||||
|
print(f"Not randomising timing")
|
||||||
|
|
||||||
pickle.dump(res, fp)
|
with open(dirname + '/res.pkl', 'wb') as fp:
|
||||||
sys.exit(0)
|
res = rit.reconstruction(ev, outfile=dirname+'/fig.pdf', slice_outdir=dirname+'/', Xlow=100, N_X=23, Xhigh=1200)
|
||||||
|
|
||||||
# Else do single slice for original timing
|
|
||||||
# and randomised timing
|
|
||||||
print("Shower plane reconstruction + randomised timing")
|
|
||||||
|
|
||||||
atm = AtmoCal()
|
pickle.dump(res, fp)
|
||||||
X = 750
|
sys.exit(0)
|
||||||
rit.set_pol_and_bp(ev)
|
|
||||||
dXref = atm.distance_to_slant_depth(np.deg2rad(ev.zenith),X,0)
|
|
||||||
scale2d = dXref*np.tan(np.deg2rad(2.))
|
|
||||||
|
|
||||||
ants_copy = deepcopy(ev.antennas)
|
# Only a single slice
|
||||||
clock_offsets = max_clock_offset * (2*rng.uniform(size=len(ants_copy)) - 1)
|
else:
|
||||||
for i, ant in enumerate(ants_copy):
|
print("Shower plane reconstruction")
|
||||||
ant.t -= clock_offsets[i]
|
|
||||||
|
|
||||||
fig, axs = plt.subplots(1,2, sharex=True, sharey=True)
|
# atm = AtmoCal()
|
||||||
|
# X = 750
|
||||||
|
# rit.set_pol_and_bp(ev)
|
||||||
|
# dXref = atm.distance_to_slant_depth(np.deg2rad(ev.zenith),750,0)
|
||||||
|
# scale2d = dXref*np.tan(np.deg2rad(2.))
|
||||||
|
|
||||||
|
if max_clock_offset is None:
|
||||||
|
print(" + randomised timing")
|
||||||
|
|
||||||
|
ants_copy = deepcopy(ev.antennas)
|
||||||
|
clock_offsets = max_clock_offset * (2*rng.uniform(size=len(ants_copy)) - 1)
|
||||||
|
for i, ant in enumerate(ants_copy):
|
||||||
|
ant.t -= clock_offsets[i]
|
||||||
|
|
||||||
|
fig, axs = plt.subplots(1,1+(max_clock_offset is not None), sharex=True, sharey=True)
|
||||||
fig.suptitle(f"Reconstructed Shower plane slice at X={X}")
|
fig.suptitle(f"Reconstructed Shower plane slice at X={X}")
|
||||||
|
if max_clock_offset is None:
|
||||||
|
axs = [ax]
|
||||||
for ax in axs:
|
for ax in axs:
|
||||||
ax.set_xlabel("-v x B (m)")
|
ax.set_xlabel("-v x B (m)")
|
||||||
ax.set_ylabel(" vxvxB (m)")
|
ax.set_ylabel(" vxvxB (m)")
|
||||||
axs[0].set_title("Simulated timing")
|
|
||||||
axs[1].set_title(f"Randomised timing [0, {max_clock_offset}]")
|
if max_clock_offset is not None:
|
||||||
|
axs[0].set_title("Simulated timing")
|
||||||
|
axs[1].set_title(f"Randomised timing [0, {max_clock_offset}]")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i, ax in enumerate(axs):
|
for i, ax in enumerate(axs):
|
||||||
|
@ -97,19 +112,11 @@ if __name__ == "__main__":
|
||||||
fig.colorbar(sc, ax=axs[0])
|
fig.colorbar(sc, ax=axs[0])
|
||||||
# Always make sure to show the plot
|
# Always make sure to show the plot
|
||||||
except:
|
except:
|
||||||
|
if True:
|
||||||
|
fig.savefig(dirname + f"/shower_plane_slice_X{X}_T{max_clock_offset}_exception.pdf")
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
fig.savefig(dirname + f"/shower_plane_slice_X{X}_T{max_clock_offset}.pdf")
|
fig.savefig(dirname + f"/shower_plane_slice_X{X}_T{max_clock_offset}.pdf")
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
raise NotImplementedError
|
|
||||||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
|
||||||
|
|
||||||
if not path.isfile(antennas_fname):
|
|
||||||
print("Antenna file cannot be found, did you try generating a beacon?")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
Loading…
Reference in a new issue