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

complexFaultRupture error, too many values to unpack? #8278

Closed YProDia closed 1 year ago

YProDia commented 1 year ago

I've been having some trouble with a seismic hazard scenario simulation including a complex fault rupture in OpenQuake. The simulation keeps failing and this is the traceback error that I get:

Traceback (most recent call last):

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\baselib\node.py", line 799, in context

    yield node

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\hazardlib\sourceconverter.py", line 547, in convert_complexFaultRupture

    [surface] = node.getnodes('complexFaultGeometry')

ValueError: too many values to unpack (expected 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\engine\engine.py", line 261, in run_calc

    calc.run(exports=exports, **kw)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\calculators\base.py", line 248, in run

    self.result = self.execute()

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\calculators\event_based.py", line 308, in execute

    self._read_scenario_ruptures()

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\calculators\event_based.py", line 253, in _read_scenario_ruptures

    rup = readinput.get_rupture(oq)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\commonlib\readinput.py", line 634, in get_rupture

    rup = conv.convert_node(rup_node)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\hazardlib\sourceconverter.py", line 418, in convert_node

    return getattr(self, 'convert_' + striptag(node.tag))(node)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\hazardlib\sourceconverter.py", line 547, in convert_complexFaultRupture

    [surface] = node.getnodes('complexFaultGeometry')

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\contextlib.py", line 99, in __exit__

    self.gen.throw(type, value, traceback)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\baselib\node.py", line 804, in context

    raise_(etype, msg, tb)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\baselib\python3compat.py", line 86, in raise_

    raise exc.with_traceback(tb)

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\baselib\node.py", line 799, in context

    yield node

  File "C:\Program Files\OpenQuake Engine\python3.6\lib\site-packages\openquake\hazardlib\sourceconverter.py", line 547, in convert_complexFaultRupture

    [surface] = node.getnodes('complexFaultGeometry')

ValueError: node complexFaultRupture: too many values to unpack (expected 1), line 3 of None

The rupture input file that I'm using is this one:

<?xml version="1.0" encoding="utf-8"?>
<nrml xmlns:gml="http://www.opengis.net/gml" xmlns="http://openquake.org/xmlns/nrml/0.4">
    <complexFaultRupture>
        <magnitude>7</magnitude>
        <rake>90</rake>
        <hypocenter lat="36.577" lon="-4.639" depth="13"/>
        <complexFaultGeometry>
            <faultTopEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.7441  36.6842  0.5
                        -4.6708  36.7057 0.5
                    </gml:posList>
                </gml:LineString>
            </faultTopEdge>
            <intermediateEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.707  36.6219  2.5
                        -4.629  36.635  2.5
                    </gml:posList>
                </gml:LineString>
            </intermediateEdge>
            <faultBottomEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.694  36.568  13
                        -4.614  36.58  13
                    </gml:posList>
                </gml:LineString>
            </faultBottomEdge>
        </complexFaultGeometry>
        <complexFaultGeometry>
            <faultTopEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.661 36.6894 0.5
                        -4.5983 36.7082 0.5
                    </gml:posList>
                </gml:LineString>
            </faultTopEdge>
            <intermediateEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.629 36.635 2.5
                        -4.568 36.643 2.5
                    </gml:posList>
                </gml:LineString>
            </intermediateEdge>
            <faultBottomEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.614 36.58 13
                        -4.554 36.589 13
                    </gml:posList>
                </gml:LineString>
            </faultBottomEdge>
        </complexFaultGeometry>
        <complexFaultGeometry>
            <faultTopEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.568 36.643 2.5
                        -4.4982 36.6542 2.5
                    </gml:posList>
                </gml:LineString>
            </faultTopEdge>
            <faultBottomEdge>
                <gml:LineString>
                    <gml:posList>
                        -4.554 36.589 13
                        -4.486 36.602 13
                    </gml:posList>
                </gml:LineString>
            </faultBottomEdge>
        </complexFaultGeometry>
    </complexFaultRupture>
</nrml>

The weird thing is, I've done simulations with the same rupture before (a few years ago), and they used to work. But now I have to redo some calculations and I need to make a new simulation with this particular rupture, and it no longer works. The old simulation crashes too if I try to remake it, and I get exactly the same traceback, so my guess is the issue is somewhere around the rupture file. I've even remade the rupture input file to make sure the format was up to date with the current version of the engine, and the simulation still fails. I'm not really a programmer, I use OpenQuake through the webui user interface, and I don't really understand where is the error exactly or how to fix it. If someone could please help me with this issue, I'd honestly appreciate it.

micheles commented 1 year ago

Where did you get the rupture file? The format it uses is invalid and before it only happened to work. The error message is clear, you have too many complexFaultGeometry nodes, there can be only one. Before the engine was just taking the first node, now it is warning you about the others. If you want to get the same results as in the past just remove the extra nodes of kind complexFaultGeometry.

raoanirudh commented 1 year ago

Previous issue and resolution: https://github.com/gem/oq-engine/issues/5440

YProDia commented 1 year ago

Where did you get the rupture file? The format it uses is invalid and before it only happened to work. The error message is clear, you have too many complexFaultGeometry nodes, there can be only one. Before the engine was just taking the first node, now it is warning you about the others. If you want to get the same results as in the past just remove the extra nodes of kind complexFaultGeometry.

Thanks for your answer. I made the rupture file in the webui interface with the earthquake rupture preparation tools. My rupture is an actual fault in my study area, so I used its coordinates. Sorry, I'm afraid I'm not quite sure what are the "nodes" exactly. I've taken a look at the user manual and I'm not sure whether it's the English language (which is not my mother tongue) or the programmer language, but I'm not really grasping what are you referring to. I checked issue #5440 before opening this issue but I still couldn't figure out where the problem was for the same reason, I don't know what "node" refers to in this context.

micheles commented 1 year ago

This is a node named complexFaultGeometry in XML:

<complexFaultGeometry>
 ... something inside ...
</complexFaultGeometry>

In general any structure with the form <name> ... </name> is an XML node called name.

YProDia commented 1 year ago

Ok, thank you so much! I get it now. You see, this fault has a really weird geometry, it not only changes dip with depth but the upper part sort of bifurcates into two strands, like in depth it can be projected in the horizontal as a single straight line, but as you move from the lower part towards the surface that line splits into two at a certain point (at 2.5 km depth) and from there upwards the dip changes for both strands. At first I tried including two complexFaultGeometry surfaces which at 2.5 km depth shared the middle point in the intermediate edge, because I thought that was the most accurate way to represent that geometry... Clearly not a good idea now that I know how it works and reads the file. Thanks again!