TNO Intern

Commit a8da3d1d authored by Florian Knappers's avatar Florian Knappers
Browse files

Merge branch '94-finish-the-utc-calculation-4' into 'python-rewrite-of-java-code'

Resolve "finish the utc calculation"

See merge request !116
parents 9b98434b 88e3ace5
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -11,3 +11,5 @@ dist
tests/resources/test_output

pydoubletcalc_install

workdir
 No newline at end of file
+191 −31
Original line number Diff line number Diff line
@@ -52,9 +52,11 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/dask-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/dask-core-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/dbus-1.13.6-h5008d03_3.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/deprecated-1.3.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/distributed-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/docutils-0.21.2-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/donfig-0.8.1.post1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/et_xmlfile-2.0.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.3.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/expat-2.7.0-h5888daf_0.conda
@@ -63,6 +65,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/linux-64/gflags-2.2.2-h5888daf_1005.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/ghp-import-2.1.0-pyhd8ed1ab_2.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/glog-0.7.1-hbabe93e_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/google-crc32c-1.7.1-py313h74173ec_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/griffe-1.7.3-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.2.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda
@@ -164,6 +167,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/linux-64/nlohmann_json-3.12.0-h3f2d84a_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.9.1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/numba-0.62.1-py313hd8e3f9f_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/numcodecs-0.16.5-py313h08cd8bf_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/numpy-2.2.5-py313h17eae1a_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/openjpeg-2.5.3-h5fbd93e_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/openpyxl-3.1.5-py313h9c9eb82_1.conda
@@ -231,11 +235,13 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/noarch/virtualenv-20.34.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/watchdog-6.0.0-py313h78bf25f_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/wheel-0.45.1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2024.9.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/wrapt-1.17.3-py313h07c4f96_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2025.12.0-pyhcf101f3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/xorg-libxau-1.0.12-hb9d3cd8_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/xorg-libxdmcp-1.1.5-hb9d3cd8_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xyzservices-2025.4.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/yaml-0.2.5-h7f98852_2.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/zarr-3.1.5-pyhcf101f3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/zict-3.0.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.21.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/linux-64/zlib-1.3.1-hb9d3cd8_2.conda
@@ -306,14 +312,17 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/win-64/cytoolz-1.0.1-py313ha7868ed_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/dask-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/dask-core-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/deprecated-1.3.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/distributed-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/docutils-0.21.2-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/donfig-0.8.1.post1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/et_xmlfile-2.0.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.3.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.19.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/fsspec-2025.5.1-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/ghp-import-2.1.0-pyhd8ed1ab_2.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/google-crc32c-1.7.1-py313h5327936_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/griffe-1.7.3-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.2.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/hpack-4.1.0-pyhd8ed1ab_0.conda
@@ -400,6 +409,7 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/win-64/nh3-0.2.21-py39he870945_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.9.1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/numba-0.62.1-py313h924e429_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/numcodecs-0.16.5-py313hc90dcd4_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/numpy-2.2.5-py313hefb8edb_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/openjpeg-2.5.3-h4d64b90_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/openpyxl-3.1.5-py313he57e174_1.conda
@@ -470,11 +480,13 @@ environments:
      - conda: https://conda.anaconda.org/conda-forge/win-64/watchdog-6.0.0-py313hfa70ccb_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/wheel-0.45.1-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/win_inet_pton-1.1.0-pyh7428d3b_8.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2024.9.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/wrapt-1.17.3-py313h5ea7bf4_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2025.12.0-pyhcf101f3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/xorg-libxau-1.0.12-h0e40799_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/xorg-libxdmcp-1.1.5-h0e40799_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/xyzservices-2025.4.0-pyhd8ed1ab_0.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/yaml-0.2.5-h8ffe710_2.tar.bz2
      - conda: https://conda.anaconda.org/conda-forge/noarch/zarr-3.1.5-pyhcf101f3_0.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/zict-3.0.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.21.0-pyhd8ed1ab_1.conda
      - conda: https://conda.anaconda.org/conda-forge/win-64/zstandard-0.23.0-py313ha7868ed_2.conda
