Files
opm-common/python/opm/util/__init__.py

33 lines
1.0 KiB
Python
Raw Permalink Normal View History

2021-04-11 09:11:35 +02:00
from opm._common import EModel, eclArrType
from opm._common import calc_cell_vol
def emodel_add_filter(self, key, operator, val1, val2 = None):
if key in ["I", "J", "K", "ROW", "COLUMN", "LAYER"]:
arrType=eclArrType.INTE
else:
arrList = self.get_list_of_arrays()
arrNameList = [item[0] for item in arrList]
arrTypeList = [item[1] for item in arrList]
2021-11-11 14:17:16 +01:00
2021-04-11 09:11:35 +02:00
if key not in arrNameList:
raise ValueError("{} array not found in EModel".format(key))
2021-11-11 14:17:16 +01:00
2021-04-11 09:11:35 +02:00
ind = arrNameList.index(key)
2021-11-11 14:17:16 +01:00
2021-04-11 09:11:35 +02:00
arrType = arrTypeList[ind]
2021-11-11 14:17:16 +01:00
2021-04-11 09:11:35 +02:00
if not val2:
if arrType == eclArrType.INTE:
self.__add_filter(key, operator, int(val1))
elif arrType == eclArrType.REAL:
self.__add_filter(key, operator, float(val1))
else:
if arrType == eclArrType.INTE:
self.__add_filter(key, operator, int(val1), int(val2))
elif arrType == eclArrType.REAL:
self.__add_filter(key, operator, float(val1), float(val2))
2021-11-11 14:17:16 +01:00
2021-04-11 09:11:35 +02:00
setattr(EModel, "add_filter", emodel_add_filter)