TNO Intern

Commit 2f4a59ad authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Merge branch '68-update-pygridsio' into 'main'

Resolve "update pygridsio"

Closes #68

See merge request AGS/Geothermal/thermogis/pythermogis!83
parents 3f7f7335 a489f81d
Loading
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -33,8 +33,9 @@ directory of the repository.

```python
from pythermogis import calculate_doublet_performance_stochastic, calculate_pos
from pygridsio import read_grid, plot_grid, resample_xarray_grid
from pygridsio import read_grid, plot_grid, resample_grid
from matplotlib import pyplot as plt
import numpy as np
import xarray as xr
from pathlib import Path
from os import path
@@ -51,13 +52,13 @@ 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
reservoir_properties = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
reservoir_properties["thickness_sd"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
reservoir_properties["ntg"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
reservoir_properties["porosity"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
reservoir_properties["depth"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
reservoir_properties["ln_permeability_mean"] = np.log(resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
reservoir_properties["ln_permeability_sd"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)
reservoir_properties = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
reservoir_properties["thickness_sd"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
reservoir_properties["ntg"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
reservoir_properties["porosity"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
reservoir_properties["depth"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
reservoir_properties["ln_permeability_mean"] = np.log(resample_grid(read_grid(input_data_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
reservoir_properties["ln_permeability_sd"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)

# simulate
# if doublet simulation has already been run then read in results, or run the simulation and write results out
+7 −7
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ environments:
      - pypi: https://files.pythonhosted.org/packages/f5/64/41c4367bcaecbc03ef0d2a3ecee58a7065d0a36ae1aa817fe573a2da66d4/matplotlib-3.10.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
      - pypi: https://files.pythonhosted.org/packages/d1/80/b9c19f1bb4ac6c5fa6f94a4f278bc68a778473d1814a86a375d7cffa193a/netCDF4-1.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
      - pypi: https://files.pythonhosted.org/packages/02/65/ad2bc85f7377f5cfba5d4466d5474423a3fb7f6a97fd807c06f92dd3e721/plotly-6.0.1-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/c2/70/6b5ba59d170fa4a873ae30de74c5d234a12654c282df64b0479413f08ccc/pygridsio-0.3.27-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/c9/58/c3bc54c0fad9a82899e9a2703e04ee6e8eaa76caa90c0689fd1b468a4427/pygridsio-1.0-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/ea/00/d815833441d8c52bf4a6930952e77d3de77d0bf67b3202ccc12dabdae279/pykrige-1.7.2.tar.gz
      - pypi: https://files.pythonhosted.org/packages/9f/bb/e12bebcf2668bcb83736cc76177f36ee300ac8069880fca3a73f8753fc70/pyogrio-0.11.0-cp313-cp313-manylinux_2_28_x86_64.whl
      - pypi: https://files.pythonhosted.org/packages/05/e7/df2285f3d08fee213f2d041540fa4fc9ca6c2d44cf36d3a035bf2a8d2bcc/pyparsing-3.2.3-py3-none-any.whl
@@ -481,7 +481,7 @@ environments:
      - pypi: https://files.pythonhosted.org/packages/b1/0f/eed564407bd4d935ffabf561ed31099ed609e19287409a27b6d336848653/matplotlib-3.10.3-cp313-cp313-win_amd64.whl
      - pypi: https://files.pythonhosted.org/packages/66/b5/e04550fd53de57001dbd5a87242da7ff784c80790adc48897977b6ccf891/netCDF4-1.7.2-cp313-cp313-win_amd64.whl
      - pypi: https://files.pythonhosted.org/packages/02/65/ad2bc85f7377f5cfba5d4466d5474423a3fb7f6a97fd807c06f92dd3e721/plotly-6.0.1-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/c2/70/6b5ba59d170fa4a873ae30de74c5d234a12654c282df64b0479413f08ccc/pygridsio-0.3.27-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/c9/58/c3bc54c0fad9a82899e9a2703e04ee6e8eaa76caa90c0689fd1b468a4427/pygridsio-1.0-py3-none-any.whl
      - pypi: https://files.pythonhosted.org/packages/ea/00/d815833441d8c52bf4a6930952e77d3de77d0bf67b3202ccc12dabdae279/pykrige-1.7.2.tar.gz
      - pypi: https://files.pythonhosted.org/packages/46/8f/a9d134fbbf213db259b79f5bd5bbe7e3de1ff34fbe2a0b0be9d7d2919323/pyogrio-0.11.0-cp313-cp313-win_amd64.whl
      - pypi: https://files.pythonhosted.org/packages/05/e7/df2285f3d08fee213f2d041540fa4fc9ca6c2d44cf36d3a035bf2a8d2bcc/pyparsing-3.2.3-py3-none-any.whl
@@ -4672,10 +4672,10 @@ packages:
  - pkg:pypi/pygments?source=hash-mapping
  size: 888600
  timestamp: 1736243563082
- pypi: https://files.pythonhosted.org/packages/c2/70/6b5ba59d170fa4a873ae30de74c5d234a12654c282df64b0479413f08ccc/pygridsio-0.3.27-py3-none-any.whl
- pypi: https://files.pythonhosted.org/packages/c9/58/c3bc54c0fad9a82899e9a2703e04ee6e8eaa76caa90c0689fd1b468a4427/pygridsio-1.0-py3-none-any.whl
  name: pygridsio
  version: 0.3.27
  sha256: b8b222455de2a2c447609eb4ac13a11777ce63ce70512feb56ebe5898be7a674
  version: '1.0'
  sha256: 07468ac4df8295421054a38965dbac73b68daf11deee5f3d0fa2565da83ec92d
  requires_dist:
  - numpy
  - pandas
@@ -4828,14 +4828,14 @@ packages:
- pypi: ./
  name: pythermogis
  version: 1.1.1
  sha256: 6144a7e98f661d174d6aeae7b3695e7d78fa2ad50a26133e22e6c0239ec33186
  sha256: 77448402bd1f149d14b6ef577dd4e1b1f200c2b6f0e20c782f73fd5f55824804
  requires_dist:
  - jpype1>=1.5.2,<2
  - xarray==2024.9.0.*
  - pandas>=2.2.3,<3
  - pytz>=2024.1,<2025
  - build>=1.2.2.post1,<2
  - pygridsio>=0.3.27,<0.4
  - pygridsio>=1.0,<2.0
  requires_python: '>=3.11'
  editable: true
- conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.13.3-hf636f53_101_cp313.conda
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ dependencies = [
    "pandas>=2.2.3,<3",
    "pytz>=2024.1,<2025",
    "build>=1.2.2.post1,<2",
    "pygridsio>=0.3.27,<0.4"]
    "pygridsio>=1.0,<2.0"]


[tool.pytest.ini_options]
+8 −8
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ def test_example_5():

def test_example_6():
    from pythermogis import calculate_doublet_performance_stochastic, calculate_pos
    from pygridsio import read_grid, plot_grid, resample_xarray_grid
    from pygridsio import read_grid, plot_grid, resample_grid
    from matplotlib import pyplot as plt
    import numpy as np
    import xarray as xr
@@ -119,13 +119,13 @@ def test_example_6():

    # grids can be in .nc, .asc, .zmap or .tif format: see pygridsio package
    new_cellsize = 20000  # in m, this sets the resolution of the model; to speed up calcualtions you can increase the cellsize
    reservoir_properties = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
    reservoir_properties["thickness_sd"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["ntg"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["porosity"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
    reservoir_properties["depth"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["ln_permeability_mean"] = np.log(resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
    reservoir_properties["ln_permeability_sd"] = resample_xarray_grid(read_grid(input_data_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)
    reservoir_properties = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
    reservoir_properties["thickness_sd"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["ntg"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["porosity"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
    reservoir_properties["depth"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
    reservoir_properties["ln_permeability_mean"] = np.log(resample_grid(read_grid(input_data_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
    reservoir_properties["ln_permeability_sd"] = resample_grid(read_grid(input_data_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)

    # simulate
    # if doublet simulation has already been run then read in results, or run the simulation and write results out
+11 −10
Original line number Diff line number Diff line
import shutil
import timeit
from os import path
from unittest.case import TestCase, skip
from pygridsio import read_grid, resample_xarray_grid
from unittest.case import TestCase

from pygridsio import read_grid, resample_grid

from pythermogis import *


class PyThermoGIS(TestCase):
    test_files_path = Path(path.dirname(__file__), "resources") / "test_input" / "example_data"
    test_files_out_path = Path(path.dirname(__file__), "resources") / "test_output" / "example_data"
@@ -35,11 +36,11 @@ class PyThermoGIS(TestCase):

    def read_input_grids(self):
        new_cellsize=5000 # in m
        input_grids = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
        input_grids["thickness_sd"] = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
        input_grids["ntg"] = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
        input_grids["porosity"] = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
        input_grids["depth"] = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
        input_grids["ln_permeability_mean"] = np.log(resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
        input_grids["ln_permeability_sd"] = resample_xarray_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)
        input_grids = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__thick.zmap"), new_cellsize=new_cellsize).to_dataset(name="thickness_mean")
        input_grids["thickness_sd"] = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__thick_sd.zmap"), new_cellsize=new_cellsize)
        input_grids["ntg"] = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__ntg.zmap"), new_cellsize=new_cellsize)
        input_grids["porosity"] = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__poro.zmap"), new_cellsize=new_cellsize) / 100
        input_grids["depth"] = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__top.zmap"), new_cellsize=new_cellsize)
        input_grids["ln_permeability_mean"] = np.log(resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__perm.zmap"), new_cellsize=new_cellsize))
        input_grids["ln_permeability_sd"] = resample_grid(read_grid(self.test_files_out_path / "ROSL_ROSLU__ln_perm_sd.zmap"), new_cellsize=new_cellsize)
        return input_grids
 No newline at end of file