diff --git a/rubem/configuration/app_settings.py b/rubem/configuration/app_settings.py index c0c3a28..6b8f50a 100644 --- a/rubem/configuration/app_settings.py +++ b/rubem/configuration/app_settings.py @@ -13,11 +13,15 @@ class AppSettings: __instance = None __default_appsettings_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) - __default_appsettings_file = os.path.join(__default_appsettings_dir, "appsettings.json") + __default_appsettings_file = os.path.abspath( + os.path.join(__default_appsettings_dir, "appsettings.json") + ) if "PYTHON_ENVIRONMENT" in os.environ and os.environ["PYTHON_ENVIRONMENT"]: custom_env_settings = f"appsettings.{os.environ['PYTHON_ENVIRONMENT']}.json" - custom_env_settings_path = os.path.join(__default_appsettings_dir, custom_env_settings) + custom_env_settings_path = os.path.abspath( + os.path.join(__default_appsettings_dir, custom_env_settings) + ) if ( os.path.isfile(custom_env_settings_path) and os.path.getsize(custom_env_settings_path) > 0 @@ -58,7 +62,7 @@ def load(self, app_settings_file_path: Optional[Union[str, bytes, os.PathLike]] """ if app_settings_file_path: - app_settings_file_path_str = str(app_settings_file_path) + app_settings_file_path_str = os.path.abspath(app_settings_file_path) else: app_settings_file_path_str = self.__default_appsettings_file diff --git a/rubem/configuration/input_raster_series.py b/rubem/configuration/input_raster_series.py index 4a8e9bc..405aae7 100644 --- a/rubem/configuration/input_raster_series.py +++ b/rubem/configuration/input_raster_series.py @@ -89,13 +89,19 @@ def __init__( else: self.logger.warning("Input data directories validation is disabled.") - self.etp = os.path.join(str(self.__etp_dir_path), self.__etp_filename_prefix) - self.precipitation = os.path.join( - str(self.__precipitation_dir_path), self.__precipitation_filename_prefix + self.etp = os.path.abspath( + os.path.join(str(self.__etp_dir_path), self.__etp_filename_prefix) + ) + self.precipitation = os.path.abspath( + os.path.join(str(self.__precipitation_dir_path), self.__precipitation_filename_prefix) + ) + self.ndvi = os.path.abspath( + os.path.join(str(self.__ndvi_dir_path), self.__ndvi_filename_prefix) + ) + self.kp = os.path.abspath(os.path.join(str(self.__kp_dir_path), self.__kp_filename_prefix)) + self.landuse = os.path.abspath( + os.path.join(str(self.__landuse_dir_path), self.__landuse_filename_prefix) ) - self.ndvi = os.path.join(str(self.__ndvi_dir_path), self.__ndvi_filename_prefix) - self.kp = os.path.join(str(self.__kp_dir_path), self.__kp_filename_prefix) - self.landuse = os.path.join(str(self.__landuse_dir_path), self.__landuse_filename_prefix) def __validate_directories(self) -> None: directories = [ diff --git a/rubem/file/_file_convertions.py b/rubem/file/_file_convertions.py index c8fc6a3..aacf05b 100644 --- a/rubem/file/_file_convertions.py +++ b/rubem/file/_file_convertions.py @@ -31,9 +31,9 @@ def tss2csv(tss_dir_path: str, cols_names: list[str], should_delete_src_tss: boo header = ["0"] header.extend(cols_names) - for tss_file in glob.glob(os.path.join(tss_dir_path, "*.tss")): - dst_file_path = os.path.join( - os.path.dirname(tss_file), f"{os.path.splitext(tss_file)[0]}.csv" + for tss_file in glob.glob(os.path.abspath(os.path.join(tss_dir_path, "*.tss"))): + dst_file_path = os.path.abspath( + os.path.join(os.path.dirname(tss_file), f"{os.path.splitext(tss_file)[0]}.csv") ) with open(file=tss_file, mode="r", encoding="utf8") as f: lines = f.readlines() diff --git a/rubem/file/_file_generators.py b/rubem/file/_file_generators.py index 56bff4f..11b1019 100644 --- a/rubem/file/_file_generators.py +++ b/rubem/file/_file_generators.py @@ -68,12 +68,14 @@ def __report( no_data_value: float = -9999, ): if timestep: - out_tif = os.path.join( - str(outpath), - f"{name}{str(timestep).zfill(10 - len(name))}.{extension}", + out_tif = os.path.abspath( + os.path.join( + str(outpath), + f"{name}{str(timestep).zfill(10 - len(name))}.{extension}", + ) ) else: - out_tif = os.path.join(str(outpath), f"{name}.{extension}") + out_tif = os.path.abspath(os.path.join(str(outpath), f"{name}.{extension}")) gdal.UseExceptions() gdal.AllRegister()