From 2906af69189d212f108b231d4a99ee4ba387722f Mon Sep 17 00:00:00 2001 From: ftong Date: Wed, 9 Jul 2025 15:09:44 +0200 Subject: [PATCH] improve error message when user provides magnitude file incompatible with ground motion model --- src/seismic_hazard_forecasting.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/seismic_hazard_forecasting.py b/src/seismic_hazard_forecasting.py index 6fc5d73..100a651 100644 --- a/src/seismic_hazard_forecasting.py +++ b/src/seismic_hazard_forecasting.py @@ -378,8 +378,11 @@ verbose: {verbose}") # validate m_max against the grond motion model models_anthro_limited = ['Lasocki2013', 'Atkinson2015', 'ConvertitoEtAl2012Geysers'] # these models require that m_max<=4.5 - if m_max > 4.5 and model in models_anthro_limited: - msg = f"Selected ground motion model {model} is only valid up to a maximum magnitude of 4.5. Please try again with a lower maximum magnitude." + if m_max > 4.5 and model in models_anthro_limited: + if m_file is None: + msg = f"Selected ground motion model {model} is only valid up to a maximum magnitude of 4.5. Please try again with a lower maximum magnitude." + else: + msg = f"Selected ground motion model {model} is only valid up to a maximum magnitude of 4.5. The magnitude file provided has a range up to {m_max}." logger.error(msg) raise Exception(msg)