#1641 Update libecl to latest revision from master

This commit is contained in:
Bjørnar Grip Fjær
2017-06-22 11:51:46 +02:00
parent faf225d8c3
commit 956798afd6
556 changed files with 4579 additions and 3573 deletions

View File

@@ -30,7 +30,9 @@ function(add_python_package target package_path source_files install_package)
list(APPEND build_files ${build_file} )
if (install_package)
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${package_path})
# For cmake versions >= 2.8.12 the preferred keyword is DIRECTORY.
get_filename_component( src_path ${file} PATH )
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${package_path}/${src_path})
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/bin/cmake_pyc_file ${install_file})")
endif()

View File

@@ -34,5 +34,5 @@ macro( addPythonTest TEST_CLASS )
set_property(TEST ${TEST_NAME} PROPERTY LABELS "Python")
endif()
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "CTEST_PYTHONPATH=${CTEST_PYTHONPATH}")
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "CTEST_PYTHONPATH=${CTEST_PYTHONPATH};ERT_ROOT=${ERT_ROOT}")
endmacro( )

View File

@@ -27,6 +27,7 @@ function(find_python_package_version package)
endfunction()
# If we find the correct module and new enough version, set PY_package, where
# "package" is the given argument to the version we found else, display warning
# and do not set any variables.
@@ -34,17 +35,22 @@ function(find_python_package package version python_prefix)
if (CMAKE_PREFIX_PATH)
set( ORG_PYTHONPATH $ENV{PYTHONPATH} )
set( CMAKE_PYTHONATH "")
set( sep "")
foreach ( PREFIX_PATH ${CMAKE_PREFIX_PATH} )
set(THIS_PYTHONPATH "${PREFIX_PATH}/${python_prefix}")
set(ENV{PYTHONPATH} "${THIS_PYTHONPATH}:${ORG_PYTHONPATH}")
find_python_package_version(${package})
if (DEFINED PY_${package})
if (${PY_${package}_PATH} STREQUAL ${THIS_PYTHONPATH})
set(CTEST_PYTHONPATH "${PY_${package}_PATH}:${CTEST_PYTHONPATH}" PARENT_SCOPE)
endif()
break( )
endif()
set( CMAKE_PYTHONPATH "${CMAKE_PYTHONPATH}${sep}${PREFIX_PATH}/${python_prefix}")
set( sep ":")
endforeach()
set(ENV{PYTHONPATH} "${CMAKE_PYTHONPATH}:${ORG_PYTHONPATH}")
find_python_package_version(${package})
if (DEFINED PY_${package})
STRING(FIND ${CMAKE_PYTHONPATH} ${PY_${package}_PATH} pos)
if (${pos} GREATER -1)
set(CTEST_PYTHONPATH "${PY_${package}_PATH}:${CMAKE_PYTHONPATH}" PARENT_SCOPE)
endif()
endif()
set(ENV{PYTHONPATH} ${ORG_PYTHONPATH})
else()
find_python_package_version(${package})

View File

@@ -105,15 +105,34 @@ def runTestCase(tests, verbosity=0):
sys.exit(1)
# This will update both the internal sys.path load order and the
# environment variable PYTHONPATH with the following list:
#
# cwd:CTEST_PYTHONPATH:PYTHONPATH
def update_path():
for path in os.environ['CTEST_PYTHONPATH'].split(':'):
sys.path.insert(0 , path)
path_list = [os.getcwd()]
if 'CTEST_PYTHONPATH' in os.environ:
ctest_pythonpath = os.environ['CTEST_PYTHONPATH']
for path in ctest_pythonpath.split(':'):
path_list.append( path )
for path in reversed(path_list):
sys.path.insert(0 , path)
if 'PYTHONPATH' in os.environ:
pythonpath = os.environ['PYTHONPATH']
for path in pythonpath.split(':'):
path_list.append( path )
os.environ['PYTHONPATH'] = ':'.join( path_list )
if __name__ == '__main__':
update_path( )
from ecl.test import ErtTestRunner
for test_class in sys.argv[1:]:
tests = ErtTestRunner.getTestsFromTestClass(test_class)
@@ -172,4 +191,4 @@ for file in sys.argv[1:]:
endfunction()
endfunction()

View File

@@ -29,12 +29,11 @@ the py_compile module.
Installing the shared libraries
-------------------------------
The ctypes module is based on the dlopen() system call to open shared
libraries libecl.so, libert_util.so and so on. The final dlopen() call is
not passed any path information, i.e. the runtime linker must be able
to locate the shared libraries based solely on the normal runtime
linking conventions. This means that you have two alternatives when
installing the shared libraries:
The ctypes module is based on the dlopen() system call to open the shared
libecl.so. The final dlopen() call is not passed any path information, i.e. the
runtime linker must be able to locate the shared libraries based solely on the
normal runtime linking conventions. This means that you have two alternatives
when installing the shared libraries:
1. Install all the libraries in one of the standard library locations
like /usr/local/lib.
@@ -43,8 +42,7 @@ installing the shared libraries:
subsequently update the LD_LIBRARY_PATH variable to point to this
directory.
The shared libraries you will need are: libert_util.so, libecl.so,
librms.so, libsched.so, libenkf.so, libjob_queue.so, libconfig.so and libgeometry.so
The shared libraries you will need is 'libecl.so'
The test environment
--------------------

View File

@@ -2,4 +2,7 @@ configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/t
add_subdirectory(cwrap)
add_subdirectory( ecl )
add_subdirectory( bin )
if (INSTALL_ERT_LEGACY)
add_subdirectory( legacy/ert )
endif()

View File

@@ -1,24 +0,0 @@
if (BUILD_ERT)
set(application_list
ert_tcp_server
ertshell
ert_upgrade_fs107
)
foreach(prog ${application_list} )
file(COPY ${prog} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
endforeach()
endif()
if (INSTALL_ERT)
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
foreach(prog ${application_list} )
install(PROGRAMS ${prog} DESTINATION ${destination})
if (INSTALL_GROUP)
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})")
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})")
endif()
endforeach()
endif()

View File

@@ -1,53 +0,0 @@
#!/usr/bin/env python
import argparse
import socket
import sys
from ert.server.ertrpcserver import ErtRPCServer
default_port = 0
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=default_port, dest="port")
parser.add_argument("--host", default=socket.gethostname(), dest="host")
parser.add_argument("--localhost", default=False, action="store_true", dest="localhost")
parser.add_argument("--log-file", default="ert-server.log", dest="log_file")
parser.add_argument("--log-level", type=int, default=1, dest="log_level")
parser.add_argument("config_file")
args = parser.parse_args()
config_file = args.config_file
port = args.port
log_level = args.log_level
# By default the server will bind with the publicly available hostname
# socket.gethostname() - meaning that clients can connect from
# anywhere, but by using the --localhost switch the server can be
# instructed to only accept connections from localhost.
#
# On some computers the socket.gethostname() will not include the
# domain name; that will not work and we exit the server and ask the
# user to supply the full hostname using --host.
if args.localhost:
host = "localhost"
else:
host = args.host
if host.count(".") == 0:
sys.exit("Sorry - could not determine FQDN for server - use the --host option to supply.")
server = ErtRPCServer(config_file, host, port, log_requests=log_level > 1, verbose_queue=True)
try:
print("ERT Server running on port: %d at host: %s" % (server.port, host))
server.start()
except KeyboardInterrupt:
try:
server.stop()
print("ERT Server 'smoothly' killed the running jobs")
except Exception as e:
print("Unable to stop server 'gracefully'!")
raise e

View File

@@ -1,76 +0,0 @@
#!/usr/bin/env python
import sys
import os
import os.path
from ert.config import ConfigParser, ContentTypeEnum, UnrecognizedEnum
from ert.enkf import TimeMap,EnkfFs
from ert.ecl import EclSum
#TimeMap._upgrade107 =
def parse(config_file):
parser = ConfigParser( )
item = parser.add("REFCASE", False )
item.iset_type(0 , ContentTypeEnum.CONFIG_PATH )
item = parser.add("ENSPATH" , False )
item.iset_type(0 , ContentTypeEnum.CONFIG_EXISTING_PATH )
content = parser.parse( config_file , unrecognized = UnrecognizedEnum.CONFIG_UNRECOGNIZED_IGNORE )
if "REFCASE" in content:
refcase = EclSum( content.getValue( "REFCASE" ))
else:
refcase = None
if "ENSPATH" in content:
path = content["ENSPATH"]
enspath = path[0].getPath( )
else:
enspath = "storage"
return enspath , refcase
def upgrade(ens_path, refcase):
for case in os.listdir( ens_path ):
full_case = os.path.join( ens_path , case )
if os.path.isdir( full_case ):
version = EnkfFs.diskVersion( full_case )
try:
version = EnkfFs.diskVersion( full_case )
except IOError:
print "The case:%s was ignored" % full_case
continue
if version < 105:
print "Very old case: %s ignored - you should probably delete this" % full_case
continue
if version < 107:
print "Upgrading %s to version 107" % full_case
time_map_file = os.path.join( full_case , "files/time-map")
if os.path.isfile( time_map_file ):
time_map = TimeMap( time_map_file)
assert( isinstance( refcase , EclSum ))
time_map.upgrade107( refcase )
time_map.fwrite( time_map_file )
else:
print "No time-map file found"
EnkfFs.updateVersion( full_case, version , 107 )
fs = EnkfFs( full_case )
if len(sys.argv) != 2:
sys.exit("Script must have exactly one argument: config_file")
config_file = sys.argv[1]
ens_path , refcase = parse( config_file )
if refcase:
print "Upgrading storage:%s with refcase:%s" % (ens_path , refcase.case )
upgrade( ens_path , refcase )