@@ -1624,6 +1636,18 @@ packages:
  purls: []
  size: 618596
  timestamp: 1640112124844
- conda: https://conda.anaconda.org/conda-forge/noarch/deprecated-1.3.1-pyhd8ed1ab_0.conda
  sha256: c994a70449d548dd388768090c71c1da81e1e128a281547ab9022908d46878c5
  md5: bf74a83f7a0f2a21b5d709997402cac4
  depends:
  - python >=3.10
  - wrapt <2,>=1.10
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/deprecated?source=hash-mapping
  size: 15815
  timestamp: 1761813872696
- conda: https://conda.anaconda.org/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda
  sha256: 6d977f0b2fc24fee21a9554389ab83070db341af6d6f09285360b2e09ef8b26e
  md5: 003b8ba0a94e2f1e117d0bd46aebc901
@@ -1674,6 +1698,18 @@ packages:
  - pkg:pypi/docutils?source=hash-mapping
  size: 402700
  timestamp: 1733217860944
- conda: https://conda.anaconda.org/conda-forge/noarch/donfig-0.8.1.post1-pyhd8ed1ab_1.conda
  sha256: d58e97d418f71703e822c422af5b9c431e3621a0ecdc8b0334c1ca33e076dfe7
  md5: c56a7fa5597ad78b62e1f5d21f7f8b8f
  depends:
  - python >=3.9
  - pyyaml
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/donfig?source=hash-mapping
  size: 22491
  timestamp: 1734368817583
- conda: https://conda.anaconda.org/conda-forge/noarch/et_xmlfile-2.0.0-pyhd8ed1ab_1.conda
  sha256: 2209534fbf2f70c20661ff31f57ab6a97b82ee98812e8a2dcb2b36a0d345727c
  md5: 71bf9646cbfabf3022c8da4b6b4da737
@@ -1864,6 +1900,37 @@ packages:
  purls: []
  size: 143452
  timestamp: 1718284177264
- conda: https://conda.anaconda.org/conda-forge/linux-64/google-crc32c-1.7.1-py313h74173ec_1.conda
  sha256: 81ca7fb5c0756e3a5934fe18b44b90be475a03329bcd715334455aec340e34c0
  md5: 8580f244242b4d6a8c1933d8d0475b9c
  depends:
  - __glibc >=2.17,<3.0.a0
  - libcrc32c >=1.1.2,<1.2.0a0
  - libgcc >=14
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  license: Apache-2.0
  license_family: Apache
  purls:
  - pkg:pypi/google-crc32c?source=hash-mapping
  size: 24798
  timestamp: 1755850411927
- conda: https://conda.anaconda.org/conda-forge/win-64/google-crc32c-1.7.1-py313h5327936_1.conda
  sha256: 5d1a3322ab5949c63326bbb779feaf47f95902849a9687da094e8de490250e22
  md5: 35b1131e4ea5eb0f27664eeb68c9a29b
  depends:
  - libcrc32c >=1.1.2,<1.2.0a0
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  - ucrt >=10.0.20348.0
  - vc >=14.3,<15
  - vc14_runtime >=14.44.35208
  license: Apache-2.0
  license_family: Apache
  purls:
  - pkg:pypi/google-crc32c?source=hash-mapping
  size: 27799
  timestamp: 1755850484807
- conda: https://conda.anaconda.org/conda-forge/noarch/griffe-1.7.3-pyhd8ed1ab_0.conda
  sha256: c1e4039c9b6d613e8e9feafa21fae58db5eebeaa5f8bece5d8610154ae6ebf80
  md5: aafe052f140a58b1afaf8ab473f5ac0d
@@ -4178,6 +4245,46 @@ packages:
  - pkg:pypi/numba?source=hash-mapping
  size: 5706597
  timestamp: 1759165298367
