Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev_fix_dc2' into grandio_light
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyjim committed Jan 16, 2025
2 parents a681089 + da91463 commit 4488a0c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
13 changes: 13 additions & 0 deletions grand/basis/du_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from scipy.spatial import Delaunay



logger = getLogger(__name__)


Expand Down Expand Up @@ -44,6 +45,8 @@ def __init__(self, name="NotDefined"):
self.du_pos = np.zeros((nb_du, 3))
self.idx2idt = np.arange(nb_du)
self.area_km2 = -1
self.xmax_pos = None
self.core_pos = None

def init_pos_id(self, du_pos, du_id=None):
"""Init object with array DU position and identifier
Expand Down Expand Up @@ -210,6 +213,16 @@ def on_click(event):
cmap=my_cmaps,
)
fig.colorbar(scm, label=unit)
if self.core_pos is not None:
plt.plot(self.core_pos[0], self.core_pos[1], marker="*", color="green", markersize=20)
if self.xmax_pos is not None:
delta = self.xmax_pos[:2] - self.core_pos[:2]
delta /= np.linalg.norm(delta)
delta *= 1000
plt.arrow(
self.core_pos[0], self.core_pos[1], delta[0], delta[1], color="green", width=50
)

xlabel = "North [m] (azimuth=0°) =>"
if traces is not None:
xlabel += f"\n{traces.info_shower}"
Expand Down
23 changes: 14 additions & 9 deletions grand/dataio/root_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ def get_obj_handling3dtraces(self):
l_idx = [self.idt2idx[idt] for idt in self.du_id]
o_tevent.init_network(self.du_xyz[l_idx])
o_tevent.network.name = self.tt_run.site
d_sim = self.get_simu_parameters()
o_tevent.network.xmax_pos = d_sim["FIX_xmax_pos"]
o_tevent.network.core_pos = d_sim["shower_core_pos"]
shw = self.tt_shower
xmax = shw.xmax_pos_shc
xmax = o_tevent.network.xmax_pos
dist_xmax = np.linalg.norm(xmax) / 1000
o_tevent.info_shower = f"||xmax_pos_shc||={dist_xmax:.1f} km;"
azi, zenith = shw.azimuth, shw.zenith
Expand All @@ -209,22 +212,24 @@ def get_simu_parameters(self):
:return: dictionary with some raw value of simulation parameters
"""
d_simu = {}
# raw
xmax_temp = self.tt_shower.xmax_pos_shc
d_simu["xmax_pos_shc"] = xmax_temp
# raw parameters
d_simu["azimuth"] = self.tt_shower.azimuth
d_simu["zenith"] = self.tt_shower.zenith
d_simu["energy_primary"] = self.tt_shower.energy_primary
d_simu["shower_core_pos"] = self.tt_shower.shower_core_pos
d_simu["magnetic_field"] = self.tt_shower.magnetic_field
origin_geoid = self.tt_run.origin_geoid
d_simu["origin_geoid"] = origin_geoid
# DC2 bug xmax_pos isn't filled
xmax_temp = self.tt_shower.xmax_pos_shc
d_simu["xmax_pos_shc"] = xmax_temp
d_simu["xmax_pos"] = self.tt_shower.xmax_pos
#logger.warn("DC2 FIX to define 'xmax_pos' in DU Frame")
d_simu["FIX_xmax_pos"] = (
xmax_temp + d_simu["shower_core_pos"] - np.array([0, 0, origin_geoid[2]])
)
# FIX parameters
logger.warn("DC2 FIX to define 'xmax_pos' in DU Frame")
# DC2 FIX: Xmax don't the right value
# https://github.com/grand-mother/collab-issues/issues/34
d_simu["FIX_xmax_pos_grandlib"] = xmax_temp + d_simu["shower_core_pos"]
# DC2 FIX: correct value of Xmax
d_simu["FIX_xmax_pos"] = d_simu["FIX_xmax_pos_grandlib"] - np.array([0, 0, origin_geoid[2]])
return d_simu


Expand Down

0 comments on commit 4488a0c

Please sign in to comment.