View File

@@ -1,35 +0,0 @@
#!/usr/bin/env python
import os
from PyQt4.QtGui import QApplication
import sys
import ert_gui
from ert_gui.ertwidgets import resourceIcon
from ert_gui.shell import ErtShell
from ert_gui.tools import HelpCenter
if __name__ == '__main__':
if os.getenv("ERT_SHARE_PATH"):
ert_share_path = os.getenv("ERT_SHARE_PATH")
else:
ert_share_path = os.path.realpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../share"))
ert_gui.ertwidgets.img_prefix = ert_share_path + "/gui/img/"
help_center = HelpCenter("ERT")
help_center.setHelpLinkPrefix(os.getenv("ERT_SHARE_PATH") + "/gui/help/")
app = QApplication(sys.argv)
app.setWindowIcon(resourceIcon("application/window_icon_cutout"))
ert_shell = ErtShell()
if len(sys.argv) > 1:
ert_shell.onecmd('load_config %s' % sys.argv[1])
if len(sys.argv) > 2:
for workflow in sys.argv[2:]:
ert_shell.onecmd('workflows run %s' % workflow)
ert_shell.cmdloop()

View File

@@ -14,20 +14,6 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
"""Convenience module for loading shared library.
Observe that to ensure that all libraries are loaded through the same
code path, all required libraries should be loaded explicitly through
the use of import statements; i.e. the ecl.geo package requires the
libert_util librarary, to ensure that the correct version of the
libert_util.so library file is loaded we should manually load that
first as:
import ecl.util
GEO_LIB = ecl.load("libert_geometry")
Otherwise the standard operating system dependency resolve code will
be invoked when loading libert_geometry, and that could in principle
lead to loading a different version of libert_util.so
"""
import platform

View File

