oasislmf.pytools.gulmc.aggregate¶
This file contains specific functionality needed for aggregate vulnerabilities.
Attributes¶
Functions¶
|
Load the aggregate vulnerability definitions from file. |
|
Load the vulnerability weights definitions from file. |
|
Rearrange aggregate vulnerability definitions from tabular format into CRS arrays |
Populate the weight field in the merged data array by matching aggregate_weights records. |
|
|
Loads vulnerability adjustments from the analysis settings file. |
Module Contents¶
- oasislmf.pytools.gulmc.aggregate.read_aggregate_vulnerability(storage: oasis_data_manager.filestore.backends.base.BaseStorage, ignore_file_type=set())[source]¶
Load the aggregate vulnerability definitions from file.
- Parameters:
storage (BaseStorage) – the storage manager for fetching model data
ignore_file_type (Set[str]) – file extension to ignore when loading.
- Returns:
aggregate vulnerability table.
- Return type:
np.array[AggregateVulnerability]
- oasislmf.pytools.gulmc.aggregate.read_vulnerability_weights(storage: oasis_data_manager.filestore.backends.base.BaseStorage, ignore_file_type=set())[source]¶
Load the vulnerability weights definitions from file.
- Parameters:
storage – (BaseStorage) the storage manager for fetching model data
ignore_file_type (Set[str]) – file extension to ignore when loading.
- Returns:
vulnerability weights table.
- Return type:
np.array[VulnerabilityWeight]
- oasislmf.pytools.gulmc.aggregate.process_aggregate_vulnerability(aggregate_vulnerability)[source]¶
Rearrange aggregate vulnerability definitions from tabular format into CRS arrays mapping aggregate vulnerability id to the list of vulnerability ids that compose it.
- Parameters:
aggregate_vulnerability (np.array[AggregateVulnerability]) – aggregate vulnerability table.
- Returns:
sorted array of aggregate vulnerability ids. agg_vuln_id_ja_offsets (np.array[oasis_int]): jagged array offsets. Row i spans
agg_vuln_id_ja_vuln_ids[agg_vuln_id_ja_offsets[i]:agg_vuln_id_ja_offsets[i+1]].
agg_vuln_id_ja_vuln_ids (np.array[oasis_int]): flat jagged array of constituent vulnerability ids.
- Return type:
agg_vuln_ids (np.array[oasis_int])
- oasislmf.pytools.gulmc.aggregate.process_vulnerability_weights(areaperil_agg_vuln_idx_ja_areaperil_ids, areaperil_agg_vuln_idx_ja_data, vuln_map, vuln_map_keys, aggregate_weights)[source]¶
Populate the weight field in the merged data array by matching aggregate_weights records.
Builds a (areaperil_id, vuln_idx) -> weight hashmap from aggregate_weights once, then iterates entries with one O(1) lookup each. Total cost: O(W + E).
Iterating from the weight side handles the case where the same (ap, vuln_idx) pair appears in multiple entries (two distinct aggregate definitions sharing a sub-vuln on the same areaperil): every such entry gets the same weight, since each is looked up independently.
- Parameters:
areaperil_agg_vuln_idx_ja_areaperil_ids (np.array[areaperil_int]) – areaperil_id for each entry.
areaperil_agg_vuln_idx_ja_data (np.array[agg_vuln_idx_weight_dtype]) – merged (vuln_idx, weight) per entry.
vuln_map (np.ndarray[uint8]) – packed hashmap table mapping vuln_id to dense index.
vuln_map_keys (np.ndarray[int32]) – array of unique vulnerability ids (hashmap keys).
aggregate_weights (np.array[VulnerabilityWeight]) – vulnerability weights table.
- oasislmf.pytools.gulmc.aggregate.get_vuln_rngadj(run_dir, vuln_map, vuln_map_keys)[source]¶
Loads vulnerability adjustments from the analysis settings file.
- Parameters:
run_dir (str) – path to the run directory (used to load the analysis settings)
vuln_map (np.ndarray[uint8]) – packed hashmap table mapping vuln_id to dense index.
vuln_map_keys (np.ndarray[int32]) – array of unique vulnerability ids (hashmap keys).
Returns: (np.ndarray[oasis_float]) vulnerability adjustments array, indexed by dense vuln index.