TNO Intern

Commit d89cb025 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

updating the docs to reflect this new way of working

parent a8c09ae8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
# API Reference

::: pythermogis.doublet_simulation.deterministic_doublet
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
# API Reference

::: pythermogis.doublet_simulation.stochastic_doublet
 No newline at end of file
+7 −9
Original line number Diff line number Diff line
@@ -39,21 +39,19 @@ Here is an example, where the default utc_properties is used, but the UseHeatPum
`utc_properties` themselves, with the `.build()` method of the `utc_properties_builder`.

```python
from src.pythermogis import calculate_doublet_performance_stochastic, instantiate_utc_properties_builder
from pythermogis import calculate_doublet_performance, instantiate_utc_properties_builder
import xarray as xr

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),
    "thickness": 300,
    "ntg": 0.5,
    "porosity": 0.5,
    "depth": 2000,
    "permeability": 300,
})

utc_properties = instantiate_utc_properties_builder().setUseHeatPump(True).build()
results = calculate_doublet_performance_stochastic(input_data, utc_properties=utc_properties)
results = calculate_doublet_performance(input_data, utc_properties=utc_properties)
print(results)
```

+25 −30
Original line number Diff line number Diff line
## Detmerninistic Doublet Performance Calculations
## Deterministic Doublet Performance Calculations

This is a very simple example of how to use the `calculate_doublet_performance` function from 
the `pythermogis` package to run a deterministic (without uncertainty quatification) to run a doublet simulation.
This is a simple example of how to use the `calculate_doublet_performance` function from 
the `pythermogis` package to run a deterministic (without uncertainty quantification) doublet simulation.

!!! note "xarray is at the heart of data handling in pythermogis"
    The `calculate_doublet_performance` function expects an xarray Dataset as input, which contains the necessary reservoir properties.
@@ -11,25 +11,22 @@ the `pythermogis` package to run a deterministic (without uncertainty quatificat

### 🧪 Basic Example

This example demonstrates how to run a deterministic doublet simulation using the `calculate_doublet_performance` function 
for a single location. The outcomes correspond to the mean values of the input parameters, 
and the results are printed to the console.
This example demonstrates how to run a deterministic doublet simulation using the `calculate_doublet_performance` function for a single location. 
The outcomes are deterministic, meaning there is no stochastic sampling or probabilities associated with this simulation, the results are printed to the console.

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

input_data = xr.Dataset({
    "thickness_mean": ((), 300),
    "thickness_sd": ((), 50),
    "ntg": ((), 0.5),
    "porosity": ((), 0.5),
    "depth": ((), 2000),
    "ln_permeability_mean": ((), 5),
    "ln_permeability_sd": ((), 0.5),
    "thickness": 300,
    "ntg": 0.5,
    "porosity": 0.5,
    "depth": 2000,
    "permeability": 300,
})

results = calculate_doublet_performance_stochastic(input_data)
results = calculate_doublet_performance(input_data)
print(results)
```

@@ -38,25 +35,23 @@ print(results)
### 🌍 2D Grid Example

This example demonstrates how to run a deterministic doublet simulation using the `calculate_doublet_performance` function 
for a user defined 2-d grid of locations. The outcomes correspond to the mean values of the input parameters, 
and the results are printed to the console
for a user defined 2-d grid of locations.
The outcomes are deterministic, meaning there is no stochastic sampling or probabilities associated with this simulation, the results are printed to the console.

```python
from src.pythermogis import calculate_doublet_performance_stochastic
from pythermogis import calculate_doublet_performance
import xarray as xr
import numpy as np

input_data = xr.Dataset({
    "thickness_mean": (("x", "y"), np.array([[300, 300], [200, 200]])),
    "thickness_sd": (("x", "y"), np.array([[50, 50], [25, 25]])),
    "thickness": (("x", "y"), np.array([[300, 300], [200, 200]])),
    "ntg": (("x", "y"), np.array([[0.5, 0.5], [0.25, 0.25]])),
    "porosity": (("x", "y"), np.array([[0.5, 0.5], [0.75, 0.7]])),
    "depth": (("x", "y"), np.array([[5000, 5000], [4500, 4500]])),
    "ln_permeability_mean": (("x", "y"), np.array([[5, 5], [4.5, 4.5]])),
    "ln_permeability_sd": (("x", "y"), np.array([[0.5, 0.5], [0.75, 0.75]])),
    "permeability": (("x", "y"), np.array([[300, 300], [450, 450]])),
}, coords={"x": [0, 1], "y": [10, 20]})

results = calculate_doublet_performance_stochastic(input_data)
results = calculate_doublet_performance(input_data)
print(results)
```

@@ -71,23 +66,23 @@ run a deterministic doublet simulation using the `calculate_doublet_performance`
    Example input data for some of these examples is available in the `/resources/example_data` directory

```python
from src.pythermogis import calculate_doublet_performance_stochastic
from pythermogis import calculate_doublet_performance
from pygridsio import read_grid
import numpy as np

input_grids = read_grid("thickness.zmap").to_dataset(name="thickness_mean")
input_grids["thickness_sd"] = read_grid("thickness_sd.zmap")
input_grids = read_grid("thickness.zmap").to_dataset(name="thickness")
input_grids["ntg"] = read_grid("ntg.zmap")
input_grids["porosity"] = read_grid("porosity.zmap")
input_grids["depth"] = read_grid("top_depth.zmap")
input_grids["mask"] = read_grid("hydrocarbons.zmap")
input_grids["ln_permeability_mean"] = read_grid("ln_perm.zmap")
input_grids["ln_permeability_sd"] = read_grid("ln_perm_sd.zmap")
input_grids["permeability"] = np.exp(read_grid("ln_perm.zmap")) # convert to natural space permeability

results = calculate_doublet_performance_stochastic(input_grids)
results = calculate_doublet_performance(input_grids)
print(results)
x, y = 125e3, 525e3  # define location
results_loc = results.sel(x=x, y=y, method="nearest")
print(results_loc)
```

note: you get the results for a specific location by using xarray function `sel` to select the desired location from the results Dataset
!!! info "Selecting values from a dataset"
    You get the results for a specific location by using xarray function `sel` to select the desired location from the results Dataset, see [here](https://docs.xarray.dev/en/stable/user-guide/indexing.html) for more details.
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ This example demonstrates the following steps:

Example input data for this workflow is available in the `/resources/example_data` directory of the repository.

This example corresponds to test case `test_example5` in `test_doc_examples.py` in the `tests` 
This example corresponds to test case `test_example6` in `test_doc_examples.py` in the `tests` 
directory of the repository.

```python
@@ -47,7 +47,7 @@ output_data_path = Path(path.dirname(__file__), "resources") / "test_output" / "
output_data_path.mkdir(parents=True, exist_ok=True)

# if set to True then simulation is always run, otherwise pre-calculated results are read (if available)
run_simulation = False
run_simulation = True

# grids can be in .nc, .asc, .zmap or .tif format: see pygridsio package
new_cellsize = 5000  # in m, this sets the resolution of the model; to speed up calcualtions you can increase the cellsize
Loading