Skip to content

Commit

Permalink
new file added
Browse files Browse the repository at this point in the history
  • Loading branch information
snonis committed Feb 17, 2024
1 parent bd7c2a1 commit 1381ae3
Show file tree
Hide file tree
Showing 41 changed files with 2,464 additions and 1,521 deletions.
536 changes: 0 additions & 536 deletions calculate_RFchain.ipynb

This file was deleted.

34 changes: 17 additions & 17 deletions examples/sim/antenna.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/sim/galactic_noise.ipynb

Large diffs are not rendered by default.

Binary file removed freq_mhz.npy
Binary file not shown.
Binary file added grand/sim/detector/TotalRFchainAbssparam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grand/sim/detector/TotalRFchainPhasesparam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions grand/sim/detector/antenna_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ def __init__(self, du_type="GP300"):
elif du_type=="GP300_nec":
logger.info(f"Loading GP300 antenna model ...")

path_ant = grand_add_path_data("detector/Light_GP300Antenna_Nec_EWarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_nec_Yarm_leff.npz")
self.leff_ew = tabulated_antenna_model(path_ant)
path_ant = grand_add_path_data("detector/Light_GP300Antenna_Nec_NSarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_nec_Xarm_leff.npz")
self.leff_sn = tabulated_antenna_model(path_ant)
path_ant = grand_add_path_data("detector/Light_GP300Antenna_Nec_Zarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_nec_Zarm_leff.npz")
self.leff_z = tabulated_antenna_model(path_ant)

elif du_type=="GP300_mat":
logger.info(f"Loading GP300 antenna model ...")

path_ant = grand_add_path_data("detector/Light_GP300Antenna_Mat_EWarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_mat_Yarm_leff.npz")
self.leff_ew = tabulated_antenna_model(path_ant)
path_ant = grand_add_path_data("detector/Light_GP300Antenna_Mat_NSarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_mat_Xarm_leff.npz")
self.leff_sn = tabulated_antenna_model(path_ant)
path_ant = grand_add_path_data("detector/Light_GP300Antenna_Mat_Zarm_leff.npz")
path_ant = grand_add_path_data("detector/Light_GP300Antenna_mat_Zarm_leff.npz")
self.leff_z = tabulated_antenna_model(path_ant)

elif du_type=='Horizon':
Expand Down
1,012 changes: 1,012 additions & 0 deletions grand/sim/detector/rf_chain2.py

Large diffs are not rendered by default.

52 changes: 42 additions & 10 deletions grand/sim/efield2voltage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

from .detector.antenna_model import AntennaModel
from .detector.process_ant import AntennaProcessing
from .detector.rf_chain import RFChain
#from .detector.rf_chain import RFChain
from .detector.rf_chain2 import RFChain
from .detector.rf_chain2 import RFChainNut
from .shower.gen_shower import ShowerEvent
from .noise.galaxy import galactic_noise

