Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# coding: utf-8
from __future__ import division, absolute_import
from __future__ import print_function
import os
from os.path import join
import io
import threading
import pytest
import xtgeo
from xtgeo.common import XTGeoDialog
import test_common.test_xtg as tsetup
xtg = XTGeoDialog()
logger = xtg.basiclogger(__name__)
if not xtg.testsetup():
raise SystemExit
TMPD = xtg.tmpdir
TPATH = xtg.testpath
XTGSHOW = False
if "XTG_SHOW" in os.environ:
XTGSHOW = True
# =============================================================================
# Do tests
# =============================================================================
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import
from __future__ import print_function
from os.path import join
import pytest
import xtgeo
xtg = xtgeo.common.XTGeoDialog()
logger = xtg.basiclogger(__name__)
if not xtg.testsetup():
raise SystemExit
TMPDIR = xtg.tmpdir
TESTPATH = xtg.testpath
WFILE = join(TESTPATH, "wells/battle/1/WELLX.rmswell")
SFILE = join(TESTPATH, "surfaces/etc/battle_1330.gri")
def test_get_well_x_surf():
"""Getting XYZ, MD for well where crossing a surface"""
wll = xtgeo.Well(WFILE, mdlogname="Q_MDEPTH")
# coding: utf-8
from __future__ import division, absolute_import
from __future__ import print_function
import os
import numpy as np
import xtgeo
from xtgeo.common import XTGeoDialog
import test_common.test_xtg as tsetup
xtg = XTGeoDialog()
logger = xtg.basiclogger(__name__)
if not xtg.testsetup():
raise SystemExit
TMPDIR = xtg.tmpdir
TESTPATH = xtg.testpath
DUALFILE1 = "../xtgeo-testdata/3dgrids/etc/TEST_DP"
DUALFILE2 = "../xtgeo-testdata/3dgrids/etc/TEST_DPDK" # dual poro + dual perm oil/water
DUALFILE3 = "../xtgeo-testdata/3dgrids/etc/TEST2_DPDK_WG" # aa but gas/water
# =============================================================================
# Do tests
# =============================================================================
"""Export Cube data via SegyIO library or XTGeo CLIB."""
import shutil
import numpy as np
import segyio
import xtgeo
import xtgeo.cxtgeo._cxtgeo as _cxtgeo
from xtgeo.common import XTGeoDialog
xtg = XTGeoDialog()
logger = xtg.functionlogger(__name__)
# _cxtgeo.xtg_verbose_file("NONE")
def export_segy(self, sfile, template=None, pristine=False, engine="xtgeo"):
"""Export on SEGY using segyio library.
Args:
self (:class:`xtgeo.cube.Cube`): The instance
sfile (str): File name to export to.
template (str): Use an existing file a template.
pristine (bool): Make SEGY from scrtach if True; otherwise use an
existing SEGY file.
# -*- coding: utf-8 -*-
"""Do gridding from 3D parameters"""
from __future__ import division, absolute_import
from __future__ import print_function
import warnings
import numpy as np
import numpy.ma as ma
import scipy.interpolate
import scipy.ndimage
import xtgeo
xtg = xtgeo.common.XTGeoDialog()
logger = xtg.functionlogger(__name__)
# Note: 'self' is an instance of RegularSurface
# pylint: disable=too-many-branches, too-many-statements, too-many-locals
def points_gridding(self, points, method="linear", coarsen=1):
"""Do gridding from a points data set."""
xiv, yiv = self.get_xy_values()
dfra = points.dataframe
xcv = dfra[points.xname].values
ycv = dfra[points.yname].values
# 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.
If value is not float but 'poly', then the avg of each polygon Z value will
be used instead.
'Inside' several polygons will become a union, while 'outside' polygons
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import
from xtgeo.common import XTGeoDialog
import xtgeo.cxtgeo._cxtgeo as _cxtgeo
xtg = XTGeoDialog()
logger = xtg.functionlogger(__name__)
def export_roff(self, gfile, option):
"""Export grid to ROFF format (binary)"""
logger.debug("Export to ROFF...")
nsubs = 0
if self.subgrids is None:
logger.debug("Create a pointer for subgrd_v ...")
subgrd_v = _cxtgeo.new_intpointer()
else:
nsubs = len(self.subgrids)
subgrd_v = _cxtgeo.new_intarray(nsubs)
"""Some common XTGEO calculation routines."""
import numpy as np
import xtgeo.cxtgeo._cxtgeo as _cxtgeo
from xtgeo.common import XTGeoDialog
xtg = XTGeoDialog()
logger = xtg.functionlogger(__name__)
def ib_to_ijk(ib, nx, ny, nz, ibbase=0, forder=True):
"""Convert a 1D index (starting from ibbase) to cell indices I J K.
The default is F-order, but ``forder=False`` gives C order
Returns I J K as a tuple.
"""
logger.info("IB to IJK")
if forder:
iv, jv, kv = _cxtgeo.x_ib2ijk(ib, nx, ny, nz, ibbase)