oasislmf.pytools.plt.manager ============================ .. py:module:: oasislmf.pytools.plt.manager Attributes ---------- .. autoapisummary:: oasislmf.pytools.plt.manager.logger oasislmf.pytools.plt.manager.SPLT_output oasislmf.pytools.plt.manager.MPLT_output oasislmf.pytools.plt.manager.QPLT_output oasislmf.pytools.plt.manager.SPLT_headers oasislmf.pytools.plt.manager.MPLT_headers oasislmf.pytools.plt.manager.QPLT_headers oasislmf.pytools.plt.manager.SPLT_dtype oasislmf.pytools.plt.manager.MPLT_dtype oasislmf.pytools.plt.manager.QPLT_dtype oasislmf.pytools.plt.manager.SPLT_fmt oasislmf.pytools.plt.manager.MPLT_fmt oasislmf.pytools.plt.manager.QPLT_fmt Classes ------- .. autoapisummary:: oasislmf.pytools.plt.manager.PLTReader Functions --------- .. autoapisummary:: oasislmf.pytools.plt.manager.read_buffer oasislmf.pytools.plt.manager.read_input_files oasislmf.pytools.plt.manager.run oasislmf.pytools.plt.manager.main Module Contents --------------- .. py:data:: logger .. py:data:: SPLT_output .. py:data:: MPLT_output .. py:data:: QPLT_output .. py:data:: SPLT_headers .. py:data:: MPLT_headers .. py:data:: QPLT_headers .. py:data:: SPLT_dtype .. py:data:: MPLT_dtype .. py:data:: QPLT_dtype .. py:data:: SPLT_fmt :value: '' .. py:data:: MPLT_fmt :value: '' .. py:data:: QPLT_fmt :value: '' .. py:class:: PLTReader(len_sample, compute_splt, compute_mplt, compute_qplt, occ_map, period_weights, granular_date, 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:: splt_data .. py:attribute:: splt_idx .. py:attribute:: mplt_data .. py:attribute:: mplt_idx .. py:attribute:: qplt_data .. py:attribute:: qplt_idx .. py:attribute:: state .. py:attribute:: occ_map .. py:attribute:: period_weights .. py:attribute:: granular_date .. 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, state, splt_data, splt_idx, mplt_data, mplt_idx, qplt_data, qplt_idx, occ_map, period_weights, granular_date, intervals) .. py:function:: read_input_files(run_dir, compute_qplt, 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_qplt (bool): Compute QPLT 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, splt_output_file=None, mplt_output_file=None, qplt_output_file=None, noheader=False) Runs PLT 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 splt_output_file (str, optional): Path to SPLT output file. Defaults to None. mplt_output_file (str, optional): Path to MPLT output file. Defaults to None. qplt_output_file (str, optional): Path to QPLT output file. Defaults to None. noheader (bool): Boolean value to skip header in output file .. py:function:: main(run_dir='.', files_in=None, splt=None, mplt=None, qplt=None, noheader=False, **kwargs)