gem / oq-engine

OpenQuake Engine: a software for Seismic Hazard and Risk Analysis
https://github.com/gem/oq-engine/#openquake-engine
GNU Affero General Public License v3.0
377 stars 273 forks source link

disaggregation by MDE fails when the MFD includes only one magnitude for a characteristicFaultSource #7940

Closed kejohnso closed 2 years ago

kejohnso commented 2 years ago

For characteristicFaultSource with a single magnitude-rate pair in the MFD (i.e., there is only one rupture), disaggregation fails with the error below. The problem resolves if a second rate is added, even if it is extremely tiny. @mmpagani knows how to fix this. I will send an example file separately.

`Traceback (most recent call last):
  File "/Users/kjohnson/openquake/bin/oq", line 33, in <module>
    sys.exit(load_entry_point('openquake.engine', 'console_scripts', 'oq')())
  File "/Users/kjohnson/GEM/oq-engine/openquake/commands/__main__.py", line 57, in oq
    sap.run(commands, prog='oq')
  File "/Users/kjohnson/GEM/oq-engine/openquake/baselib/sap.py", line 225, in run
    return _run(parser(funcdict, **parserkw), argv)
  File "/Users/kjohnson/GEM/oq-engine/openquake/baselib/sap.py", line 216, in _run
    return func(**dic)
  File "/Users/kjohnson/GEM/oq-engine/openquake/commands/engine.py", line 175, in main
    run_jobs(jobs)
  File "/Users/kjohnson/GEM/oq-engine/openquake/engine/engine.py", line 414, in run_jobs
    run_calc(job)
  File "/Users/kjohnson/GEM/oq-engine/openquake/engine/engine.py", line 278, in run_calc
    calc.run(shutdown=True)
  File "/Users/kjohnson/GEM/oq-engine/openquake/calculators/base.py", line 242, in run
    self.post_execute(self.result)
  File "/Users/kjohnson/GEM/oq-engine/openquake/calculators/disaggregation.py", line 399, in post_execute
    results = {smk: _matrix(dic, T, Ma) for smk, dic in results.items()}
  File "/Users/kjohnson/GEM/oq-engine/openquake/calculators/disaggregation.py", line 399, in <dictcomp>
    results = {smk: _matrix(dic, T, Ma) for smk, dic in results.items()}
  File "/Users/kjohnson/GEM/oq-engine/openquake/calculators/disaggregation.py", line 55, in _matrix
    mat[trti, magi] = matrices[trti, magi]
IndexError: index 0 is out of bounds for axis 1 with size 0`
micheles commented 2 years ago

The issue here is that there is a single magnitude and the binning procedure fails to build a proper magnitude bin. Looks easy to fix.

kejohnso commented 2 years ago

@micheles the solution works for a single source, but there is a similar error when the ssmLT is comprised of multiple single-magnitude nonparametric sources. I will send a test job separately.