gem/oq-irmt-qgis

Enable the visualization of dmg_by_event and losses_by_event for event based

Closed this issue · 1 comments

We have to check why they were disabled for event based (maybe because they could be huge?) and perhaps pre-filter them by event id like what we did in #710

@micheles, fyi, demos contain only one example of dmg_by_event output, in: "Calculation 8 (scenario_damage): Scenario Damage and Consequences Demo (Nepal)", that is not an event-based, and it is loaded correctly.
There are more examples of losses_by_event. If I enable the loader also for event-based, the output of the integration tests is the following:

test_load_losses_by_event (svir.test.integration.test_drive_oq_engine.LoadOqEngineOutputsTestCase) ...
        Calculation 31 (ebrisk): Stochastic Event-Based Demo (Nepal)
                GET: http://172.17.0.1:8800/v1/calc/result/153?export_type=csv&dload=true
  File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/svir/test/integration/test_drive_oq_engine.py", line 361, in load_calc_output
    n_simulations=n_simulations)
  File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/svir/test/integration/test_drive_oq_engine.py", line 495, in load_output
    filepath = self.download_output(output['id'], filetype)
  File "/root/.local/share/QGIS/QGIS3/profiles/default/python/plugins/svir/test/integration/test_drive_oq_engine.py", line 300, in download_output
    raise Exception(resp.text)
DataStoreExportError: Could not export losses_by_event in csv: the datastore is at version 3.8.0-git6368ff7, but the exporter at version 3.8.0-git50527020ea
  File "/home/paolo/projects/oq-engine/openquake/engine/export/core.py", line 65, in export_from_db
    exported = export(output_key, dstore)
  File "/home/paolo/projects/oq-engine/openquake/baselib/general.py", line 550, in __call__
    return self[key](obj, *args, **kw)
  File "/home/paolo/projects/oq-engine/openquake/calculators/export/risk.py", line 243, in export_losses_by_event
    table = add_columns(aw.to_table(), **columns)
  File "/home/paolo/projects/oq-engine/openquake/calculators/export/risk.py", line 50, in add_columns
    for rec in itertools.starmap(Ntuple, rows):
__new__() takes 4 positional arguments but 7 were given

        Calculation 25 (scenario_risk): Scenario Risk Demo (Nepal)
                GET: http://172.17.0.1:8800/v1/calc/result/131?export_type=csv&dload=true
                ok
                (loading time: 2.8048 sec)

        Calculation 24 (event_based_risk): Stochastic Event-Based Demo (Nepal)
                GET: http://172.17.0.1:8800/v1/calc/result/122?export_type=csv&dload=true
                ok
                (loading time: 2.9632 sec)

        Calculation 8 (scenario_damage): Scenario Damage and Consequences Demo (Nepal)
                GET: http://172.17.0.1:8800/v1/calc/result/32?export_type=csv&dload=true
                ok
                (loading time: 2.9461 sec)