Commit a00953ba authored by Enrique Garcia's avatar Enrique Garcia
Browse files

entry point and script of stream_real_data_to_simulation_structure

parent c77b2b94
......@@ -12,10 +12,11 @@ install_package:
- hiperta_stream_start -h
- hiperta_dl1_to_dl2 -h # lstchain dependencies
- stream_get_zfits_pix_order -h
- stream_create_base_config -h # ctapip_io_lst dependencies
- stream_create_base_config -h # ctapipe_io_lst dependencies
- stream_log_summary -h
- stream_create_base_config -h
- stream_plot_dl1 -h
- stream_plot_r0_calib -h
- stream_realData2simulStructure -h
only:
- branches
#!/usr/bin/env python
# E. Garcia - Avr 2021
import tables
import argparse
def main():
parser = argparse.ArgumentParser(description="Merge a LST1 real data (already converted) hdf5 file together with "
"the base hdf5 structure - to make the RD compliant with the DCS. ")
parser.add_argument('--input_file', '-i', action='store', type=str,
dest='input_file',
help='Path to real data .h5 file to be converted.',
required=True
)
parser.add_argument('--base_h5_structure', '-b', action='store', type=str,
dest='base_h5_structure',
help='Path to base hdf5 file containing the base structure (tree path) to be merged with the '
'input file.',
default=None,
required=True
)
parser.add_argument('--output_file', '-o', action='store', type=str,
dest='output_file',
help='Output filename.',
default='./LST1_real_data_for_DCS.h5'
)
args = parser.parse_args()
# Read infile files and use same h5 filters as the ones used in the real data
h_base_h5 = tables.open_file(args.base_h5_structure, 'r')
hf_real_data = tables.open_file(args.input_file, 'r')
h5_filter = hf_real_data.filters # tables.Filters
# Create hout
hout = tables.open_file(args.output_file, 'w', filters=h5_filter)
# Copy the hdf5 structure, configuration and r0
hout.copy_node(h_base_h5.root.configuration, newparent=hout.root, recursive=True)
hout.copy_node(h_base_h5.root.r0, newparent=hout.root, recursive=True)
h_base_h5.close()
# Merge waveforms and trigger in R0:
# Copy waveform node, and trigger table (all the subarray group, that contains trigger and more...)
hout.create_group('/r0', 'event')
hout.create_group('/r0/event', 'telescope')
hout.copy_node(hf_real_data.root.r0.event.telescope.waveform,
newparent=hout.root.r0.event.telescope, recursive=True)
hout.copy_node(hf_real_data.root.r0.event.subarray,
newparent=hout.root.r0.event, recursive=True)
hf_real_data.close()
hout.close()
if __name__ == '__main__':
main()
......@@ -10,7 +10,8 @@ entry_points = {
'stream_create_base_config = hiperta_stream.create_base_hdf5_config_structure_for_hiperta_stream:main',
'stream_log_summary = hiperta_stream.create_log_summary:main',
'stream_plot_dl1 = hiperta_stream.stream_plot_dl1:main',
'stream_plot_r0_calib = hiperta_stream.stream_plot_r0_calib:main'
'stream_plot_r0_calib = hiperta_stream.stream_plot_r0_calib:main',
'stream_realData2simulStructure = hiperta_stream.stream_real_data_to_simulation_structure:main'
]}
setup(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment