oasislmf.pytools.elt.manager ============================ .. py:module:: oasislmf.pytools.elt.manager Attributes ---------- .. autoapisummary:: oasislmf.pytools.elt.manager.logger oasislmf.pytools.elt.manager.SELT_output oasislmf.pytools.elt.manager.MELT_output oasislmf.pytools.elt.manager.QELT_output oasislmf.pytools.elt.manager.SELT_headers oasislmf.pytools.elt.manager.MELT_headers oasislmf.pytools.elt.manager.QELT_headers oasislmf.pytools.elt.manager.SELT_dtype oasislmf.pytools.elt.manager.MELT_dtype oasislmf.pytools.elt.manager.QELT_dtype oasislmf.pytools.elt.manager.SELT_fmt oasislmf.pytools.elt.manager.MELT_fmt oasislmf.pytools.elt.manager.QELT_fmt Classes ------- .. autoapisummary:: oasislmf.pytools.elt.manager.ELTReader Functions --------- .. autoapisummary:: oasislmf.pytools.elt.manager.read_buffer oasislmf.pytools.elt.manager.read_input_files oasislmf.pytools.elt.manager.run oasislmf.pytools.elt.manager.main Module Contents --------------- .. py:data:: logger .. py:data:: SELT_output .. py:data:: MELT_output .. py:data:: QELT_output .. py:data:: SELT_headers .. py:data:: MELT_headers .. py:data:: QELT_headers .. py:data:: SELT_dtype .. py:data:: MELT_dtype .. py:data:: QELT_dtype .. py:data:: SELT_fmt :value: '' .. py:data:: MELT_fmt :value: '' .. py:data:: QELT_fmt :value: '' .. py:class:: ELTReader(len_sample, compute_selt, compute_melt, compute_qelt, unique_event_ids, event_rates, intervals) Bases: :py:obj:`oasislmf.pytools.common.event_stream.EventReader` Abstract class to read event stream This class provide a generic interface to read multiple event stream using: - selector : handle back pressure, the program is paused and don't use resource if nothing is in the stream buffer - memoryview : read a chuck (PIPE_CAPACITY) of data at a time then work on it using a numpy byte view of this buffer To use those methods need to be implemented: - __init__(self, ...) the constructor with all data structure needed to read and store the event stream - read_buffer(self, byte_mv, cursor, valid_buff, event_id, item_id) simply point to a local numba.jit function name read_buffer (a template is provided bellow) this function should implement the specific logic of where and how to store the event information. Those to method may be overwritten - item_exit(self): specific logic to do when an item is finished (only executed once the stream is finished but no 0,0 closure was present) - event_read_log(self): what kpi to log when a full event is read usage snippet: with ExitStack() as stack: streams_in, (stream_type, stream_agg_type, len_sample) = init_streams_in(files_in, stack) reader = CustomReader() for event_id in reader.read_streams(streams_in): .. py:attribute:: logger .. py:attribute:: selt_data .. py:attribute:: selt_idx .. py:attribute:: melt_data .. py:attribute:: melt_idx .. py:attribute:: qelt_data .. py:attribute:: qelt_idx .. py:attribute:: state .. py:attribute:: unique_event_ids .. py:attribute:: event_rates .. py:attribute:: intervals .. py:attribute:: curr_file_idx :value: None .. py:method:: read_buffer(byte_mv, cursor, valid_buff, event_id, item_id, file_idx) .. py:function:: read_buffer(byte_mv, cursor, valid_buff, event_id, item_id, selt_data, selt_idx, state, melt_data, melt_idx, qelt_data, qelt_idx, intervals, unique_event_ids, event_rates) .. py:function:: read_input_files(run_dir, compute_melt, compute_qelt, sample_size) Reads all input files and returns a dict of relevant data Args: run_dir (str | os.PathLike): Path to directory containing required files structure compute_melt (bool): Compute MELT bool compute_qelt (bool): Compute QELT bool sample_size (int): Sample size Returns: file_data (Dict[str, Any]): A dict of relevent data extracted from files .. py:function:: run(run_dir, files_in, selt_output_file=None, melt_output_file=None, qelt_output_file=None, noheader=False) Runs ELT calculations Args: run_dir (str | os.PathLike): Path to directory containing required files structure files_in (str | os.PathLike): Path to summary binary input file selt_output_file (str, optional): Path to SELT output file. Defaults to None. melt_output_file (str, optional): Path to MELT output file. Defaults to None. qelt_output_file (str, optional): Path to QELT output file. Defaults to None. noheader (bool): Boolean value to skip header in output file .. py:function:: main(run_dir='.', files_in=None, selt=None, melt=None, qelt=None, noheader=None, **kwargs)