@@ -160,6 +160,9 @@ class Prototype(object):
@classmethod
def registerType(cls, type_name, type_class_or_function, is_return_type=True, storage_type=None):
if storage_type is None and (inspect.isfunction(type_class_or_function)):
storage_type = ctypes.c_void_p
_registerType(type_name,
type_class_or_function,
is_return_type = is_return_type,

View File

@@ -47,7 +47,8 @@ class EclGrid(BaseCClass):
_alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular( int , int , int , double , double , double , int*)" , bind = False)
_exists = EclPrototype("bool ecl_grid_exists( char* )" , bind = False)
_get_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr( ecl_grid , char* )")
_get_numbered_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr_from_lgr_nr( ecl_grid , int)")
_get_named_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr( ecl_grid , char* )")
_get_cell_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_cell_lgr1( ecl_grid , int )")
_num_coarse_groups = EclPrototype("int ecl_grid_get_num_coarse_groups( ecl_grid )")
_in_coarse_group1 = EclPrototype("bool ecl_grid_cell_in_coarse_group1( ecl_grid , int)")
@@ -78,7 +79,8 @@ class EclGrid(BaseCClass):
_cell_contains = EclPrototype("bool ecl_grid_cell_contains_xyz1( ecl_grid , int , double , double , double )")
_cell_regular = EclPrototype("bool ecl_grid_cell_regular1( ecl_grid , int)")
_num_lgr = EclPrototype("int ecl_grid_get_num_lgr( ecl_grid )")
_has_lgr = EclPrototype("bool ecl_grid_has_lgr( ecl_grid , char* )")
_has_numbered_lgr = EclPrototype("bool ecl_grid_has_lgr_nr( ecl_grid , int)")
_has_named_lgr = EclPrototype("bool ecl_grid_has_lgr( ecl_grid , char* )")
_grid_value = EclPrototype("double ecl_grid_get_property( ecl_grid , ecl_kw , int , int , int)")
_get_cell_volume = EclPrototype("double ecl_grid_get_cell_volume1( ecl_grid , int )")
_get_cell_thickness = EclPrototype("double ecl_grid_get_cell_thickness1( ecl_grid , int )")
@@ -103,6 +105,11 @@ class EclGrid(BaseCClass):
_compressed_kw_copy = EclPrototype("void ecl_grid_compressed_kw_copy( ecl_grid , ecl_kw , ecl_kw)")
_global_kw_copy = EclPrototype("void ecl_grid_global_kw_copy( ecl_grid , ecl_kw , ecl_kw)")
_create_volume_keyword = EclPrototype("ecl_kw_obj ecl_grid_alloc_volume_kw( ecl_grid , bool)")
_use_mapaxes = EclPrototype("bool ecl_grid_use_mapaxes(ecl_grid)")
_export_coord = EclPrototype("ecl_kw_obj ecl_grid_alloc_coord_kw( ecl_grid )")
_export_zcorn = EclPrototype("ecl_kw_obj ecl_grid_alloc_zcorn_kw( ecl_grid )")
_export_actnum = EclPrototype("ecl_kw_obj ecl_grid_alloc_actnum_kw( ecl_grid )")
_export_mapaxes = EclPrototype("ecl_kw_obj ecl_grid_alloc_mapaxes_kw( ecl_grid )")
@@ -896,31 +903,40 @@ class EclGrid(BaseCClass):
"""
Query if the grid has an LGR with name @lgr_name.
"""
if self._has_lgr( lgr_name ):
if self._has_named_lgr( lgr_name ):
return True
else:
return False
def get_lgr( self , lgr_name ):
"""
Get EclGrid instance with LGR content.
def get_lgr(self, lgr_key):
"""Get EclGrid instance with LGR content.
Return an EclGrid instance based on the LGR named
@lgr_name. The LGR grid instance is in most questions like an
ordinary grid instance; the only difference is that it can not
be used for further queries about LGRs.
Return an EclGrid instance based on the LGR @lgr, the input
argument can either be the name of an LGR or the grid number
of the LGR. The LGR grid instance is mostly like an ordinary
grid instance; the only difference is that it can not be used
for further queries about LGRs.
If the grid does not contain an LGR with this name/nr
exception KeyError will be raised.
If the grid does not contain an LGR with this name the method
will return None.
"""
if self._has_lgr( lgr_name ):
lgr = self._get_lgr( name )
lgr.setParent( self )
return lgr
lgr = None
if isinstance(lgr_key, int):
if self._has_numbered_lgr(lgr_key):
lgr = self._get_numbered_lgr(lgr_key)
else:
raise KeyError("No such LGR:%s" % lgr_name)
if self._has_named_lgr(lgr_key):
lgr = self._get_named_lgr(lgr_key)
if lgr is None:
raise KeyError("No such LGR: %s" % lgr_key)
lgr.setParent(self)
return lgr
def get_cell_lgr( self, active_index = None , global_index = None , ijk = None):
"""
@@ -1199,3 +1215,18 @@ class EclGrid(BaseCClass):
"""
return self._create_volume_keyword( active_size )
def export_coord(self):
return self._export_coord()
def export_zcorn(self):
return self._export_zcorn()
def export_actnum(self):
return self._export_actnum()
def export_mapaxes(self):
if not self._use_mapaxes():
return None
return self._export_mapaxes()

View File

@@ -14,45 +14,92 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
import itertools
import numpy
import itertools, numpy
from math import sqrt
from ecl.util import IntVector
from ecl.ecl import EclGrid, EclKW, EclDataType, EclPrototype
def flatten(l):
return [elem for sublist in l for elem in sublist]
def divide(l, size):
return [l[i:i+size:] for i in range(0, len(l), size)]
def duplicate_inner(l):
return [elem for elem in l for i in range(2)][1:-1:]
def construct_floatKW(name, values):
kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
for i, value in enumerate(values):
kw[i] = value
return kw
def pre_mapaxes_translation(translation, mapaxes):
if mapaxes is None:
return translation
x, y, z = translation
unit_y = numpy.array((mapaxes[0]-mapaxes[2], mapaxes[1]-mapaxes[3]));
unit_y /= sqrt(numpy.sum(unit_y*unit_y))
unit_x = numpy.array((mapaxes[4]-mapaxes[2], mapaxes[5]-mapaxes[3]));
unit_x /= sqrt(numpy.sum(unit_x*unit_x))
det = 1.0 / (unit_x[0]*unit_y[1] - unit_x[1] * unit_y[0]);
return (
( x*unit_y[1] - y*unit_y[0]) * det,
(-x*unit_x[1] + y*unit_x[0]) * det,
z
)
class EclGridGenerator:
_alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular( int , int , int , double , double , double , int*)" , bind = False)
_alloc_rectangular = EclPrototype("ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind=False)
@classmethod
def createRectangular(cls, dims , dV , actnum = None):
def createRectangular(cls, dims, dV, actnum=None):
"""
Will create a new rectangular grid. @dims = (nx,ny,nz) @dVg = (dx,dy,dz)
With the default value @actnum == None all cells will be active,
"""
if actnum is None:
ecl_grid = cls._alloc_rectangular( dims[0] , dims[1] , dims[2] , dV[0] , dV[1] , dV[2] , None )
ecl_grid = cls._alloc_rectangular(
dims[0], dims[1], dims[2],
dV[0], dV[1], dV[2],
None
)
else:
if not isinstance(actnum , IntVector):
tmp = IntVector(initial_size = len(actnum))
for (index , value) in enumerate(actnum):
if not isinstance(actnum, IntVector):
tmp = IntVector(initial_size=len(actnum))
for (index, value) in enumerate(actnum):
tmp[index] = value
actnum = tmp
if not len(actnum) == dims[0] * dims[1] * dims[2]:
raise ValueError("ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" % (len(actnum) , dims[0] * dims[1] * dims[2]))
ecl_grid = cls._alloc_rectangular( dims[0] , dims[1] , dims[2] , dV[0] , dV[1] , dV[2] , actnum.getDataPtr() )
if not len(actnum) == dims[0]*dims[1]*dims[2]:
raise ValueError(
"ACTNUM size mismatch: len(ACTNUM):%d Expected:%d"
% (len(actnum), dims[0]*dims[1]*dims[2])
)
ecl_grid = cls._alloc_rectangular(
dims[0], dims[1], dims[2],
dV[0], dV[1], dV[2],
actnum.getDataPtr()
)
# If we have not succeeded in creatin the grid we *assume* the
# error is due to a failed malloc.
if ecl_grid is None:
raise MemoryError("Failed to allocated regualar grid")
return ecl_grid
@classmethod
def createSingleCellGrid(cls, corners):
def create_single_cell_grid(cls, corners):
"""
Provided with the corners of the grid in a similar manner as the eight
corners are output for a single cell, this method will create a grid
@@ -61,17 +108,21 @@ class EclGridGenerator:
zcorn = [corners[i][2] for i in range(8)]
flatten = lambda l : [elem for sublist in l for elem in sublist]
coord = [(corners[i], corners[i+4]) for i in range(4)]
coord = flatten(flatten(coord))
def constructFloatKW(name, values):
def construct_floatKW(name, values):
kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
for i in range(len(values)):
kw[i] = values[i]
return kw
grid = EclGrid.create((1,1,1), constructFloatKW("ZCORN", zcorn), constructFloatKW("COORD", coord), None)
grid = EclGrid.create(
(1, 1, 1),
construct_floatKW("ZCORN", zcorn),
construct_floatKW("COORD", coord),
None
)
if not corners == [grid.getCellCorner(i, 0) for i in range(8)]:
raise AssertionError("Failed to generate single cell grid. " +
@@ -80,7 +131,101 @@ class EclGridGenerator:
return grid
@classmethod
def createGrid(cls, dims, dV, offset=1,
def create_zcorn(cls, dims, dV, offset=1, escape_origo_shift=(1,1,0),
irregular_offset=False, irregular=False, concave=False,
faults=False):
cls.__assert_zcorn_parameters(dims, dV, offset, escape_origo_shift,
irregular_offset, irregular, concave, faults)
nx, ny, nz = dims
dx, dy, dz = dV
# Compute zcorn
z = escape_origo_shift[2]
zcorn = [z]*(4*nx*ny)
for k in range(nz-1):
z = z+dz
local_offset = offset + (dz/2. if irregular_offset and k%2 == 0 else 0)
layer = []
for i in range(ny+1):
shift = ((i if concave else 0) + (k/2 if irregular else 0)) % 2
path = [z if i%2 == shift else z+local_offset for i in range(nx+1)]
layer.append(duplicate_inner(path))
zcorn = zcorn + (2*flatten(duplicate_inner(layer)))
z = z+dz
zcorn = zcorn + ([z]*(4*nx*ny))
if faults:
# Ensure that drop does not align with grid structure
drop = (offset+dz)/2. if abs(offset-dz/2.) > 0.2 else offset + 0.4
zcorn = cls.__create_faults(nx, ny, nz, zcorn, drop)
if z != escape_origo_shift[2] + nz*dz:
raise ValueError("%f != %f" % (z, escape_origo_shift[2] + nz*dz))
cls.assert_zcorn(nx, ny, nz, zcorn)
return construct_floatKW("ZCORN", zcorn)
@classmethod
def create_coord(cls, dims, dV, escape_origo_shift=(1,1,0),
scale=1, translation=(0,0,0), rotate=False, misalign=False):
nx, ny, nz = dims
dx, dy, dz = dV
# Compute coord
z = escape_origo_shift[2] + nz*dz
coord = []
for j, i in itertools.product(range(ny+1), range(nx+1)):
x, y = i*dx+escape_origo_shift[0], j*dy+escape_origo_shift[1]
coord = coord + [x, y, escape_origo_shift[2], x, y, z]
# Apply transformations
lower_center = (
nx*dx/2. + escape_origo_shift[0],
ny*dy/2. + escape_origo_shift[1]
)
if misalign:
coord = cls.__misalign_coord(coord, dims, dV)
coord = cls.__scale_coord(coord, scale, lower_center)
if rotate:
coord = cls.__rotate_coord(coord, lower_center)
coord = cls.__translate_lower_coord(coord, translation)
cls.assert_coord(nx, ny, nz, coord)
return construct_floatKW("COORD", coord)
@classmethod
def __assert_zcorn_parameters(cls, dims, dV, offset, escape_origo_shift,
irregular_offset, irregular, concave, faults):
nx, ny, nz = dims
dx, dy, dz = dV
# Validate arguments
if min(dims + dV) <= 0:
raise ValueError("Expected positive grid and cell dimentions")
if offset < 0:
raise ValueError("Expected non-negative offset")
if irregular and offset + (dz/2. if irregular_offset else 0) > dz:
raise AssertionError("Arguments can result in self-" +
"intersecting cells. Increase dz, deactivate eiter " +
"irregular or irregular_offset, or decrease offset to avoid " +
"any problems")
@classmethod
def create_grid(cls, dims, dV, offset=1,
escape_origo_shift=(1,1,0),
irregular_offset=False, irregular=False, concave=False,
faults=False, scale=1, translation=(0,0,0), rotate=False,
@@ -132,85 +277,16 @@ class EclGridGenerator:
@irregular_offset.
"""
nx, ny, nz = dims
dx, dy, dz = dV
zcorn = cls.create_zcorn(dims, dV, offset, escape_origo_shift,
irregular_offset, irregular, concave, faults)
# Validate arguments
if min(dims + dV) <= 0:
raise ValueError("Expected positive grid and cell dimentions")
coord = cls.create_coord(dims, dV, escape_origo_shift, scale,
translation, rotate, misalign)
if offset < 0:
raise ValueError("Expected non-negative offset")
if irregular and offset + (dz/2. if irregular_offset else 0) > dz:
raise AssertionError("Arguments can result in self-" +
"intersecting cells. Increase dz, deactivate eiter " +
"irregular or irregular_offset, or decrease offset to avoid " +
"any problems")
verbose = lambda l : [elem for elem in l for i in range(2)][1:-1:]
flatten = lambda l : [elem for sublist in l for elem in sublist]
# Compute zcorn
z = escape_origo_shift[2]
zcorn = [z]*(4*nx*ny)
for k in range(nz-1):
z = z+dz
local_offset = offset + (dz/2. if irregular_offset and k%2 == 0 else 0)
layer = []
for i in range(ny+1):
shift = ((i if concave else 0) + (k/2 if irregular else 0)) % 2
path = [z if i%2 == shift else z+local_offset for i in range(nx+1)]
layer.append(verbose(path))
zcorn = zcorn + (2*flatten(verbose(layer)))
z = z+dz
zcorn = zcorn + ([z]*(4*nx*ny))
if faults:
# Ensure that drop does not align with grid structure
drop = (offset+dz)/2. if abs(offset-dz/2.) > 0.2 else offset + 0.4
zcorn = cls.__createFaults(nx, ny, nz, zcorn, drop)
cls.assertZcorn(nx, ny, nz, zcorn)
# Compute coord
coord = []
for j, i in itertools.product(range(ny+1), range(nx+1)):
x, y = i*dx+escape_origo_shift[0], j*dy+escape_origo_shift[1]
coord = coord + [x, y, escape_origo_shift[2], x, y, z]
# Apply transformations
lower_center = (
nx*dx/2. + escape_origo_shift[0],
ny*dy/2. + escape_origo_shift[1]
)
if misalign:
coord = cls.__misalignCoord(coord, dims, dV)
coord = cls.__scaleCoord(coord, scale, lower_center)
if rotate:
coord = cls.__rotateCoord(coord, lower_center)
coord = cls.__translateCoord(coord, translation)
cls.assertCoord(nx, ny, nz, coord)
# Construct grid
def constructFloatKW(name, values):
kw = EclKW(name, len(values), EclDataType.ECL_FLOAT)
for i in range(len(values)):
kw[i] = values[i]
return kw
return EclGrid.create(dims, constructFloatKW("ZCORN", zcorn), constructFloatKW("COORD", coord), None)
return EclGrid.create(dims, zcorn, coord, None)
@classmethod
def __createFaults(cls, nx, ny, nz, zcorn, drop):
def __create_faults(cls, nx, ny, nz, zcorn, drop):
"""
Will create several faults consisting of all cells such that either its
i or j index is 1 modulo 3.
@@ -236,7 +312,7 @@ class EclGridGenerator:
return zcorn
@classmethod
def assertZcorn(cls, nx, ny, nz, zcorn):
def assert_zcorn(cls, nx, ny, nz, zcorn, twisted_check=True):
"""
Raises an AssertionError if the zcorn is not as expected. In
@@ -255,14 +331,14 @@ class EclGridGenerator:
plane_size = 4*nx*ny
for p in range(8*nx*ny*nz - plane_size):
if zcorn[p] > zcorn[p + plane_size]:
if zcorn[p] > zcorn[p + plane_size] and twisted_check:
raise AssertionError(
"Twisted cell was created. " +
"Decrease offset or increase dz to avoid this!"
)
@classmethod
def __scaleCoord(cls, coord, scale, lower_center):
def __scale_coord(cls, coord, scale, lower_center):
coord = numpy.array([
map(float, coord[i:i+6:])
for i in range(0, len(coord), 6)
@@ -274,7 +350,7 @@ class EclGridGenerator:
return coord.flatten().tolist()
@classmethod
def __misalignCoord(cls, coord, dims, dV):
def __misalign_coord(cls, coord, dims, dV):
nx, ny, nz = dims
coord = numpy.array([
@@ -282,8 +358,9 @@ class EclGridGenerator:
for i in range(0, len(coord), 6)
])
tf = lambda i, j: 1./2 if abs(i)+abs(j) <= 1 else 0.25
adjustment = numpy.array([
(0, 0, 0, i*dV[0]/2., j*dV[1]/2., 0) for i, j in itertools.product([-1, 0, 1], repeat=2)
(0, 0, 0, i*tf(i,j)*dV[0], j*tf(i,j)*dV[1], 0) for i, j in itertools.product([-1, 0, 1], repeat=2)
])
for i, c in enumerate(coord):
@@ -298,7 +375,7 @@ class EclGridGenerator:
return coord.flatten().tolist()
@classmethod
def __rotateCoord(cls, coord, lower_center):
def __rotate_coord(cls, coord, lower_center):
coord = numpy.array([
map(float, coord[i:i+6:])
for i in range(0, len(coord), 6)
@@ -314,7 +391,7 @@ class EclGridGenerator:
return coord.flatten().tolist()
@classmethod
def __translateCoord(cls, coord, translation):
def __translate_lower_coord(cls, coord, translation):
coord = numpy.array([
map(float, coord[i:i+6:])
for i in range(0, len(coord), 6)
@@ -325,14 +402,15 @@ class EclGridGenerator:
return coord.flatten().tolist()
@classmethod
def assertCoord(cls, nx, ny, nz, coord):
def assert_coord(cls, nx, ny, nz, coord, negative_values=False):
"""
Raises an AssertionError if the coord is not as expected. In
particular, it is verfied that:
particular, it is verified that:
- coord has the approperiate length (6*(nx+1)*(ny+1)) and
- that all values are positive.
- that all values are positive unless negative_values are
explicitly allowed.
"""
@@ -342,10 +420,286 @@ class EclGridGenerator:
(6*(nx+1)*(ny+1), len(coord))
)
if min(coord) < 0:
if not negative_values and min(coord) < 0:
raise AssertionError("Negative COORD values was generated. " +
"This is likely due to a tranformation. " +
"Increasing the escape_origio_shift will most likely " +
"fix the problem")
@classmethod
def assert_actnum(cls, nx, ny, nz, actnum):
"""
Raises an AssertionError if the actnum is not as expected. In
particular, it is verified that:
- actnum has the approperiate length nx*ny*nz and
- that all values are either 0 or 1.
"""
if actnum is None:
return
if len(actnum) != nx*ny*nz:
raise AssertionError(
"Expected the length of ACTNUM to be %d, was %s."
%(nx*ny*nz, len(actnum))
)
if set(actnum)-set([0,1]):
raise AssertionError(
"Expected ACTNUM to consist of 0's and 1's, was %s."
% ", ".join(map(str, set(actnum)))
)
@classmethod
def extract_coord(cls, dims, coord, ijk_bounds):
nx, ny, nz = dims
(lx, ux), (ly, uy), (lz, uz) = ijk_bounds
new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1
cls.assert_coord(nx, ny, nz, coord, negative_values=True)
# Format COORD
coord = divide(divide(coord, 6), nx+1)
# Extract new COORD
new_coord = [coord_slice[lx:ux+2:]
for coord_slice in coord[ly:uy+2]]
# Flatten and verify
new_coord = flatten(flatten(new_coord))
cls.assert_coord(new_nx, new_ny, new_nz, new_coord,
negative_values=True)
return construct_floatKW("COORD", new_coord)
@classmethod
def extract_zcorn(cls, dims, zcorn, ijk_bounds):
nx, ny, nz = dims
(lx, ux), (ly, uy), (lz, uz) = ijk_bounds
new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1
cls.assert_zcorn(nx, ny, nz, zcorn, twisted_check=False)
# Format ZCORN
zcorn = divide(divide(zcorn, 2*nx), 2*ny)
# Extract new ZCORN
new_zcorn = [
y_slice[2*lx:2*ux+2:]
for z_slice in zcorn[2*lz:2*uz+2:]
for y_slice in z_slice[2*ly:2*uy+2:]
]
# Flatten and verify
new_zcorn = flatten(new_zcorn)
cls.assert_zcorn(new_nx, new_ny, new_nz, new_zcorn)
return construct_floatKW("ZCORN", new_zcorn)
@classmethod
def extract_actnum(cls, dims, actnum, ijk_bounds):
if actnum is None:
return None
nx, ny, nz = dims
(lx, ux), (ly, uy), (lz, uz) = ijk_bounds
new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1
cls.assert_actnum(nx, ny, nz, actnum)
actnum = divide(divide(actnum, nx), ny)
new_actnum = [
y_slice[lx:ux+1:]
for z_slice in actnum[lz:uz+1:]
for y_slice in z_slice[ly:uy+1:]
]
new_actnum = flatten(new_actnum)
cls.assert_actnum(new_nx, new_ny, new_nz, new_actnum)
actnumkw = EclKW("ACTNUM", len(new_actnum), EclDataType.ECL_INT)
for i, value in enumerate(new_actnum):
actnumkw[i] = value
return actnumkw
@classmethod
def __translate_coord(cls, coord, translation):
coord = numpy.array([
map(float, coord[i:i+6:])
for i in range(0, len(coord), 6)
])
translation = numpy.array(list(translation) + list(translation))
coord = coord + translation
return construct_floatKW("COORD", coord.flatten().tolist())
@classmethod
def extract_subgrid(cls, grid, ijk_bounds,
decomposition_change=False, translation=None):
"""
Extracts a subgrid from the given grid according to the specified
bounds.
@ijk_bounds: The bounds describing the subgrid. Should be a tuple of
length 3, where each element gives the bound for the i, j, k
coordinates of the subgrid to be described, respectively. Each bound
should either be an interval of the form (a, b) where 0 <= a <= b < nx
or a single integer a which is equivialent to the bound (a, a).
NOTE: The given bounds are including endpoints.
@decomposition_change: Depending on the given ijk_bounds, libecl might
decompose the cells of the subgrid differently when extracted from
grid. This is somewhat unexpected behaviour and if this event occur we
give an exception together with an description for how to avoid this,
unless decompostion_change is set to True.
@translation: Gives the possibility of translating the subgrid. Should
be given as a tuple (dx, dy, dz), where each coordinate of the grid
will be moved by di in direction i.
"""
gdims = grid.getDims()[:-1:]
nx, ny, nz = gdims
ijk_bounds = cls.assert_ijk_bounds(gdims, ijk_bounds)
coord = grid.export_coord()
cls.assert_coord(nx, ny, nz, coord, negative_values=True)
zcorn = grid.export_zcorn()
cls.assert_zcorn(nx, ny, nz, zcorn)
actnum = grid.export_actnum()
cls.assert_actnum(nx, ny, nz, actnum)
mapaxes = grid.export_mapaxes()
sub_data = cls.extract_subgrid_data(
gdims,
coord, zcorn,
ijk_bounds=ijk_bounds,
actnum=actnum,
mapaxes=mapaxes,
decomposition_change=decomposition_change,
translation=translation
)
sdim = tuple([b-a+1 for a,b in ijk_bounds])
sub_coord, sub_zcorn, sub_actnum = sub_data
return EclGrid.create(sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes)
@classmethod
def extract_subgrid_data(cls, dims, coord, zcorn, ijk_bounds, actnum=None,
mapaxes=None, decomposition_change=False, translation=None):
"""
Extracts subgrid data from COORD, ZCORN and potentially ACTNUM. It
returns similar formatted data for the subgrid described by the bounds.
@dims: The dimentions (nx, ny, nz) of the grid
@coord: The COORD data of the grid.
@zcorn: The ZCORN data of the grid.
@ijk_bounds: The bounds describing the subgrid. Should be a tuple of
length 3, where each element gives the bound for the i, j, k
coordinates of the subgrid to be described, respectively. Each bound
should either be an interval of the form (a, b) where 0 <= a <= b < nx
or a single integer a which is equivialent to the bound (a, a).
NOTE: The given bounds are including endpoints.
@actnum: The ACTNUM data of the grid.
@mapaxes The MAPAXES data of the grid.
@decomposition_change: Depending on the given ijk_bounds, libecl might
decompose the cells of the subgrid differently when extracted from
grid. This is somewhat unexpected behaviour and if this event occur we
give an exception together with an description for how to avoid this,
unless decompostion_change is set to True.
@translation: Gives the possibility of translating the subgrid. Should
be given as a tuple (dx, dy, dz), where each coordinate of the grid
will be moved by di in direction i.
"""
coord, zcorn = list(coord), list(zcorn)
actnum = None if actnum is None else list(actnum)
ijk_bounds = cls.assert_ijk_bounds(dims, ijk_bounds)
cls.assert_decomposition_change(ijk_bounds, decomposition_change)
nx, ny, nz = dims
(lx, ux), (ly, uy), (lz, uz) = ijk_bounds
new_nx, new_ny, new_nz = ux-lx+1, uy-ly+1, uz-lz+1
new_coord = cls.extract_coord(dims, coord, ijk_bounds)
new_zcorn = cls.extract_zcorn(dims, zcorn, ijk_bounds)
new_actnum = cls.extract_actnum(dims, actnum, ijk_bounds)
if translation is not None:
mtranslation = pre_mapaxes_translation(translation, mapaxes)
new_coord = cls.__translate_coord(new_coord, mtranslation)
for i in range(len(new_zcorn)):
new_zcorn[i] += translation[2]
return new_coord, new_zcorn, new_actnum
@classmethod
def assert_ijk_bounds(cls, dims, ijk_bounds):
ijk_bounds = list(ijk_bounds)
for i in range(len(ijk_bounds)):
if isinstance(ijk_bounds[i], int):
ijk_bounds[i] = [ijk_bounds[i]]
if len(ijk_bounds[i]) == 1:
ijk_bounds[i] += ijk_bounds[i]
if len(ijk_bounds) != 3:
raise ValueError(
"Expected ijk_bounds to contain three intervals, " +
"contained only %d" % len(ijk_bounds))
for n, bound in zip(dims, ijk_bounds):
if len(bound) != 2:
raise ValueError(
"Expected bound to consist of two elements, was %s",
str(bound))
if not (isinstance(bound[0], int) and isinstance(bound[1], int)):
raise TypeError(
"Expected bound to consist of two integers, ",
"was %s (%s)"
%(str(bound), str((map(type,bound))))
)
if not (0 <= bound[0] <= bound[1] < n):
raise ValueError(
"Expected bounds to have the following format: " +
"0 <= lower bound <= upper_bound < ni, "+
"was %d <=? %d <=? %d <? %d."
% (0, bound[0], bound[1], n))
return ijk_bounds
@classmethod
def assert_decomposition_change(cls, ijk_bounds, decomposition_change):
if sum(zip(*ijk_bounds)[0])%2 == 1 and not decomposition_change:
raise ValueError(
"The subgrid defined by %s " % str(ijk_bounds) +
"will cause an unintended decomposition change. " +
"Either change one of the lower bounds by 1 " +
"or activate decomposition_change."
)

View File

@@ -21,7 +21,7 @@ import ecl
from cwrap import Prototype
class GeoPrototype(Prototype):
lib = ecl.load("libert_geometry")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=True):
super(GeoPrototype, self).__init__(GeoPrototype.lib, prototype, bind=bind)

View File

@@ -77,12 +77,15 @@ class ExtendedTestCase(TestCase):
(first, type(first), second, type(second)))
def assertAlmostEqualList(self, first, second, msg=None):
def assertAlmostEqualList(self, first, second, msg=None, tolerance=1e-6):
if len(first) != len(second):
self.fail("Lists are not of same length!")
for index in range(len(first)):
self.assertFloatEqual(first[index], second[index], msg=msg)
self.assertFloatEqual(
first[index], second[index],
msg=msg, tolerance=tolerance
)
def assertImportable(self, module_name):

View File

@@ -20,9 +20,12 @@ import sys
import traceback
import unittest
import inspect
import imp
class ImportTestCase(unittest.TestCase):
def import_file(self, path):
return imp.load_source( "module", path)
def import_module(self , module):
mod = importlib.import_module( module )

View File

@@ -44,7 +44,7 @@ from cwrap import Prototype
class UtilPrototype(Prototype):
lib = ecl.load("libert_util")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=True):
super(UtilPrototype, self).__init__(UtilPrototype.lib, prototype, bind=bind)

View File

@@ -6,7 +6,7 @@ import ecl.ecl
from cwrap import Prototype
class WellPrototype(Prototype):
lib = ecl.load("libecl_well")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=True):
super(WellPrototype, self).__init__(WellPrototype.lib, prototype, bind=bind)

View File

@@ -1,3 +1,20 @@
# Copyright (C) 2017 Statoil ASA, Norway.
#
# This file is part of ERT - Ensemble based Reservoir Tool.
#
# ERT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from os.path import isfile
from cwrap import BaseCClass
from ecl.ecl import EclGrid
from ecl.ecl.ecl_file import EclFile
@@ -82,9 +99,14 @@ class WellInfo(BaseCClass):
"""
return self._has_well( item )
def _assert_file_exists(self, rst_file):
if not isfile(rst_file):
raise IOError('No such file %s' % rst_file)
def addWellFile(self, rst_file, load_segment_information):
""" @type rstfile: str or EclFile """
if isinstance(rst_file, str):
self._assert_file_exists(rst_file)
self._load_rstfile(rst_file, load_segment_information)
elif isinstance(rst_file, EclFile):
self._load_rst_eclfile(rst_file, load_segment_information)

View File

@@ -0,0 +1,11 @@
set(PYTHON_SOURCES
__init__.py
ecl/__init__.py
ecl/faults/__init__.py
geo/__init__.py
well/__init__.py
util/__init__.py
test/__init__.py
)
add_python_package("python.ert" ${PYTHON_INSTALL_PREFIX}/ert "${PYTHON_SOURCES}" True)

View File

View File

@@ -0,0 +1,26 @@
from ecl.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil
from ecl.ecl import EclTypeEnum, EclDataType
from ecl.ecl import EclSumVarType
from ecl.ecl import EclSumTStep
from ecl.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode
from ecl.ecl import EclSumKeyWordVector
from ecl.ecl import EclPLTCell, EclRFTCell
from ecl.ecl import EclRFT, EclRFTFile
from ecl.ecl import FortIO, openFortIO
from ecl.ecl import EclKW
from ecl.ecl import Ecl3DKW
from ecl.ecl import EclFileView
from ecl.ecl import EclFile , openEclFile
from ecl.ecl import Ecl3DFile
from ecl.ecl import EclInitFile
from ecl.ecl import EclRestartFile
from ecl.ecl import EclGrid
from ecl.ecl import EclRegion
from ecl.ecl import EclSubsidence
from ecl.ecl import phase_deltag, deltag
from ecl.ecl import EclGrav
from ecl.ecl import EclSumNode
from ecl.ecl import EclSumVector
from ecl.ecl import EclNPV , NPVPriceVector
from ecl.ecl import EclCmp
from ecl.ecl import EclGridGenerator

View File

@@ -0,0 +1,7 @@
from ecl.ecl.faults import Layer
from ecl.ecl.faults import FaultCollection
from ecl.ecl.faults import Fault
from ecl.ecl.faults import FaultLine
from ecl.ecl.faults import FaultSegment , SegmentMap
from ecl.ecl.faults import FaultBlock , FaultBlockCell
from ecl.ecl.faults import FaultBlockLayer

View File

@@ -0,0 +1,8 @@
from ecl.geo import GeoPointset
from ecl.geo import GeoRegion
from ecl.geo import CPolyline
from ecl.geo import CPolylineCollection
from ecl.geo import Polyline
from ecl.geo import XYZIo
from ecl.geo import GeometryTools
from ecl.geo import Surface

View File

@@ -0,0 +1,10 @@
from ecl.test import TestRun
from ecl.test import path_exists
from ecl.test import ExtendedTestCase
from ecl.test import SourceEnumerator
from ecl.test import TestArea , TestAreaContext
from ecl.test import TempArea , TempAreaContext
from ecl.test import ErtTestRunner
from ecl.test import PathContext
from ecl.test import LintTestCase
from ecl.test import ImportTestCase

View File

@@ -0,0 +1,25 @@
from ecl.util import Version
from ecl.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum
from ecl.util import CTime
from ecl.util import PermutationVector
from ecl.util import VectorTemplate
from ecl.util import DoubleVector
from ecl.util import IntVector
from ecl.util import BoolVector
from ecl.util import TimeVector
from ecl.util import StringList
from ecl.util import RandomNumberGenerator
from ecl.util import Matrix
from ecl.util import quantile, quantile_sorted, polyfit
from ecl.util import Log
from ecl.util import LookupTable
from ecl.util import Buffer
from ecl.util import Hash, StringHash, DoubleHash, IntegerHash
from ecl.util import SubstitutionList
from ecl.util import UIReturn
from ecl.util import ThreadPool
from ecl.util import CThreadPool, startCThreadPool
from ecl.util import installAbortSignals, updateAbortSignals
from ecl.util import Profiler
from ecl.util import ArgPack
from ecl.util import PathFormat

View File

@@ -0,0 +1,7 @@
from ecl.well import WellTypeEnum
from ecl.well import WellConnectionDirectionEnum
from ecl.well import WellConnection
from ecl.well import WellSegment
from ecl.well import WellState
from ecl.well import WellTimeLine
from ecl.well import WellInfo

View File

@@ -12,5 +12,9 @@ add_subdirectory(well)
add_subdirectory(cwrap)
add_subdirectory(global)
if (INSTALL_ERT_LEGACY)
add_subdirectory(legacy)
endif()
configure_file( test_install.in ${EXECUTABLE_OUTPUT_PATH}/test_install @ONLY )

View File

@@ -4,7 +4,7 @@ from cwrap import BaseCValue, Prototype
from ecl.test import ExtendedTestCase
class TestPrototype(Prototype):
lib = ecl.load("libert_util")
lib = ecl.load("libecl")
def __init__(self, prototype):
super(TestPrototype, self).__init__(self.lib, prototype)

View File

@@ -6,7 +6,7 @@ from ecl.test.test_area import TestAreaContext
# Local copies so that the real ones don't get changed
class TestUtilPrototype(Prototype):
lib = ecl.load("libert_util")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=False):
super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind)

View File

@@ -9,7 +9,7 @@ from ecl.test import ExtendedTestCase
# Local copies so that the real ones don't get changed
class TestUtilPrototype(Prototype):
lib = ecl.load("libert_util")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=False):
super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind)
@@ -113,7 +113,6 @@ class MetaWrapTest(ExtendedTestCase):
def stringObj(c_ptr):
char_ptr = ctypes.c_char_p(c_ptr)
python_string = char_ptr.value
TestUtilPrototype.lib.free(c_ptr)
return python_string.decode('ascii')
Prototype.registerType("string_obj", stringObj)

