IndexError: string index out of range - depth distribution uncertainty

6 views
Skip to first unread message

Joseph Meehan

unread,
5:03 AM (8 hours ago) 5:03 AM
to OpenQuake Users

Hello,

Here is my system information:

  • Windows 11 Enterprise 10.0.26100 Build 26100
  • Installed using Universal installer
  • Version 3.23.4

I am running an OpenQuake analysis with several branchsets. My intention is to capture zonation, focal depth distribution, rate, and maxmag uncertainty. From reading the documentation it looks like it is not possible to add focal depth distribution as an uncertaintytype in the logic tree, and therefore I have had to duplicate the source models which in turn leads to the large number of branches.

The logic tree I am using roughly looks like:

  1. Base model (1 branch)

  2. Extend model (4 branches):

     - SSM-A_SHALLOW

     - SSM-B_SHALLOW

     - SSM-A_DEEP

     - SSM-B_DEEP

  3. Zones included:

     - SSM-A_SHALLOW: ZONE1, ZONE2

     - SSM-B_SHALLOW: ZONE1, ZONE3

     - SSM-A_DEEP:    ZONE1, ZONE2

     - SSM-B_DEEP:    ZONE1, ZONE3

  4. For each model/zone combination:

     - abGRAbsolute uncertainty:

       - 25 branches (rate_1 ... rate_25)

     - maxMagGRAbsolute uncertainty:

       - 4 branches (mmax_1 ... mmax_4)

My GMPE has 9 branches so in total there are 360000 realisations.

When I run the analysis using: "oq engine --run config.ini --exports csv" the calculation seems to run, however I encounter two errors that prevent me from being able to export the results. 

After preclassical but before classical, I receive this error:

[2026-06-11 13:55:29 #478 ERROR] Could not export ('realizations', 'csv'): string index out of range

and no realization file is exported. The site_model.csv file however is exported and the calculation continues. Classical and postclassical both reach 100% and maximum hazard map values for the specified intensity measures are reported in the log.

Then, I receive this error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Scripts\oq.exe\__main__.py", line 5, in <module>
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\commands\__main__.py", line 48, in oq
    sap.run(commands, prog='oq')
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\baselib\sap.py", line 212, in run
    return _run(parser(funcdict, **parserkw), argv)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\baselib\sap.py", line 203, in _run
    return func(**dic)
           ^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\commands\engine.py", line 180, in main
    run_jobs(jobs, nodes=nodes, sbatch=True, precalc=not multi)
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\engine\engine.py", line 380, in run_jobs
    run_calc(jobctx)
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\engine\engine.py", line 210, in run_calc
    expose_outputs(calc.datastore)
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\calculators\base.py", line 1737, in expose_outputs
    rlzs = dstore['full_lt'].rlzs
           ~~~~~~^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\commonlib\datastore.py", line 494, in __getitem__
    val = self.hdf5[key]
          ~~~~~~~~~^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\baselib\hdf5.py", line 529, in __getitem__
    h5obj = {unquote_plus(k): self['%s/%s' % (path, k)]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\baselib\hdf5.py", line 529, in <dictcomp>
    h5obj = {unquote_plus(k): self['%s/%s' % (path, k)]
                              ~~~~^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\baselib\hdf5.py", line 534, in __getitem__
    obj.__fromh5__(h5obj, h5attrs)
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\hazardlib\logictree.py", line 985, in __fromh5__
    CompositeLogicTree(bsets)  # perform attach_to_branches
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\hazardlib\lt.py", line 814, in __init__
    self.basepaths = self._attach_to_branches()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\hazardlib\lt.py", line 847, in _attach_to_branches
    brno = add_path(bset, i+1, brno, len(previous_branches), nb, paths)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UserAccount\Documents\OpenQuake\venv\Lib\site-packages\openquake\hazardlib\lt.py", line 796, in add_path
    br.short_id = base[brno]
                  ~~~~^^^^^^
IndexError: string index out of range

I found two previous threads discussing this error: IndexError: string index out of range and  Error when use a very big source model logic tree, however the responses suggested that the error was caused when the number of branches in an individual branchset exceeded 184. I may be misunderstanding the branch/branchset concept, but as far as I am aware the largest number of branches in a branchset in my logic tree is only 25. I've tried reducing the maximum branchset size to 16 branches rather than 25 and it works, but ideally I would be able to use 25 and I am not sure what is preventing me from doing so. I may be setting my logic tree up incorrectly.

Any help and advice would be appreciated. 

Thanks in advance

Reply all
Reply to author
Forward
0 new messages