Skip to content

Commit

Permalink
Restored accidental change
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 18, 2024
1 parent 438f662 commit e9760af
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions openquake/calculators/export/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ def modal_damage_array(data, dstates):
acc = general.AccumDict(accum=[])
for name in data.dtype.names: # peril-ltype-dstate
try:
peril, ltype, _dstate = name.split('~')
peril, ltype, _dstate = name.split('-')
modal = f'modal-ds-{peril}~{ltype}'
except ValueError:
ltype, _dstate = name.split('~')
ltype, _dstate = name.split('-')
modal = 'modal-ds-' + ltype
if ltype != 'no_damage':
acc[modal].append(data[name])
Expand Down Expand Up @@ -437,8 +437,8 @@ def export_damages_csv(ekey, dstore):
else:
damages = orig[:, i]
fname = dstore.build_fname(name, ros, ekey[1])
writer.save(compose_arrays(assets, damages), fname,
comment=md, renamedict=dict(id='asset_id'))
arr = compose_arrays(assets, damages)
writer.save(arr, fname, comment=md, renamedict=dict(id='asset_id'))
return writer.getsaved()


Expand Down
2 changes: 1 addition & 1 deletion openquake/calculators/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def _dmg_get(array, loss_type):
out = []
for name in array.dtype.names:
try:
ltype, _dstate = name.split('~')
ltype, _dstate = name.split('-')
except ValueError:
# ignore secondary perils
continue
Expand Down
2 changes: 1 addition & 1 deletion openquake/calculators/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def view_portfolio_dmgdist(token, dstore):
sums = sum_records(dstore['damages-rlzs'][:, 0])
acc = AccumDict(accum=[])
for name in sums.dtype.names:
ltype, dstate = name.split('~')
ltype, dstate = name.split('-')
acc[dstate].append(sums[name][0])
if dstate == 'no_damage':
acc['loss_type'].append(ltype)
Expand Down
4 changes: 2 additions & 2 deletions openquake/risklib/riskmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ def multi_damage_dt(self):
for ltype in self.oqparam.loss_types:
for dc in dcs:
if peril == 'earthquake':
field = f'{ltype}~{dc}'
field = f'{ltype}-{dc}'
else:
field = f'{peril}~{ltype}~{dc}'
field = f'{peril}-{ltype}-{dc}'
lst.append((field, F32))
return numpy.dtype(lst)

Expand Down

0 comments on commit e9760af

Please sign in to comment.