View File

@@ -19,6 +19,7 @@ set(TEST_SOURCES
test_grdecl.py
test_grid.py
test_grid_statoil.py
test_grid_generator.py
test_indexed_read.py
test_ecl_kw_statoil.py
test_ecl_kw.py
@@ -40,11 +41,14 @@ set(TEST_SOURCES
test_geertsma.py
test_ecl_type.py
test_restart_head.py
test_fk_user_data.py
)
add_python_package("python.tests.ecl" ${PYTHON_INSTALL_PREFIX}/tests/ecl "${TEST_SOURCES}" False)
addPythonTest(tests.ecl.test_fk_user_data.FKTest)
addPythonTest(tests.ecl.test_grid.GridTest )
addPythonTest(tests.ecl.test_grid_generator.GridGeneratorTest )
addPythonTest(tests.ecl.test_ecl_kw.KWTest)
addPythonTest(tests.ecl.test_kw_function.KWFunctionTest)
addPythonTest(tests.ecl.test_ecl_3dkw.Ecl3DKWTest )

View File

@@ -79,7 +79,37 @@ class EclFileTest(ExtendedTestCase):
self.assertTrue( ecl_file.has_kw("KW2"))
self.assertEqual(ecl_file[1], ecl_file[-1])
def test_save_kw(self):
with TestAreaContext("python/ecl_file/save_kw"):
data = range(1000)
kw = EclKW("MY_KEY", len(data), EclDataType.ECL_INT)
for index, val in enumerate(data):
kw[index] = val
clean_dump = "my_clean_file"
fortio = FortIO(clean_dump, FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
test_file = "my_dump_file"
fortio = FortIO(test_file, FortIO.WRITE_MODE)
kw.fwrite(fortio)
fortio.close()
self.assertFilesAreEqual(clean_dump, test_file)
ecl_file = EclFile(test_file, flags=EclFileFlagEnum.ECL_FILE_WRITABLE)
loaded_kw = ecl_file["MY_KEY"][0]
self.assertTrue(kw.equal(loaded_kw))
ecl_file.save_kw(loaded_kw)
ecl_file.close()
self.assertFilesAreEqual(clean_dump, test_file)
ecl_file = EclFile(test_file)
loaded_kw = ecl_file["MY_KEY"][0]
self.assertTrue(kw.equal(loaded_kw))
def test_gc(self):
kw1 = EclKW("KW1" , 100 , EclDataType.ECL_INT)

View File

@@ -21,12 +21,12 @@ from ecl.test import ExtendedTestCase
class EclUtilTest(ExtendedTestCase):
def test_enums(self):
source_file_path = "libecl/include/ert/ecl/ecl_util.h"
source_file_path = "lib/include/ert/ecl/ecl_util.h"
self.assertEnumIsFullyDefined(EclFileEnum, "ecl_file_enum", source_file_path)
self.assertEnumIsFullyDefined(EclPhaseEnum, "ecl_phase_enum", source_file_path)
self.assertEnumIsFullyDefined(EclUnitTypeEnum, "ert_ecl_unit_enum", source_file_path)
source_file_path = "libecl/include/ert/ecl/ecl_type.h"
source_file_path = "lib/include/ert/ecl/ecl_type.h"
self.assertEnumIsFullyDefined(EclTypeEnum, "ecl_type_enum", source_file_path)
def test_file_type(self):

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python
# Copyright (C) 2017 Statoil ASA, Norway.
#
# The file 'test_ecl_cell_containment.py' is part of ERT - Ensemble based Reservoir Tool.
#
# ERT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ecl.ecl import EclGrid
from ecl.test import ExtendedTestCase, TestAreaContext
class FKTest(ExtendedTestCase):
def test_cell_containment(self):
grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID"
well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt"
for i in range(1, 8):
grid_file = self.createTestPath(grid_location % i)
well_file = self.createTestPath(well_location % i)
grid = EclGrid(grid_file)
# Load well data
with open(well_file, "r") as f:
lines = [line.split() for line in f.readlines()]
points = [map(float, line[:3:]) for line in lines]
exp_cells = [tuple(map(int, line[3::])) for line in lines]
msg = "Expected point %s to be in cell %s, was in %s."
for point, exp_cell in zip(points, exp_cells):
reported_cell = grid.find_cell(*point)
self.assertEqual(
exp_cell,
reported_cell,
msg % (str(point), str(exp_cell), str(reported_cell))
)

View File

@@ -49,21 +49,21 @@ CORNER_HOME = {
def createVolumeTestGridBase(dim, dV, offset=1):
return [
GridGen.createGrid(dim, dV, offset=0),
GridGen.createGrid(dim, dV, offset=offset),
GridGen.createGrid(dim, dV, offset=offset, irregular_offset=True),
GridGen.createGrid(dim, dV, offset=offset, concave=True),
GridGen.createGrid(dim, dV, offset=offset, irregular=True),
GridGen.createGrid(dim, dV, offset=offset, concave=True, irregular=True),
GridGen.createGrid(dim, dV, offset=offset, irregular_offset=True, concave=True),
GridGen.createGrid(dim, dV, offset=0, faults=True),
GridGen.createGrid(dim, dV, offset=offset, faults=True),
GridGen.createGrid(dim, dV, escape_origo_shift=(100, 100, 0), scale=2),
GridGen.createGrid(dim, dV, escape_origo_shift=(100, 100, 0), scale=0.5),
GridGen.createGrid(dim, dV, escape_origo_shift=(100, 100, 0), translation=(50,50,0)),
GridGen.createGrid(dim, dV, escape_origo_shift=(100, 100, 0), rotate=True),
GridGen.createGrid(dim, dV, escape_origo_shift=(100, 100, 0), misalign=True),
GridGen.createGrid(dim, dV, offset=offset, escape_origo_shift=(100, 100, 0),
GridGen.create_grid(dim, dV, offset=0),
GridGen.create_grid(dim, dV, offset=offset),
GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True),
GridGen.create_grid(dim, dV, offset=offset, concave=True),
GridGen.create_grid(dim, dV, offset=offset, irregular=True),
GridGen.create_grid(dim, dV, offset=offset, concave=True, irregular=True),
GridGen.create_grid(dim, dV, offset=offset, irregular_offset=True, concave=True),
GridGen.create_grid(dim, dV, offset=0, faults=True),
GridGen.create_grid(dim, dV, offset=offset, faults=True),
GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=2),
GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), scale=0.5),
GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), translation=(50,50,0)),
GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), rotate=True),
GridGen.create_grid(dim, dV, escape_origo_shift=(100, 100, 0), misalign=True),
GridGen.create_grid(dim, dV, offset=offset, escape_origo_shift=(100, 100, 0),
irregular_offset=True, concave=True, irregular=True,
scale=1.5, translation=(5,5,0), rotate=True,
misalign=True)
@@ -71,11 +71,11 @@ def createVolumeTestGridBase(dim, dV, offset=1):
def createContainmentTestBase():
return [
(3, GridGen.createGrid((6,6,6), (1,1,1), offset=1)),
(10, GridGen.createGrid((3,3,3), (1,1,1), offset=1, concave=True)),
(4, GridGen.createGrid((10,10,1), (1,1,1), offset=0., misalign=True)),
(3, GridGen.create_grid((6,6,6), (1,1,1), offset=1)),
(10, GridGen.create_grid((3,3,3), (1,1,1), offset=1, concave=True)),
(4, GridGen.create_grid((10,10,1), (1,1,1), offset=0., misalign=True)),
(3,
GridGen.createGrid((6,6,6), (1,1,1), offset=0.,
GridGen.create_grid((6,6,6), (1,1,1), offset=0.,
escape_origo_shift=(100, 100, 0),
irregular_offset=True, concave=True, irregular=True,
scale=1.5, translation=(5,5,0),
@@ -110,7 +110,7 @@ def createWrapperGrid(grid):
for i, pos in enumerate(corner_pos)
]
return GridGen.createSingleCellGrid(corners)
return GridGen.create_single_cell_grid(corners)
def average(points):
p = reduce(lambda a,b: (a[0]+b[0], a[1]+b[1], a[2]+b[2]), points)
@@ -334,6 +334,15 @@ class GridTest(ExtendedTestCase):
self.assertEqual( len(grid) , nx*ny*nz )
self.assertEqual( grid.getNumActive( ) , 4 )
def test_export(self):
dims = (3, 3, 3)
coord = GridGen.create_coord(dims, (1,1,1))
zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
grid = EclGrid.create(dims, zcorn, coord, None)
self.assertEqual(zcorn, grid.export_zcorn())
self.assertEqual(coord, grid.export_coord())
def test_output_units(self):
n = 10
@@ -389,11 +398,13 @@ class GridTest(ExtendedTestCase):
for i in range(grid.getGlobalSize())
].count(True)
self.assertTrue(hits in [0, 1])
self.assertIn(hits, [0, 1])
expected = 1 if wgrid.cell_contains(x, y, z, 0) else 0
self.assertEqual(
1 if wgrid.cell_contains(x, y, z, 0) else 0,
hits
expected,
hits,
'Expected %d for (%g,%g,%g), got %d' % (expected, x, y, z, hits)
)
def test_cell_corner_containment(self):
@@ -445,7 +456,7 @@ class GridTest(ExtendedTestCase):
(20, 20, 20)
]
grid = GridGen.createSingleCellGrid(points)
grid = GridGen.create_single_cell_grid(points)
assertPoint = lambda p : self.assertTrue(
grid.cell_contains(p[0], p[1], p[2], 0)
@@ -505,7 +516,7 @@ class GridTest(ExtendedTestCase):
(25, 25, 25)
]
grid = GridGen.createSingleCellGrid(points)
grid = GridGen.create_single_cell_grid(points)
assertPoint = lambda p : self.assertTrue(
grid.cell_contains(p[0], p[1], p[2], 0)

View File

@@ -0,0 +1,272 @@
#!/usr/bin/env python
# Copyright (C) 2017 Statoil ASA, Norway.
#
# The file 'test_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool.
#
# ERT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from itertools import product as prod
import operator, random, numpy
from ecl.ecl import EclGrid, EclKW, EclDataType
from ecl.ecl import EclGridGenerator as GridGen
from ecl.test import ExtendedTestCase, TestAreaContext
def generate_ijk_bounds(dims):
ibounds = [(l, u) for l in range(dims[0]) for u in range(l, dims[0])]
jbounds = [(l, u) for l in range(dims[1]) for u in range(l, dims[1])]
kbounds = [(l, u) for l in range(dims[2]) for u in range(l, dims[2])]
return prod(ibounds, jbounds, kbounds)
def decomposition_preserving(ijk_bound):
return sum(zip(*ijk_bound)[0])%2 is 0
class GridGeneratorTest(ExtendedTestCase):
def setUp(self):
self.test_base = [
(
list(GridGen.create_coord((4,4,4), (1,1,1))),
list(GridGen.create_zcorn((4,4,4), (1,1,1), offset=0)),
GridGen.create_grid((4,4,4), (1,1,1), offset=0)
),
(
list(
GridGen.create_coord((5,5,5), (1,1,1),
translation=(10,10,0))
),
list(
GridGen.create_zcorn((5,5,5), (1,1,1), offset=0.5,
irregular_offset=True, concave=True, irregular=True)
),
GridGen.create_grid(
(5,5,5), (1,1,1), offset=0.5,
irregular=True, irregular_offset=True, concave=True,
translation=(10,10,0)
)
)
]
def test_extract_grid_decomposition_change(self):
dims = (4,4,4)
zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0))
coord = list(GridGen.create_coord(dims, (1,1,1)))
ijk_bounds = generate_ijk_bounds(dims)
for ijk_bounds in ijk_bounds:
if decomposition_preserving(ijk_bounds):
GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds)
else:
with self.assertRaises(ValueError):
GridGen.extract_subgrid_data(dims, coord, zcorn, ijk_bounds)
GridGen.extract_subgrid_data(dims,
coord, zcorn,
ijk_bounds,
decomposition_change=True)
def test_extract_grid_invalid_bounds(self):
dims = (3,3,3)
zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0))
coord = list(GridGen.create_coord(dims, (1,1,1)))
with self.assertRaises(ValueError):
GridGen.extract_subgrid_data(dims, coord, zcorn, ((-1,0), (2,2), (2,2)))
with self.assertRaises(ValueError):
GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,6), (2,2), (2,2)))
with self.assertRaises(ValueError):
GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,2), (2,0), (2,2)))
def test_extract_grid_slice_spec(self):
dims = (4,4,4)
zcorn = list(GridGen.create_zcorn(dims, (1,1,1), offset=0))
coord = list(GridGen.create_coord(dims, (1,1,1)))
ijk_bounds = generate_ijk_bounds(dims)
for ijk in ijk_bounds:
ijk = list(ijk)
for i in range(3):
if len(set(ijk[i])) == 1:
ijk[i] = ijk[i][0]
GridGen.extract_subgrid_data(dims,
coord, zcorn,
ijk,
decomposition_change=True)
def assertSubgrid(self, grid, subgrid, ijk_bound):
sijk_space = prod(*[range(d) for d in subgrid.getDims()[:-1:]])
for sijk in sijk_space:
gijk = tuple([a+b for a, b in zip(sijk, zip(*ijk_bound)[0])])
self.assertEqual(
[subgrid.getCellCorner(i, ijk=sijk) for i in range(8)],
[grid.getCellCorner(i, ijk=gijk) for i in range(8)]
)
self.assertEqual(grid.active(ijk=gijk), subgrid.active(ijk=sijk))
def test_validate_cells(self):
for coord, zcorn, grid in self.test_base:
grid_dims = grid.getDims()[:-1:]
ijk_bounds = generate_ijk_bounds(grid_dims)
for ijk_bound in ijk_bounds:
if not decomposition_preserving(ijk_bound):
continue
sub_dims = tuple([u-l+1 for l, u in ijk_bound])
sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data(
grid_dims,
coord,
zcorn,
ijk_bound
)
subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, None)
self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
self.assertSubgrid(grid, subgrid, ijk_bound)
def test_actnum_extraction(self):
dims = (4,4,4)
coord = GridGen.create_coord(dims, (1,1,1))
zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
actnum = EclKW("ACTNUM", reduce(operator.mul, dims), EclDataType.ECL_INT)
random.seed(1337)
for i in range(len(actnum)):
actnum[i] = random.randint(0, 1)
grid = EclGrid.create(dims, zcorn, coord, actnum)
ijk_bounds = generate_ijk_bounds(dims)
for ijk_bound in ijk_bounds:
if not decomposition_preserving(ijk_bound):
continue
sub = GridGen.extract_subgrid_data(
dims,
coord,
zcorn,
ijk_bound,
actnum=actnum
)
sub_coord, sub_zcorn, sub_actnum = sub
sub_dims = tuple([u-l+1 for l, u in ijk_bound])
subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum)
self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
self.assertSubgrid(grid, subgrid, ijk_bound)
def test_translation(self):
dims = (3,3,3)
coord = GridGen.create_coord(dims, (1,1,1))
zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0)
grid = EclGrid.create(dims, zcorn, coord, None)
ijk_bound = [(0, d-1) for d in dims]
translation = (1, 2, 3)
sub_coord, sub_zcorn, _ = GridGen.extract_subgrid_data(
dims,
coord,
zcorn,
ijk_bound,
translation=translation
)
tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None)
self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize())
for gi in range(grid.getGlobalSize()):
translation = numpy.array(translation)
corners = [grid.getCellCorner(i, gi) for i in range(8)]
corners = [tuple(numpy.array(c)+translation) for c in corners]
tcorners = [tgrid.getCellCorner(i, gi) for i in range(8)]
self.assertEqual(corners, tcorners)
def test_subgrid_extration(self):
for _, _, grid in self.test_base[:-1:]:
grid_dims = grid.getDims()[:-1:]
ijk_bounds = generate_ijk_bounds(grid_dims)
for ijk_bound in ijk_bounds:
if not decomposition_preserving(ijk_bound):
continue
sub_dims = tuple([u-l+1 for l, u in ijk_bound])
subgrid = GridGen.extract_subgrid(grid, ijk_bound)
self.assertEqual(sub_dims, subgrid.getDims()[:-1:])
self.assertSubgrid(grid, subgrid, ijk_bound)
def test_subgrid_translation(self):
grid = GridGen.create_grid((4,4,4), (1,1,1), offset=0.5,
irregular=True, irregular_offset=True, concave=True,
translation=(10,10,0))
# Create grid with MAPAXES
mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT)
for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]):
mapaxes[i] = val
grid = EclGrid.create(
grid.getDims(),
grid.export_zcorn(),
grid.export_coord(),
None,
mapaxes=mapaxes
)
for translation in [
(0,0,0),
(10, 10, 100),
(-1, -1, -1)
]:
subgrid = GridGen.extract_subgrid(
grid,
((0,3), (0,3), (0,3)),
translation=translation
)
self.assertEqual(grid.getDims(), subgrid.getDims())
translation = numpy.array(translation)
for gindex in range(grid.getGlobalSize()):
grid_corners = [
grid.getCellCorner(i, global_index=gindex)
for i in range(8)
]
subgrid_corners = [
subgrid.getCellCorner(i, global_index=gindex)
for i in range(8)
]
subgrid_corners = [
list(numpy.array(corner) - translation)
for corner in subgrid_corners
]
for gc, sc in zip(grid_corners, subgrid_corners):
self.assertAlmostEqualList(
gc,
sc,
msg="Failed to translate corners correctly." +
"Expected %s, was %s." % (gc, sc),
tolerance=10e-10
)

