From 60ae1c96cdef4191068181e8835bb525e42ec48c Mon Sep 17 00:00:00 2001 From: ftong Date: Mon, 7 Jul 2025 14:43:42 +0200 Subject: [PATCH] raise exception for null magnitude values --- src/seismic_hazard_forecasting.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/seismic_hazard_forecasting.py b/src/seismic_hazard_forecasting.py index 3417616..15826b3 100644 --- a/src/seismic_hazard_forecasting.py +++ b/src/seismic_hazard_forecasting.py @@ -138,6 +138,12 @@ verbose: {verbose}") time, mag, lat, lon, depth = read_mat_cat(catalog_file, mag_label=mag_label, catalog_label='Catalog') + # check for null magnitude values + m_null_idx = np.where(np.isnan(mag))[0] + if len(m_null_idx) > 0: + msg = f"There are null values in the magnitude column of the catalog at indices {m_null_idx}" + logger.error(msg) + raise Exception(msg) if mc != None: logger.info("Mc value provided by user") trim_to_mc = True