Skip to content

Commit

Permalink
Merge branch 'feature/trigger_devel' of github.com:nu-radio/NuRadioMC…
Browse files Browse the repository at this point in the history
… into feature/trigger_devel
  • Loading branch information
Alan Coleman committed Sep 18, 2023
2 parents d2cb3a6 + dee70b0 commit eb9a237
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 127 deletions.
2 changes: 1 addition & 1 deletion NuRadioMC/utilities/Veff.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def get_Veff_Aeff_array(data):
* array of unique trigger names
Examples
---------
--------
To plot the full sky effective volume for 'all_triggers' do
Expand Down
1 change: 0 additions & 1 deletion NuRadioReco/detector/ARA/ara_detector_db.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
{
"_default": {},
"channels": {
Expand Down
32 changes: 14 additions & 18 deletions NuRadioReco/detector/RNO_G/RNO_single_station.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
"ant_rotation_phi": 90.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"cab_time_delay": 19.8,
"reference_channel": 0,
"channel_id": 12,
"station_id": 11
Expand All @@ -211,7 +210,6 @@
"ant_rotation_phi": 90.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"cab_time_delay": 19.8,
"reference_channel": 0,
"channel_id": 13,
"station_id": 11
Expand All @@ -228,23 +226,21 @@
"ant_rotation_phi": 90.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"cab_time_delay": 19.8,
"reference_channel": 0,
"channel_id": 14,
"station_id": 11
},
"15": {
"amp_type": "rno_surface",
"ant_comment": "second arm south-east from DAQ, north-east position in arm, pointing side-downwards",
"ant_orientation_phi": 240.0,
"ant_orientation_phi": 120.0,
"ant_orientation_theta": 135.0,
"ant_position_x": -10.276,
"ant_position_y": -4.2,
"ant_position_z": -2.0,
"ant_rotation_phi": 330.0,
"ant_rotation_phi": 210.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"cab_time_delay": 19.8,
"reference_channel": 0,
"channel_id": 15,
"station_id": 11
Expand All @@ -258,10 +254,9 @@
"ant_position_x": -9.526,
"ant_position_y": -5.5,
"ant_position_z": -2.0,
"ant_rotation_phi": 330.0,
"ant_rotation_phi": 210.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"cab_time_delay": 19.8,
"reference_channel": 0,
"channel_id": 16,
"station_id": 11
Expand All @@ -270,12 +265,12 @@
"17": {
"amp_type": "rno_surface",
"ant_comment": "second arm south-east from DAQ, south-west position in arm, pointing side-downwards",
"ant_orientation_phi": 60.0,
"ant_orientation_phi": 300.0,
"ant_orientation_theta": 135.0,
"ant_position_x": -8.776,
"ant_position_y": -6.8,
"ant_position_z": -2,
"ant_rotation_phi": 330.0,
"ant_rotation_phi": 210.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"reference_channel": 0,
Expand All @@ -286,12 +281,12 @@
"18": {
"amp_type": "rno_surface",
"ant_comment": "third arm south-west from DAQ, south-east position in arm, pointing side-downwards",
"ant_orientation_phi": 120.0,
"ant_orientation_phi": 240.0,
"ant_orientation_theta": 135.0,
"ant_position_x": 8.776,
"ant_position_y": -6.8,
"ant_position_z": -2.0,
"ant_rotation_phi": 210.0,
"ant_rotation_phi": 330.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"reference_channel": 0,
Expand All @@ -306,7 +301,7 @@
"ant_position_x": 9.526,
"ant_position_y": -5.5,
"ant_position_z": -2.0,
"ant_rotation_phi": 210.0,
"ant_rotation_phi": 330.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"reference_channel": 0,
Expand All @@ -316,12 +311,12 @@
"20": {
"amp_type": "rno_surface",
"ant_comment": "third arm south-west from DAQ, north-west position in arm, pointing side-downwards",
"ant_orientation_phi": 300.0,
"ant_orientation_phi": 60.0,
"ant_orientation_theta": 135.0,
"ant_position_x": -10.276,
"ant_position_y": 4.2,
"ant_position_x": 10.276,
"ant_position_y": -4.2,
"ant_position_z": -2.0,
"ant_rotation_phi": 210.0,
"ant_rotation_phi": 330.0,
"ant_rotation_theta": 90.0,
"ant_type": "createLPDA_100MHz_InfFirn_n1.4",
"reference_channel": 0,
Expand Down Expand Up @@ -381,7 +376,8 @@
"pos_northing": 0.0,
"pos_site": "summit",
"station_id": 11,
"station_type": null
"station_type": null,
"reference_station": 11
}
}
}
22 changes: 9 additions & 13 deletions NuRadioReco/detector/antenna_models_hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"dip7cm_z200m_InFirn_RG.pkl": "49ea79abe0784f216ffc4c88db540785a38b87d9",
"dip7cm_InfAir.pkl": "407ab67708d750c1c0e6bb83f4a3b41168fc7d1b",
"dip7cm_z270mm_InAir.pkl": "a669d71b79d653c4ea8eb6ab3cbb17bb9026ff9d",
"dip7cm_z260mm_InFirn_RG.pkl": "d72fe75ae0f16f9e40d69796aa015e528735d2ec",
"dip7cm_z1m_InAir.pkl": "1c5e4f65bd15b227fb2eebe1e61c1813509ebd97",
"dip7cm_z1m_InAir_RG_NearHorizontalHD.pkl": "6a08c240e8162b8193da91e1528d301f9a017e3a",
"dip7cm_z1m_InAir_RG_NearHorizontalHD2.pkl": "e880c00f3087ed3b3f8276d78645b4ea13217721",
Expand All @@ -42,16 +41,13 @@
"createLPDA_100MHz_z1cm_InAir_RG.pkl": "9202fa4842792b241366b38cd9a358c03f83acbd",
"XFDTD_Hpol_150mmHole_n1.78.pkl": "cfa1e1d1ddbd146ca3b89c580e137e22300551c4",
"XFDTD_Vpol_CrossFeed_150mmHole_n1.78.pkl": "5d87513779cf2cb5d3309a9bb89dbb163d656114",
"trislot_RNOG.pkl": "29ef63bc9f25da743dd85d33e5645fc6330f6675",
"RNOG_vpol_v1_n1.73.pkl": "4bd0b5941b31c6c39fd6b438f005075b025fee8d",
"RNOG_vpol_v1_n1.4.pkl": "1b8be66b64f241d26e34567167318aa85c396f2a",
"RNOG_vpol_4inch_half_1.73.pkl":
"f08d263233503f79e5be10c18bc7587b8b421c1d",
"RNOG_vpol_4inch_center_1.73.pkl":
"5f429ed9ed08175a7f75fd44422367d2278bf2e1",
"RNOG_vpol_4inch_wall_1.73.pkl":
"da24017eb80f7a68348a674be2c527457fe19992",
"RNOG_quadslot_v1_1.74.pkl":
"e9c4946dd2176489249c862f32ef272ab627dc28",
"RNOG_quadslot_v2_1.74.pkl": "b99d69578f8e7c006dcce3de51e26c4f463872b8"
"trislot_RNOG.pkl": "29ef63bc9f25da743dd85d33e5645fc6330f6675",
"RNOG_vpol_v1_n1.73.pkl": "4bd0b5941b31c6c39fd6b438f005075b025fee8d",
"RNOG_vpol_v1_n1.4.pkl": "1b8be66b64f241d26e34567167318aa85c396f2a",
"RNOG_vpol_4inch_half_n1.73.pkl": "f08d263233503f79e5be10c18bc7587b8b421c1d",
"RNOG_vpol_4inch_center_n1.73.pkl": "5f429ed9ed08175a7f75fd44422367d2278bf2e1",
"RNOG_vpol_4inch_wall_n1.73.pkl": "da24017eb80f7a68348a674be2c527457fe19992",
"RNOG_quadslot_v1_n1.74.pkl": "e9c4946dd2176489249c862f32ef272ab627dc28",
"RNOG_quadslot_v2_n1.74.pkl": "b99d69578f8e7c006dcce3de51e26c4f463872b8",
"SKALA_InfFirn": "69b3007da083bb722a4494af97221917973ab297"
}
4 changes: 2 additions & 2 deletions NuRadioReco/framework/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def deserialize(triggers_pkl):
trigger = EnvelopePhasedTrigger(None, None, None, None)
elif(trigger_type == 'rnog_surface_trigger'):
trigger = RNOGSurfaceTrigger(None, None, None, None)
elif(trigger_type == 'time_over_threshold'):
trigger = TimeOverThresholdTrigger(None, None, None, None)
elif(trigger_type == 'gru_time_over_threshold'):
trigger = GruTimeOverThresholdTrigger(None, None, None)
else:
raise ValueError("unknown trigger type")
trigger.deserialize(data_pkl)
Expand Down
2 changes: 1 addition & 1 deletion NuRadioReco/modules/analogToDigitalConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def get_digital_trace(self, station, det, channel,
if trigger_filter is not None:

trace_fft = np.fft.rfft(trace)
if(len(trace_fft) != trigger_filter):
if len(trace_fft) != len(trigger_filter):
raise ValueError("Wrong filter length to apply to traces")

trace = np.fft.irfft(trace_fft * trigger_filter)
Expand Down
77 changes: 65 additions & 12 deletions NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,35 @@
from NuRadioReco.utilities import units
import mattak.Dataset

import string
import random


def create_random_directory_path(prefix="/tmp/", n=7):
"""
Produces a path for a temporary directory with a n letter random suffix
Parameters
----------
prefix: str
Path prefix, i.e., root directory. (Defaut: /tmp/)
n: int
Number of letters for the random suffix. (Default: 7)
Returns
-------
path: str
Return path (e.g, /tmp/readRNOGData_XXXXXXX)
"""
# generating random strings
res = ''.join(random.choices(string.ascii_lowercase + string.digits, k=n))
path = os.path.join(prefix, "readRNOGData_" + res)

return path


def baseline_correction(wfs, n_bins=128, func=np.median):
"""
Expand Down Expand Up @@ -152,6 +181,8 @@ def __init__(self, run_table_path=None, log_level=logging.INFO):

# Initialize run table for run selection
self.__run_table = None

self.__temporary_dirs = []

if run_table_path is None:
try:
Expand Down Expand Up @@ -310,15 +341,31 @@ def begin(self,
if not all_files_in_directory(dir_file):
self.logger.error(f"Incomplete directory: {dir_file}. Skip ...")
continue

try:
dataset = mattak.Dataset.Dataset(station=0, run=0, data_dir=dir_file, verbose=verbose, **mattak_kwargs)
except (ReferenceError, KeyError) as e:
self.logger.error(f"The following exeption was raised reading in the run: {dir_file}. Skip that run ...:\n", exc_info=e)
continue
else:
raise NotImplementedError("The option to read in files is not implemented yet")
# Providing direct paths to a Mattak combined.root file is not supported by the mattak library yet.
# It only accepts directry paths in which it will look for a file called `combined.root` (or waveforms.root if
# it is not a combined file). To work around this: Create a tmp directory under `/tmp/`, link the file you want to
# read into this directory with the the name `combined.root`, use this path to read the run.

path = create_random_directory_path()
self.logger.debug(f"Create temporary directory: {path}")
if os.path.exists(path):
raise ValueError(f"Temporary directory {path} already exists.")

os.mkdir(path)
self.__temporary_dirs.append(path) # for housekeeping

self.logger.debug(f"Create symlink for {dir_file}")
os.symlink(dir_file, os.path.join(path, "combined.root"))

dir_file = path # set path to e.g. /tmp/NuRadioReco_XXXXXXX/combined.root


try:
dataset = mattak.Dataset.Dataset(station=0, run=0, data_dir=dir_file, verbose=verbose, **mattak_kwargs)
except (ReferenceError, KeyError) as e:
self.logger.error(f"The following exeption was raised reading in the run: {dir_file}. Skip that run ...:\n", exc_info=e)
continue

# filter runs/datasets based on
if select_runs and self.__run_table is not None and not self.__select_run(dataset):
Expand Down Expand Up @@ -515,7 +562,8 @@ def get_events_information(self, keys=["station", "run", "eventNumber"]):

if not do_read:
# ... or when it does not have the desired information
first_event_info = next(iter(self._events_information))
first_event_info = self._events_information[list(self._events_information.keys())[0]]

for key in keys:
if key not in list(first_event_info.keys()):
do_read = True
Expand Down Expand Up @@ -556,8 +604,7 @@ def _check_for_valid_information_in_event_info(self, event_info):
is_valid: bool
Returns True if all information valid, false otherwise
"""



if math.isinf(event_info.triggerTime):
self.logger.error(f"Event {event_info.eventNumber} (st {event_info.station}, run {event_info.run}) "
"has inf trigger time. Skip event...")
Expand All @@ -567,7 +614,7 @@ def _check_for_valid_information_in_event_info(self, event_info):

if (event_info.sampleRate == 0 or event_info.sampleRate is None) and self._overwrite_sampling_rate is None:
self.logger.error(f"Event {event_info.eventNumber} (st {event_info.station}, run {event_info.run}) "
f"has a sampling rate of {event_info.sampleRate:.2f} GHz. Event is skipped ... "
f"has a sampling rate of {event_info.sampleRate} GHz. Event is skipped ... "
f"You can avoid this by setting 'overwrite_sampling_rate' in the begin() method.")
self.__invalid += 1
return False
Expand Down Expand Up @@ -788,4 +835,10 @@ def end(self):
f"\n\tRead {self.__n_runs} runs, skipped {self.__skipped_runs} runs.")
else:
self.logger.info(
f"\n\tRead {self.__counter} events (skipped {self.__skipped} events, {self.__invalid} invalid events)")
f"\n\tRead {self.__counter} events (skipped {self.__skipped} events, {self.__invalid} invalid events)")

# Clean up links and temporary directories.
for d in self.__temporary_dirs:
self.logger.debug(f"Remove temporary folder: {d}")
os.unlink(os.path.join(d, "combined.root"))
os.rmdir(d)
5 changes: 4 additions & 1 deletion NuRadioReco/modules/measured_noise/RNO_G/noiseImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ def begin(self, noise_folders, file_pattern="*",

if not isinstance(noise_folders, list):
noise_folders = [noise_folders]

# find all subfolders
noise_files = []
for noise_folder in noise_folders:
if noise_folder == "":
continue

noise_files += glob.glob(f"{noise_folder}/**/{file_pattern}root", recursive=True)
self.__noise_folders = np.unique([os.path.dirname(e) for e in noise_files])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def begin(self, filenames=None, folder=None, file_pattern="*",
including subdirectories. (Default: None)
file_pattern: str
Use glob.glob(f"{folder}/**/{file_pattern}.nur", recursive=True) to search for files. (Default: "*")
Use ``glob.glob(f"{folder}/**/{file_pattern}.nur", recursive=True)`` to search for files. (Default: "*")
random_seed: int, default: None
Seed for the random number generator. By default, no seed is set.
Expand Down
Loading

0 comments on commit eb9a237

Please sign in to comment.