View File

@@ -387,3 +387,22 @@ class GridTest(ExtendedTestCase):
grdecl_file = self.createTestPath("Statoil/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl")
grid = EclGrid.loadFromGrdecl( grdecl_file )
def test_lgr_get(self):
grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID"))
for (nr,name) in [ ( 104 , "LG003017"),
(2 , "LG006024"),
( 4 , "LG005025"),
( 82 , "LG011029"),
(100 , "LG007021"),
(110 , "LG003014")]:
lgr_name = grid.get_lgr( name )
lgr_nr = grid.get_lgr( nr )
self.assertEqual( lgr_name , lgr_nr )
with self.assertRaises(KeyError):
grid.get_lgr("NO/SUCHLGR")
with self.assertRaises(KeyError):
grid.get_lgr(1024)

View File

@@ -59,7 +59,7 @@ class SumTest(ExtendedTestCase):
def test_identify_var_type(self):
self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "libecl/include/ert/ecl/smspec_node.h")
self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h")
self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR )
self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR )
self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR )

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env python
import sys
# This is a small executable which is used to verify the install,
# Prior to calling this the environment must have been prepared to
# ensure that the newly installed versions are picked up - this can
# typically be achieved with the bash script bin/test_install which is
# generated during the configure process.
from ecl.ecl import EclSum, EclGrid

