oasislmf.pytools.gulmc.aggregate ================================ .. py:module:: oasislmf.pytools.gulmc.aggregate .. autoapi-nested-parse:: This file contains specific functionality needed for aggregate vulnerabilities. Attributes ---------- .. autoapisummary:: oasislmf.pytools.gulmc.aggregate.logger oasislmf.pytools.gulmc.aggregate.AGG_VULN_WEIGHTS_KEY_TYPE oasislmf.pytools.gulmc.aggregate.AGG_VULN_WEIGHTS_VAL_TYPE oasislmf.pytools.gulmc.aggregate.AggregateVulnerability oasislmf.pytools.gulmc.aggregate.VulnerabilityWeight Functions --------- .. autoapisummary:: oasislmf.pytools.gulmc.aggregate.gen_empty_agg_vuln_to_vuln_ids oasislmf.pytools.gulmc.aggregate.gen_empty_areaperil_vuln_ids_to_weights oasislmf.pytools.gulmc.aggregate.read_aggregate_vulnerability oasislmf.pytools.gulmc.aggregate.read_vulnerability_weights oasislmf.pytools.gulmc.aggregate.process_aggregate_vulnerability oasislmf.pytools.gulmc.aggregate.process_vulnerability_weights oasislmf.pytools.gulmc.aggregate.map_agg_vuln_ids_to_agg_vuln_idxs oasislmf.pytools.gulmc.aggregate.map_areaperil_vuln_id_to_weight_to_areaperil_vuln_idx_to_weight Module Contents --------------- .. py:data:: logger .. py:data:: AGG_VULN_WEIGHTS_KEY_TYPE .. py:data:: AGG_VULN_WEIGHTS_VAL_TYPE .. py:data:: AggregateVulnerability .. py:data:: VulnerabilityWeight .. py:function:: gen_empty_agg_vuln_to_vuln_ids() Generate empty map to store the definitions of aggregate vulnerability functions. Returns: dict[int, list[int]]: map of aggregate vulnerability id to list of vulnerability ids. .. py:function:: gen_empty_areaperil_vuln_ids_to_weights() Generate empty map to store the weights of individual vulnerability functions in each aggregate vulnerability. Returns: dict[AGG_VULN_WEIGHTS_KEY_TYPE, AGG_VULN_WEIGHTS_VAL_TYPE]: map of areaperil_id, vulnerability id to weight. .. py:function:: read_aggregate_vulnerability(storage: oasis_data_manager.filestore.backends.base.BaseStorage, ignore_file_type=set()) Load the aggregate vulnerability definitions from file. Args: storage: (BaseStorage) the storage manager for fetching model data ignore_file_type (Set[str]): file extension to ignore when loading. Returns: np.array[AggregateVulnerability]: aggregate vulnerability table. .. py:function:: read_vulnerability_weights(storage: oasis_data_manager.filestore.backends.base.BaseStorage, ignore_file_type=set()) Load the vulnerability weights definitions from file. Args: storage: (BaseStorage) the storage manager for fetching model data ignore_file_type (Set[str]): file extension to ignore when loading. Returns: np.array[VulnerabilityWeight]: vulnerability weights table. .. py:function:: process_aggregate_vulnerability(aggregate_vulnerability) Rearrange aggregate vulnerability definitions from tabular format to a map between aggregate vulnerability id and the list of vulnerability ids that it is made of. Args: aggregate_vulnerability (np.array[AggregateVulnerability]): aggregate vulnerability table. Returns: dict[int, list[int]]: map of aggregate vulnerability id to list of vulnerability ids. .. py:function:: process_vulnerability_weights(aggregate_weights, agg_vuln_to_vuln_id) Rearrange vulnerability weights from tabular format to a map between (areaperil_id, vulnerability_id) and the vulnerability weight. Args: aggregate_weights (np.array[VulnerabilityWeight]): vulnerability weights table. agg_vuln_to_vuln_id (dict[int, list[int]]): map of aggregate vulnerability id to list of vulnerability ids. Returns: dict[AGG_VULN_WEIGHTS_KEY_TYPE, AGG_VULN_WEIGHTS_VAL_TYPE]: map of areaperil_id, vulnerability id to weight. .. py:function:: map_agg_vuln_ids_to_agg_vuln_idxs(agg_vulns, agg_vuln_to_vuln_id, vuln_dict) For each aggregate vulnerability listed in `agg_vulns`, map the individual vulnerability_ids that compose it to the indices where they are stored in `vuln_array`. Args: agg_vulns (List[int32]) agg_vuln_to_vuln_id (dict[int, list[int]]): map of aggregate vulnerability id to list of vulnerability ids. vuln_dict (Tuple[Dict[int, int]): vulnerability dictionary. Returns: dict[int, list[int]]: map between aggregate vulnerability id and the list of indices where the individual vulnerability_ids that compose it are stored in `vuln_array`. .. py:function:: map_areaperil_vuln_id_to_weight_to_areaperil_vuln_idx_to_weight(areaperil_to_vulns, areaperil_vuln_id_to_weight, vuln_dict) Make map between aggregate vulnerability id and the list of sub-vulnerability ids of which they are composed, where the value of the sub-vulnerability id is the internal pointer (i.e., the index, startinf from 0) to the dense array where they are stored, not the vulnerability id (which starts from 1). Args: areaperil_to_vulns (List[int32]) areaperil_vuln_id_to_weight (dict[AGG_VULN_WEIGHTS_KEY_TYPE, AGG_VULN_WEIGHTS_VAL_TYPE]): map of areaperil_id, vulnerability id to weight. vuln_dict (Tuple[Dict[int, int]): vulnerability dictionary. Returns: dict[AGG_VULN_WEIGHTS_KEY_TYPE, AGG_VULN_WEIGHTS_VAL_TYPE]: map between the areaperil id and the index where the vulnerability function is stored in `vuln_array` and the vulnerability weight.