I/O#

This module include I/O related functionality.

io_handler#

Handle input and output paths.

class io_operations.io_handler.IOHandler(*args, **kwargs)[source]#

Handle input and output paths.

get_input_data_file(parent_dir=None, file_name=None, test=False)[source]#

Get path of a data file, using data_path.

Parameters:
parent_dir: str

Parent directory of the file.

files_name: str

File name.

test: bool

If true, return test resources location

Returns:
Path
Raises:
IncompleteIOHandlerInitError

if data_path is not set

get_output_directory(label=None, sub_dir=None)[source]#

Return path to output directory.

Parameters:
label: str

Instance label.

sub_dir: str

Name of the subdirectory (ray-tracing, model etc)

Returns:
Path
Raises:
FileNotFoundError

if error creating directory

TypeError

raised for errors while creating directory name

get_output_file(file_name, label=None, sub_dir=None)[source]#

Get path of an output file.

Parameters:
files_name: str

File name.

label: str

Instance label.

sub_dir: str

Name of the subdirectory (ray-tracing, model etc)

Returns:
Path
set_paths(output_path=None, data_path=None, model_path=None, use_plain_output_path=False)[source]#

Set paths for input and output.

Parameters:
output_path: str or Path

Path pointing to the output directory.

data_path: str or Path

Path pointing to the data files (e.g., CORSIKA or sim_telarray output).

model_path: str or Path

Path pointing to the model file directory.

use_plain_output_path: bool

Use plain output path without adding tool name and date

class io_operations.io_handler.IOHandlerSingleton[source]#

Singleton base class.

hdf5_handler#

Helper module for reading and writing in hd5 format.

io_operations.hdf5_handler.fill_hdf5_table(hist, x_bin_edges, y_bin_edges, x_label, y_label, meta_data)[source]#

Create and fill an hdf5 table with the histogram information.

It works for both 1D and 2D distributions.

Parameters:
hist: numpy.ndarray

The counts of the histograms.

x_bin_edges: numpy.array

The x bin edges of the histograms.

y_bin_edges: numpy.array

The y bin edges of the histograms. Use None for 1D histograms.

x_label: str

X bin edges label.

y_label: str

Y bin edges label. Use None for 1D histograms.

meta_data: dict

Dictionary with the histogram metadata.

io_operations.hdf5_handler.read_hdf5(hdf5_file_name)[source]#

Read a hdf5 output file.

Parameters:
hdf5_file_name: str or Path

Name or Path of the hdf5 file to read from.

Returns:
list

The list with the astropy.Table instances for the various 1D and 2D histograms saved in the hdf5 file.