View File

@@ -0,0 +1,16 @@
set(TEST_SOURCES
__init__.py
test_ecl.py
test_geo.py
test_well.py
test_util.py
test_test.py
)
add_python_package("python.tests.legacy.ert" ${PYTHON_INSTALL_PREFIX}/tests/legacy "${TEST_SOURCES}" False)
addPythonTest(tests.legacy.test_ecl.ErtLegacyEclTest)
addPythonTest(tests.legacy.test_geo.ErtLegacyGeoTest)
addPythonTest(tests.legacy.test_well.ErtLegacyWellTest)
addPythonTest(tests.legacy.test_util.ErtLegacyUtilTest)
addPythonTest(tests.legacy.test_test.ErtLegacyTestTest)

View File

View File

@@ -0,0 +1,41 @@
from ert.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil
from ert.ecl import EclTypeEnum, EclDataType
from ert.ecl import EclSumVarType
from ert.ecl import EclSumTStep
from ert.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode
from ert.ecl import EclSumKeyWordVector
from ert.ecl import EclPLTCell, EclRFTCell
from ert.ecl import EclRFT, EclRFTFile
from ert.ecl import FortIO, openFortIO
from ert.ecl import EclKW
from ert.ecl import Ecl3DKW
from ert.ecl import EclFileView
from ert.ecl import EclFile , openEclFile
from ert.ecl import Ecl3DFile
from ert.ecl import EclInitFile
from ert.ecl import EclRestartFile
from ert.ecl import EclGrid
from ert.ecl import EclRegion
from ert.ecl import EclSubsidence
from ert.ecl import phase_deltag, deltag
from ert.ecl import EclGrav
from ert.ecl import EclSumNode
from ert.ecl import EclSumVector
from ert.ecl import EclNPV , NPVPriceVector
from ert.ecl import EclCmp
from ert.ecl import EclGridGenerator
from ert.ecl.faults import Layer
from ert.ecl.faults import FaultCollection
from ert.ecl.faults import Fault
from ert.ecl.faults import FaultLine
from ert.ecl.faults import FaultSegment , SegmentMap
from ert.ecl.faults import FaultBlock , FaultBlockCell
from ert.ecl.faults import FaultBlockLayer
from ecl.test import ExtendedTestCase
class ErtLegacyEclTest(ExtendedTestCase):
pass

