Occurrence Rate in Event Based Hazard Calculation

46 views
Skip to first unread message

Shaadi 2021

unread,
May 20, 2021, 11:36:37 AMMay 20
to OpenQuake Users
Dear All,

How can I get the Occurrence rate of my stochastic earthquake scenarios in version 3.11.3 of OpenQuake?  the "year" column in event Outputs is not the return period.

this command ($ oq show ruptures CALCID > theruptures.csv) that we used in last year`s version does not work in the new one.

Thanks and I look forward to hearing from you.
Best Regards,
Shaadi

Peter Pažák

unread,
May 27, 2021, 11:51:00 PMMay 27
to OpenQuake Users
Hi,

you are right that occurrence rate for the ruptures is not output when you download i.e. via clicking on Earthquake Ruptures in webui.
It is though saved in the output hdf5 and you can export with a few python lines (you need to run with OQ python and specify full hdf5 path or be in the same directory...):

import h5py
import pandas as pd
f = h5py.File('calc_41.hdf5', 'r')
rup = pd.DataFrame(f['ruptures'][:],columns=['id','n_occ','occurrence_rate','mag','source_id','rake'])
rup['source_id'] = rup['source_id'].apply(lambda x: x.decode('utf-8')) #source_id is a binary string, assuming utf-8 encoding (most of the time it will be ASCII)
tmpdf = pd.DataFrame(f['ruptures']['hypo'])
rup['centroid_lon'] = tmpdf[0]
rup['centroid_lat'] = tmpdf[1]
rup['centroid_depth'] = tmpdf[2]
rup.to_csv('ruptures.csv',index=None)

the output looks e.g. like this:

id,n_occ,occurrence_rate,mag,source_id,rake,centroid_lon,centroid_lat,centroid_depth
0,1,5.32637e-07,5.05,NANHY,0.0,-71.62193,45.19251,9.0
1,1,5.32637e-07,5.05,NANHY,0.0,-71.75035,45.102577,9.0
2,1,4.408667e-07,5.15,NANHY,0.0,-71.75035,45.102577,9.0
3,1,3.0278636e-07,5.35,NANHY,0.0,-71.881325,44.562984,9.0

Peter

Dátum: štvrtok 20. mája 2021, čas: 17:36:37 UTC+2, odosielateľ: shaad...@gmail.com

Michele Simionato

unread,
May 28, 2021, 1:08:34 PMMay 28
to OpenQuake Users
Better to so something like this:
try:
   from openquake.baselib import datastore  # engine 3.11
except ImportError:  # newer engine
   from openquake.commonlib import datastore
dstore = datastore.read(41)
print(dstore.read_df('ruptures'))  # returns a pandas DataFrame

Shaadi 2021

unread,
May 29, 2021, 11:38:20 AMMay 29
to openqua...@googlegroups.com
Dear Peter and Dear Michele,

Thank you so much for your responses. Both methods were helpful for me and now I have my occurrence rates.

Best Regards,
Shaadi



--
You received this message because you are subscribed to the Google Groups "OpenQuake Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openquake-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openquake-users/3a4627ee-5f70-4437-8de3-9537ef0f6331n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages