Skip to content

Commit

Permalink
Fixed extract gmf_data
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 14, 2024
1 parent cb62330 commit 790403c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 2 additions & 3 deletions openquake/calculators/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,8 @@ def extract_gmf_npz(dstore, what):
# zero GMF
yield 'rlz-%03d' % rlzi, []
else:
imts = list(oq.imtls)
sec_imts = oq.sec_imts
gmfa = _gmf(df, n, imts, sec_imts)
prim_imts = list(oq.get_primary_imtls())
gmfa = _gmf(df, n, prim_imts, oq.sec_imts)
yield 'rlz-%03d' % rlzi, util.compose_arrays(sites, gmfa)


Expand Down
8 changes: 7 additions & 1 deletion openquake/calculators/tests/multi_risk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ def test_case_1(self):
# case with volcanic multiperil ASH, LAVA, LAHAR, PYRO
self.run_calc(case_1.__file__, 'job.ini')

# check extract
# check extract gmf_data, called by QGIS
aw = extract(self.calc.datastore, 'gmf_data?event_id=0')
ae(len(aw['rlz-000']), 173)
ae(aw['rlz-000'].dtype.names,
('custom_site_id', 'lon', 'lat', 'ASH', 'LAVA', 'LAHAR', 'PYRO'))

# check extract exposure_metadata
md = json.loads(extract(self.calc.datastore, 'exposure_metadata').json)
ae(md['names'], ['value-number', 'value-structural', 'occupants_night'])
ae(md['multi_risk'], ['collapse-structural-ASH_DRY',
Expand Down
6 changes: 4 additions & 2 deletions openquake/commonlib/oqvalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1697,9 +1697,8 @@ def get_primary_imtls(self):
"""
:returns: IMTs and levels which are not secondary
"""
sec_imts = set(self.sec_imts) or self.inputs.get('multi_peril', ())
return {imt: imls for imt, imls in self.imtls.items()
if imt not in sec_imts}
if imt not in self.sec_imts}

def hmap_dt(self): # used for CSV export
"""
Expand Down Expand Up @@ -1840,6 +1839,9 @@ def sec_imts(self):
"""
:returns: a list of secondary outputs
"""
mp = self.inputs.get('multi_peril', ())
if mp:
return list(mp) # ASH, PYRO, etc
outs = []
for sp in self.get_sec_perils():
outs.extend(sp.outputs)
Expand Down
1 change: 1 addition & 0 deletions openquake/hazardlib/gsim/abrahamson_2014.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def get_epistemic_sigma(ctx):

return sigma_epi


class AbrahamsonEtAl2014(GMPE):
"""
Implements GMPE by Abrahamson, Silva and Kamai developed within the
Expand Down

0 comments on commit 790403c

Please sign in to comment.