Skip to content

Commit

Permalink
Merge pull request #8958 from gem/hdf5
Browse files Browse the repository at this point in the history
Fixing the usual HDF5 error
  • Loading branch information
micheles authored Aug 28, 2023
2 parents 7414043 + 6d24c6f commit ac2c4b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openquake/commonlib/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,18 @@ def starmap_from_gmfs(task_func, oq, dstore):
if 'site_model' in ds:
N = max(N, len(ds['site_model']))
num_assets = get_counts(dstore['assetcol/array']['site_id'], N)
def weight(rec, dset=dstore['gmf_data/sid']):
sids = dstore['gmf_data/sid'][:]
def weight(rec):
s0, s1 = rec['start'], rec['stop']
w = num_assets[dset[s0:s1]].sum()
w = num_assets[sids[s0:s1]].sum()
return w

data = ds['gmf_data']
try:
sbe = data['slice_by_event'][:]
except KeyError:
sbe = build_slice_by_event(data['eid'][:])
dstore.swmr_on()
smap = parallel.Starmap.apply(
task_func, (sbe, oq, ds),
maxweight=A*10, weight=weight,
Expand Down

0 comments on commit ac2c4b6

Please sign in to comment.