Skip to content

Commit

Permalink
Merge pull request #8870 from gem/cond_gmfs
Browse files Browse the repository at this point in the history
Fixed another bug with conditioned GMFs
  • Loading branch information
micheles committed Jun 27, 2023
2 parents 422fda9 + 683cae0 commit a68c660
Show file tree
Hide file tree
Showing 10 changed files with 781 additions and 2 deletions.
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[Michele Simionato]
* Fixed another bug with conditioned GMFs appearing as the error
`array[m, n, bad] = exp(mean_covs[0, g, m, n], im)
TypeError: list indices must be integers or slices, not tuple`

[Claudio Schill]
* Fixed sorting bug in the sigma_mu adjustment factor in
the Kuehn et al. (2020) GMM
Expand Down
9 changes: 8 additions & 1 deletion openquake/calculators/tests/scenario_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from openquake.qa_tests_data.scenario import (
case_1, case_2, case_3, case_4, case_5, case_6, case_7, case_8,
case_9, case_10, case_11, case_12, case_13, case_14, case_15, case_16,
case_17, case_18, case_19, case_20, case_21, case_22, case_23, case_24)
case_17, case_18, case_19, case_20, case_21, case_22, case_23, case_24,
case_26)
from openquake.baselib.general import gettemp
from openquake.hazardlib import InvalidFile, nrml
from openquake.calculators.export import export
Expand Down Expand Up @@ -265,3 +266,9 @@ def test_case_24(self):
self.run_calc(case_24.__file__, 'job.ini')
[f] = export(('avg_gmf', 'csv'), self.calc.datastore)
self.assertEqualFiles('expected/avg_gmf.csv', f)

def test_case_26(self):
# conditioned GMFs with extreme_gmv
self.run_calc(case_26.__file__, 'job.ini')
[f] = export(('avg_gmf', 'csv'), self.calc.datastore)
self.assertEqualFiles('expected/avg_gmf.csv', f)
3 changes: 2 additions & 1 deletion openquake/hazardlib/calc/conditioned_gmfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def compute_all(self, scenario, sig_eps=None, max_iml=None):
if (array[m] > max_iml[m]).any():
for n in range(N):
bad = array[m, n] > max_iml[m] # shape E
array[m, n, bad] = exp(mean_covs[0, g, m, n], im)
mean = mean_covs[0][im] # shape (N, 1)
array[m, n, bad] = exp(mean[n, 0], im)

# manage min_iml
for n in range(N):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<nrml xmlns:gml="http://www.opengis.net/gml" xmlns="http://openquake.org/xmlns/nrml/0.4">
<singlePlaneRupture>
<magnitude>5.7</magnitude>
<rake>-156</rake>
<hypocenter lat="41.8" lon="14.88" depth="15"/>
<planarSurface strike="263" dip="86">
<topLeft lon="14.93542" lat="41.80316" depth="12.00145"/>
<topRight lon="14.82521" lat="41.79307" depth="12.00145"/>
<bottomLeft lon="14.93480" lat="41.80690" depth="17.99855"/>
<bottomRight lon="14.82459" lat="41.79681" depth="17.99855"/>
</planarSurface>
</singlePlaneRupture>
</nrml>
359 changes: 359 additions & 0 deletions openquake/qa_tests_data/scenario/case_26/expected/avg_gmf.csv

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions openquake/qa_tests_data/scenario/case_26/job.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[general]
description = 20021101_M5.72_Molise gmfs - GEMbest + GCMT, stations: seismic
calculation_mode = scenario

[site_params]
site_model_file = site_model_europe.csv site_model_stations_europe.csv

[station_data]
station_data_file = stationlist_seismic.csv

[rupture]
rupture_model_file = earthquake_rupture_model_GCMT.xml
rupture_mesh_spacing = 2.0

[calculation]
intensity_measure_types = PGA, SA(0.3), SA(0.6), SA(1.0)
random_seed = 42
truncation_level = 3.0
maximum_distance = 300
gsim = AkkarEtAlRjb2014
number_of_ground_motion_fields = 1000
extreme_gmv = {"PGA": 2.5, "SA(0.3)": 3.5, "SA(0.6)": 3.0, "SA(1.0)": 1.5}
347 changes: 347 additions & 0 deletions openquake/qa_tests_data/scenario/case_26/site_model_europe.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lon,lat,slope,vs30,geology,xvf,region,vs30measured,custom_site_id
13.42593,42.02746,0.018701343,348.21295,HOLOCENE,-129.50730850744876,3,0,s_0
14.14781,42.36983,0.029801892,419.65768,PLEISTOCENE,-61.95392025911484,2,0,s_1
14.44984,41.86832,0.11060915,617.0962,CENOZOIC,-52.71360413236034,2,0,s_2
14.75668,41.50907,0.078881994,623.4191,CRETACEOUS,-38.56973806294744,3,0,s_3
13.51936,42.42069,0.085941836,725.9243,CRETACEOUS,-110.11034098686378,3,0,s_4
13.55,42.46,0.21504244,898.5033,JURASSIC-TRIASSIC,-106.49528965425012,3,0,s_5
13.09242,42.79244,0.077045344,611.5537,PLEISTOCENE,-132.2632142788214,3,0,s_6
13.64235,41.95361,0.007360887,350.6723,HOLOCENE,-114.5507794138697,3,0,s_7
14.88045,41.30636,0.09018347,612.67035,CENOZOIC,-34.44019047004751,3,0,s_8
15.38574,41.68116,0.014401777,316.48657,PLEISTOCENE,16.89847743670429,2,0,s_9
14.70719,42.12218,0.021811597,460.58032,PLEISTOCENE,-24.796579357148754,2,0,s_10
12 changes: 12 additions & 0 deletions openquake/qa_tests_data/scenario/case_26/stationlist_seismic.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
STATION_ID,STATION_NAME,LONGITUDE,LATITUDE,STATION_TYPE,PGA_VALUE,PGA_LN_SIGMA,SOIL_TYPE,VS30,VS30_TYPE,VS30_USGS
AVZ,AVEZZANO,13.425929,42.027458,seismic,0.003669,0,C,199.0,C,230.0
CHT,CHIETI,14.147809,42.369827,seismic,0.007813,0,B (inferred from geology),596.0,inferred_USGS,596.0
CMM,CASTIGLIONE MESSER MARINO,14.44984,41.86832,seismic,0.006892,0,B (inferred from geology),996.0,inferred_USGS,996.0
GLD,GILDONE,14.756682,41.509072,seismic,0.018126,0,B,472.0,B,985.0
GSA,GRAN SASSO LAB. INFN ASSERGI,13.519362,42.420689,seismic,0.001169,0,B,492.0,B,239.0
GSG,GRAN SASSO (LAB. INFN GALLERIA),13.55,42.46,seismic,0.000298,0,B (inferred from geology),1000.0,inferred_USGS,1000.0
NOR,NORCIA LA CASTELLINA,13.092422,42.792442,seismic,0.001594,0,B,423.0,B,788.0
ORC,ORTUCCHIO NUOVA,13.642346,41.953606,seismic,0.003103,0,B,767.0,B,231.0
SCV,S. MARCO DEI CAVOTI,14.880446,41.306362,seismic,0.004566,0,B (inferred from geology),1000.0,inferred_USGS,1000.0
SSV,S. SEVERO,15.385745,41.68116,seismic,0.024585,0,B,386.0,B,595.0
VSE,VASTO (EUROPA),14.707188,42.12218,seismic,0.032413,0,B (inferred from geology),598.0,inferred_USGS,598.0

0 comments on commit a68c660

Please sign in to comment.