diff --git a/debian/changelog b/debian/changelog index e7fa26361b20..b0d630e8c654 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,8 +13,7 @@ * Raised an error in case of non-invertible hazard curves, affecting disaggregation and site-specific hazard spectrum calculations * Changed the ruptures.csv exporter to also export the source IDs - * Specifying total_losses is now mandatory in damage calculations with - multiple loss types + * Restricted damage calculations to a single loss type * Added support for consequence=losses for liquefaction and landslides * Added a check for missing secondary perils * Added loss types liquefaction and landslide diff --git a/openquake/calculators/classical_bcr.py b/openquake/calculators/classical_bcr.py index 2d1bd4c16669..1d700a525820 100644 --- a/openquake/calculators/classical_bcr.py +++ b/openquake/calculators/classical_bcr.py @@ -49,7 +49,7 @@ def classical_bcr(riskinputs, param, monitor): for taxo, assets in ri.asset_df.groupby('taxonomy'): for rlz in range(R): hcurve = haz[:, rlz] - out = crmodel.get_output(assets, hcurve) + [out] = crmodel.get_outputs(assets, hcurve) for asset, (eal_orig, eal_retro, bcr) in zip( assets.to_records(), out['structural']): aval = asset['value-structural'] diff --git a/openquake/calculators/classical_damage.py b/openquake/calculators/classical_damage.py index 8c67cf0b8a4b..90fc6a06a4e6 100644 --- a/openquake/calculators/classical_damage.py +++ b/openquake/calculators/classical_damage.py @@ -39,7 +39,7 @@ def classical_damage(riskinputs, param, monitor): dictionaries asset_ordinal -> damage(R, L, D) """ crmodel = monitor.read('crmodel') - total_loss_types = crmodel.oqparam.total_loss_types + [loss_type] = crmodel.oqparam.total_loss_types mon = monitor('getting hazard', measuremem=False) for ri in riskinputs: R = ri.hazard_getter.R @@ -50,10 +50,9 @@ def classical_damage(riskinputs, param, monitor): for taxo, assets in ri.asset_df.groupby('taxonomy'): for rlz in range(R): hcurve = haz[:, rlz] - out = crmodel.get_output(assets, hcurve) - for loss_type in total_loss_types: - for a, frac in zip(assets.ordinal, out[loss_type]): - result[a][rlz] += frac + [out] = crmodel.get_outputs(assets, hcurve) + for a, frac in zip(assets.ordinal, out[loss_type]): + result[a][rlz] += frac yield result diff --git a/openquake/calculators/classical_risk.py b/openquake/calculators/classical_risk.py index 4cf12bc99883..86faa747327a 100644 --- a/openquake/calculators/classical_risk.py +++ b/openquake/calculators/classical_risk.py @@ -51,7 +51,7 @@ def classical_risk(riskinputs, oqparam, monitor): for taxo, asset_df in ri.asset_df.groupby('taxonomy'): for rlz in range(R): hcurve = haz[:, rlz] - out = crmodel.get_output(asset_df, hcurve) + [out] = crmodel.get_outputs(asset_df, hcurve) for li, loss_type in enumerate(crmodel.loss_types): # loss_curves has shape (A, C) for i, asset in enumerate(asset_df.to_records()): diff --git a/openquake/calculators/event_based_damage.py b/openquake/calculators/event_based_damage.py index db6c68cc2f3b..199cd5b2a573 100644 --- a/openquake/calculators/event_based_damage.py +++ b/openquake/calculators/event_based_damage.py @@ -95,7 +95,7 @@ def _gen_dd3(asset_df, gmf_df, crmodel, dparam, mon): [lt] = oq.loss_types # assume single loss type for taxo, adf in asset_df.groupby('taxonomy'): with mon: - outs = crmodel.get_output(adf, gmf_df) # dicts loss_type -> array + outs = crmodel.get_outputs(adf, gmf_df) # dicts loss_type -> array aids = adf.index.to_numpy() A = len(aids) assets = adf.to_records() diff --git a/openquake/calculators/event_based_risk.py b/openquake/calculators/event_based_risk.py index 7366a9e9ae82..a80b912df593 100644 --- a/openquake/calculators/event_based_risk.py +++ b/openquake/calculators/event_based_risk.py @@ -242,7 +242,7 @@ def gen_outputs(df, crmodel, rng, monitor): if len(gmf_df) == 0: # common enough continue with mon_risk: - [out] = crmodel.get_output( + [out] = crmodel.get_outputs( adf, gmf_df, crmodel.oqparam._sec_losses, rng) yield out diff --git a/openquake/commonlib/oqvalidation.py b/openquake/commonlib/oqvalidation.py index 826fd90da079..5123b69ac918 100644 --- a/openquake/commonlib/oqvalidation.py +++ b/openquake/commonlib/oqvalidation.py @@ -1389,9 +1389,8 @@ def check_risk(self): self.raise_invalid('missing investigation_time') # check total_losses - if ('damage' in self.calculation_mode and len(self.loss_types) > 1 - and not self.total_losses): - self.raise_invalid('you forgot to specify total_losses =') + if 'damage' in self.calculation_mode and len(self.loss_types) > 1: + self.raise_invalid('Only a single loss type is supported') def check_ebrisk(self): # check specific to ebrisk @@ -1641,6 +1640,7 @@ def levels_per_imt(self): """ return self.imtls.size // len(self.imtls) + # called in CompositeRiskModel.init def set_risk_imts(self, risklist): """ :param risklist: diff --git a/openquake/commonlib/readinput.py b/openquake/commonlib/readinput.py index 45ad94aa3691..e5c7ddbaae50 100644 --- a/openquake/commonlib/readinput.py +++ b/openquake/commonlib/readinput.py @@ -969,12 +969,16 @@ def get_imts(oqparam): def _cons_coeffs(df, perils, loss_dt, limit_states): + # returns composite array peril -> loss_type -> coeffs dtlist = [(peril, loss_dt) for peril in perils] coeffs = numpy.zeros(len(limit_states), dtlist) - for lt in loss_dt.names: + for loss_type in loss_dt.names: for peril in perils: - the_df = df[(df.peril == peril) & (df.loss_type == lt)] - coeffs[peril][lt] = the_df[limit_states].to_numpy()[0] + the_df = df[(df.peril == peril) & (df.loss_type == loss_type)] + if len(the_df) == 1: + coeffs[peril][loss_type] = the_df[limit_states].to_numpy()[0] + elif len(the_df) > 1: + raise ValueError(f'Multiple consequences for {loss_type=}, {peril=}\n%s' % the_df) return coeffs @@ -1308,7 +1312,6 @@ def get_pmap_from_csv(oqparam, fnames): imtls[wrapper.imt] = levels_from(wrapper.dtype.names) oqparam.hazard_imtls = imtls oqparam.investigation_time = wrapper.investigation_time - oqparam.set_risk_imts(get_risk_functions(oqparam)) array = wrapper.array mesh = geo.Mesh(array['lon'], array['lat']) N = len(mesh) diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-000.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-000.csv index ea1f67e9dafc..27b833b94f6e 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-000.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-000.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.998277E+00,1.549844E-03,1.528456E-04,-2.386025E-05,4.399191E-05 -a2,tax2,-122.11400,38.11300,1.913250E+00,5.807586E-02,2.242159E-02,4.821683E-03,1.431285E-03 -a5,tax1,-122.00000,37.91000,1.987242E+00,1.067162E-02,1.927039E-03,-1.350661E-04,2.948547E-04 -a4,tax3,-122.00000,38.00000,1.986066E+00,4.290140E-03,8.074959E-03,9.858516E-04,5.835333E-04 -a1,tax1,-122.00000,38.11300,1.694859E+00,2.327103E-01,6.623603E-02,-1.804596E-03,7.999271E-03 -a6,tax2,-122.00000,38.22500,1.938662E+00,3.990732E-02,1.620035E-02,3.745712E-03,1.484197E-03 -a7,tax1,-121.88600,38.11300,1.869867E+00,1.115292E-01,1.705063E-02,-1.693876E-03,3.247469E-03 +a3,tax1,-122.57000,38.11300,9.999696E-01,2.261184E-05,-1.226951E-05,-2.393570E-05,4.399191E-05 +a2,tax2,-122.11400,38.11300,9.322674E-01,4.585588E-02,1.835168E-02,3.067535E-03,4.575377E-04 +a5,tax1,-122.00000,37.91000,9.997233E-01,2.157100E-04,-7.729786E-05,-1.565156E-04,2.948542E-04 +a4,tax3,-122.00000,38.00000,9.923542E-01,4.016777E-03,3.360802E-03,2.034804E-04,6.476747E-05 +a1,tax1,-122.00000,38.11300,9.882498E-01,8.929287E-03,-1.409995E-03,-3.754844E-03,7.985783E-03 +a6,tax2,-122.00000,38.22500,9.489189E-01,3.400429E-02,1.387795E-02,2.599849E-03,5.990231E-04 +a7,tax1,-121.88600,38.11300,9.976006E-01,1.805372E-03,-8.960359E-04,-1.757380E-03,3.247468E-03 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-001.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-001.csv index dce277201489..56edd6c02e37 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-001.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-001.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.998277E+00,1.549844E-03,1.528456E-04,-2.386025E-05,4.399191E-05 -a2,tax2,-122.11400,38.11300,1.944924E+00,3.716147E-02,1.430538E-02,2.849912E-03,7.597793E-04 -a5,tax1,-122.00000,37.91000,1.989360E+00,8.684242E-03,1.825052E-03,-1.005612E-04,2.314308E-04 -a4,tax3,-122.00000,38.00000,1.990458E+00,2.965260E-03,5.162247E-03,8.662506E-04,5.482275E-04 -a1,tax1,-122.00000,38.11300,1.610178E+00,2.665182E-01,1.121456E-01,5.965764E-04,1.056187E-02 -a6,tax2,-122.00000,38.22500,1.966308E+00,2.084171E-02,9.150427E-03,2.473373E-03,1.226747E-03 -a7,tax1,-121.88600,38.11300,1.938749E+00,5.296675E-02,7.540755E-03,-7.680986E-04,1.511287E-03 +a3,tax1,-122.57000,38.11300,9.999696E-01,2.261184E-05,-1.226951E-05,-2.393570E-05,4.399191E-05 +a2,tax2,-122.11400,38.11300,9.533088E-01,3.180291E-02,1.251272E-02,2.067391E-03,3.082247E-04 +a5,tax1,-122.00000,37.91000,9.997671E-01,1.831161E-04,-5.960704E-05,-1.220105E-04,2.314303E-04 +a4,tax3,-122.00000,38.00000,9.950176E-01,2.510339E-03,2.219452E-03,1.890041E-04,6.362498E-05 +a1,tax1,-122.00000,38.11300,9.744580E-01,2.035833E-02,-1.005837E-03,-4.358555E-03,1.054811E-02 +a6,tax2,-122.00000,38.22500,9.725770E-01,1.774328E-02,7.581992E-03,1.622358E-03,4.753142E-04 +a7,tax1,-121.88600,38.11300,9.988057E-01,9.085286E-04,-4.115155E-04,-8.140158E-04,1.511286E-03 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-002.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-002.csv index 5593e5af4979..8175afdd3aa1 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-002.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-002.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.999184E+00,7.445792E-04,6.138617E-05,-1.176918E-05,2.164294E-05 -a2,tax2,-122.11400,38.11300,1.908983E+00,5.970215E-02,2.378543E-02,5.554129E-03,1.974999E-03 -a5,tax1,-122.00000,37.91000,1.984706E+00,1.208605E-02,2.964990E-03,-1.008783E-04,3.442468E-04 -a4,tax3,-122.00000,38.00000,1.981027E+00,5.510297E-03,1.039710E-02,1.852476E-03,1.212891E-03 -a1,tax1,-122.00000,38.11300,1.691064E+00,2.333505E-01,6.775014E-02,-7.433513E-04,8.579229E-03 -a6,tax2,-122.00000,38.22500,1.934200E+00,4.115461E-02,1.757336E-02,4.657266E-03,2.414319E-03 -a7,tax1,-121.88600,38.11300,1.865018E+00,1.135707E-01,1.958847E-02,-1.547292E-03,3.370233E-03 +a3,tax1,-122.57000,38.11300,9.999850E-01,1.112310E-05,-6.036313E-06,-1.177593E-05,2.164294E-05 +a2,tax2,-122.11400,38.11300,9.307349E-01,4.636396E-02,1.894894E-02,3.355900E-03,5.963054E-04 +a5,tax1,-122.00000,37.91000,9.994944E-01,4.069995E-04,-7.434270E-05,-1.713099E-04,3.442393E-04 +a4,tax3,-122.00000,38.00000,9.895406E-01,4.911242E-03,4.642667E-03,6.296659E-04,2.757944E-04 +a1,tax1,-122.00000,38.11300,9.855644E-01,1.052235E-02,-9.863286E-04,-3.637878E-03,8.537482E-03 +a6,tax2,-122.00000,38.22500,9.472890E-01,3.437518E-02,1.447330E-02,2.985321E-03,8.771567E-04 +a7,tax1,-121.88600,38.11300,9.968301E-01,2.446766E-03,-8.673773E-04,-1.779680E-03,3.370202E-03 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-003.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-003.csv index 0f741466cfd0..325d9be7208d 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-003.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-003.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.999184E+00,7.445792E-04,6.138617E-05,-1.176918E-05,2.164294E-05 -a2,tax2,-122.11400,38.11300,1.940593E+00,3.883852E-02,1.568091E-02,3.583889E-03,1.303726E-03 -a5,tax1,-122.00000,37.91000,1.986819E+00,1.010340E-02,2.863133E-03,-6.637553E-05,2.808261E-04 -a4,tax3,-122.00000,38.00000,1.985408E+00,4.190961E-03,7.490140E-03,1.732990E-03,1.177599E-03 -a1,tax1,-122.00000,38.11300,1.606531E+00,2.671197E-01,1.135538E-01,1.655002E-03,1.114040E-02 -a6,tax2,-122.00000,38.22500,1.961794E+00,2.212925E-02,1.053399E-02,3.386045E-03,2.156991E-03 -a7,tax1,-121.88600,38.11300,1.933583E+00,5.529822E-02,1.010585E-02,-6.216466E-04,1.634264E-03 +a3,tax1,-122.57000,38.11300,9.999850E-01,1.112310E-05,-6.036313E-06,-1.177593E-05,2.164294E-05 +a2,tax2,-122.11400,38.11300,9.517417E-01,3.233826E-02,1.311680E-02,2.356229E-03,4.470131E-04 +a5,tax1,-122.00000,37.91000,9.995382E-01,3.744152E-04,-5.665246E-05,-1.368070E-04,2.808186E-04 +a4,tax3,-122.00000,38.00000,9.921965E-01,3.410127E-03,3.503535E-03,6.151993E-04,2.746522E-04 +a1,tax1,-122.00000,38.11300,9.718100E-01,2.191650E-02,-5.834434E-04,-4.241480E-03,1.109839E-02 +a6,tax2,-122.00000,38.22500,9.709066E-01,1.814533E-02,8.186086E-03,2.008529E-03,7.534823E-04 +a7,tax1,-121.88600,38.11300,9.980343E-01,1.550814E-03,-3.828969E-04,-8.364497E-04,1.634233E-03 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-004.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-004.csv index 44e3a802ef86..c7cd1e7cf931 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-004.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-004.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.996214E+00,3.034316E-03,6.927171E-04,-2.675036E-05,8.599757E-05 -a2,tax2,-122.11400,38.11300,1.988183E+00,6.179728E-03,3.302769E-03,1.351375E-03,9.833903E-04 -a5,tax1,-122.00000,37.91000,1.984782E+00,1.081161E-02,3.502139E-03,3.709266E-04,5.330054E-04 -a4,tax3,-122.00000,38.00000,1.988891E+00,2.805475E-03,5.732820E-03,1.501942E-03,1.068395E-03 -a1,tax1,-122.00000,38.11300,1.962833E+00,2.058786E-02,1.306398E-02,1.961525E-03,1.553869E-03 -a6,tax2,-122.00000,38.22500,1.984314E+00,7.503678E-03,4.594965E-03,2.075249E-03,1.512110E-03 -a7,tax1,-121.88600,38.11300,1.979648E+00,1.441766E-02,4.843344E-03,4.235312E-04,6.670861E-04 +a3,tax1,-122.57000,38.11300,9.998759E-01,1.001978E-04,-1.900840E-05,-4.311249E-05,8.599729E-05 +a2,tax2,-122.11400,38.11300,9.935337E-01,3.635901E-03,1.967967E-03,6.055560E-04,2.568487E-04 +a5,tax1,-122.00000,37.91000,9.982929E-01,1.166614E-03,1.155449E-04,-9.807565E-05,5.230483E-04 +a4,tax3,-122.00000,38.00000,9.948829E-01,2.081388E-03,2.281787E-03,5.035270E-04,2.503980E-04 +a1,tax1,-122.00000,38.11300,9.923527E-01,5.546285E-03,6.518250E-04,-7.838313E-05,1.527564E-03 +a6,tax2,-122.00000,38.22500,9.915789E-01,4.251128E-03,2.703378E-03,9.936396E-04,4.729925E-04 +a7,tax1,-121.88600,38.11300,9.979896E-01,1.363858E-03,1.261618E-04,-1.339089E-04,6.542685E-04 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-005.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-005.csv index 80c3d88ae9c6..09602c4dc2d4 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-005.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-005.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.996034E+00,3.155441E-03,7.584836E-04,-3.362695E-05,8.526586E-05 -a2,tax2,-122.11400,38.11300,1.987424E+00,6.317404E-03,3.555771E-03,1.543790E-03,1.159444E-03 -a5,tax1,-122.00000,37.91000,1.984711E+00,1.090305E-02,3.599533E-03,2.989511E-04,4.874240E-04 -a4,tax3,-122.00000,38.00000,1.988497E+00,2.897600E-03,5.904475E-03,1.580434E-03,1.120392E-03 -a1,tax1,-122.00000,38.11300,1.962312E+00,2.077802E-02,1.327125E-02,2.046587E-03,1.592087E-03 -a6,tax2,-122.00000,38.22500,1.983638E+00,7.685255E-03,4.831842E-03,2.223620E-03,1.620792E-03 -a7,tax1,-121.88600,38.11300,1.978948E+00,1.463055E-02,5.091744E-03,5.828862E-04,7.464238E-04 +a3,tax1,-122.57000,38.11300,9.999031E-01,7.803310E-05,-2.176010E-05,-4.462452E-05,8.526585E-05 +a2,tax2,-122.11400,38.11300,9.930049E-01,3.725733E-03,2.151848E-03,7.463385E-04,3.712521E-04 +a5,tax1,-122.00000,37.91000,9.982938E-01,1.252433E-03,8.353237E-05,-1.134513E-04,4.836516E-04 +a4,tax3,-122.00000,38.00000,9.947194E-01,2.135765E-03,2.367573E-03,5.265573E-04,2.506631E-04 +a1,tax1,-122.00000,38.11300,9.919826E-01,5.836202E-03,6.874065E-04,-7.488640E-05,1.568677E-03 +a6,tax2,-122.00000,38.22500,9.911189E-01,4.368307E-03,2.873265E-03,1.098400E-03,5.410928E-04 +a7,tax1,-121.88600,38.11300,9.974712E-01,1.721891E-03,1.933157E-04,-1.203973E-04,7.340014E-04 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-006.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-006.csv index f93de1307037..95ab9c338f49 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-006.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-006.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.997119E+00,2.230757E-03,6.013126E-04,-1.465999E-05,6.364954E-05 -a2,tax2,-122.11400,38.11300,1.983778E+00,7.918378E-03,4.690836E-03,2.085903E-03,1.527233E-03 -a5,tax1,-122.00000,37.91000,1.982249E+00,1.222533E-02,4.538105E-03,4.050934E-04,5.823863E-04 -a4,tax3,-122.00000,38.00000,1.983845E+00,4.030895E-03,8.058288E-03,2.367978E-03,1.697588E-03 -a1,tax1,-122.00000,38.11300,1.958612E+00,2.153068E-02,1.469936E-02,3.020946E-03,2.137419E-03 -a6,tax2,-122.00000,38.22500,1.979770E+00,8.815601E-03,5.984129E-03,2.987915E-03,2.442166E-03 -a7,tax1,-121.88600,38.11300,1.974288E+00,1.693619E-02,7.415859E-03,5.698069E-04,7.901687E-04 +a3,tax1,-122.57000,38.11300,9.998913E-01,8.871040E-05,-1.277537E-05,-3.095343E-05,6.364926E-05 +a2,tax2,-122.11400,38.11300,9.919006E-01,4.224747E-03,2.584032E-03,8.950350E-04,3.956442E-04 +a5,tax1,-122.00000,37.91000,9.980643E-01,1.357594E-03,1.184920E-04,-1.128686E-04,5.724221E-04 +a4,tax3,-122.00000,38.00000,9.920622E-01,2.981880E-03,3.565104E-03,9.294421E-04,4.613858E-04 +a1,tax1,-122.00000,38.11300,9.896562E-01,7.149705E-03,1.074412E-03,3.685855E-05,2.082855E-03 +a6,tax2,-122.00000,38.22500,9.898757E-01,4.678756E-03,3.314109E-03,1.380230E-03,7.511611E-04 +a7,tax1,-121.88600,38.11300,9.972188E-01,2.005560E-03,1.547161E-04,-1.564306E-04,7.773216E-04 diff --git a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-007.csv b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-007.csv index 68089118b923..d2d846fa69ec 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-007.csv +++ b/openquake/qa_tests_data/classical_damage/case_master/expected/damages-rlz-007.csv @@ -1,9 +1,9 @@ -#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-gitcb9ea472a1', start_date='2024-10-23T02:17:55', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" +#,,,,,,,,"generated_by='OpenQuake engine 3.22.0-giteb247f4214', start_date='2024-11-06T07:06:29', checksum=3613274803, investigation_time=1.0, risk_investigation_time=1.0" asset_id,taxonomy,lon,lat,no_damage,ds1,ds2,ds3,ds4 -a3,tax1,-122.57000,38.11300,1.996939E+00,2.352060E-03,6.670852E-04,-2.153659E-05,6.291781E-05 -a2,tax2,-122.11400,38.11300,1.983020E+00,8.055299E-03,4.943287E-03,2.278153E-03,1.703246E-03 -a5,tax1,-122.00000,37.91000,1.982178E+00,1.231667E-02,4.635426E-03,3.331209E-04,5.368069E-04 -a4,tax3,-122.00000,38.00000,1.983452E+00,4.122619E-03,8.229471E-03,2.446385E-03,1.749563E-03 -a1,tax1,-122.00000,38.11300,1.958092E+00,2.172025E-02,1.490609E-02,3.105924E-03,2.175614E-03 -a6,tax2,-122.00000,38.22500,1.979096E+00,8.996506E-03,6.220484E-03,3.136117E-03,2.550803E-03 -a7,tax1,-121.88600,38.11300,1.973589E+00,1.714874E-02,7.663382E-03,7.291377E-04,8.694966E-04 +a3,tax1,-122.57000,38.11300,9.999185E-01,6.654534E-05,-1.552706E-05,-3.246546E-05,6.291780E-05 +a2,tax2,-122.11400,38.11300,9.913725E-01,4.314169E-03,2.767563E-03,1.035724E-03,5.100318E-04 +a5,tax1,-122.00000,37.91000,9.980654E-01,1.443410E-03,8.648081E-05,-1.282443E-04,5.330274E-04 +a4,tax3,-122.00000,38.00000,9.918992E-01,3.036004E-03,3.650695E-03,9.524576E-04,4.616508E-04 +a1,tax1,-122.00000,38.11300,9.892871E-01,7.438704E-03,1.109936E-03,4.034818E-05,2.123945E-03 +a6,tax2,-122.00000,38.22500,9.894166E-01,4.795585E-03,3.483672E-03,1.484894E-03,8.192425E-04 +a7,tax1,-121.88600,38.11300,9.967008E-01,2.363213E-03,2.218586E-04,-1.429185E-04,8.570447E-04 diff --git a/openquake/qa_tests_data/classical_damage/case_master/job_haz.ini b/openquake/qa_tests_data/classical_damage/case_master/job_haz.ini index 5fa68c62a6b0..6280f93ff635 100644 --- a/openquake/qa_tests_data/classical_damage/case_master/job_haz.ini +++ b/openquake/qa_tests_data/classical_damage/case_master/job_haz.ini @@ -41,5 +41,5 @@ poes = 0.0004, 0.0020 [fragility] structural_fragility_file = structural_fragility_model.xml -nonstructural_fragility_file = nonstructural_fragility_model.xml -total_losses = structural+nonstructural +#nonstructural_fragility_file = nonstructural_fragility_model.xml +#total_losses = structural+nonstructural diff --git a/openquake/risklib/riskmodels.py b/openquake/risklib/riskmodels.py index 5bc5cf6fe85c..44b548bb72cd 100644 --- a/openquake/risklib/riskmodels.py +++ b/openquake/risklib/riskmodels.py @@ -829,13 +829,13 @@ def get_loss_ratios(self): def __getitem__(self, taxo): return self._riskmodels[taxo] - def get_output(self, asset_df, haz, sec_losses=(), rndgen=None): + def get_outputs(self, asset_df, haz, sec_losses=(), rndgen=None): """ :param asset_df: a DataFrame of assets with the same taxonomy and country :param haz: a DataFrame of GMVs on the sites of the assets :param sec_losses: a list of functions :param rndgen: a MultiEventRNG instance - :returns: one or more dictionaries loss_type-> output + :returns: a list of dictionaries loss_type-> output """ # rc.pprint() # dic = rc.todict() @@ -844,9 +844,7 @@ def get_output(self, asset_df, haz, sec_losses=(), rndgen=None): # _assert_equal(dic, dic2) rc = scientific.RiskComputer(self, asset_df) out = rc.output(haz, sec_losses, rndgen) - if not hasattr(haz, 'eid'): # classical - return next(out) - return out + return list(out) def __iter__(self): return iter(sorted(self._riskmodels))