Skip to content

Commit

Permalink
improve some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerd-bouma committed Jan 9, 2024
1 parent 4168204 commit 679cb88
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions NuRadioReco/modules/io/RNO_G/readRNOGDataMattak.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,41 @@ class readRNOGData:

def __init__(self, run_table_path=None, load_run_table=True, log_level=logging.INFO):
"""
Reader for RNO-G ``.root`` files
This class provides read access to RNO-G ``.root`` files and converts them
to NuRadioMC :class:`Events <NuRadioReco.framework.event.Event>`. Requires ``mattak``
(https://github.com/RNO-G/mattak) to be installed.
Parameters
----------
run_table_path: str | None
Path to a run_table.cvs file. If None, the run table is queried from the DB. (Default: None)
Path to a run_table.csv file. If None, the run table is queried from the DB. (Default: None)
load_run_table: bool
If True, try to load the run_table from run_table_path. Otherwise, skip this.
log_level: enum
Set verbosity level of logger. If logging.DEBUG, set mattak to verbose (unless specified in mattak_kwargs).
(Default: logging.INFO)
Examples
--------
.. code-block::
reader = readRNOGDataMattak.readRNOGData() # initialize reader
reader.begin('/path/to/root_file_or_folder')
evt = reader.get_event_by_index(0) # returns the first event in the file
# OR
evt = reader.get_event(run_nr=1100, event_id=679) # returns the event with run_number 1100 and event_id 679
# OR
for evt in reader.run(): # loop over all events in file
# perform some analysis
pass
"""
self.logger = logging.getLogger('NuRadioReco.readRNOGData')
self.logger.setLevel(log_level)
Expand Down Expand Up @@ -721,10 +744,10 @@ def run(self):
"""
Loop over all events.
Returns
-------
Yields
------
evt: generator(NuRadioReco.framework.event)
evt: `NuRadioReco.framework.event.Event`
"""
event_idx = -1
for dataset in self._datasets:
Expand Down Expand Up @@ -774,7 +797,7 @@ def get_event_by_index(self, event_index):
Returns
-------
evt: NuRadioReco.framework.event
evt: `NuRadioReco.framework.event.Event`
"""

self.logger.debug(f"Processing event number {event_index} out of total {self._n_events_total}")
Expand Down Expand Up @@ -816,7 +839,7 @@ def get_event(self, run_nr, event_id):
Returns
-------
evt: NuRadioReco.framework.event
evt: `NuRadioReco.framework.event.Event`
"""

self.logger.debug(f"Processing event {event_id}")
Expand Down

0 comments on commit 679cb88

Please sign in to comment.