oq-mbtk calculate completeness

39 views
Skip to first unread message

Hasib Abdulrazaq

unread,
Nov 1, 2025, 12:48:22 PMNov 1
to OpenQuake Users
Hi all

I am trying to calculate and apply completeness. I am using the code provided in here without any modifications (apart from 'pattern'): 

completeness_param_folder = './completeness_windows/' cmd = f"oqm cat completeness_generate {config} {completeness_param_folder}"p = subprocess.run(cmd, shell=True)pattern = os.path.join(".", "subcatalogues", "*.csv")folder_figs = "./zone_completeness_figs" folder_compl_results = "./zone_completeness" cmd = f"oqm cat completeness_analysis \"{pattern}\" {config} {folder_figs} {completeness_param_folder} {folder_compl_results}" p = subprocess.run(cmd, shell=True)

The previous parts of the code all worked fine, I can get the completeness windows files (.npy files) however when running completeness_analysis i fail to get any outputs (no folder or figures are created). I am using python 3.11.6 and OQ Engine 3.21.0 on Windows. Is there a problem with the code or version I am using?

I am supposed to get the following from the script above: "for each csv file in the subcatalogues folder, it will test the completeness windows for the catalogue, calculate the FMD parameters for the best fitting window and write these to the config along with the completeness windows, and plot the best-fitting model in a png stored in folder_figs. "

Kirsty Bayliss

unread,
Nov 1, 2025, 2:15:28 PMNov 1
to OpenQuake Users
Hi Hasib, 

Thanks for getting in touch. I suspect that the paths for the folder_figs and folder_completeness are not formatted properly for windows - they should be using the os.path.join notation as in the pattern example (e.g. folder_figs = os.path.join(".", "zone_completeness_figs" ), or to wherever you prefer the files to go). We are working on some updates to the documentation and I will check if we have fixed this for the next version.

There is a second issue here that I have encountered where jupyter sometimes hides the errors rather than printing them in the notebook. If you launched jupyter from a terminal you might see that there's an error printed there that would have been much more useful.

I think this should fix your issue, but let me know if not!

Kirsty

Hasib Abdulrazaq

unread,
Nov 12, 2025, 9:51:28 AMNov 12
to OpenQuake Users
Thanks for your reply. the path is not the issue - it works fine as it is for  completeness_generate function. I am not able to see any errors either in terminal...

In the mfd plot for cumulative rate  I am getting a decrease in cumulative rate where I don't have any change in the number of events (e.g., M3.5 to M4 in screenshot attached). 
Is there any existing guidance on how the binning works/how the cumulative rate is determined? the Hazard Modeller's Toolkit - User Guide (2021) is pretty limited. Or are there any examples of inputs and outputs for b-value determination/ WKF tool.


thanks
Hasib
Screenshot 2025-11-12 144054.png

Kirsty Bayliss

unread,
Nov 13, 2025, 9:44:20 AMNov 13
to OpenQuake Users
Hi Hasib, 

Sorry, I understood that you weren't getting any outputs. Is this figure in the specified folder? Maybe you generated it separately but it looks like the expected output to me. Are the b-values not being written to the toml file?
I don't think I am understanding the problem. It's a little odd that you're not getting any errors or warnings if it's failing. 

As described in the mbtk documentation (and widely used in PSHA), the parameters are calculated using the method of Weichert 1980. This is a likelihood-based approach to fitting the full distribution, and the individual bin rates will fluctuate. The cumulative rate is counted from the largest magnitude.  In this case the fit is very poor due to a lack of data - you have very few events in this source zone which is going to lead to unreliable MFD  parameter estimates. They also cover a very small range of magnitudes, which is known to be problematic for fitting. There is no solution to the binning that will help with this, it is simply a question of data, and you would need more events to get a robust estimate of the MFD parameters. 

Note that in your figure, the b-value is very low. The bmin and bmax values in the config limit the possible range of b-values accepted, so in this case the code may fail to write b-values to your config because the b-value is outwith the  permitted range. I would recommend checking this. 
Reply all
Reply to author
Forward
0 new messages