Skip to content

Commit

Permalink
Merge pull request #9179 from gem/insured
Browse files Browse the repository at this point in the history
Fixed insured losses larger than ground losses
  • Loading branch information
micheles authored Nov 3, 2023
2 parents 0713744 + e9591f9 commit 9422898
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
2 changes: 2 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[Michele Simionato]
* Fixed a bug causing the insured losses to be larger than the
ground losses in some cases
* Added command `oq info executing`
* Added `extract/relevant_gmfs?threshold=` functionality
* Added `extract/ruptures?threshold=` functionality
Expand Down
2 changes: 1 addition & 1 deletion openquake/risklib/scientific.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ def _agg(loss_dfs, weights=None):
for loss_df, w in zip(loss_dfs, weights):
loss_df['variance'] *= w
loss_df['loss'] *= w
return pandas.concat(loss_dfs).groupby(['eid', 'aid']).sum().reset_index()
return pandas.concat(loss_dfs).groupby(['aid', 'eid']).sum().reset_index()


class RiskComputer(dict):
Expand Down
43 changes: 22 additions & 21 deletions openquake/sep/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
import abc
import inspect
from openquake.hazardlib import imt
from openquake.sep.landslide.common import static_factor_of_safety, rock_slope_static_factor_of_safety
from openquake.sep.landslide.common import (
static_factor_of_safety, rock_slope_static_factor_of_safety)
from openquake.sep.landslide.newmark import (
newmark_critical_accel,
newmark_displ_from_pga_M,
prob_failure_given_displacement,
)
prob_failure_given_displacement)
from openquake.sep.landslide.rockfalls import (
critical_accel_rock_slope,
newmark_displ_from_pga
)
newmark_displ_from_pga)
from openquake.sep.liquefaction.liquefaction import (
hazus_liquefaction_probability,
zhu_etal_2015_general,
Expand All @@ -39,16 +38,12 @@
akhlagi_etal_2021_model_b,
bozzoni_etal_2021_europe,
todorovic_silva_2022_nonparametric_general,
HAZUS_LIQUEFACTION_PGA_THRESHOLD_TABLE,
)
HAZUS_LIQUEFACTION_PGA_THRESHOLD_TABLE)
from openquake.sep.liquefaction.lateral_spreading import (
hazus_lateral_spreading_displacement
)

hazus_lateral_spreading_displacement)
from openquake.sep.liquefaction.vertical_settlement import (
hazus_vertical_settlement,
HAZUS_VERT_SETTLEMENT_TABLE
)
hazus_vertical_settlement)


class SecondaryPeril(metaclass=abc.ABCMeta):
"""
Expand Down Expand Up @@ -227,7 +222,8 @@ class ZhuEtAl2015LiquefactionGeneral(SecondaryPeril):
"""
outputs = ["LiqProb","LiqOccur"]

def __init__(self, intercept=24.1, pgam_coeff=2.067, cti_coeff=0.355, vs30_coeff=-4.784):
def __init__(self, intercept=24.1, pgam_coeff=2.067, cti_coeff=0.355,
vs30_coeff=-4.784):
self.intercept = intercept
self.pgam_coeff = pgam_coeff
self.cti_coeff = cti_coeff
Expand All @@ -254,8 +250,8 @@ class ZhuEtAl2017LiquefactionCoastal(SecondaryPeril):
"""
outputs = ["LiqProb","LiqOccur","LSE"]

def __init__(self, intercept=12.435, pgv_coeff=0.301, vs30_coeff=-2.615,
dr_coeff=0.0666, dc_coeff=-0.0287, dcdr_coeff = -0.0369,
def __init__(self, intercept=12.435, pgv_coeff=0.301, vs30_coeff=-2.615,
dr_coeff=0.0666, dc_coeff=-0.0287, dcdr_coeff = -0.0369,
precip_coeff=0.0005556):
self.intercept = intercept
self.pgv_coeff = pgv_coeff
Expand Down Expand Up @@ -389,7 +385,9 @@ def compute(self, mag, imt_gmf, sites):
continue
# Raise error if either PGA or PGV is missing
if pga is None or pgv is None:
raise ValueError("Both PGA and PGV are required to compute liquefaction probability using the AllstadtEtAl2022Liquefaction model")
raise ValueError(
"Both PGA and PGV are required to compute liquefaction "
"probability using the AllstadtEtAl2022Liquefaction model")

prob_liq, out_class, lse = allstadt_etal_2022(
pga=pga, pgv=pgv, mag=mag, vs30=sites.vs30, dw=sites.dw,
Expand Down Expand Up @@ -471,7 +469,8 @@ class Bozzoni2021LiquefactionEurope(SecondaryPeril):
"""
outputs = ["LiqProb","LiqOccur"]

def __init__(self, intercept=-11.489, pgam_coeff=3.864, cti_coeff=2.328, vs30_coeff=-0.091):
def __init__(self, intercept=-11.489, pgam_coeff=3.864, cti_coeff=2.328,
vs30_coeff=-0.091):
self.intercept = intercept
self.pgam_coeff = pgam_coeff
self.cti_coeff = cti_coeff
Expand Down Expand Up @@ -512,11 +511,13 @@ def compute(self, mag, imt_gmf, sites):
out = []
for im, gmf in imt_gmf:
if im.string == 'PGV':
out_class, out_prob = todorovic_silva_2022_nonparametric_general(
pgv=gmf, vs30=sites.vs30, dw=sites.dw, wtd=sites.gwd, precip=sites.precip)
out_class, out_prob = \
todorovic_silva_2022_nonparametric_general(
pgv=gmf, vs30=sites.vs30, dw=sites.dw,
wtd=sites.gwd, precip=sites.precip)
out.append(out_class)
out.append(out_prob)
return out


supported = [cls.__name__ for cls in SecondaryPeril.__subclasses__()]
supported = [cls.__name__ for cls in SecondaryPeril.__subclasses__()]

0 comments on commit 9422898

Please sign in to comment.