dstore: extracting weights per rlz

31 views
Skip to first unread message

Cecilia I. Nievas

unread,
Sep 1, 2026, 7:53:55 AMSep 1
to openqua...@googlegroups.com

Dear OpenQuake community,

I am trying to use openquake.calculators.extract to retrieve the weights associated with each end branch of the logic tree.

I am running the calculation and accessing the results by means of Python code by doing:

    calc_id = main(path_to_job_ini)

    dstore = read(calc_id)

For a scenario damage example I am running with 2 branches of the GMM logic tree, the output of extract(dstore, "full_lt").get_realizations() looks like this:

array([<0,w=[0.333]>, <1,w=[0.667]>], dtype=object)

For each element of this array (which I call "rlz_weights_raw"), I can do rlz_weights_raw[rlz].weight and retrieve the array of weights (i.e., [0.333] and [0.667]). But I am not managing to understand why the weight is an array and not a number. I can of course do rlz_weights_raw[rlz].weight[0], but I am concerned I may be missing the reason for which "w" is a Numpy array and thus not be contemplating other possibilities that may come up for me in the future.

What I have found under hazardlib/logictree.py searching for "LtRealization" has not helped me clarify this. (E.g. line 195, weight = numpy.array([len(rows) / len(triples)])).

Can you please help me understand when would I obtain more than one number inside the "weight" array? My ultimate purpose is to retrieve the weights associated with each "rlz" (as output, for example, in damage results).

Thank you very much in advance!

Best regards,

Cecilia


Michele Simionato

unread,
Sep 8, 2026, 8:38:34 AM (14 days ago) Sep 8
to OpenQuake Users
The engine must support the Canada model, which has IMT-dependent weights. This is the reason why there is a matrix of weights, one per each IMT.
See for instance the test oq-engine/openquake/qa_tests_data/classical/case_39 where one gets
```
$ oq show full_lt/gsim_lt
| trt                  | branch | uncertainty             | PGA    | SA(0.2) | SA(1.0) | weight |
|----------------------+--------+-------------------------+--------+---------+---------+--------|
| Active Shallow Crust | gA0    | [ChiouYoungs2014]       | 0.0    | 0.2500  | 0.2500  | 0.2500 |
| Active Shallow Crust | gB0    | [BooreEtAl2014]         | 0.0    | 0.2500  | 0.2500  | 0.2500 |
| Active Shallow Crust | gC0    | [CampbellBozorgnia2014] | 0.0    | 0.2500  | 0.2500  | 0.2500 |
| Active Shallow Crust | gD0    | [CauzziEtAl2014]        | 0.0    | 0.2500  | 0.2500  | 0.2500 |
| Active Shallow Crust | gE0    | [SiMidorikawa1999Asc]   | 1.0000 | 0.0     | 0.0     | 0.0    |
```
HTH,

                                   Michele
Reply all
Reply to author
Forward
0 new messages