Expand Down Expand Up @@ -47,7 +49,8 @@ class Efield2Voltage:
* Save output in ROOT format
"""

def __init__(self, f_input, f_output="", seed=None, padding_factor=1.0):
def __init__(self, f_input, f_output="", seed=None, padding_factor=1.0, du_type='GP300'):
# du_type='GP300' (using hfss simulations), 'GP300_nec' (using nec simulations), 'GP300_mat' (using matlab simulations), 'Horizon'
self.f_input = f_input
self.f_output = f_output
self.seed = seed # used to generate same set of random numbers. (gal noise)
Expand All @@ -56,9 +59,11 @@ def __init__(self, f_input, f_output="", seed=None, padding_factor=1.0):
self.run = groot.TRun(f_input) # site_long, site_lat info is stored here. Used to define shower frame.
self.shower = groot.TShower(f_input) # shower info (like energy, theta, phi, xmax etc) are stored here.
self.events_list = self.events.get_list_of_events() # [[evt0, run0], [evt1, run0], ...[evt0, runN], ...]
self.rf_chain = RFChain() # loads RF chain. # RK: TODO: load this only if we want to add RF Chain.
self.ant_model = AntennaModel() # loads antenna models. time consuming. du_type='GP300' (default), 'Horizon'
self.params = {"add_noise": True, "lst": 18.0, "add_rf_chain":True}
#self.rf_chain = RFChain() # loads RF chain. # RK: TODO: load this only if we want to add RF Chain.
self.rf_chain2 = RFChain()
self.rf_chain2nut = RFChainNut()
self.ant_model = AntennaModel(du_type) # loads antenna models. time consuming. du_type='GP300' (default using hfss simulations), 'GP300_nec', 'GP300_mat', 'Horizon'
self.params = {"add_noise": True, "lst": 18.0, "add_rf_chain":True, "add_rf_chain_nut":False}
self.previous_run = -1 # Not to load run info everytime event info is loaded.

def get_event(self, event_idx=None, event_number=None, run_number=None):
Expand Down Expand Up @@ -146,8 +151,13 @@ def get_event(self, event_idx=None, event_number=None, run_number=None):
)
# compute total transfer function of RF chain. Can be computed only once in __init__ if length of time traces does not change between events.
if self.params["add_rf_chain"]:
self.rf_chain.compute_for_freqs(self.freqs_mhz)

#self.rf_chain.compute_for_freqs(self.freqs_mhz)
self.rf_chain2.compute_for_freqs(self.freqs_mhz)

if self.params["add_rf_chain_nut"]:
# #self.rf_chain.compute_for_freqs(self.freqs_mhz)
self.rf_chain2nut.compute_for_freqs(self.freqs_mhz)

def get_leff(self, du_idx):
"""
Define for each antenna in DU du_idx an object AntennaProcessing according its position
Expand Down Expand Up @@ -331,14 +341,24 @@ def compute_voltage_du(self, du_idx):

# ----- Add RF chain -----
if self.params["add_rf_chain"]:
self.vout_f[du_idx] *= self.rf_chain.get_tf()
#self.vout_f[du_idx] *= self.rf_chain.get_tf()
self.vout_f[du_idx] *= self.rf_chain2.get_tf()

if self.params["add_rf_chain_nut"]:
#self.vout_f[du_idx] *= self.rf_chain.get_tf()
self.vout_f[du_idx] *= self.rf_chain2nut.get_tf()

# Final voltage output for antenna with index du_idx
if self.params["add_noise"] or self.params["add_rf_chain"]:
# inverse FFT and remove zero-padding
# WARNING: do not used sf.irfft(fft_vlna, self.sig_size) to remove padding
self.vout[du_idx] = sf.irfft(self.vout_f[du_idx])[:, : self.sig_size]


if self.params["add_noise"] or self.params["add_rf_chain_nut"]:
# inverse FFT and remove zero-padding
# WARNING: do not used sf.irfft(fft_vlna, self.sig_size) to remove padding
self.vout[du_idx] = sf.irfft(self.vout_f[du_idx])[:, : self.sig_size]

# compute voltage in all antennas of one event.
def compute_voltage_event(self, event_idx=None, event_number=None, run_number=None):
"""
Expand Down Expand Up @@ -366,7 +386,13 @@ def compute_voltage_event(self, event_idx=None, event_number=None, run_number=No

# ----- Add RF chain -----
if self.params["add_rf_chain"]:
self.multiply(self.rf_chain.get_tf())
#self.multiply(self.rf_chain.get_tf())
self.multiply(self.rf_chain2.get_tf())

if self.params["add_rf_chain_nut"]:
#self.multiply(self.rf_chain.get_tf())
self.multiply(self.rf_chain2nut.get_tf())


# Final voltage output for antenna with index du_idx
if self.params["add_noise"] or self.params["add_rf_chain"]:
Expand All @@ -375,6 +401,12 @@ def compute_voltage_event(self, event_idx=None, event_number=None, run_number=No
#self.vout = sf.irfft(self.vout_f)[..., :self.sig_size]
self.final_voltage() # inverse fourier transform. update self.vout.

if self.params["add_noise"] or self.params["add_rf_chain_nut"]:
# # inverse FFT and remove zero-padding
# # WARNING: do not used sf.irfft(fft_vlna, self.sig_size) to remove padding
# #self.vout = sf.irfft(self.vout_f)[..., :self.sig_size]
self.final_voltage() # inverse fourier transform. update self.vout.

# Primary method to compute voltage.
# Compute voltage in any one antennas of any one event. If None, voltage for all DUs of all events is computed.
def compute_voltage(self,
Expand Down
Loading

0 comments on commit 1381ae3

Please sign in to comment.