TNO Intern

Commit 6efd2b75 authored by Florian Knappers's avatar Florian Knappers
Browse files

new filestructure

parent f8f696e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,4 +10,4 @@ dist

tests/resources/test_output

/src/pythermogis/jvm/JVM17
 No newline at end of file
/src/pythermogis/resources/JVM17
 No newline at end of file
+32 −26
Original line number Diff line number Diff line
@@ -11,16 +11,18 @@ Luckily, it is easy (and insightful) to use pythermogis to generate samples and
Here is a simple example where you define probability distributions on your input parameters and then run simulations across random combinations of those input parameters before deriving statistics from those simulations:

```python
from pythermogis import calculate_doublet_performance, calculate_pos, plot_exceedance
from pythermogis.doublet import calculate_doublet_performance
from pythermogis.plot import plot_exceedance
from pythermogis.postprocess import calculate_pos
import xarray as xr
from matplotlib import pyplot as plt
from pathlib import Path
from os import path
import numpy as np


# output directory to write output to
output_data_path = Path(path.dirname(__file__), "resources") / "test_output" / "exceedance_example"
output_data_path = Path(path.dirname(__file__),
                        "resources") / "test_output" / "exceedance_example"
output_data_path.mkdir(parents=True, exist_ok=True)

# generate simulation samples across desired reservoir properties
@@ -42,13 +44,16 @@ reservoir_properties = xr.Dataset(
)

# For every sample, run a doublet simulation store the output values
simulations = calculate_doublet_performance(reservoir_properties, print_execution_duration=True)
simulations = calculate_doublet_performance(reservoir_properties,
                                            print_execution_duration=True)

# post process the samples to calculate the percentiles of each variable
percentiles = np.arange(1, 99)
results = simulations.quantile(q=percentiles / 100, dim="sample")
results = results.assign_coords(quantile=("quantile", percentiles)) # Overwrite the 'quantile' coordinate with integer percentiles
results = results.rename({"quantile": "p_value"}) # Rename dimension to 'p_value' to match nomenclature in the rest of pythermogis
results = results.assign_coords(quantile=("quantile",
                                          percentiles))  # Overwrite the 'quantile' coordinate with integer percentiles
results = results.rename({
                             "quantile": "p_value"})  # Rename dimension to 'p_value' to match nomenclature in the rest of pythermogis
results["pos"] = calculate_pos(results)

# plotting
@@ -76,7 +81,8 @@ plot_exceedance(results["permeability"], ax=axes[0,0])
plot_exceedance(results["utc"], ax=axes[0, 1])
plot_exceedance(results["power"], ax=axes[1, 0])
plot_exceedance(results["npv"], ax=axes[1, 1])
axes[1, 1].axhline(results["pos"], ls="--", c="tab:orange", label=f"POS: {results["pos"]:.1f}%")   # add the probability of success
axes[1, 1].axhline(results["pos"], ls="--", c="tab:orange",
                   label=f"POS: {results["pos"]:.1f}%")  # add the probability of success
axes[1, 1].axvline(0, ls="--", c="tab:orange")  # add the probability of success
axes[1, 1].legend()
plt.savefig(output_data_path / "exceedance_probabilities.png")
+4 −2
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ Here is an example, where the default utc_properties is used, but the UseHeatpum
`utc_properties` themselves, with the `.setupUTCParameters()` method of the `thermogis_properties`.

```python
from pythermogis import calculate_doublet_performance, instantiate_thermogis_parameters
from pythermogis.doublet import calculate_doublet_performance
from pythermogis.properties import instantiate_thermogis_parameters
import xarray as xr

input_data = xr.Dataset({
@@ -67,7 +68,8 @@ The vast majority of the parameters in the xml are not used by this python API;
unfortunately they are still needed in the xml file to enable parsing.

```python
from src.pythermogis import calculate_doublet_performance_stochastic, instantiate_thermogis_properties_from_file
from pythermogis.doublet import calculate_doublet_performance_stochastic
from pythermogis.properties import instantiate_thermogis_properties_from_file
import xarray as xr

input_data = xr.Dataset({
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import numpy as np
import xarray as xr
from matplotlib import pyplot as plt

from pythermogis import calculate_doublet_performance
from pythermogis.doublet import calculate_doublet_performance

# output directory to write output to
output_data_path = Path(__file__).parent.parent / "resources" / "test_output" / "example9"
+2 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ This example demonstrates how to run a deterministic doublet simulation using th
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 pythermogis import calculate_doublet_performance
from pythermogis.doublet import calculate_doublet_performance
import xarray as xr

input_data = xr.Dataset({
@@ -39,7 +39,7 @@ 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 pythermogis import calculate_doublet_performance
from pythermogis.doublet import calculate_doublet_performance
import xarray as xr
import numpy as np

Loading