import numba as nb
import numpy as np
from oasislmf.pytools.common.data import areaperil_int, oasis_float
# gul stream type
# probably need to set this dynamically depending on the stream type
[docs]
Item = nb.from_dtype(np.dtype([('item_id', np.int32),
('coverage_id', np.int32),
('areaperil_id', areaperil_int),
('vulnerability_id', np.int32),
('group_id', np.int32)
]))
[docs]
ItemAdjustment = nb.from_dtype(np.dtype([('item_id', np.int32),
('intensity_adjustment', np.int32),
('return_period', np.int32)
]))
[docs]
items_data_type = nb.from_dtype(np.dtype([('item_id', np.int32),
('damagecdf_i', np.int32),
('rng_index', np.int32)
]))
[docs]
items_MC_data_type = nb.from_dtype(np.dtype([('item_id', np.int32),
('item_idx', np.int32),
('hazcdf_i', np.int32),
('rng_index', np.int32),
('hazard_rng_index', np.int32),
('intensity_adjustment', np.int32),
('return_period', np.int32)
]))
[docs]
VulnCdfLookup = nb.from_dtype(np.dtype([('start', np.int32),
('length', np.int32)]))
[docs]
coverage_type = nb.from_dtype(np.dtype([('tiv', np.float64),
('max_items', np.int32),
('start_items', np.int32),
('cur_items', np.int32)
]))
[docs]
ITEM_MAP_KEY_TYPE = nb.types.Tuple((nb.from_dtype(areaperil_int), nb.types.int32))
# ITEM_MAP_VALUE_TYPE = nb.types.UniTuple(nb.types.int32, 1)
[docs]
ITEM_MAP_VALUE_TYPE = nb.types.int64
[docs]
AREAPERIL_TO_EFF_VULN_KEY_TYPE = nb.types.Tuple((nb.from_dtype(areaperil_int), nb.types.int64))
[docs]
AREAPERIL_TO_EFF_VULN_VALUE_TYPE = nb.types.UniTuple(nb.types.int32, 2)
# compute the relative size of oasis_float and areaperil_int vs int32
[docs]
oasis_float_to_int32_size = oasis_float.itemsize // np.int32().itemsize
[docs]
areaperil_int_to_int32_size = areaperil_int.itemsize // np.int32().itemsize
[docs]
haz_cdf_type = nb.from_dtype(np.dtype([('probability', oasis_float),
('intensity_bin_id', np.int32)]))
[docs]
ProbMean = nb.from_dtype(np.dtype([('prob_to', oasis_float),
('bin_mean', oasis_float)
]))
[docs]
ProbMean_size = ProbMean.size
[docs]
damagecdfrec_stream = nb.from_dtype(np.dtype([('event_id', np.int32),
('areaperil_id', areaperil_int),
('vulnerability_id', np.int32)
]))
[docs]
damagecdfrec = nb.from_dtype(np.dtype([('areaperil_id', areaperil_int),
('vulnerability_id', np.int32)
]))
[docs]
gulSampleslevelRec = nb.from_dtype(np.dtype([('sidx', 'i4'),
('loss', oasis_float),
]))
[docs]
gulSampleslevelRec_size = gulSampleslevelRec.size
[docs]
Keys = {'LocID': np.int32,
'PerilID': 'category',
'CoverageTypeID': np.int32,
'AreaPerilID': areaperil_int,
'VulnerabilityID': np.int32}
[docs]
NormInversionParameters = nb.from_dtype(np.dtype([('x_min', np.float32),
('x_max', np.float32),
('N', np.int32),
('cdf_min', np.float32),
('cdf_max', np.float32),
]))