NuRadioReco.modules.io.LOFAR.readLOFARData module

NuRadioReco.modules.io.LOFAR.readLOFARData.get_metadata(filenames, metadata_dir)[source]

Get metadata from TBB file.

Parameters:
filenameslist[str]

List of TBB file paths to read in

metadata_dirstr

Path to the TBB metadata directory

NuRadioReco.modules.io.LOFAR.readLOFARData.lora_timestamp_to_blocknumber(lora_seconds, lora_nanoseconds, start_time, sample_number, clock_offset=10000.0, block_size=65536, sampling_frequency=0.2)[source]

Calculates block number corresponding to LORA timestamp and the sample number within that block

Parameters:
lora_secondsint

LORA timestamp in seconds (UTC timestamp, second after 1st January 1970)

lora_nanosecondsint

LORA timestamp in nanoseconds

start_timeint

LOFAR TBB timestamp

sample_numberint

Sample number in the block where the trace starts

clock_offsetfloat, default=1e4 * units.ns

Clock offset between LORA and LOFAR

block_sizeint, default=2**16

Block size of the LOFAR data

sampling_frequencyfloat, default=200 * units.MHz

Sampling frequency of LOFAR

Returns:
A tuple containing blocknumber and samplenumber, in this order.
NuRadioReco.modules.io.LOFAR.readLOFARData.tbb_filetag_from_utc(timestamp)[source]

Returns TBB filename based on UTC timestamp of an event.

Parameters:
timestamp: int

UTC timestamp from GPS

Returns:
filename: str

The tag in the TBB filename identifying the files of the event.

class NuRadioReco.modules.io.LOFAR.readLOFARData.getLOFARtraces(tbb_h5_filename, metadata_dir, time_s, time_ns, trace_length_nbins)[source]

Bases: object

A Class to facilitate getting traces from LOFAR TBB HDF5 Files

Parameters:
time_s: int

Event trigger timestamp in UTC seconds

time_ns: int

Event trigger timestamp in ns past UTC second

trace_length_nbinsint

Desired length of trace to be loaded from TBB HDF5 files. This does not affect trace size read-in for RFI cleaning

Methods

check_trace_quality()

Check all traces recorded from the TBB against quality requirements.

get_trace(dipole_id)

Parameters:

setup_trace_loading()

Opens the file and sets some variables.

close_file

setup_trace_loading()[source]

Opens the file and sets some variables. so that get_trace() can be called repeatedly for different dipoles.

check_trace_quality()[source]

Check all traces recorded from the TBB against quality requirements.

get_trace(dipole_id)[source]
Parameters:
dipole_id: str

The dipole id

close_file()[source]
class NuRadioReco.modules.io.LOFAR.readLOFARData.readLOFARData(restricted_station_set=None, tbb_directory=None, json_directory=None, metadata_directory=None)[source]

Bases: object

This class reads in the data from the TBB files and puts them into an Event structure. It relies on the KRATOS package. If the directory paths are not provided, they default to the ones on COMA.

Parameters:
tbb_directory: Path-like str, default=”/vol/astro3/lofar/vhecr/lora_triggered/data/”

The path to the directory containing the TBB files.

json_directory: Path-like str, default=”/vol/astro7/lofar/kratos_files/json”

The path to the directory containing the JSON files from LORA.

metadata_directory: Path-like str, default=”/vol/astro7/lofar/vhecr/kratos/data/”

The path to the directory containing the LOFAR metadata (antenna positions and timing calibrations).

Methods

begin(event_id[, logger_level])

Prepare the reader to ingest the event with ID event_id.

get_stations()

Return the internal dictionary which contains the paths to the TBB event files and the extracted metadata per stations.

run(detector[, trace_length])

Runs the reader with the provided detector.

end

get_stations()[source]

Return the internal dictionary which contains the paths to the TBB event files and the extracted metadata per stations.

Returns:
stationsdict

Dictionary with station names as keys and dictionaries as values, who have a files key with as value a list of TBB filepaths and a metadata key which has a list with metadat as value.

Notes

The metadata key is only set in the readLOFARData.begin() function, to avoid setting it multiple times if there is more than 1 TBB file for a given station.

Metadata is a list containing (in this order):
  1. station name

  2. antenna set

  3. tbb timestamp (seconds)

  4. tbb timestamp (nanoseconds)

  5. station clock frequency (Hz)

  6. positions of antennas

  7. dipole IDs

  8. calibration delays per dipole

begin(event_id, logger_level=0)[source]

Prepare the reader to ingest the event with ID event_id. This resets the internal representation of the stations as well as the event ID. The timestamps are read from the LORA JSON file corresponding to the event. The function then globs through the TBB directory to find all files corresponding to the event and adds them to the corresponding station file list. It also loads the metadata for every station.

Parameters:
event_id: int

The ID of the event to load.

logger_levelint, default=logging.NOTSET

Use this parameter to override the logging level for this module.

run(detector, trace_length=65536)[source]

Runs the reader with the provided detector. For every station that has files associated with it, a Station object is created together with its channels (pulled from the detector description). Every channel also gets a group ID which corresponds to the polarisation (i.e. 0 for even and 1 for odd), as to be able to retrieve all channels per polarisation during processing.

Parameters:
detector: Detector object

The detector description to be used for this event.

trace_length: int

Desired length of the trace to be loaded from TBB files.

Yields:
evt: Event object

The event containing all the loaded traces.

end()[source]