View File

@@ -0,0 +1,14 @@
from ert.geo import GeoPointset
from ert.geo import GeoRegion
from ert.geo import CPolyline
from ert.geo import CPolylineCollection
from ert.geo import Polyline
from ert.geo import XYZIo
from ert.geo import GeometryTools
from ert.geo import Surface
from ecl.test import ExtendedTestCase
class ErtLegacyGeoTest(ExtendedTestCase):
pass

View File

@@ -0,0 +1,16 @@
from ert.test import TestRun
from ert.test import path_exists
from ert.test import ExtendedTestCase
from ert.test import SourceEnumerator
from ert.test import TestArea , TestAreaContext
from ert.test import TempArea , TempAreaContext
from ert.test import ErtTestRunner
from ert.test import PathContext
from ert.test import LintTestCase
from ert.test import ImportTestCase
from ecl.test import ExtendedTestCase
class ErtLegacyTestTest(ExtendedTestCase):
pass

View File

@@ -0,0 +1,31 @@
from ert.util import Version
from ert.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum
from ert.util import CTime
from ert.util import PermutationVector
from ert.util import VectorTemplate
from ert.util import DoubleVector
from ert.util import IntVector
from ert.util import BoolVector
from ert.util import TimeVector
from ert.util import StringList
from ert.util import RandomNumberGenerator
from ert.util import Matrix
from ert.util import quantile, quantile_sorted, polyfit
from ert.util import Log
from ert.util import LookupTable
from ert.util import Buffer
from ert.util import Hash, StringHash, DoubleHash, IntegerHash
from ert.util import SubstitutionList
from ert.util import UIReturn
from ert.util import ThreadPool
from ert.util import CThreadPool, startCThreadPool
from ert.util import installAbortSignals, updateAbortSignals
from ert.util import Profiler
from ert.util import ArgPack
from ert.util import PathFormat
from ecl.test import ExtendedTestCase
class ErtLegacyUtilTest(ExtendedTestCase):
pass

