Skip to content

Commit

Permalink
improved error message for problems with timeseries parameter file dates
Browse files Browse the repository at this point in the history
  • Loading branch information
alsnhll committed Nov 9, 2023
1 parent 3dc5678 commit a80a672
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions flepimop/gempyor_pkg/src/gempyor/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a80a672

Please sign in to comment.