Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into more-infra-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ptormene committed Jul 17, 2023
2 parents ae3a03f + 2fe0c91 commit 368eafb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
19 changes: 12 additions & 7 deletions openquake/calculators/event_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,19 @@ def event_based(proxies, cmaker, dstore, monitor):
if sum(len(df) for df in alldata):
gmfdata = strip_zeros(pandas.concat(alldata))
else:
gmfdata = ()
gmfdata = {}
times = numpy.array([tup + (monitor.task_no,) for tup in times], rup_dt)
times.sort(order='rup_id')
if not oq.ground_motion_fields:
gmfdata = ()
return dict(gmfdata=gmfdata, times=times,
gmfdata = {}
return dict(gmfdata=todict(gmfdata), times=times,
sig_eps=numpy.array(sig_eps, se_dt))

def todict(dframe):
if len(dframe) == 0:
return {}
return {k: dframe[k].to_numpy() for k in dframe.columns}


def starmap_from_rups(func, oq, full_lt, sitecol, dstore, save_tmp=None):
"""
Expand Down Expand Up @@ -456,12 +461,12 @@ def agg_dicts(self, acc, result):
if result is None: # instead of a dict
raise MemoryError('You ran out of memory!')
sav_mon = self.monitor('saving gmfs')
agg_mon = self.monitor('aggregating hcurves')
primary = self.oqparam.get_primary_imtls()
sec_imts = self.oqparam.get_sec_imts()
with sav_mon:
df = result.pop('gmfdata')
if len(df):
gmfdata = result.pop('gmfdata')
if len(gmfdata):
df = pandas.DataFrame(gmfdata)
dset = self.datastore['gmf_data/sid']
times = result.pop('times')
hdf5.extend(self.datastore['gmf_data/rup_info'], times)
Expand Down Expand Up @@ -644,7 +649,7 @@ def post_execute(self, dummy):
if self.datastore.parent:
self.datastore.parent.open('r')
if oq.hazard_curves_from_gmfs:
if size > 1E6:
if size > 4E6:
msg = 'gmf_data has {:_d} rows'.format(size)
raise RuntimeError(f'{msg}: too big to compute the hcurves')
build_hcurves(self)
3 changes: 2 additions & 1 deletion openquake/calculators/event_based_risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def ebrisk(proxies, cmaker, dstore, monitor):
dic = event_based.event_based(proxies, cmaker, dstore, monitor)
if len(dic['gmfdata']) == 0: # no GMFs
return {}
return event_based_risk(dic['gmfdata'], cmaker.oq, monitor)
gmf_df = pandas.DataFrame(dic['gmfdata'])
return event_based_risk(gmf_df, cmaker.oq, monitor)


@base.calculators.add('ebrisk', 'scenario_risk', 'event_based_risk')
Expand Down

0 comments on commit 368eafb

Please sign in to comment.