TNO Intern

Commit 56dc15db authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Fixing the tests and ensuring test output is not added to the repo

parent 4d43a46a
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,3 +6,5 @@ __pycache__
*.egg-info
build
dist

tests/resources/test_output
 No newline at end of file
+10 −3
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@ def calculate_doublet_performance(reservoir_properties: xr.Dataset, utc_properti
        - "transmissivity"
        - "transmissivity_with_ntg"
    """
    if print_execution_duration: start = timeit.default_timer()
    if print_execution_duration:
        start = timeit.default_timer()

    validate_input(reservoir_properties)

@@ -107,8 +108,12 @@ def calculate_doublet_performance(reservoir_properties: xr.Dataset, utc_properti

    output_data = reservoir_properties.copy()
    output_data = simulate_doublet(output_data, reservoir_properties, rng_seed, utc_properties, mask_value=mask_value)
    if chunk_size is not None: output_data.load() # If chunking has occurred then the data must be de-chunked
    if print_execution_duration: print(f"Doublet simulation took {timeit.default_timer() - start:.1f} seconds")

    if chunk_size is not None:
        output_data.load() # If chunking has occurred then the data must be de-chunked

    if print_execution_duration:
        print(f"Doublet simulation took {timeit.default_timer() - start:.1f} seconds")

    return output_data

@@ -131,11 +136,13 @@ def validate_input(reservoir_properties: xr.Dataset):
    for variable in ["thickness", "porosity", "ntg", "depth"]:
        if variable not in reservoir_properties:
            missing_variables.append(variable)

    if len(missing_variables) > 0:
        raise ValueError(f"provided reservoir properties Dataset does not contain the following required variables: {missing_variables}")

    if "permeability" not in reservoir_properties and "transmissivity" not in reservoir_properties:
        raise ValueError(f"provided reservoir properties Dataset must provide either permeability or transmissivity variables, currently neither are provided")

    if "permeability" in reservoir_properties and "transmissivity" in reservoir_properties:
        warnings.warn("Both reservoir permeability and transmissivity provided; however the doublet simulation will use only the provided transmissivity and ignore permeability (transmissivity = permeability * thickness)")

+5 −8
Original line number Diff line number Diff line
@@ -99,8 +99,11 @@ def calculate_performance_of_single_location(mask: float, depth: float, thicknes
    inj_temp: float [C]
    prd_temp: float [C]
    """
    if not validate_input(depth, mask, ntg, porosity, temperature, thickness, transmissivity,
                   transmissivity_with_ntg, utc_properties):
    if not validate_input(depth, ntg, porosity, temperature, thickness, transmissivity,
                   transmissivity_with_ntg):
        return (np.nan,) * 14

    if not np.isnan(mask) or temperature < utc_properties.minProdTemp():
        return (mask_value,) * 14

    # Instantiate ThermoGIS doublet
@@ -147,17 +150,14 @@ def calculate_performance_of_single_location(mask: float, depth: float, thicknes


def validate_input(depth: float,
    mask: float,
    ntg: float,
    porosity: float,
    temperature: float,
    thickness: float,
    transmissivity: float,
    transmissivity_with_ntg: float,
    utc_properties: float,
) -> bool:
    if np.any(np.isnan([depth,
                        mask,
                        ntg,
                        porosity,
                        temperature,
@@ -165,9 +165,6 @@ def validate_input(depth: float,
                        transmissivity,
                        transmissivity_with_ntg])):
        return False

    if temperature < utc_properties.minProdTemp():
        return False
    return True

def instantiate_thermogis_doublet(utc_properties, rng_seed: int = None) -> JClass:
−21.2 KiB
Loading image diff...