Skip to content

Commit

Permalink
Merge pull request #10096 from gem/case_22
Browse files Browse the repository at this point in the history
Temporarily using the mean damage distribution
  • Loading branch information
micheles authored Oct 26, 2024
2 parents 09db3ec + a88adbe commit 09a7a54
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 232 deletions.
14 changes: 5 additions & 9 deletions openquake/calculators/event_based_damage.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ def _gen_dd3(asset_df, gmf_df, crmodel, dparam):
else:
loss_types = {lt: i for i, lt in enumerate(oq.loss_types)}
if L > 1:
# compose probabilities
dd3 = numpy.zeros((A, E, dparam.Dc), F32)
for a in range(A):
dd3[a] = general.pprod(dd4[:, a] / number[a], axis=0) * number[a]
# compose damage distribution
dd3 = dd4.mean(axis=0)
else:
dd3 = dd4[0]
csq = crmodel.compute_csq(
Expand Down Expand Up @@ -303,12 +301,10 @@ def post_execute(self, dummy):
D = len(self.crmodel.damage_states)
# fix no_damage distribution for events with zero damage
number = self.assetcol['value-number']
L = len(oq.loss_types)
for r in range(self.R):
ne = prc.num_events[r]
self.dmgcsq[:, r, 0] = ( # no damage
number * ne * L - self.dmgcsq[:, r, 1:D].sum(axis=1))
self.dmgcsq[:, r] /= (ne * L)
self.dmgcsq[:, r] /= prc.num_events[r]
self.dmgcsq[:, r, 0] = number - self.dmgcsq[:, r, 1:D].sum(axis=1)

assert (self.dmgcsq >= 0).all() # sanity check
self.datastore['damages-rlzs'] = self.dmgcsq
set_rlzs_stats(self.datastore,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#,,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitafc5cab7ae', start_date='2024-10-26T05:43:19', checksum=2614000066, investigation_time=None, risk_investigation_time=None"
#,,,,,,,,,"generated_by='OpenQuake engine 3.22.0-git09db3ec359', start_date='2024-10-26T07:40:24', checksum=2614000066, investigation_time=None, risk_investigation_time=None"
loss_type,parent_id,rlz_id,no_damage,slight,moderate,extensive,complete,non_operational_value,non_operational_ratio
structural,A,0,9.66667E-01,0.00000E+00,0.00000E+00,0.00000E+00,1.00000E-01,1.00000E-01,1.00000E-01
structural,A,1,9.33333E-01,0.00000E+00,0.00000E+00,0.00000E+00,2.00000E-01,2.00000E-01,2.00000E-01
structural,A,0,9.88889E-01,0.00000E+00,0.00000E+00,0.00000E+00,3.33333E-02,1.00000E-01,1.00000E-01
structural,A,1,9.77778E-01,0.00000E+00,0.00000E+00,0.00000E+00,6.66667E-02,2.00000E-01,2.00000E-01
structural,B,0,1.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00
structural,B,1,1.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00,0.00000E+00
structural,E1,0,6.66667E-01,0.00000E+00,0.00000E+00,0.00000E+00,1.00000E+00,3.00000E+00,3.00000E+00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitafc5cab7ae', start_date='2024-10-26T05:43:19', checksum=2614000066, investigation_time=None, risk_investigation_time=None"
#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-git09db3ec359', start_date='2024-10-26T07:40:24', checksum=2614000066, investigation_time=None, risk_investigation_time=None"
loss_type,rlz_id,no_damage,slight,moderate,extensive,complete,non_operational_value,non_operational_ratio
structural,0,2.63333E+00,0.00000E+00,0.00000E+00,0.00000E+00,1.10000E+00,3.10000E+00,1.03333E+00
structural,1,2.60000E+00,0.00000E+00,0.00000E+00,0.00000E+00,1.20000E+00,3.20000E+00,1.06667E+00
structural,0,2.65556E+00,0.00000E+00,0.00000E+00,0.00000E+00,1.03333E+00,3.10000E+00,1.03333E+00
structural,1,2.64444E+00,0.00000E+00,0.00000E+00,0.00000E+00,1.06667E+00,3.20000E+00,1.06667E+00
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitafc5cab7ae', start_date='2024-10-26T05:43:19', checksum=4025559538, investigation_time=None, risk_investigation_time=None"
#,,,,,,,"generated_by='OpenQuake engine 3.22.0-git09db3ec359', start_date='2024-10-26T07:40:25', checksum=4025559538, investigation_time=None, risk_investigation_time=None"
loss_type,no_damage,slight,moderate,extreme,complete,losses_value,losses_ratio
structural,1.17053E+01,1.41803E+00,1.39786E+00,9.49061E-01,6.11920E+00,1.84217E+04,1.08299E-01
structural,1.35885E+01,4.72676E-01,4.65954E-01,3.16354E-01,2.97940E+00,1.84217E+04,1.08299E-01
24 changes: 12 additions & 12 deletions openquake/qa_tests_data/scenario_damage/case_22/expected/dmg.csv
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#,,,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitafc5cab7ae', start_date='2024-10-26T05:43:19', checksum=4025559538"
#,,,,,,,,,,"generated_by='OpenQuake engine 3.22.0-git09db3ec359', start_date='2024-10-26T07:40:25', checksum=4025559538"
asset_id,NAME_1,taxonomy,lon,lat,no_damage,slight,moderate,extreme,complete,losses
a1,a,Wood1,83.31382,29.46117,9.267137E-01,4.338550E-02,2.389134E-02,4.983467E-03,1.026009E-03,1.492097E+02
a2,a,Wood1,83.31382,29.23617,9.323701E-01,4.003692E-02,2.204736E-02,4.598836E-03,9.468218E-04,1.376935E+02
a3,a,Wood1,83.53882,29.08617,8.998597E-01,5.549773E-02,3.362454E-02,8.460126E-03,2.557830E-03,2.299460E+02
a1,a,Wood1,83.31382,29.46117,9.267137E-01,4.338550E-02,2.389134E-02,4.983469E-03,1.026009E-03,4.476292E+02
a2,a,Wood1,83.31382,29.23617,9.323701E-01,4.003693E-02,2.204736E-02,4.598836E-03,9.468192E-04,4.130804E+02
a3,a,Wood1,83.53882,29.08617,8.998598E-01,5.549773E-02,3.362455E-02,8.460126E-03,2.557828E-03,6.898380E+02
a4,a,Wood1,80.68882,28.93617,1.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00
a5,a,Wood1,83.53882,29.01117,8.605580E-01,7.386524E-02,4.770378E-02,1.326893E-02,4.604037E-03,3.436947E+02
a5,a,Wood1,83.53882,29.01117,8.605580E-01,7.386523E-02,4.770378E-02,1.326894E-02,4.604037E-03,1.031084E+03
a6,a,Wood1,81.13882,28.78617,1.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00
a7,a,Wood1,83.98882,28.48617,7.524759E-01,8.566736E-02,8.970005E-02,4.155788E-02,3.059878E-02,9.213160E+02
a8,a,Concrete1,83.23882,29.38617,5.814353E-01,2.247916E-02,3.195053E-02,3.080165E-02,3.333333E-01,5.401368E+02
a9,a,Concrete1,83.01382,29.08617,5.764725E-01,2.497276E-02,3.440397E-02,3.081745E-02,3.333333E-01,5.061439E+02
a10,a,Concrete1,83.31382,28.71117,4.975556E-01,4.471088E-02,6.344895E-02,6.095122E-02,3.333333E-01,1.065684E+03
a11,a,Concrete1,86.91382,27.73617,6.157925E-01,1.408595E-02,1.940564E-02,1.738266E-02,3.333333E-01,2.854917E+02
a12,a,Concrete1,83.16382,29.31117,5.906469E-01,2.104818E-02,2.899724E-02,2.597436E-02,3.333333E-01,4.266012E+02
a7,a,Wood1,83.98882,28.48617,7.521410E-01,8.566736E-02,8.970004E-02,4.155788E-02,3.093375E-02,2.763948E+03
a8,a,Concrete1,83.23882,29.38617,4.697937E-01,2.247916E-02,3.195053E-02,3.080165E-02,4.449750E-01,1.620410E+03
a9,a,Concrete1,83.01382,29.08617,4.619936E-01,2.497276E-02,3.440396E-02,3.081745E-02,4.478122E-01,1.518432E+03
a10,a,Concrete1,83.31382,28.71117,1.616083E-01,4.471088E-02,6.344895E-02,6.095121E-02,6.692806E-01,3.197053E+03
a11,a,Concrete1,86.91382,27.73617,6.076256E-01,1.408595E-02,1.940564E-02,1.738266E-02,3.415002E-01,8.564750E+02
a12,a,Concrete1,83.16382,29.31117,5.451101E-01,2.104818E-02,2.899723E-02,2.597436E-02,3.788701E-01,1.279804E+03
a13,a,Concrete1,80.61382,28.93617,1.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00
a14,a,Concrete1,83.91382,29.01117,4.714025E-01,4.692676E-02,7.078026E-02,7.755719E-02,3.333333E-01,1.534645E+03
a14,a,Concrete1,83.91382,29.01117,1.478412E-01,4.692677E-02,7.078026E-02,7.755719E-02,6.568946E-01,4.603935E+03
a15,a,Concrete1,82.03882,30.28617,1.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00,0.000000E+00
Loading

0 comments on commit 09a7a54

Please sign in to comment.