# Occurrence Rate in Event Based Hazard Calculation

46 views

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,

### Peter Pažák

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

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
from openquake.commonlib import datastore
print(dstore.read_df('ruptures'))  # returns a pandas DataFrame

May 29, 2021, 11:38:20 AMMay 29
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,