I/O#
This module include I/O related functionality.
io_handler#
- 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, dir_type='simtools')[source]#
Return path to output directory
- Parameters:
- label: str
Instance label.
- sub_dir: str
Name of the subdirectory (ray-tracing, model etc)
- dir_type: str
The type of directory (e.g., ‘simtools’, ‘test’, ‘simtools-result’). If ‘simtools-result’ is used, the output directory will be returned without appending a subdirectory string when using the use_plain_output_path option. For the cause of not using use_plain_output_path, output paths appended by ‘simtools-output’.
- 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, dir_type='simtools')[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)
- dir_type: str
Directory type (e.g., ‘simtools’, ‘test’, ‘simtools-result’) If ‘simtools-result’ is used, the output directory will be returned without appending a subdirectory string when using the use_plain_output_path option.
- 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
hdf5_handler#
- 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.