oasislmf.pytools.gulmc.items

This file contains specific functionality to read and process items files.

Attributes

Functions

read_items(input_path[, ignore_file_type, ...])

Load the items from the items file.

generate_item_map(items, coverages, ...)

Generate item_map; requires items to be sorted.

Module Contents

oasislmf.pytools.gulmc.items.logger[source]
oasislmf.pytools.gulmc.items.read_items(input_path, ignore_file_type=set(), dynamic_footprint=False, legacy=False)[source]

Load the items from the items file.

Args:

input_path (str): the path pointing to the file ignore_file_type (Set[str]): file extension to ignore when loading.

Returns:
Tuple[Dict[int, int], List[int], Dict[int, int], List[Tuple[int, int]], List[int]]

vulnerability dictionary, vulnerability IDs, areaperil to vulnerability index dictionary, areaperil ID to vulnerability index array, areaperil ID to vulnerability array

oasislmf.pytools.gulmc.items.generate_item_map(items, coverages, valid_areaperil_id, agg_vuln_to_vulns)[source]

Generate item_map; requires items to be sorted.

Args:
items (numpy.ndarray[int32, int32, int32]): 1-d structured array storing

item_id, coverage_id, group_id for all items. items need to be sorted by increasing areaperil_id, vulnerability_id in order to output the items in correct order.

coverages (numpy.ndarray): coverage id to information on items valid_areaperil_id (numpy.ndarray[int32]): list of non-filtered area_peril_id (None is no filter) agg_vuln_to_vulns (dict[int, list[int]]): map of aggregate vulnerability id to list of vulnerability ids.

Returns:
item_map (Dict[ITEM_MAP_KEY_TYPE, ITEM_MAP_VALUE_TYPE]): dict storing

the mapping between areaperil_id, vulnerability_id to item.

areaperil_ids_map (Dict[int, Dict[int, int]]) dict storing the mapping between each

areaperil_id and all the vulnerability ids associated with it.

vuln id to vuln idx for each vulnerability in each areaperil, list of all used vulnerability ids. agg_vuln_to_vuln_idxs 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.

areaperil_vuln_idx_to_weight 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.