From ec654c17d0070393ce9137aac7efdf619173fed0 Mon Sep 17 00:00:00 2001 From: Joseph Lemaitre Date: Fri, 19 Apr 2024 11:37:10 +0200 Subject: [PATCH] more support for working out of directory --- flepimop/gempyor_pkg/src/gempyor/parameters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flepimop/gempyor_pkg/src/gempyor/parameters.py b/flepimop/gempyor_pkg/src/gempyor/parameters.py index 37fbee557..71a224d84 100644 --- a/flepimop/gempyor_pkg/src/gempyor/parameters.py +++ b/flepimop/gempyor_pkg/src/gempyor/parameters.py @@ -9,6 +9,7 @@ from . import model_info, NPI, utils import datetime import xarray as xr +import os logger = logging.getLogger(__name__) @@ -29,6 +30,7 @@ def __init__( ti: datetime.date, tf: datetime.date, subpop_names: list, + path_prefix: str = ".", ): self.pconfig = parameter_config self.pnames = [] @@ -55,7 +57,7 @@ def __init__( # Parameter given as a file elif self.pconfig[pn]["timeseries"].exists(): - fn_name = self.pconfig[pn]["timeseries"].get() + fn_name = os.path.join(path_prefix, self.pconfig[pn]["timeseries"].get()) df = utils.read_df(fn_name).set_index("date") df.index = pd.to_datetime(df.index) if len(df.columns) == 1: # if only one ts, assume it applies to all subpops