- conda: https://conda.anaconda.org/conda-forge/linux-64/numcodecs-0.16.5-py313h08cd8bf_0.conda
  sha256: 7c35d46639f8638849535a22cb7ae1b7210121be0c7b053d8e2ab7ed485e6bff
  md5: 0f394ef25fb81d1dec8ff4fa716f00bd
  depends:
  - __glibc >=2.17,<3.0.a0
  - deprecated
  - libgcc >=14
  - libstdcxx >=14
  - msgpack-python
  - numpy >=1.23,<3
  - numpy >=1.24
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  - typing_extensions
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/numcodecs?source=hash-mapping
  size: 808201
  timestamp: 1764782369322
- conda: https://conda.anaconda.org/conda-forge/win-64/numcodecs-0.16.5-py313hc90dcd4_0.conda
  sha256: 008d11564f2a3bac16ea0e323a02b24ca06fb28f8b74c01cde13098003c35b9b
  md5: 4006d795b35200d0d6e28a1de84dfcc5
  depends:
  - deprecated
  - msgpack-python
  - numpy >=1.23,<3
  - numpy >=1.24
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  - typing_extensions
  - ucrt >=10.0.20348.0
  - vc >=14.3,<15
  - vc14_runtime >=14.44.35208
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/numcodecs?source=hash-mapping
  size: 516677
  timestamp: 1764782612807
- conda: https://conda.anaconda.org/conda-forge/linux-64/numpy-2.2.5-py313h17eae1a_0.conda
  sha256: c0a200d0e53a1acbfa1d1e2277e3337ea2aa8cb584448790317a98c62dcaebce
  md5: 6ceeff9ed72e54e4a2f9a1c88f47bdde
@@ -4945,10 +5052,10 @@ packages:
- pypi: ./
  name: pythermogis
  version: 1.2.0
  sha256: 35de67af8136fb6442b90f5a2956e6ac57f8a6f52f1fbbfad15768e83e08b31f
  sha256: 5307b5b9e674861991952ee2bb4da21dfc517e11259fd4ed7735f28b5fb54408
  requires_dist:
  - jpype1>=1.5.2,<2
  - xarray==2024.9.0.*
  - xarray==2025.12.0.*
  - pandas>=2.2.3,<3
  - pytz>=2024.1,<2025
  - build>=1.2.2.post1,<2
@@ -5949,41 +6056,73 @@ packages:
  - pkg:pypi/win-inet-pton?source=hash-mapping
  size: 9555
  timestamp: 1733130678956
- conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2024.9.0-pyhd8ed1ab_1.conda
  sha256: 8bb5b522cdf1905d831a9b371a3a3bd2932a9f53398332fbd38ed3442015bbaf
  md5: dc790d427d89b85ae12fc094e264833f
- conda: https://conda.anaconda.org/conda-forge/linux-64/wrapt-1.17.3-py313h07c4f96_1.conda
  sha256: 3688598866224e3fbeed8a74f12fd0a3c19dadcb931ce778bdc6cc2e04621b3b
  md5: c2662497e9a9ff2153753682f53989c9
  depends:
  - numpy >=1.24
  - packaging >=23.1
  - pandas >=2.1
  - python >=3.10
  - __glibc >=2.17,<3.0.a0
  - libgcc >=14
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  license: BSD-2-Clause
  license_family: BSD
  purls:
  - pkg:pypi/wrapt?source=hash-mapping
  size: 64865
  timestamp: 1756851811052
- conda: https://conda.anaconda.org/conda-forge/win-64/wrapt-1.17.3-py313h5ea7bf4_1.conda
  sha256: 260a3295f39565c28be9232a11ca7ee435af6e9366ffd2569ff29a63e7c144a0
  md5: 3e199c8db04833fe628867462aeaca24
  depends:
  - python >=3.13,<3.14.0a0
  - python_abi 3.13.* *_cp313
  - ucrt >=10.0.20348.0
  - vc >=14.3,<15
  - vc14_runtime >=14.44.35208
  license: BSD-2-Clause
  license_family: BSD
  purls:
  - pkg:pypi/wrapt?source=hash-mapping
  size: 63385
  timestamp: 1756851987645
