# coding: utf-8 from os.path import join import tests.test_common.test_xtg as tsetup import xtgeo from xtgeo.common import XTGeoDialog xtg = XTGeoDialog() logger = xtg.basiclogger(__name__) if not xtg.testsetup(): raise SystemExit # ============================================================================= # Do tests # ============================================================================= TPATH = xtg.testpathobj SURF1 = TPATH / "surfaces/reek/1/topreek_rota.gri" POLY1 = TPATH / "polygons/reek/1/closedpoly1.pol" def test_operations_inside_outside_polygon_generic(): """Do perations in relation to polygons in a generic way""" logger.info("Simple case...") surf = xtgeo.surface.RegularSurface(SURF1) tsetup.assert_almostequal(surf.values.mean(), 1698.65, 0.01)
# coding: utf-8 """Various operations on XYZ data""" from __future__ import print_function, absolute_import import numpy as np import pandas as pd from scipy.interpolate import interp1d, UnivariateSpline import shapely.geometry as sg import xtgeo from xtgeo.common import XTGeoDialog import xtgeo.cxtgeo.cxtgeo as _cxtgeo xtg = XTGeoDialog() logger = xtg.functionlogger(__name__) XTGDEBUG = 0 # pylint: disable=protected-access def operation_polygons(self, poly, value, opname="add", inside=True, where=True): """ Operations re restricted to closed polygons, for points or polyline points.
"""Import RegularSurface data.""" # pylint: disable=protected-access import numpy as np import numpy.ma as ma import xtgeo import xtgeo.cxtgeo.cxtgeo as _cxtgeo # pylint: disable=import-error from xtgeo.common import XTGeoDialog xtg = XTGeoDialog() logger = xtg.functionlogger(__name__) DEBUG = xtg.get_syslevel() if DEBUG < 0: DEBUG = 0 _cxtgeo.xtg_verbose_file("NONE") def import_irap_binary(self, mfile): """Import Irap binary format.""" # using swig type mapping logger.debug("Enter function...") # need to call the C function... _cxtgeo.xtg_verbose_file("NONE") # read with mode 0, to get mx my xlist = _cxtgeo.surf_import_irap_bin(mfile, 0, 1, 0, DEBUG)
from xtgeo.grid3d import Grid from xtgeo.grid3d import GridProperty from xtgeo.surface import RegularSurface from xtgeo.common import XTGeoDialog import test_common.test_xtg as tsetup path = "TMP" try: os.makedirs(path) except OSError: if not os.path.isdir(path): raise # set default level xtg = XTGeoDialog() logger = xtg.basiclogger(__name__) roff1_grid = "../xtgeo-testdata/3dgrids/eme/1/emerald_hetero_grid.roff" roff1_props = "../xtgeo-testdata/3dgrids/eme/1/emerald_hetero.roff" @tsetup.skipifroxar def test_hcpvfz1(): """HCPV thickness map.""" # It is important that inpyut are pure numpies, not masked logger.info("Name is %s", __name__) g = Grid()
import os import sys import logging from xtgeo.well import Well from xtgeo.common import XTGeoDialog path = 'TMP' try: os.makedirs(path) except OSError: if not os.path.isdir(path): raise xtg = XTGeoDialog() format = xtg.loggingformat logging.basicConfig(format=format, stream=sys.stdout) logging.getLogger().setLevel(xtg.logginglevel) # root logger! logger = logging.getLogger(__name__) # ========================================================================= # Do tests # ========================================================================= def test_wellzone_to_points(): """Import well from file and put zone boundaries to a Pandas object.""" wfile = "../xtgeo-testdata/wells/reek/1/OP_1.w"
# coding: utf-8 """Testing new xtg formats both natiev ans hdf5 based.""" from os.path import join import pytest from numpy.testing import assert_allclose import xtgeo from xtgeo.common import XTGeoDialog xtg = XTGeoDialog() if not xtg.testsetup(): raise SystemExit @pytest.fixture(name="benchmark_surface") def benchmark_surface_fixture(testpath): return xtgeo.RegularSurface(join(testpath, "surfaces/reek/1/topreek_rota.gri")) @pytest.mark.benchmark(group="import/export") def test_benchmark_xtgregsurf_export(benchmark, tmp_path, benchmark_surface): """Test exporting to xtgregsurf format.""" fname = tmp_path / "benchmark_surface.xtgregsurf" @benchmark def write(): benchmark_surface.to_file(fname, fformat="xtgregsurf")