TNO Intern

Commit 3d4be995 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Merge branch '5-clean-up-code-and-make-ready-for-beta-testing' into 'main'

Resolve "Clean up code and make ready for beta testing"

Closes #5

See merge request AGS/pythermogis!9
parents 76d9f597 137dcd6a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@
        <entryData>
          <resourceRoots>
            <path value="file://$PROJECT_DIR$/src/resources" />
            <path value="file://$PROJECT_DIR$/pythermogis/resources" />
            <path value="file://$PROJECT_DIR$/pythermogis/resources/java" />
            <path value="file://$PROJECT_DIR$/pythermogis/resources/thermogis_jar" />
          </resourceRoots>
        </entryData>
      </entry>
+74 −2
Original line number Diff line number Diff line
# PyThermoGIS
# pyThermoGIS

This is a python API to the ThermoGIS Java code calculations
pyThermoGIS is a Python package that provides API access to the ThermoGIS Geothermal simulation (https://www.thermogis.nl/en). The simulations are conducted in java and this code uses the JPype package as a python-java
binding.

It uses xarray (https://docs.xarray.dev/en/stable/index.html) Datasets as input to the simulation and can be combined with the pygridsio package (https://pypi.org/project/pygridsio/) to read in and process 2D rasters
   
### Install via pip from GitLab

To install `pyThermoGIS` into your own project directly from GitLab, run:

```sh
pip install git+https://gitlab.com/your-repo/pythermogis.git
```

This will fetch the latest version from the public GitLab repository.

## Usage

Here’s a simple example demonstrating how to use `pyThermoGIS` for a single set of input values:

```python
from pythermogis.pythermogis import calculate_doublet_performance
import xarray as xr

# Initialize an input Dataset with the required input variables:
input_data = xr.Dataset({
         "thickness_mean": ((), 300),
         "thickness_sd": ((), 50),
         "ntg": ((), 0.5),
         "porosity": ((), 0.5),
         "depth": ((), 5000),
         "ln_permeability_mean": ((), 5),
         "ln_permeability_sd": ((), 0.5),
     })

# Simulate a Geothermal doublet using the ThermoGIS methodology
doublet_simulation_results = calculate_doublet_performance(input_data)

# Display results
print(doublet_simulation_results)
```

## Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

## License

This project is licensed under the MIT License. See `LICENSE` for details.


## Installation for further development

### Install from Source with Pixi for further Development

To install `pyThermoGIS` from source using Pixi, follow these steps:

1. Clone the repository:
   ```sh
   git clone https://gitlab.com/your-repo/pythermogis.git
   cd pythermogis
   ```
2. Ensure Pixi is installed:
   ```sh
   curl -sSL https://pixi.sh/install.sh | bash
   ```
3. Install dependencies and create an isolated environment:
   ```sh
   pixi install
   ```
4. Activate the environment:
   ```sh
   pixi run python
   ```
+0 −0

Empty file deleted.

+0 −28
Original line number Diff line number Diff line
import os
from pathlib import Path

from git import Repo
from pydantic import BaseModel, model_validator


class DoubletParameters(BaseModel):
    use_stimulation: bool = False
    use_heat_pump: bool = False
    hp_minimum_injection_temperature: float = 15
    max_cooling_temperature_range: float = 100
    stimKhMax: float = 20
    return_temperature: float = 30
    surface_temperature: float = 10
class Config(BaseModel):
    input_data_path: Path | None
    results_path: Path | None

    DoubletParameters : DoubletParameters


    @model_validator(mode="after")
    def set_paths(self):
        if not self.output_path:
            repo_path = Path(Repo(".", search_parent_directories=True).working_tree_dir)
            self.output_path = repo_path / "models" / self.model_name
        return self
+2 −2
Original line number Diff line number Diff line
def calculate_temperature_from_gradient(depth, thickness, degrees_per_km, surface_temperature):
def calculate_temperature_from_gradient(depth: float, thickness: float, degrees_per_km: float, surface_temperature: float):
    return surface_temperature + (depth + thickness / 2) * (degrees_per_km * 0.001)
Loading