- conda: https://conda.anaconda.org/conda-forge/noarch/xarray-2025.12.0-pyhcf101f3_0.conda
  sha256: b35f6848f229d65dc6e6d58a232099a5e293405a5e3e369b15110ed255cf9872
  md5: efdb3ef0ff549959650ef070ba2c52d2
  depends:
  - python >=3.11
  - numpy >=1.26
  - packaging >=24.1
  - pandas >=2.2
  - python
  constrains:
  - seaborn-base >=0.12
  - distributed >=2023.9
  - scipy >=1.11
  - bottleneck >=1.4
  - cartopy >=0.23
  - cftime >=1.6
  - dask-core >=2024.6
  - distributed >=2024.6
  - flox >=0.9
  - h5netcdf >=1.3
  - h5py >=3.11
  - hdf5 >=1.14
  - iris >=3.9
  - matplotlib-base >=3.8
  - nc-time-axis >=1.4
  - netcdf4 >=1.6.0
  - numba >=0.60
  - numbagg >=0.8
  - pint >=0.24
  - pydap >=3.5.0
  - scipy >=1.13
  - seaborn-base >=0.13
  - sparse >=0.15
  - toolz >=0.12
  - nc-time-axis >=1.4
  - cftime >=1.6
  - h5netcdf >=1.2
  - matplotlib-base >=3.7
  - h5py >=3.8
  - zarr >=2.16
  - hdf5 >=1.12
  - numba >=0.57
  - iris >=3.7
  - cartopy >=0.22
  - dask-core >=2023.9
  - flox >=0.7
  - bottleneck >=1.3
  - pint >=0.22
  - sparse >=0.14
  - zarr >=2.18
  license: Apache-2.0
  license_family: APACHE
  purls:
  - pkg:pypi/xarray?source=hash-mapping
  size: 801066
  timestamp: 1728453306227
  size: 994025
  timestamp: 1764974555156
- conda: https://conda.anaconda.org/conda-forge/linux-64/xorg-libxau-1.0.12-hb9d3cd8_0.conda
  sha256: ed10c9283974d311855ae08a16dfd7e56241fac632aec3b92e3cfe73cff31038
  md5: f6ebe2cb3f82ba6c057dde5d9debe4f7
@@ -6062,6 +6201,27 @@ packages:
  purls: []
  size: 63274
  timestamp: 1641347623319
- conda: https://conda.anaconda.org/conda-forge/noarch/zarr-3.1.5-pyhcf101f3_0.conda
  sha256: c36bec7d02d2f227409fcc4cf586cf3a658af068b58374de7f8f2d0b5c1c84f9
  md5: c1844a94b2be61bb03bbb71574a0abfc
  depends:
  - python >=3.11
  - packaging >=22.0
  - numpy >=1.26
  - numcodecs >=0.14
  - typing_extensions >=4.9
  - donfig >=0.8
  - google-crc32c >=1.5
  - python
  constrains:
  - fsspec >=2023.10.0
  - obstore >=0.5.1
  license: MIT
  license_family: MIT
  purls:
  - pkg:pypi/zarr?source=hash-mapping
  size: 305998
  timestamp: 1763742695201
- conda: https://conda.anaconda.org/conda-forge/noarch/zict-3.0.0-pyhd8ed1ab_1.conda
  sha256: 5488542dceeb9f2874e726646548ecc5608060934d6f9ceaa7c6a48c61f9cc8d
  md5: e52c2ef711ccf31bb7f70ca87d144b9e
