Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/73_dev_for_merge' into dev_io_root
Browse files Browse the repository at this point in the history
  • Loading branch information
lwpiotr committed Feb 14, 2024
2 parents 8b59a06 + 6fcf76e commit 561db7a
Show file tree
Hide file tree
Showing 204 changed files with 127,867 additions and 44,932 deletions.
5 changes: 5 additions & 0 deletions env/_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ echo "=============================="
export PYTHONPATH=$GRAND_ROOT:$PYTHONPATH
echo "add grand to PYTHONPATH"
echo "=============================="


export AIRESBINDIR=${HOME}/aires/bin
echo "add AIRESBINDIR"
echo "============================="
9 changes: 8 additions & 1 deletion grand/dataio/root_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def fill(self):
def write(self, *args, close_file=True, overwrite=False, force_close_file=False, **kwargs):
"""Write the tree to the file"""
# Add the tree friends to this tree
# self.add_proper_friends()
self.add_proper_friends()

# If string is ending with ".root" given as a first argument, create the TFile
# ToDo: Handle TFile if added as the argument
Expand Down Expand Up @@ -1181,6 +1181,8 @@ def add_proper_friends(self):
"""Add proper friends to this tree"""
# Create the indices
self.build_index("run_number", "event_number")
# For now, do not add friends
return 0

# Add the Run tree as a friend if exists already
loc_vars = dict(locals())
Expand Down Expand Up @@ -1397,6 +1399,11 @@ def get_list_of_all_used_dus(self):
else:
return None

def get_dus_indices_in_run(self, trun):
"""Gets an array of the indices of DUs of the current event in the TRun tree"""

return np.nonzero(np.isin(np.asarray(trun.du_id), np.asarray(self.du_id)))[0]


## A class wrapping around a TTree holding values common for the whole run
@dataclass
Expand Down
27 changes: 16 additions & 11 deletions grand/sim/detector/process_ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def init_interpolation(cls, freq_sampling_mhz, freq_out_mhz):
pre = PreComputeInterpol()
pre.init_linear_interpol(freq_sampling_mhz, freq_out_mhz)
cls.pre_cpt = pre
logger.debug(pre)
#logger.debug(pre)

def set_out_freq_mhz(self, a_freq):
"""
Expand Down Expand Up @@ -161,7 +161,7 @@ def effective_length(
direction_sphr = SphericalRepresentation(direction_cart)
theta_efield, phi_efield = direction_sphr.theta, direction_sphr.phi
logger.debug(f"type theta_efield: {type(theta_efield)} {theta_efield}")
logger.info(
logger.debug(
f"Source direction (degree): azimuth={float(phi_efield):.1f}, zenith={float(theta_efield):.1f}"
)
# logger.debug(f"{theta_efield.r}")
Expand Down Expand Up @@ -191,7 +191,7 @@ def effective_length(
# fft
# logger.info(efield.e_xyz.info())
e_xyz = efield.e_xyz
logger.debug(e_xyz.shape)
logger.debug(f"e_xyz.shape:{e_xyz.shape}")
# Leff ref frequency [Hz]
freq_ref_hz = self.model_leff.frequency
# frequency [Hz] with padding
Expand Down Expand Up @@ -269,25 +269,30 @@ def compute_voltage(
:type frame:
"""
# frame is shower frame. self.frame is antenna frame.
print("pos",self.pos)
logger.debug(f"pos {self.pos}")
if (not np.all(np.isfinite(self.pos))) or (not np.all(np.isfinite(frame))): # which one
raise MissingFrameError("missing antenna or shower frame")

# Compute the voltage. input fft_leff and field are in shower frame.
leff_f = self.effective_length(xmax, efield, frame)
logger.debug(leff_f.shape)
logger.debug(f"leff_f.shape {leff_f.shape}")
# E is CartesianRepresentation
fft_e = efield.get_fft(self.size_fft)
logger.debug(f"size_fft leff={leff_f.shape}")
logger.debug(f"size_fft efield={leff_f.shape}")
logger.debug(f"size_fft efield={fft_e.shape}")
# convol e_xyz field by Leff in Fourier space
self.voc_f = (
fft_e[0] * leff_f[0] + fft_e[1] * leff_f[1] + fft_e[2] * leff_f[2]
)
# inverse FFT and remove zero-padding
voc = sf.irfft(self.voc_f)[: efield.e_xyz.shape[1]]
# WARNING do not used : sf.irfft(self.fft_resp_volt, efield.e_xyz.shape[1])
t = efield.a_time
logger.debug(f"time : {t.dtype} {t.shape}")
#voc = sf.irfft(self.voc_f)[: efield.e_xyz.shape[1]]
voc = sf.irfft(self.voc_f) #we do not want to remove the zero padding any more.
# WARNING do not use : sf.irfft(self.fft_resp_volt, efield.e_xyz.shape[1])

dt= np.round(efield.get_delta_time_s(),decimals=15) #this is to remove floating point garbage that can eventually appear caused due to be working in seconds, very deep into the floar pecision. Should be good to femtoseconds
t=np.arange(0, len(voc)*dt, dt) + efield.a_time[0]


logger.debug(f"time : {t.dtype} {t.shape} {dt}")
logger.debug(f"volt : {voc.dtype} {voc.shape}")
return Voltage(t=t, V=voc)
return Voltage(t=t, V=voc)
Loading

0 comments on commit 561db7a

Please sign in to comment.