Read and process multifault ruptures
Opened this issue · 6 comments
Hamlet cannot consistently read all of the source files for multifault ruptures.
When MultiFaultSources are used in the source model, the following error results:
Traceback (most recent call last): File "/Users/kjohnson/python/py36/bin/hamlet", line 11, in <module> load_entry_point('openquake.hme', 'console_scripts', 'hamlet')() File "/Users/kjohnson/GEM/hamlet/openquake/hme/bin/hamlet.py", line 35, in main run_tests(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 365, in run_tests bin_gdf, eq_gdf = load_inputs(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 270, in load_inputs rupture_gdf = load_ruptures_from_ssm(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 235, in load_ruptures_from_ssm branch=source_cfg["branch"], File "/Users/kjohnson/GEM/hamlet/openquake/hme/utils/io.py", line 177, in process_source_logic_tree branch=branch) File "/Users/kjohnson/GEM/hamlet/openquake/hme/utils/io.py", line 123, in sort_sources source_df = source_list[0].to_frame().transpose() AttributeError: 'NoneType' object has no attribute 'to_frame'
A partial solution is implemented in the branch multifault, however, it requires that the source model files are listed in the following order:
- sections file
- rupture file
If the rupture file comes before the sections file, the following error results:
Traceback (most recent call last):
File "/Users/kjohnson/python/py36/bin/hamlet", line 11, in <module>
load_entry_point('openquake.hme', 'console_scripts', 'hamlet')()
File "/Users/kjohnson/GEM/hamlet/openquake/hme/bin/hamlet.py", line 35, in main
run_tests(cfg)
File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 365, in run_tests
bin_gdf, eq_gdf = load_inputs(cfg)
File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 270, in load_inputs
rupture_gdf = load_ruptures_from_ssm(cfg)
File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 235, in load_ruptures_from_ssm
branch=source_cfg["branch"],
File "/Users/kjohnson/GEM/hamlet/openquake/hme/utils/io.py", line 192, in process_source_logic_tree
branch=branch)
File "/Users/kjohnson/GEM/hamlet/openquake/hme/utils/io.py", line 127, in sort_sources
source.set_sections(sections_geom)
File "/Users/kjohnson/GEM/oq-engine/openquake/hazardlib/source/multi_fault.py", line 101, in set_sections
assert sections
AssertionError
There are some simple ways to fix this that require things of the user:
- require the string "sections" in the file name
- require the files to be listed in order
Or, there could be an additional step before the source files are processed that finds the sections file
- read a few lines of each file until one is found that contains "geometryModel"
but there may be a more efficient way.
Reading MultiFaultSources is difficult. Hamlet should just use the engine libraries doing that, i.e. call readinput.get_composite_source_model(oqparam).
When extendModel
is used, hamlet fails with the following:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/bin/hamlet", line 33, in <module> sys.exit(load_entry_point('openquake.hme', 'console_scripts', 'hamlet')()) File "/Users/kjohnson/GEM/hamlet/openquake/hme/bin/hamlet.py", line 35, in main run_tests(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 392, in run_tests bin_gdf, eq_gdf = load_inputs(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 294, in load_inputs rupture_gdf = load_ruptures_from_ssm(cfg) File "/Users/kjohnson/GEM/hamlet/openquake/hme/core/core.py", line 252, in load_ruptures_from_ssm ssm_lt_sources, weights = process_source_logic_tree_oq( File "/Users/kjohnson/GEM/hamlet/openquake/hme/utils/io.py", line 242, in process_source_logic_tree_oq branch_csms[br] = readinput.get_composite_source_model( File "/Users/kjohnson/GEM/oq-engine/openquake/commonlib/readinput.py", line 791, in get_composite_source_model csm = get_csm(oqparam, full_lt, h5) File "/Users/kjohnson/GEM/oq-engine/openquake/commonlib/source_reader.py", line 162, in get_csm groups = _build_groups(full_lt, smdict) File "/Users/kjohnson/GEM/oq-engine/openquake/commonlib/source_reader.py", line 232, in _build_groups frac = 1. / len(full_lt.sm_rlzs) ZeroDivisionError: float division by zero
because full_lt.sm_rlzs
is empty. I'm able to trace it back to here, where the else
statement is used but the no sm_rlzs
are appended, but I stopped there.
example.zip
has an example that uses 'extendModel' and one that doesn't.