Skip to content

Commit

Permalink
make some readRNOGDataMattak functions protected to reduce clutter
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerd-bouma committed Jan 9, 2024
1 parent 679cb88 commit fbc9691
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand All @@ -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:
Expand All @@ -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.")
Expand Down

0 comments on commit fbc9691

Please sign in to comment.