oq-engine icon indicating copy to clipboard operation
oq-engine copied to clipboard

WIP: aftershock PSHA

Open cossatot opened this issue 2 years ago • 7 comments

cossatot avatar Jul 07 '22 12:07 cossatot

@cossatot, the way to extract the rupture IDs is explained in this comment: https://github.com/gem/oq-engine/pull/7961#issuecomment-1184162163

micheles avatar Jul 15 '22 05:07 micheles

Ok thanks @micheles. Just so that I'm aware, are there restrictions on the types of sources that can be used at this point?

cossatot avatar Jul 15 '22 05:07 cossatot

No, the beauty of this approach is that it works for all kind of sources.

micheles avatar Jul 15 '22 06:07 micheles

Thanks @micheles, I've looked at this a bit now and it looks quite useful. I have a few questions, though.

First, will the rupids returned in this way match that from using source.iter_ruptures() ? If not (or even if so), is there a better way to iterate through ruptures (from the datastore perhaps) rather than by using source.iter_ruptures()?

Second, the first field of the dstore['source_info'] array looks like a source id string. Is this unique and can it be used as the srcid you wrote in the comment rather than the integer expressing its order in the datastore?

cossatot avatar Jul 19 '22 22:07 cossatot

will the rupids returned in this way match that from using source.iter_ruptures()

Absolutely yes, this is the point of it.

the first field of the dstore['source_info'] array looks like a source id string. Is this unique and can it be used as the srcid ?

While it should be unique with the current implementation, there is no uniqueness check, so I would suggest to use the integer id. Notice that after running a preclassical each source object has an .id attribute corresponding to that index. Given an area source splittable in 100 point sources, each of the point sources will have the .id of the original area source but different .source_id attributes.

micheles avatar Jul 20 '22 03:07 micheles

@micheles how do I get sources (Python objects) that correspond to the source_info? It looks like the CompositeSourceModel already has the sources broken into very many smaller chunks, and the source_info has aggregated statistics from them. So if I want to use the integer ID (rather than a string), I need to have a list of sources in the correct order, with the same number of sources and the same number of ruptures as in the source_info, but I can't seem to find this in the datastore and it's not the same as in the XML source files.

cossatot avatar Jul 20 '22 17:07 cossatot

There is way to run a preclassical calculation without splitting the sources so that there is correspondence between source_info and get_sources. Here is how to do it:

from openquake.calculators.base import run_calc
if __name__ == '__main__':
    calc = run_calc('job.ini', calculation_mode='preclassical',
                    split_sources='false')
    info = calc.datastore['source_info'][:]
    for src in calc.csm.get_sources():
        print(src, info[src.id])

Notice that the rupture IDs will be the same even if in the real calculation the sources will be split (as stated in https://github.com/gem/oq-engine/issues/7960).

micheles avatar Jul 21 '22 03:07 micheles

Superseded by https://github.com/gem/oq-engine/pull/8174.

micheles avatar Oct 21 '22 05:10 micheles