Skip to content

API Reference

get_viscosity_mode(mode)

Map a string to the Java ViscosityMode enum.

Parameters:

Name Type Description Default
mode Literal[kestin, batzlewang]

The viscosity mode to select.

required

Returns:

Name Type Description
viscosity_mode_enum JClass

The corresponding Java enum instance.

Source code in src/pythermogis/thermogis_classes/utc_properties.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def get_viscosity_mode(mode: t.Literal["kestin", "batzlewang"]) -> JClass:
    """
    Map a string to the Java ViscosityMode enum.

    Parameters
    ----------
    mode : Literal["kestin", "batzlewang"]
        The viscosity mode to select.

    Returns
    -------
    viscosity_mode_enum : jpype.JClass
        The corresponding Java enum instance.
    """
    start_jvm()
    viscosity_mode = JClass("tno.geoenergy.ViscosityMode")

    if mode == "kestin":
        return viscosity_mode.KESTIN
    elif mode == "batzlewang":
        return viscosity_mode.BATZLEWANG
    else:
        raise ValueError(f"Unknown viscosity mode: {mode}")

instantiate_utc_properties_builder()

Create and return a UTCPropertiesBuilder Java object.

The builder wraps the ThermoGIS UTCPropertiesBuilder Java class, which can

  • parse ThermoGIS scenario XML files, and
  • programmatically modify individual scenario parameters prior to running a simulation.

Returns:

Name Type Description
utc_properties_builder JClass

An instantiated UTCPropertiesBuilder that can be used to build or modify UTCProperties objects for ThermoGIS simulations.

Source code in src/pythermogis/thermogis_classes/utc_properties.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def instantiate_utc_properties_builder() -> JClass:
    """
    Create and return a ``UTCPropertiesBuilder`` Java object.

    The builder wraps the ThermoGIS **UTCPropertiesBuilder** Java class, which can

    * parse ThermoGIS scenario XML files, and
    * programmatically modify individual scenario parameters prior to running a simulation.

    Returns
    -------
    utc_properties_builder : jpype.JClass
        An instantiated ``UTCPropertiesBuilder`` that can be used to build or modify
        ``UTCProperties`` objects for ThermoGIS simulations.
    """
    start_jvm()
    return JClass("thermogis.properties.builders.UTCPropertiesBuilder")()

instantiate_utc_properties_from_xml(xml_file)

Provided the path to an xml scenario file, parse this file for the utc properties; beware, the xml parses does some validation checks, checking that files exist. Even if these parameters are not needed by the pyThermoGIS module, if these validation checks fail, the xml parser will fail. To get around this set these variables to null

Source code in src/pythermogis/thermogis_classes/utc_properties.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def instantiate_utc_properties_from_xml(xml_file: str | Path) -> JClass:
    """Provided the path to an xml scenario file, parse this file for the utc properties; beware, the xml parses does some validation checks, checking that files exist.
    Even if these parameters are not needed by the pyThermoGIS module, if these validation checks fail, the xml parser will fail. To get around this set these variables to null"""
    start_jvm()
    root = ET.parse(xml_file).getroot()

    # change the parameters input_data_directory, results_directory, and temperature_voxet_file to null; these parameters are not used by pyThermoGIS, and if they are not null then the UTCXmlParser will check for directory and file
    #   existence and cause the parsing to fail if they do not exist.
    variables = [root.find(variable) for variable in ["input_data_directory", "results_directory", "temperature_voxet_file"]]
    for var in variables:
        var.text = ""

    # parse to string and pass to the Java utc xml parser
    return JClass("thermogis.properties.parsers.UTCXmlParser")().parse(ET.tostring(root, encoding='utf8', method='xml'))