From a80a672d1f4de3e7113705e416880cd2a1de2751 Mon Sep 17 00:00:00 2001 From: Alison Hill <34223923+alsnhll@users.noreply.github.com> Date: Thu, 9 Nov 2023 00:02:56 -0500 Subject: [PATCH] improved error message for problems with timeseries parameter file dates --- flepimop/gempyor_pkg/src/gempyor/parameters.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/flepimop/gempyor_pkg/src/gempyor/parameters.py b/flepimop/gempyor_pkg/src/gempyor/parameters.py index 674506e8d..e2a63eb49 100644 --- a/flepimop/gempyor_pkg/src/gempyor/parameters.py +++ b/flepimop/gempyor_pkg/src/gempyor/parameters.py @@ -71,17 +71,20 @@ def __init__( print("loaded dates:", df.index) raise ValueError( f"""ERROR loading file {fn_name} for parameter {pn}: - the 'date' index of the provided file does not cover the whole config time span from - {ti}->{tf}, where we have dates from {str(df.index[0])} to {str(df.index[-1])}""" + the 'date' entries of the provided file do not include all the days specified to be modeled by + the config. the provided file includes {len(df.index)} days between {str(df.index[0])} to {str(df.index[-1])}, + while there are {len(pd.date_range(ti, tf))} days in the config time span of {ti}->{tf}. The file must contain entries for the + the exact start and end dates from the config. """ ) - # check the date range, need the lenght to be equal if not (pd.date_range(ti, tf) == df.index).all(): print("config dates:", pd.date_range(ti, tf)) print("loaded dates:", df.index) raise ValueError( f"""ERROR loading file {fn_name} for parameter {pn}: - the 'date' index of the provided file does not cover the whole config time span from - {ti}->{tf}""" + the 'date' entries of the provided file do not include all the days specified to be modeled by + the config. the provided file includes {len(df.index)} days between {str(df.index[0])} to {str(df.index[-1])}, + while there are {len(pd.date_range(ti, tf))} days in the config time span of {ti}->{tf}. The file must contain entries for the + the exact start and end dates from the config. """ ) self.pdata[pn]["ts"] = df