How to use the xtgeo.grid3d.GridProperty 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_grid3d / test_grid_property.py View on Github external
def test_io_ecl_dates():
    """Import Eclipse with some more flexible dates settings"""

    logger.info("Name is {}".format(__name__))
    po = GridProperty()
    px = GridProperty()
    mygrid = Grid(TESTFILE5)
    po.from_file(TESTFILE7, fformat="unrst", name="PRESSURE", grid=mygrid, date="first")
    assert po.date == 19991201
    px.from_file(TESTFILE7, fformat="unrst", name="PRESSURE", grid=mygrid, date="last")
    assert px.date == 20030101
github equinor / xtgeo / tests / test_grid3d / test_grid_property.py View on Github external
def test_eclunrst_import_soil_reek():
    """Property UNRST import from Eclipse, computing SOIL. Reek"""

    gg = Grid(TESTFILE5, fformat="egrid")

    logger.info("Import RESTART (UNIFIED) ...")
    swat = GridProperty(TESTFILE7, name="SWAT", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(swat.values.mean(), 0.8780, 0.001)

    sgas = GridProperty(TESTFILE7, name="SGAS", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(sgas.values.mean(), 0.000, 0.001)

    soil = GridProperty(TESTFILE7, name="SOIL", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(soil.values.mean(), 1.0 - 0.8780, 0.001)
github equinor / xtgeo / tests / test_grid3d / test_grid_property.py View on Github external
def test_eclunrst_import_soil_reek():
    """Property UNRST import from Eclipse, computing SOIL. Reek"""

    gg = Grid(TESTFILE5, fformat="egrid")

    logger.info("Import RESTART (UNIFIED) ...")
    swat = GridProperty(TESTFILE7, name="SWAT", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(swat.values.mean(), 0.8780, 0.001)

    sgas = GridProperty(TESTFILE7, name="SGAS", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(sgas.values.mean(), 0.000, 0.001)

    soil = GridProperty(TESTFILE7, name="SOIL", fformat="unrst", date=19991201, grid=gg)

    tsetup.assert_almostequal(soil.values.mean(), 1.0 - 0.8780, 0.001)
github equinor / xtgeo / tests / test_surface / test_regular_surface_vs_grd3d.py View on Github external
def test_get_surface_from_grd3d_zones():
    """Sample a surface from a 3D grid, using zones"""

    surf = xtgeo.surface.RegularSurface(rtop1)
    grd = xtgeo.grid3d.Grid(rgrd2, fformat='roff')
    surf.values = 1700
    zone = xtgeo.grid3d.GridProperty(rprop2, fformat='roff', name='Zone',
                                     grid=grd)

    # slice grd3d
    surf.slice_grid3d(grd, zone, sbuffer=1)

    surf.to_file(ojn(td, 'surf_slice_grd3d_reek_zone.gri'))
    surf.quickplot(filename=ojn(td, 'surf_slice_grd3d_reek_zone.png'))
github equinor / xtgeo / tests / test_grid3d / test_grid_property.py View on Github external
def test_roffbin_import1_roffapiv2():
    """Test of import of ROFF binary using new API"""

    logger.info("Name is {}".format(__name__))

    x = GridProperty()
    logger.info("Import roff...")
    x.from_file(TESTFILE1, fformat="roff", name="PORO", _roffapiv=2)

    logger.info(repr(x.values))
    logger.info(x.values.dtype)
    logger.info("Porosity is {}".format(x.values))
    logger.info("Mean porosity is {}".format(x.values.mean()))
    assert x.values.mean() == pytest.approx(0.1677, abs=0.001)
github equinor / xtgeo / tests / test_etc / test_etc_make_hcpv_maps.py View on Github external
def test_hcpvfz1():
    """HCPV thickness map."""

    # It is important that input are pure numpies, not masked

    logger.info("Name is %s", __name__)
    grd = Grid()
    logger.info("Import roff...")
    grd.from_file(ROFF1_GRID, fformat="roff")

    # get the hcpv
    st = GridProperty()
    to = GridProperty()

    st.from_file(ROFF1_PROPS, name="Oil_HCPV")

    to.from_file(ROFF1_PROPS, name="Oil_bulk")

    # get the dz and the coordinates, with no mask (ie get value for outside)
    dz = grd.get_dz(mask=False)
    xc, yc, _zc = grd.get_xyz(mask=False)

    xcv = ma.filled(xc.values3d)
    ycv = ma.filled(yc.values3d)
    dzv = ma.filled(dz.values3d)

    hcpfz = ma.filled(st.values3d, fill_value=0.0)
    tov = ma.filled(to.values3d, fill_value=10)
github equinor / xtgeo / tests / test_grid3d / test_grid_property.py View on Github external
def test_create_from_grid():
    """Create a simple property from grid"""

    gg = Grid(TESTFILE5, fformat="egrid")
    poro = GridProperty(gg, name="poro", values=0.33)
    assert poro.ncol == gg.ncol
    assert poro.values.mean() == 0.33

    assert poro.values.dtype.kind == "f"

    faci = xtgeo.GridProperty(gg, name="FAC", values=1, discrete=True)
    assert faci.nlay == gg.nlay
    assert faci.values.mean() == 1

    assert faci.values.dtype.kind == "i"
github equinor / xtgeo / tests / test_grid3d / test_grid_property.py View on Github external
def test_grdecl_import_reek():
    """Property GRDECL import from Eclipse. Reek"""

    rgrid = Grid(TESTFILE12a, fformat="grdecl")

    assert rgrid.dimensions == (40, 64, 14)

    poro = GridProperty(TESTFILE12b, name="PORO", fformat="grdecl", grid=rgrid)

    poro2 = GridProperty(TESTFILE1, name="PORO", fformat="roff", grid=rgrid)

    tsetup.assert_almostequal(poro.values.mean(), poro2.values.mean(), 0.001)
    tsetup.assert_almostequal(poro.values.std(), poro2.values.std(), 0.001)

    with pytest.raises(KeywordNotFoundError):
        poro3 = GridProperty(TESTFILE12b, name="XPORO", fformat="grdecl", grid=rgrid)
        logger.debug("Keyword failed as expected for instance %s", poro3)

    # Export to ascii grdecl and import that again...
    exportfile = os.path.join(TMPDIR, "reekporo.grdecl")
    poro.to_file(exportfile, fformat="grdecl")
    porox = GridProperty(exportfile, name="PORO", fformat="grdecl", grid=rgrid)
    tsetup.assert_almostequal(poro.values.mean(), porox.values.mean(), 0.001)

    # Export to binary grdecl and import that again...
    exportfile = os.path.join(TMPDIR, "reekporo.bgrdecl")
    poro.to_file(exportfile, fformat="bgrdecl")
    porox = GridProperty(exportfile, name="PORO", fformat="bgrdecl", grid=rgrid)
    tsetup.assert_almostequal(poro.values.mean(), porox.values.mean(), 0.001)
github equinor / xtgeo / src / xtgeo / grid3d / grid.py View on Github external
extended ACTNUM is applied (numbers 0..3)

        Example::

            act = mygrid.get_actnum()
            print("{}% cells are active".format(act.values.mean() * 100))

        .. versionchanged:: 2.6.0 Added ``dual`` keyword
        """
        if mask is not None:
            asmasked = self._evaluate_mask(mask)

        if dual and self._dualactnum:
            act = self._dualactnum.copy()
        else:
            act = xtgeo.grid3d.GridProperty(
                ncol=self._ncol,
                nrow=self._nrow,
                nlay=self._nlay,
                values=np.zeros((self._ncol, self._nrow, self._nlay), dtype=np.int32),
                name=name,
                discrete=True,
            )

            values = _gridprop_lowlevel.f2c_order(self, self._actnumsv)
            act.values = values
            act.mask_undef()

        if asmasked:
            act.values = ma.masked_equal(act.values, 0)

        act.codes = {0: "0", 1: "1"}
github equinor / xtgeo / src / xtgeo / grid3d / _gridprop_op1.py View on Github external
else the active cells corners will be present while the property
    will have a -999 value.

    """

    grid = kwargs.get("grid", None)

    mask = kwargs.get("mask", True)

    if grid is None:
        raise RuntimeError("Missing grid object")

    if not isinstance(grid, xtgeo.grid3d.Grid):
        raise RuntimeError("The input grid is not a XTGeo Grid instance")

    if not isinstance(self, xtgeo.grid3d.GridProperty):
        raise RuntimeError("The property is not a XTGeo GridProperty instance")

    clist = grid.get_xyz_corners()
    actnum = grid.get_actnum()

    # set value 0 if actnum is 0 to facilitate later operations
    if mask:
        for cli in clist:
            cli.values[actnum.values == 0] = 0

    # now some numpy operations (coffee?, any?)
    xy0 = np.column_stack((clist[0].values1d, clist[1].values1d))
    xy1 = np.column_stack((clist[3].values1d, clist[4].values1d))
    xy2 = np.column_stack((clist[6].values1d, clist[7].values1d))
    xy3 = np.column_stack((clist[9].values1d, clist[10].values1d))