How to use the xtgeo.common function in xtgeo

To help you get started, we’ve selected a few xtgeo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github equinor / xtgeo / tests / test_cube / test_cube_surface_attrs.py View on Github external
# -*- coding: utf-8 -*-
from os.path import join
import pytest
import xtgeo

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.basiclogger(__name__)

if not xtg.testsetup():
    raise SystemExit("Cannot find test setup")

TMD = xtg.tmpdir
TPATH = xtg.testpath

SFILE1 = join(TPATH, "cubes/etc/ib_synth_iainb.segy")


# ======================================================================================
# This is a a set of tests towards a synthetic small cube made by I Bush in order to
# test all attributes in detail
# ======================================================================================
github equinor / xtgeo / tests / test_surface / test_surfaces.py View on Github external
# coding: utf-8
from __future__ import division, absolute_import
from __future__ import print_function

import math
from os.path import join

import numpy as np

import xtgeo
import test_common.test_xtg as tsetup

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.basiclogger(__name__)

if not xtg.testsetup():
    raise SystemExit

TMPD = xtg.tmpdir
TESTPATH = xtg.testpath


# =============================================================================
# Do tests
# =============================================================================

TESTSET1A = "../xtgeo-testdata/surfaces/reek/1/topreek_rota.gri"
TESTSET1B = "../xtgeo-testdata/surfaces/reek/1/basereek_rota.gri"
TESTSETG1 = "../xtgeo-testdata/3dgrids/reek/reek_geo_grid.roff"
github equinor / xtgeo / tests / test_grid3d / test_grid_fence.py View on Github external
# coding: utf-8
from __future__ import division, absolute_import
from __future__ import print_function

import os

import xtgeo
import test_common.test_xtg as tsetup

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.basiclogger(__name__)

if not xtg.testsetup():
    raise SystemExit

TMPDIR = xtg.tmpdir
TESTPATH = xtg.testpath

XTGSHOW = False
if "XTG_SHOW" in os.environ:
    XTGSHOW = True

REEKROOT = "../xtgeo-testdata/3dgrids/reek/REEK"
WELL1 = "../xtgeo-testdata/wells/reek/1/OP_1.w"
FENCE1 = "../xtgeo-testdata/polygons/reek/1/fence.pol"
FENCE2 = "../xtgeo-testdata/polygons/reek/1/minifence.pol"
github equinor / xtgeo / src / xtgeo / grid3d / _gridprop_etc.py View on Github external
"""GridProperty (not GridProperies) some etc functions"""

# from ._gridprop_import_eclrun import import_eclbinary
#  --> INIT, UNRST
#
# from ._gridprop_import_grdecl import import_grdecl_prop, import_bgrdecl_prop
#  --> ASCII and BINARY GRDECL format
# from ._gridprop_import_roff import import_roff
#  --> BINARY ROFF format

from __future__ import print_function, absolute_import
import numpy as np

import xtgeo

xtg = xtgeo.common.XTGeoDialog()

logger = xtg.functionlogger(__name__)


def gridproperty_fromgrid(self, grid, linkgeometry=False):

    """Make an simple GridProperty instance directly based on an existing grid.

    Args:
        grid (Grid): The grid geometry instance
        linkgeometry (bool): If True, connect the property.geometry to the input grid
    Example::

        import xtgeo
        grd = xtgeo.grid_from_file("my.roff")
        myporo = xtgeo.GridProperty(grd, name="PORO")
github equinor / xtgeo / src / xtgeo / surface / surfaces.py View on Github external
# -*- coding: utf-8 -*-

"""The surfaces module, which has the Surfaces class (collection of surface objects)"""

from __future__ import division, absolute_import
from __future__ import print_function

import numpy as np

import xtgeo
from . import _surfs_import

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.functionlogger(__name__)


class Surfaces(object):
    """Class for a collection of Surface objects, for operations that involves
    a number of surfaces, such as statistical numbers.

    A collection of surfaces can be different things:

    * A list if surfaces in stratigraphic order
    * A collection of different realisations of the same surface
    * A collection of isochores

    Args:
        input (list, optional): A list of XTGeo objects and/or file names)
        subtype (str): "tops", "isochores", or None (default)
github equinor / xtgeo / src / xtgeo / grid3d / grid_property.py View on Github external
import copy
from types import FunctionType

import numpy as np

import xtgeo

from ._grid3d import Grid3D
from . import _gridprop_etc
from . import _gridprop_op1
from . import _gridprop_import
from . import _gridprop_roxapi
from . import _gridprop_export
from . import _gridprop_lowlevel

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.functionlogger(__name__)

# -----------------------------------------------------------------------------
# Comment on 'asmasked' vs 'activeonly:
#
# 'asmasked'=True will return a np.ma array, while 'asmasked' = False will
# return a np.ndarray
#
# The 'activeonly' will filter out masked entries, or use None or np.nan
# if 'activeonly' is False.
#
# Use word 'zerobased' for a bool regrading startcell basis is 1 or 0
#
# For functions with mask=... ,they should be replaced with asmasked=...
# -----------------------------------------------------------------------------
github equinor / xtgeo / src / xtgeo / grid3d / _grid_import_roff.py View on Github external
"""Private module, Grid Import private functions for ROFF format"""

from __future__ import print_function, absolute_import

from collections import OrderedDict


import numpy as np

import xtgeo.cxtgeo._cxtgeo as _cxtgeo
import xtgeo

from ._gridprop_import_roff import _rkwquery, _rkwxlist, _rkwxvec
from . import _grid3d_utils as utils

xtg = xtgeo.common.XTGeoDialog()

logger = xtg.functionlogger(__name__)


def import_roff(self, gfile):

    gfile.get_cfhandle()

    _import_roff(self, gfile)

    gfile.cfclose()


def _import_roff(self, gfile):
    """Import ROFF format, version 2 (improved version)"""
github equinor / xtgeo / src / xtgeo / grid3d / _grid_wellzone.py View on Github external
"""Private module for grid vs well zonelog checks"""

from __future__ import print_function, absolute_import, division

import numpy as np
import xtgeo

xtg = xtgeo.common.XTGeoDialog()

logger = xtg.functionlogger(__name__)


def report_zone_mismatch(
    self,
    well=None,
    zonelogname="ZONELOG",
    zoneprop=None,
    onelayergrid=None,  # redundant; will be computed internally
    zonelogrange=(0, 9999),
    zonelogshift=0,
    depthrange=None,
    perflogname=None,
    filterlogname=None,
    resultformat=1,
github equinor / xtgeo / src / xtgeo / grid3d / _grid_eclbin_record.py View on Github external
"""Generic function to import ECL binary records for EGRID, INIT etc"""

from __future__ import print_function, absolute_import


import numpy as np

import xtgeo
import xtgeo.cxtgeo._cxtgeo as _cxtgeo

xtg = xtgeo.common.XTGeoDialog()

logger = xtg.functionlogger(__name__)


def eclbin_record(gfile, kwname, kwlen, kwtype, kwbyte):
    # generic: read a single binary Eclipse record via cxtgeo

    ilen = flen = dlen = 1

    if kwtype == "INTE":
        ilen = kwlen
        kwntype = 1
    elif kwtype == "REAL":
        flen = kwlen
        kwntype = 2
    elif kwtype == "DOUB":