TNO Intern

Commit ad25e580 authored by Zanne Korevaar's avatar Zanne Korevaar
Browse files

Add option for user-defined lithology_properties table in the LithologyConfig object

parent 1d1ba523
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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