Source code for oasislmf.pytools.getmodel.common

"""
This file defines the data types that are loaded from the data files.
"""
import numba as nb
import numpy as np

from oasislmf.pytools.common.data import areaperil_int, oasis_float

# Footprint file formats in order of priority
[docs] fp_format_priorities = ['parquet', 'binZ', 'bin', 'csv', 'parquet_dynamic']
# filenames
[docs] footprint_filename = 'footprint.bin'
[docs] footprint_index_filename = 'footprint.idx'
[docs] zfootprint_filename = 'footprint.bin.z'
[docs] zfootprint_index_filename = 'footprint.idx.z'
[docs] csvfootprint_filename = 'footprint.csv'
[docs] parquetfootprint_filename = 'footprint.parquet'
[docs] parquetfootprint_meta_filename = 'footprint_parquet_meta.json'
[docs] event_defintion_filename = 'event_definition.parquet'
[docs] hazard_case_filename = 'hazard_case.parquet'
[docs] FootprintHeader = nb.from_dtype(np.dtype([('num_intensity_bins', np.int32), ('has_intensity_uncertainty', np.int32) ]))
[docs] Event = nb.from_dtype(np.dtype([('areaperil_id', areaperil_int), ('intensity_bin_id', np.int32), ('probability', oasis_float) ]))
[docs] EventCSV = nb.from_dtype(np.dtype([('event_id', np.int32), ('areaperil_id', areaperil_int), ('intensity_bin_id', np.int32), ('probability', oasis_float) ]))
[docs] EventIndexBin = nb.from_dtype(np.dtype([('event_id', np.int32), ('offset', np.int64), ('size', np.int64) ]))
[docs] EventIndexBinZ = nb.from_dtype(np.dtype([('event_id', np.int32), ('offset', np.int64), ('size', np.int64), ('d_size', np.int64) ]))
[docs] Index_type = nb.from_dtype(np.dtype([('start', np.int64), ('end', np.int64) ]))
[docs] Vulnerability = nb.from_dtype(np.dtype([('vulnerability_id', np.int32), ('intensity_bin_id', np.int32), ('damage_bin_id', np.int32), ('probability', oasis_float) ]))
[docs] Item = nb.from_dtype(np.dtype([('id', np.int32), ('coverage_id', np.int32), ('areaperil_id', areaperil_int), ('vulnerability_id', np.int32), ('group_id', np.int32) ]))
[docs] Event_defintion = nb.from_dtype(np.dtype([('section_id', np.int32), ('return_period', np.int32), ('rp_from', np.int32), ('rp_to', np.int32), ('interpolation', np.int32) ]))
[docs] Hazard_case = nb.from_dtype(np.dtype([('section_id', np.int32), ('areaperil_id', areaperil_int), ('return_period', np.int32), ('intensity', np.int32) ]))
[docs] Keys = {'LocID': np.int32, 'PerilID': 'category', 'CoverageTypeID': np.int32, 'AreaPerilID': areaperil_int, 'VulnerabilityID': np.int32}