From 7e362c8a10a6eddb97e29557d5915b5ba0fd1b1c Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 10:26:41 +0100 Subject: [PATCH 1/6] remove lithology_resources_dir from constants.py --- src/geoloop/constants.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/geoloop/constants.py b/src/geoloop/constants.py index 1b4a225..e1e55cf 100644 --- a/src/geoloop/constants.py +++ b/src/geoloop/constants.py @@ -10,11 +10,6 @@ test_output_path = test_dir / "output" # Resources directory resources_path = repo_path / "resources" -# Lithology resources directory -lithology_properties_xlsx = ( - resources_path / "lithology_properties" / "lithology_properties.xlsx" -) - # Dictionary of units for various parameters in the model. units_dict = { "Q_b": "W", -- GitLab From 36c578a813a120c26e377c81b5e95cfa774ebebe Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 10:27:09 +0100 Subject: [PATCH 2/6] move lithology_properties.xlsx to a resources dir inside the lithology package --- src/geoloop/lithology/resources/__init__.py | 0 .../lithology/resources}/lithology_properties.xlsx | Bin 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/geoloop/lithology/resources/__init__.py rename {resources/lithology_properties => src/geoloop/lithology/resources}/lithology_properties.xlsx (100%) diff --git a/src/geoloop/lithology/resources/__init__.py b/src/geoloop/lithology/resources/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/resources/lithology_properties/lithology_properties.xlsx b/src/geoloop/lithology/resources/lithology_properties.xlsx similarity index 100% rename from resources/lithology_properties/lithology_properties.xlsx rename to src/geoloop/lithology/resources/lithology_properties.xlsx -- GitLab From 1d1ba523b0eb3442abc224f10d71929d0578afde Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 10:30:18 +0100 Subject: [PATCH 3/6] update the process_lithology.py module conform the new location of the lithology_properties.xslx resources file --- src/geoloop/lithology/process_lithology.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/geoloop/lithology/process_lithology.py b/src/geoloop/lithology/process_lithology.py index 74e91c2..b5659be 100644 --- a/src/geoloop/lithology/process_lithology.py +++ b/src/geoloop/lithology/process_lithology.py @@ -1,12 +1,12 @@ import math from pathlib import Path +from importlib.resources import files import numpy as np import pandas as pd import xarray as xr from geoloop.configuration import LithologyConfig -from geoloop.constants import lithology_properties_xlsx from geoloop.geoloopcore.strat_interpolator import TgInterpolator @@ -271,7 +271,7 @@ class ProcessLithologyToThermalConductivity: read_from_table: bool, ) -> None: # Read lithology properties reference table (Excel) - self.lithology_props_df = pd.read_excel(lithology_properties_xlsx) + self.lithology_props_df = self.load_lithology_properties_df() self.borehole_df = borehole_df self.lithology_props_dict = self.create_lithology_props_dict() @@ -299,6 +299,14 @@ class ProcessLithologyToThermalConductivity: self.out_table = out_table self.read_from_table = read_from_table + @staticmethod + def load_lithology_properties_df() -> pd.DataFrame: + return pd.read_excel( + files("geoloop.lithology.resources").joinpath( + "lithology_properties.xlsx" + ) + ) + def create_lithology_props_dict(self) -> dict[int, "ThermalConductivityCalculator"]: """ Creates a dictionary of physical and thermal properties for different lithologies, in the correct format for -- GitLab From ad25e5806a1663878ed534e972db973179ccba5f Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 11:17:51 +0100 Subject: [PATCH 4/6] Add option for user-defined lithology_properties table in the LithologyConfig object --- src/geoloop/configuration.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/geoloop/configuration.py b/src/geoloop/configuration.py index 248615b..5f339a1 100644 --- a/src/geoloop/configuration.py +++ b/src/geoloop/configuration.py @@ -19,6 +19,8 @@ class LithologyConfig(BaseModel): Path to the JSON configuration file that created this object. out_dir_lithology : str or Path Directory where lithology outputs will be written. + lithology_properties_path: str or Path + Path to the Excel table with lithology properties. borehole_lithology_path : str or Path Path to the Excel or CSV file containing lithology data. borehole_lithology_sheetname : str @@ -48,6 +50,7 @@ class LithologyConfig(BaseModel): config_file_path: str | Path out_dir_lithology: str | Path input_dir_lithology: str | Path + lithology_properties_path: str |Path | None = None borehole_lithology_path: str | Path borehole_lithology_sheetname: str out_table: str @@ -89,6 +92,23 @@ class LithologyConfig(BaseModel): if not isinstance(self.out_dir_lithology, Path): self.out_dir_lithology = base_dir_lithology / Path(self.out_dir_lithology) + # Lithology properties table + # Resolve user-supplied path + if self.lithology_properties_path is not None: + if not isinstance(self.lithology_properties_path, Path): + self.lithology_properties_path = Path(self.lithology_properties_path) + + if not self.lithology_properties_path.is_absolute(): + self.lithology_properties_path = ( + base_dir_lithology / self.lithology_properties_path + ).resolve() + + if not self.lithology_properties_path.exists(): + raise FileNotFoundError( + f"Lithology properties file not found: " + f"{self.lithology_properties_path}" + ) + return self -- GitLab From 6c987602a76ae29ba18ef9d033eade4f87414bc4 Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 11:19:12 +0100 Subject: [PATCH 5/6] Add option for user-defined lithology_properties table in the ProcessLithologyToThermalConductivity object --- src/geoloop/lithology/process_lithology.py | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/geoloop/lithology/process_lithology.py b/src/geoloop/lithology/process_lithology.py index b5659be..74b430b 100644 --- a/src/geoloop/lithology/process_lithology.py +++ b/src/geoloop/lithology/process_lithology.py @@ -257,6 +257,7 @@ class ProcessLithologyToThermalConductivity: def __init__( self, + lithology_properties_df: pd.DataFrame, borehole_df: pd.DataFrame, Tg: float, Tgrad: float, @@ -270,8 +271,7 @@ class ProcessLithologyToThermalConductivity: out_table: str, read_from_table: bool, ) -> None: - # Read lithology properties reference table (Excel) - self.lithology_props_df = self.load_lithology_properties_df() + self.lithology_props_df = lithology_properties_df self.borehole_df = borehole_df self.lithology_props_dict = self.create_lithology_props_dict() @@ -299,14 +299,6 @@ class ProcessLithologyToThermalConductivity: self.out_table = out_table self.read_from_table = read_from_table - @staticmethod - def load_lithology_properties_df() -> pd.DataFrame: - return pd.read_excel( - files("geoloop.lithology.resources").joinpath( - "lithology_properties.xlsx" - ) - ) - def create_lithology_props_dict(self) -> dict[int, "ThermalConductivityCalculator"]: """ Creates a dictionary of physical and thermal properties for different lithologies, in the correct format for @@ -393,12 +385,22 @@ class ProcessLithologyToThermalConductivity: Initialized instance. """ - borehole_path = config.borehole_lithology_path + # Read borehole lithology table (Excel) borehole_df = pd.read_excel( - borehole_path, sheet_name=config.borehole_lithology_sheetname + config.borehole_lithology_path, sheet_name=config.borehole_lithology_sheetname ) + # Read lithology properties reference table (Excel) + if config.lithology_properties_path is not None: + lithology_properties_df = pd.read_excel( + config.lithology_properties_path + ) + else: + lithology_properties_df = pd.read_excel( + files("geoloop.lithology.resources").joinpath("lithology_properties.xlsx") + ) return cls( + lithology_properties_df=lithology_properties_df, borehole_df=borehole_df, Tg=config.Tg, Tgrad=config.Tgrad, -- GitLab From 516acf7d6498154bf924564cdf8416daeac68ef3 Mon Sep 17 00:00:00 2001 From: korevaarzer Date: Mon, 19 Jan 2026 12:14:28 +0100 Subject: [PATCH 6/6] Update docs with the option for user-defining a file with rock properties in the lithology module configuration --- docs/manual/lithology_configuration.md | 40 ++++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/manual/lithology_configuration.md b/docs/manual/lithology_configuration.md index 5842af6..baa6f94 100644 --- a/docs/manual/lithology_configuration.md +++ b/docs/manual/lithology_configuration.md @@ -13,22 +13,23 @@ except `config_file_path`. The input JSON file for the lithology module includes the following parameters: -| Parameter | Description | Unit | Type | Remark | -|-------------------------|---------------------------------------------------------------------------------------------|------|------|---------| -| input_dir_lithology | Path to folder with Excel file containing lithology properties for the borehole | — | string | — | -| out_dir_lithology | Path to folder where lithology output is stored | — | string | Output includes tables with bulk subsurface thermal conductivity over depth and figures | -| borehole_lithology_path | Path to Excel file with subsurface lithology data | — | string | — | -| borhole_litho_sheetname | Name of tab in Excel file with subsurface lithology data | — | string | — | -| out_table | Name of HDF5 (.h5) file to store lithology and thermal conductivity data | — | string | — | -| Tg | (Sub)surface temperature | °C | scalar or list | Represents surface temperature if scalar | -| Tgrad | Subsurface temperature gradient | °C/100m | scalar | Used only if Tg is scalar | -| z_Tg | End depths of `Tg` values | m | list | Used only if Tg is a list | -| phi_scale | Factor to scale porosity uniformly over depth | — | scalar | — | -| lithology_scale | Factor to scale fraction of lithology a uniformly over depth | — | scalar | — | -| lithology_error | Random variation factor for lithology fraction over depth | — | scalar | — | -| n_samples | Number of samples for generating subsurface thermal conductivity models | — | scalar | Used only if basecase is false | -| basecase | Flag to apply error/scaling factors in lithology and porosity sampling | — | boolean | — | -| read_from_table | Flag to read pre-calculated thermal conductivity data instead of calculating during runtime | — | boolean | — | +| Parameter | Description | Unit | Type | Remark | +|---------------------------|--------------------------------------------------------------------------------------------|---------|----------------|-----------------------------------------------------------------------------------------| +| input_dir_lithology | Path to folder with Excel file containing lithology properties for the borehole | — | string | — | +| out_dir_lithology | Path to folder where lithology output is stored | — | string | Output includes tables with bulk subsurface thermal conductivity over depth and figures | +| lithology_properties_path | Path to Excel file containing user-defined soil/rock properties | - | string | Optional; default table with properties is included in the lithology package | +| borehole_lithology_path | Path to Excel file with subsurface lithology data | — | string | — | +| borhole_litho_sheetname | Name of tab in Excel file with subsurface lithology data | — | string | — | +| out_table | Name of HDF5 (.h5) file to store lithology and thermal conductivity data | — | string | — | +| Tg | (Sub)surface temperature | °C | scalar or list | Represents surface temperature if scalar | +| Tgrad | Subsurface temperature gradient | °C/100m | scalar | Used only if Tg is scalar | +| z_Tg | End depths of `Tg` values | m | list | Used only if Tg is a list | +| phi_scale | Factor to scale porosity uniformly over depth | — | scalar | — | +| lithology_scale | Factor to scale fraction of lithology a uniformly over depth | — | scalar | — | +| lithology_error | Random variation factor for lithology fraction over depth | — | scalar | — | +| n_samples | Number of samples for generating subsurface thermal conductivity models | — | scalar | Used only if basecase is false | +| basecase | Flag to apply error/scaling factors in lithology and porosity sampling | — | boolean | — | +| read_from_table | Flag to read pre-calculated thermal conductivity data instead of calculating during runtime | — | boolean | — | ### Rules for Configuration of the Lithology Module @@ -78,10 +79,11 @@ The lithology types (for `Lithology_a` and `Lithology_b`) currently supported by ### Excel Format for Lithological Thermal Properties from Literature -The lithology module relies on an Excel file (`resources/lithology_properties/lithology_properties.xlsx`) that contains +The lithology module relies on an Excel file (`lithology/resources/lithology_properties.xlsx`) that contains physical and thermal parameters for each lithology type, from Hantschel & Kauerauf (2009). This table acts as the reference -database from which all lithology-dependent thermal-conductivity calculations draw their input values. This table -should be edited for additional lithologies and/or customization of the rock properties. +database from which all lithology-dependent thermal-conductivity calculations draw their input values. Optionally, +the path to a similar table is user-defined in the configuration of the lithology module, with additional or edited soil +and/or rock properties. The Excel file includes the following columns: -- GitLab