TNO Intern

Commit 7ae11906 authored by Florian Knappers's avatar Florian Knappers
Browse files

use new setup in some tests

parent 0c008efc
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -63,11 +63,6 @@ class ThermoGISDoublet:
    ) -> ThermoGISDoubletResults:
        start = timeit.default_timer()

        if p_values is not None and not isinstance(self.aquifer, StochasticAquifer):
            raise TypeError("p_values requires a StochasticAquifer")
        if p_values is None and isinstance(self.aquifer, StochasticAquifer):
            raise TypeError("StochasticAquifer requires p_values")

        if mask_value is None:
            mask_value = 0.0 if p_values is not None else np.nan

+0 −0

File moved.

+11 −26
Original line number Diff line number Diff line
from pathlib import Path
from unittest import TestCase

import xarray as xr
from pytg3.aquifer import StochasticAquifer
from pytg3.doublet import ThermoGISDoublet
from pytg3.settings import Settings

from pythermogis.doublet import calculate_doublet_performance_stochastic
from pythermogis.properties import instantiate_thermogis_properties_from_file


class UTCBuilder(TestCase):
@@ -23,10 +23,8 @@ class UTCBuilder(TestCase):
        ]
        utc_properties = []
        for scenario in scenarios:
            tg_properties = instantiate_thermogis_properties_from_file(
                self.scenarios_file_path / scenario
            )
            utc_properties.append(tg_properties.setupUTCParameters())
            settings = Settings().from_file(self.scenarios_file_path / scenario)
            utc_properties.append(settings)

        # If test reaches here, then parsing of xml's worked,
        # check that the scenarios actually run on a set of test data:
@@ -44,28 +42,15 @@ class UTCBuilder(TestCase):
        ]
        utc_properties = []
        for scenario in scenarios:
            tg_properties = instantiate_thermogis_properties_from_file(
                self.scenarios_file_path / scenario
            )
            utc_properties.append(tg_properties.setupUTCParameters())
            settings = Settings().from_file(self.scenarios_file_path / scenario)
            utc_properties.append(settings)

        # If test reaches here, then parsing of xml's worked,
        # check that the scenarios actually run on a set of test data:
        [self.run_scenario(utc_property) for utc_property in utc_properties]

    def run_scenario(self, utc_properties):
        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),
            }
        )
    def run_scenario(self, settings: Settings):
        aquifer = StochasticAquifer(thickness_mean=300, thickness_sd=50, ntg=0.5, porosity=0.5, depth=5000, ln_permeability_mean=5, ln_permeability_sd=0.5)
        doublet = ThermoGISDoublet(settings=settings, aquifer=aquifer)
        doublet.simulate(p_values=[50])
        calculate_doublet_performance_stochastic(
            input_data, utc_properties=utc_properties
        )