From ee2561bc2839efd24e9edd3fd5c5b6850e4f0f8e Mon Sep 17 00:00:00 2001 From: David Landa Marban Date: Mon, 2 Dec 2024 17:33:16 +0100 Subject: [PATCH] Improving performance and resdata as requirement --- src/pyopmspe11/utils/mapproperties.py | 19 +++++++++---------- src/pyopmspe11/visualization/data.py | 11 ++++------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/pyopmspe11/utils/mapproperties.py b/src/pyopmspe11/utils/mapproperties.py index 0fd507a..a30dc67 100644 --- a/src/pyopmspe11/utils/mapproperties.py +++ b/src/pyopmspe11/utils/mapproperties.py @@ -10,17 +10,14 @@ import numpy as np import pandas as pd from shapely.geometry import Polygon +from resdata.resfile import ResdataFile +from resdata.grid import Grid try: from opm.io.ecl import EGrid as OpmGrid from opm.io.ecl import EclFile as OpmFile except ImportError: - print("The opm Python package was not found, using resdata") -try: - from resdata.resfile import ResdataFile - from resdata.grid import Grid -except ImportError: - print("The resdata Python package was not found, using opm") + pass def grid(dic): @@ -461,11 +458,13 @@ def get_cell_info(dic, i): else: dic["xyz"] = dic["gridf"].get_xyz(global_index=i) dic["ijk"] = dic["gridf"].get_ijk(global_index=i) - vxyz = dic["gridf"].export_corners(dic["gridf"].export_index())[i] + if "vxyz" not in dic: + dic["vxyz"] = dic["gridf"].export_corners(dic["gridf"].export_index()) dic["corns"] = ( - f"{vxyz[0]}, {dic['dims'][2] -vxyz[2]}, {vxyz[3]}, " - + f"{dic['dims'][2] -vxyz[5]}, {vxyz[15]}, {dic['dims'][2] -vxyz[17]}, " - + f"{vxyz[12]}, {dic['dims'][2] - vxyz[14]}" + f"{dic['vxyz'][i][0]}, {dic['dims'][2] - dic['vxyz'][i][2]}, {dic['vxyz'][i][3]}, " + + f"{dic['dims'][2] - dic['vxyz'][i][5]}, {dic['vxyz'][i][15]}, " + + f"{dic['dims'][2] - dic['vxyz'][i][17]}, " + + f"{dic['vxyz'][i][12]}, {dic['dims'][2] - dic['vxyz'][i][14]}" ) diff --git a/src/pyopmspe11/visualization/data.py b/src/pyopmspe11/visualization/data.py index bfb3eac..271b3b4 100644 --- a/src/pyopmspe11/visualization/data.py +++ b/src/pyopmspe11/visualization/data.py @@ -16,6 +16,9 @@ import numpy as np import pandas as pd from scipy.interpolate import interp1d +from resdata.grid import Grid +from resdata.resfile import ResdataFile +from resdata.summary import Summary try: from opm.io.ecl import EclFile as OpmFile @@ -23,13 +26,7 @@ from opm.io.ecl import ERst as OpmRestart from opm.io.ecl import ESmry as OpmSummary except ImportError: - print("The Python package opm was not found, using resdata") -try: - from resdata.grid import Grid - from resdata.resfile import ResdataFile - from resdata.summary import Summary -except ImportError: - print("The resdata Python package was not found, using opm") + pass GAS_DEN_REF = 1.86843 WAT_DEN_REF = 998.108