+4 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ license = { file = "LICENSE" }
requires-python = ">=3.11"
dependencies = [
    "jpype1>=1.5.2,<2",
    "xarray==2024.9.0.*",
    "xarray==2025.12.0.*",
    "pandas>=2.2.3,<3",
    "pytz>=2024.1,<2025",
    "build>=1.2.2.post1,<2",
@@ -42,6 +42,7 @@ platforms = ["win-64", "linux-64"]

[tool.pixi.pypi-dependencies]
pythermogis = { path = ".", editable = true }
#pydoubletcalc = { path = 'C:\Users\knappersfy\work\thermogis\pydoubletcalc', editable = true }

[tool.pixi.tasks]
test = "PYTHONPATH=src/pythermogis pytest -s tests/"
@@ -53,7 +54,7 @@ pytg = "PYTHONPATH=src pixi run python src/pythermogis/main.py"
[tool.pixi.dependencies]
python = ">=3.13.2,<3.14"
jpype1 = ">=1.5.2,<2"
xarray = "2024.9.0.*"
xarray = "2025.12.0.*"
pandas = ">=2.2.3,<3"
setuptools = ">=75.8.2,<76"
wheel = ">=0.45.1,<0.46"
@@ -71,6 +72,7 @@ pre-commit = ">=4.3.0,<5"
python-dotenv = ">=1.2.1,<2"
numba = ">=0.62.1,<0.63"
ruff = ">=0.14.8,<0.15"
zarr = ">=3.1.5,<4"

[tool.ruff]
line-length = 88
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import numpy as np
import xarray as xr
from jpype import JClass
from pythermogis.workflow.utc.doublet import calculate_doublet_performance, DoubletInput, DoubletOutput
from pythermogis.workflow.utc.utc_properties import UTCConfiguration
from pythermogis.workflow.utc.configuration import UTCConfiguration


def simulate_doublet(
+66 −1
Original line number Diff line number Diff line
import numpy as np
from scipy import stats
import xarray as xr
from numba import njit, prange
from numpy.typing import NDArray


def generate_thickness_permeability_transmissivity_for_pvalues(thickness_mean: float, thickness_sd: float, ln_permeability_mean: float, ln_permeability_sd: float, p_values: xr.DataArray, nSamples: int = 10000) -> float:
    """
@@ -53,3 +56,65 @@ def generate_thickness_permeability_transmissivity_for_pvalues(thickness_mean: f
    transmissivity_pvalues_sampled = transmissivity_samples[sample_indexes.astype(int)]

    return thickness_pvalues, permeability_pvalues, transmissivity_pvalues_sampled


@njit(parallel=True)
def calculate_transmissivity(
        thickness_mean: NDArray[np.float64],
        thickness_sd: NDArray[np.float64],
        ln_perm_mean: NDArray[np.float64],
        ln_perm_sd: NDArray[np.float64],
        quantile: float,
        z_score: float,
        n_samples: int,
):
    shape = thickness_mean.shape
    tm_flat = thickness_mean.ravel()
    ts_flat = thickness_sd.ravel()
    lpm_flat = ln_perm_mean.ravel()
    lps_flat = ln_perm_sd.ravel()

    n_cells = tm_flat.size
    idx = int(quantile * n_samples)

    thickness_p = np.empty(n_cells)
    permeability_p = np.empty(n_cells)
    transmissivity_p = np.empty(n_cells)

    for i in prange(n_cells):
        tm = tm_flat[i]
        ts = ts_flat[i]
        lpm = lpm_flat[i]
        lps = lps_flat[i]

        if np.isnan(tm) or np.isnan(ts) or np.isnan(lpm) or np.isnan(lps):
            thickness_p[i] = np.nan
            permeability_p[i] = np.nan
            transmissivity_p[i] = np.nan
            continue

        # Generate samples for this cell
        thickness_samples = np.empty(n_samples)
        ln_perm_samples = np.empty(n_samples)

        for j in range(n_samples):
            if ts == 0:
                thickness_samples[j] = tm
            else:
                thickness_samples[j] = max(0.01, np.random.normal(tm, ts))
            ln_perm_samples[j] = np.random.normal(lpm, lps)

        # Transmissivity samples
        tr_samples = np.exp(ln_perm_samples) * thickness_samples
        tr_samples.sort()
        transmissivity_p[i] = tr_samples[idx]

        # Analytical percentiles
        thickness_p[i] = tm + z_score * ts if ts > 0 else tm
        permeability_p[i] = np.exp(lpm + z_score * lps)

    return (
        thickness_p.reshape(shape),
        permeability_p.reshape(shape),
        transmissivity_p.reshape(shape),
    )
 No newline at end of file
Loading