oasislmf.pytools.getmodel.vulnerability¶
This file houses a series of functions that load, convert, and save vulnerability data with Parquet files.
Attributes¶
Functions¶
|
Extracts meta data from the vulnerability data. |
|
Flattens the vulnerability data into a one-dimensional array for each vulnerability ID. |
|
Loops through the vulnerability data, converting it into one-dimensional arrays, in-turn converting this into |
|
Converts the vulnerability data to parquet file and saves it. |
|
Module Contents¶
- oasislmf.pytools.getmodel.vulnerability.vulnerability_dataset = 'vulnerability_dataset.parquet'[source]¶
- oasislmf.pytools.getmodel.vulnerability.parquetvulnerability_meta_filename = 'vulnerability_parquet_meta.json'[source]¶
- oasislmf.pytools.getmodel.vulnerability.get_vuln_info(vulns_bin) Tuple[int, int, int] [source]¶
Extracts meta data from the vulnerability data.
- Args:
vulns_bin: (List[Vulnerability]) vulnerability data from the file
Returns: (Tuple[int, int, int]) number of vulnerability IDs, number of intensity bins, number of damage bins
- oasislmf.pytools.getmodel.vulnerability.get_array(vulns_bin, num_intensity_bins, num_damage_bins, max_vulnerability_id_size) Tuple[List[int], List[List[List[float]]]] [source]¶
Flattens the vulnerability data into a one-dimensional array for each vulnerability ID.
- NOTE => Numba: cannot cache generator for the moment to work properlly, data on the same vulnerability_id must
all be in one block
- Args:
vulns_bin: (List[Vulnerability]) vulnerability data from file num_intensity_bins: (int) the number of intensity bins in the data num_damage_bins: (int) the number of damage bins in the data max_vulnerability_id_size: (int) the size of the vulnerability_ids array inside the function, this will
be the size of the vulnerability IDs array that is returned
Returns: (Tuple[List[int], List[List[List[float]]]]) array of vulnerability IDs, vulnerability data
- oasislmf.pytools.getmodel.vulnerability.iter_table(vulns_bin, num_intensity_bins, num_damage_bins, info, max_vulnerability_id_size)[source]¶
Loops through the vulnerability data, converting it into one-dimensional arrays, in-turn converting this into PyArrow arrays and then converting into Tables.
- Args:
vulns_bin: (List[Vulnerability]) vulnerability data from file num_intensity_bins: (int) the number of intensity bins in the data num_damage_bins: (int) the number of damage bins in the data info: (dict) meta data around the vulnerability data. It has to store:
num_vulnerability_id => number of vulnerability IDs num_intensity_bins => number of intensity bins num_damage_bins => number of damage bins
max_vulnerability_id_size: (int) the size of the vulnerability_ids array
Returns: