oasislmf.pytools.lec.manager ============================ .. py:module:: oasislmf.pytools.lec.manager Attributes ---------- .. autoapisummary:: oasislmf.pytools.lec.manager.logger Functions --------- .. autoapisummary:: oasislmf.pytools.lec.manager.read_input_files oasislmf.pytools.lec.manager.get_max_summary_id oasislmf.pytools.lec.manager.do_lec_output_agg_summary oasislmf.pytools.lec.manager.process_input_file oasislmf.pytools.lec.manager.run_lec oasislmf.pytools.lec.manager.run oasislmf.pytools.lec.manager.main Module Contents --------------- .. py:data:: logger .. py:function:: read_input_files(run_dir, use_return_period, agg_wheatsheaf_mean, occ_wheatsheaf_mean, 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 use_return_period (bool): Use Return Period file. agg_wheatsheaf_mean (bool): Aggregate Wheatsheaf Mean. occ_wheatsheaf_mean (bool): Occurrence Wheatsheaf Mean. sample_size (int): Sample Size. Returns: file_data (Dict[str, Any]): A dict of relevent data extracted from files use_return_period (bool): Use Return Period file. agg_wheatsheaf_mean (bool): Aggregate Wheatsheaf Mean. occ_wheatsheaf_mean (bool): Occurrence Wheatsheaf Mean. .. py:function:: get_max_summary_id(file_handles) Get max summary_id from all summary files Args: file_handles (List[np.memmap]): List of memmaps for summary files data Returns: max_summary_id (int): Max summary ID .. py:function:: do_lec_output_agg_summary(summary_id, sidx, loss, filtered_occ_map, outloss_mean, outloss_sample, num_sidxs, max_summary_id) Populate outloss_mean and outloss_sample with aggregate and max losses Args: summary_id (oasis_int): summary_id sidx (oasis_int): Sample ID loss (oasis_float): Loss value filtered_occ_map (ndarray[occ_map_dtype]): Filtered numpy map of event_id, period_no, occ_date_id from the occurrence file_ outloss_mean (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, period_no containing aggregate and max losses outloss_sample (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, sidx, period_no containing aggregate and max losses num_sidxs (int): Number of sidxs to consider for outloss_sample max_summary_id (int): Max summary ID .. py:function:: process_input_file(fin, outloss_mean, outloss_sample, summary_ids, occ_map, use_return_period, num_sidxs, max_summary_id) Process summary file and populate outloss_mean and outloss_sample with losses Args: fin (np.memmap): summary binary memmap outloss_mean (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, period_no containing aggregate and max losses outloss_sample (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, sidx, period_no containing aggregate and max losses summary_ids (ndarray[bool]): bool array marking which summary_ids are used occ_map (ndarray[occ_map_dtype]): numpy map of event_id, period_no, occ_date_id from the occurrence file_ use_return_period (bool): Use Return Period file. num_sidxs (int): Number of sidxs to consider for outloss_sample max_summary_id (int): Max summary ID .. py:function:: run_lec(file_handles, outloss_mean, outloss_sample, summary_ids, occ_map, use_return_period, num_sidxs, max_summary_id) Process each summary file and populate outloss_mean and outloss_sample Args: file_handles (List[np.memmap]): List of memmaps for summary files data outloss_mean (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, period_no containing aggregate and max losses outloss_sample (ndarray[OUTLOSS_DTYPE]): ndarray indexed by summary_id, sidx, period_no containing aggregate and max losses summary_ids (ndarray[bool]): bool array marking which summary_ids are used occ_map (ndarray[occ_map_dtype]): numpy map of event_id, period_no, occ_date_id from the occurrence file_ use_return_period (bool): Use Return Period file. num_sidxs (int): Number of sidxs to consider for outloss_sample max_summary_id (int): Max summary ID .. py:function:: run(run_dir, subfolder, ept_output_file=None, psept_output_file=None, agg_full_uncertainty=False, agg_wheatsheaf=False, agg_sample_mean=False, agg_wheatsheaf_mean=False, occ_full_uncertainty=False, occ_wheatsheaf=False, occ_sample_mean=False, occ_wheatsheaf_mean=False, use_return_period=False, noheader=False) Runs LEC calculations Args: run_dir (str | os.PathLike): Path to directory containing required files structure subfolder (str): Workspace subfolder inside /work/ ept_output_file (str, optional): Path to EPT output file. Defaults to None psept_output_file (str, optional): Path to PSEPT output file. Defaults to None agg_full_uncertainty (bool, optional): Aggregate Full Uncertainty. Defaults to False. agg_wheatsheaf (bool, optional): Aggregate Wheatsheaf. Defaults to False. agg_sample_mean (bool, optional): Aggregate Sample Mean. Defaults to False. agg_wheatsheaf_mean (bool, optional): Aggregate Wheatsheaf Mean. Defaults to False. occ_full_uncertainty (bool, optional): Occurrence Full Uncertainty. Defaults to False. occ_wheatsheaf (bool, optional): Occurrence Wheatsheaf. Defaults to False. occ_sample_mean (bool, optional): Occurrence Sample Mean. Defaults to False. occ_wheatsheaf_mean (bool, optional): Occurrence Wheatsheaf Mean. Defaults to False. use_return_period (bool, optional): Use Return Period file. Defaults to False. noheader (bool): Boolean value to skip header in output file .. py:function:: main(run_dir='.', subfolder=None, ept=None, psept=None, agg_full_uncertainty=False, agg_wheatsheaf=False, agg_sample_mean=False, agg_wheatsheaf_mean=False, occ_full_uncertainty=False, occ_wheatsheaf=False, occ_sample_mean=False, occ_wheatsheaf_mean=False, use_return_period=False, noheader=False, **kwargs)