From fbc9691a31a88b6889def12a23cdb07d6f074413 Mon Sep 17 00:00:00 2001 From: Sjoerd Bouma Date: Tue, 9 Jan 2024 12:10:16 +0100 Subject: [PATCH] make some readRNOGDataMattak functions protected to reduce clutter --- .../modules/io/RNO_G/readRNOGDataMattak.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py b/NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py index 90834e2cb..0056f5238 100644 --- a/NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py +++ b/NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py @@ -22,7 +22,7 @@ import random -def create_random_directory_path(prefix="/tmp/", n=7): +def _create_random_directory_path(prefix="/tmp/", n=7): """ Produces a path for a temporary directory with a n letter random suffix @@ -48,7 +48,7 @@ def create_random_directory_path(prefix="/tmp/", n=7): return path -def baseline_correction(wfs, n_bins=128, func=np.median, return_offsets=False): +def _baseline_correction(wfs, n_bins=128, func=np.median, return_offsets=False): """ Simple baseline correction function. @@ -150,7 +150,7 @@ def get_time_offset(trigger_type): raise KeyError(f"Unknown trigger type: {trigger_type}. Known are: {known_trigger_types}. Abort ....") -def all_files_in_directory(mattak_dir): +def _all_files_in_directory(mattak_dir): """ Checks if all Mattak root files are in a directory. Ignoring runinfo.root because (asaik) not all runs have those and information is currently not read by Mattak. @@ -376,14 +376,14 @@ def begin(self, self._datasets = [] self.__n_events_per_dataset = [] + if not isinstance(dirs_files, (list, np.ndarray)): + dirs_files = [dirs_files] + self.logger.info(f"Parse through / read-in {len(dirs_files)} directory(ies) / file(s).") self.__skipped_runs = 0 self.__n_runs = 0 - if not isinstance(dirs_files, (list, np.ndarray)): - dirs_files = [dirs_files] - # Set verbose for mattak if "verbose" in mattak_kwargs: verbose = mattak_kwargs.pop("verbose") @@ -398,7 +398,7 @@ def begin(self, if os.path.isdir(dir_file): - if not all_files_in_directory(dir_file): + if not _all_files_in_directory(dir_file): self.logger.error(f"Incomplete directory: {dir_file}. Skip ...") continue else: @@ -407,7 +407,7 @@ def begin(self, # 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() + 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.")