View File

@@ -0,0 +1,13 @@
from ert.well import WellTypeEnum
from ert.well import WellConnectionDirectionEnum
from ert.well import WellConnection
from ert.well import WellSegment
from ert.well import WellState
from ert.well import WellTimeLine
from ert.well import WellInfo
from ecl.test import ExtendedTestCase
class ErtLegacyWellTest(ExtendedTestCase):
pass

View File

@@ -0,0 +1,6 @@
#!/bin/bash
export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@:@CTEST_PYTHONPATH@:$PYTHONPATH
@PROJECT_SOURCE_DIR@/python/tests/install/test_install.py $@

View File

@@ -2,7 +2,7 @@ import ecl
from ecl.test import ExtendedTestCase
from ecl.util import ArgPack, StringList
TEST_LIB = ecl.load("libert_util")
TEST_LIB = ecl.load("libecl")
class ArgPackTest(ExtendedTestCase):

View File

@@ -4,7 +4,7 @@ from ecl.test.extended_testcase import ExtendedTestCase
# Local copies so that the real ones don't get changed
class TestUtilPrototype(Prototype):
lib = ecl.load("libert_util")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=False):
super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind)

View File

@@ -3,7 +3,7 @@ import ecl
from ecl.test import ExtendedTestCase
from ecl.util import CThreadPool, startCThreadPool
TEST_LIB = ecl.load("libert_util")
TEST_LIB = ecl.load("libecl")
class CThreadPoolTest(ExtendedTestCase):

View File

@@ -18,8 +18,10 @@ class PathContextTest(ExtendedTestCase):
def test_chdir(self):
with PathContext("/tmp/pc"):
self.assertEqual( os.getcwd() , "/tmp/pc")
self.assertEqual(
os.path.realpath(os.getcwd()),
os.path.realpath("/tmp/pc")
)
def test_cleanup(self):
with TestAreaContext("pathcontext"):

View File

@@ -6,8 +6,8 @@ from ecl.test import ExtendedTestCase,TestAreaContext
class RngTest(ExtendedTestCase):
def test_enums(self):
self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "libert_util/include/ert/util/rng.h")
self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "libert_util/include/ert/util/rng.h")
self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "lib/include/ert/util/rng.h")
self.assertEnumIsFullyDefined(RngInitModeEnum, "rng_init_mode", "lib/include/ert/util/rng.h")
def test_rng_default(self):
rng = RandomNumberGenerator()

View File

@@ -9,7 +9,7 @@ from ecl.test.test_area import TestAreaContext
from cwrap import Prototype
class _TestSpawnPrototype(Prototype):
lib = ecl.load('libert_util')
lib = ecl.load('libecl')
def __init__(self, prototype, bind=True):
super(_TestSpawnPrototype, self).__init__(_TestSpawnPrototype.lib, prototype, bind=bind)

View File

@@ -65,5 +65,5 @@ class UIReturnTest(ExtendedTestCase):
self.assertEqual(errorList, [])
def test_status_enum(self):
source_file_path = "libert_util/include/ert/util/ui_return.h"
source_file_path = "lib/include/ert/util/ui_return.h"
self.assertEnumIsFullyDefined(UIReturnStatusEnum, "ui_return_status_enum", source_file_path)

View File

@@ -8,7 +8,7 @@ set(TEST_SOURCES
add_python_package("python.tests.well" ${PYTHON_INSTALL_PREFIX}/tests/well "${TEST_SOURCES}" False)
if (STATOIL_TESTDATA_ROOT)
addPythonTest(well.test_ecl_well.EclWellTest LABELS StatoilData)
addPythonTest(well.test_ecl_well2.EclWellTest2 LABELS StatoilData)
addPythonTest(well.test_ecl_well3.EclWellTest3 LABELS StatoilData)
addPythonTest(tests.well.test_ecl_well.EclWellTest LABELS StatoilData)
addPythonTest(tests.well.test_ecl_well2.EclWellTest2 LABELS StatoilData)
addPythonTest(tests.well.test_ecl_well3.EclWellTest3 LABELS StatoilData)
endif()

View File

@@ -65,6 +65,16 @@ class EclWellTest(ExtendedTestCase):
return EclWellTest.__well_info
def test_no_such_well(self):
grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID")
rst_path1 = self.createTestPath("nosuch/path/ECLIPSE.X001")
rst_path2 = self.createTestPath("nosuch/path/ECLIPSE.X002")
grid = EclGrid(grid_path)
with self.assertRaises(IOError):
_ = WellInfo(grid, rst_path1)
with self.assertRaises(IOError):
_ = WellInfo(grid, [rst_path1, rst_path2])
def test_construction(self):
grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID")
rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0011")
@@ -110,13 +120,13 @@ class EclWellTest(ExtendedTestCase):
def test_well_type_enum(self):
source_file_path = "libecl_well/include/ert/ecl_well/well_const.h"
source_file_path = "lib/include/ert/ecl_well/well_conn.h"
# The header file has duplicated symbols, so the simple test fails.
# self.assertEnumIsFullyDefined(WellTypeEnum, "well_type_enum", source_file_path)
def test_well_connection_direction_enum(self):
source_file_path = "libecl_well/include/ert/ecl_well/well_conn.h"
source_file_path = "lib/include/ert/ecl_well/well_conn.h"
self.assertEnumIsFullyDefined(WellConnectionDirectionEnum, "well_conn_dir_enum", source_file_path)