Example #1
0
def test_snap_to_surface():
    """Import XYZ points from file."""

    mypoints = xtgeo.Points(PFILE3)
    assert mypoints.nrow == 20

    surf1 = xtgeo.RegularSurface(SFILE1A)

    mypoints.snap_surface(surf1)
    assert mypoints.nrow == 11

    tsetup.assert_almostequal(mypoints.dataframe["Z_TVDSS"].mean(), 1661.45,
                              0.01)

    # repeat,using surface whithg rotaion and partial masks

    mypoints = xtgeo.Points(PFILE3)
    surf2 = xtgeo.RegularSurface(SFILE2A)

    mypoints.snap_surface(surf2)
    assert mypoints.nrow == 12
    tsetup.assert_almostequal(mypoints.dataframe["Z_TVDSS"].mean(), 1687.45,
                              0.01)

    # alternative; keep values as is using activeobnly=False
    mypoints = xtgeo.Points(PFILE3)
    mypoints.snap_surface(surf2, activeonly=False)
    assert mypoints.nrow == 20
    tsetup.assert_almostequal(mypoints.dataframe["Z_TVDSS"].mean(), 1012.47,
                              0.01)
    mypoints.to_file(join(TMPD, "snapped_point.poi"))
Example #2
0
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)
Example #3
0
def test_irapbin_io():
    """Import and export Irap binary."""
    logger.info("Import and export...")

    x = xtgeo.RegularSurface()
    x.from_file(TESTSET1, fformat="irap_binary")

    x.to_file("TMP/reek1_test.fgr", fformat="irap_ascii")

    logger.debug("NX is %s", x.ncol)

    tsetup.assert_equal(x.ncol, 554)

    # get the 1D numpy
    v1d = x.get_zval()

    logger.info("Mean VALUES are: %s", np.nanmean(v1d))

    zval = x.values

    # add value via numpy
    zval = zval + 300
    # update
    x.values = zval

    tsetup.assert_almostequal(x.values.mean(), 1998.648, 0.01)

    x.to_file("TMP/reek1_plus_300_a.fgr", fformat="irap_ascii")
    x.to_file("TMP/reek1_plus_300_b.gri", fformat="irap_binary")

    mfile = TESTSET1

    # direct import
    y = xtgeo.RegularSurface(mfile)
    tsetup.assert_equal(y.ncol, 554)

    # semidirect import
    cc = xtgeo.RegularSurface().from_file(mfile)
    tsetup.assert_equal(cc.ncol, 554)
Example #4
0
def test_import_export_polygons():
    """Import XYZ polygons from file. Modify, and export."""

    mypoly = Polygons()

    mypoly.from_file(PFILE, fformat="xyz")

    z0 = mypoly.dataframe["Z_TVDSS"].values[0]

    tsetup.assert_almostequal(z0, 2266.996338, 0.001)

    logger.debug(mypoly.dataframe)

    mypoly.dataframe["Z_TVDSS"] += 100

    mypoly.to_file(TMPD + "/polygon_export.xyz", fformat="xyz")

    # reimport and check
    mypoly2 = Polygons(TMPD + "/polygon_export.xyz")

    tsetup.assert_almostequal(z0 + 100, mypoly2.dataframe["Z_TVDSS"].values[0],
                              0.001)
Example #5
0
def test_reverse_row_axis_dualprops():
    """Reverse axis for distorted but small grid with props"""

    grd = Grid(DUALPROPS, fformat="eclipserun", initprops=["PORO", "PORV"])

    poro = grd.gridprops.props[0]
    logger.info(grd.gridprops.describe())
    porowas = poro.copy()
    tsetup.assert_almostequal(poro.values[1, 0, 0], 0.17777, 0.01)
    assert grd.ijk_handedness == "left"

    grd.reverse_row_axis()
    tsetup.assert_almostequal(poro.values[1, 2, 0], 0.17777, 0.01)
    assert poro.values[1, 2, 0] == porowas.values[1, 0, 0]

    grd.reverse_row_axis()
    assert poro.values[1, 0, 0] == porowas.values[1, 0, 0]
    assert grd.ijk_handedness == "left"

    grd.reverse_row_axis(ijk_handedness="left")  # ie do nothing in this case
    assert poro.values[1, 0, 0] == porowas.values[1, 0, 0]
    assert grd.ijk_handedness == "left"
Example #6
0
def test_irapbin_import_metadatafirst():
    """Import Reek Irap binary, first with metadata only, then values."""
    logger.info("Import and export...")

    nsurf = 10
    sur = []
    t1 = xtg.timer()
    for ix in range(nsurf):
        sur.append(xtgeo.RegularSurface(TESTSET2, values=False))
    t2 = xtg.timer(t1)
    logger.info("Loading %s surfaces lazy took %s secs.", nsurf, t2)
    assert sur[nsurf - 1].ncol == 1264

    t1 = xtg.timer()
    for ix in range(nsurf):
        sur[ix].load_values()
    t2 = xtg.timer(t1)
    logger.info("Loading %s surfaces actual values took %s secs.", nsurf, t2)

    assert sur[nsurf - 1].ncol == 1264
    assert sur[nsurf - 1].nrow == 2010
    tsetup.assert_almostequal(sur[nsurf - 1].values[11, 0], 1678.89733887, 0.00001)
Example #7
0
def test_get_surfaces_from_3dgrid():
    """Create surfaces from a 3D grid"""

    mygrid = xtgeo.Grid(TESTSETG1)
    surfs = xtgeo.Surfaces()
    surfs.from_grid3d(mygrid, rfactor=2)
    surfs.describe()

    tsetup.assert_almostequal(surfs.surfaces[-1].values.mean(), 1742.28, 0.04)
    tsetup.assert_almostequal(surfs.surfaces[-1].values.min(), 1589.58, 0.04)
    tsetup.assert_almostequal(surfs.surfaces[-1].values.max(), 1977.29, 0.04)
    tsetup.assert_almostequal(surfs.surfaces[0].values.mean(), 1697.02, 0.04)

    for srf in surfs.surfaces:
        srf.to_file(join(TMPD, srf.name + ".gri"))
def test_get_surface_from_grd3d_porosity():
    """Sample a surface from a 3D grid"""

    surf = xtgeo.surface.RegularSurface(rtop1)
    print(surf.values.min(), surf.values.max())
    grd = xtgeo.grid3d.Grid(rgrd1, fformat="egrid")
    surf.values = 1700
    zsurf = surf.copy()
    surfr = surf.copy()
    surf2 = surf.copy()
    phi = xtgeo.grid3d.GridProperty(rprop1,
                                    fformat="init",
                                    name="PORO",
                                    grid=grd)

    # slice grd3d
    surf.slice_grid3d(grd, phi)

    surf.to_file(ojn(td, "surf_slice_grd3d_reek.gri"))
    surf.quickplot(filename=ojn(td, "surf_slice_grd3d_reek.png"))

    # refined version:
    surfr.refine(2)
    surfr.slice_grid3d(grd, phi)

    surfr.to_file(ojn(td, "surf_slice_grd3d_reek_refined.gri"))
    surfr.quickplot(filename=ojn(td, "surf_slice_grd3d_reek_refined.png"))

    # use zsurf:
    surf2.slice_grid3d(grd, phi, zsurf=zsurf)

    surf2.to_file(ojn(td, "surf_slice_grd3d_reek_zslice.gri"))
    surf2.quickplot(filename=ojn(td, "surf_slice_grd3d_reek_zslice.png"))

    assert np.allclose(surf.values, surf2.values)

    tsetup.assert_almostequal(surf.values.mean(), 0.1667, 0.01)
    tsetup.assert_almostequal(surfr.values.mean(), 0.1667, 0.01)
Example #9
0
def test_randomline_fence_from_well():
    """Import ROFF grid with props and make fences"""

    grd = xtgeo.Grid(REEKROOT, fformat="eclipserun", initprops=["PORO"])
    wll = xtgeo.Well(WELL1, zonelogname="Zonelog")

    print(grd.describe(details=True))

    # get the polygon for the well, limit it to 1200
    fspec = wll.get_fence_polyline(sampling=10,
                                   nextend=2,
                                   asnumpy=False,
                                   tvdmin=1200)
    print(fspec.dataframe)

    tsetup.assert_almostequal(fspec.dataframe[fspec.dhname][4], 12.6335, 0.001)
    logger.info(fspec.dataframe)

    fspec = wll.get_fence_polyline(sampling=10,
                                   nextend=2,
                                   asnumpy=True,
                                   tvdmin=1200)

    # get the "image", which is a 2D numpy that can be plotted with e.g. imgshow
    hmin, hmax, vmin, vmax, por = grd.get_randomline(fspec,
                                                     "PORO",
                                                     zmin=1600,
                                                     zmax=1700,
                                                     zincrement=1.0)

    if XTGSHOW:
        import matplotlib.pyplot as plt

        plt.figure()
        plt.imshow(por, cmap="rainbow", extent=(hmin, hmax, vmax, vmin))
        plt.axis("tight")
        plt.colorbar()
        plt.show()
Example #10
0
def test_dataframe_more():
    """Get a pandas Dataframe object, more detailed testing"""

    xmap = xtgeo.RegularSurface(TESTSET1)

    xmap.describe()

    dfrc = xmap.dataframe(ijcolumns=True, order="C", activeonly=True)
    dfrf = xmap.dataframe(ijcolumns=True, order="F", activeonly=True)

    dfrc.to_csv(os.path.join(TMPD, "regsurf_df_c.csv"))
    dfrf.to_csv(os.path.join(TMPD, "regsurf_df_f.csv"))
    xmap.to_file(os.path.join(TMPD, "regsurf_df.ijxyz"), fformat="ijxyz")

    tsetup.assert_almostequal(dfrc["X_UTME"][2], 465956.274, 0.01)
    tsetup.assert_almostequal(dfrf["X_UTME"][2], 462679.773, 0.01)

    dfrcx = xmap.dataframe(ijcolumns=False, order="C", activeonly=True)
    dfrcx.to_csv(os.path.join(TMPD, "regsurf_df_noij_c.csv"))
    dfrcy = xmap.dataframe(
        ijcolumns=False, order="C", activeonly=False, fill_value=None
    )
    dfrcy.to_csv(os.path.join(TMPD, "regsurf_df_noij_c_all.csv"))
Example #11
0
def test_roffbin_get_dataframe_for_grid(load_gfile1):
    """Import ROFF grid and return a grid dataframe (no props)"""

    grd = load_gfile1

    assert isinstance(grd, Grid)

    df = grd.dataframe()
    print(df.head())

    assert len(df) == grd.nactive

    tsetup.assert_almostequal(df["X_UTME"][0], 459176.7937727844, 0.1)

    assert len(df.columns) == 6

    df = grd.dataframe(activeonly=False)
    print(df.head())

    assert len(df.columns) == 7
    assert len(df) != grd.nactive

    assert len(df) == grd.ncol * grd.nrow * grd.nlay
Example #12
0
def test_roffbin_import1(load_gfile1):
    """Test roff binary import case 1"""

    grd = load_gfile1

    tsetup.assert_equal(grd.ncol, 70, txt="Grid NCOL Emerald")
    tsetup.assert_equal(grd.nlay, 46, txt="Grid NLAY Emerald")

    # extract ACTNUM parameter as a property instance (a GridProperty)
    act = grd.get_actnum()

    # get dZ...
    dzv = grd.get_dz()

    logger.info("ACTNUM is %s", act)
    logger.debug("DZ values are \n%s", dzv.values1d[888:999])

    dzval = dzv.values
    print("DZ mean and shape: ", dzval.mean(), dzval.shape)
    # get the value is cell 32 73 1 shall be 2.761
    mydz = float(dzval[31:32, 72:73, 0:1])
    tsetup.assert_almostequal(mydz, 2.761, 0.001, txt="Grid DZ Emerald")

    # get dX dY
    logger.info("Get dX dY")
    dxv, dyv = grd.get_dxdy()

    mydx = float(dxv.values3d[31:32, 72:73, 0:1])
    mydy = float(dyv.values3d[31:32, 72:73, 0:1])

    tsetup.assert_almostequal(mydx, 118.51, 0.01, txt="Grid DX Emerald")
    tsetup.assert_almostequal(mydy, 141.26, 0.01, txt="Grid DY Emerald")

    # get X Y Z coordinates (as GridProperty objects) in one go
    logger.info("Get X Y Z...")
    xvv, yvv, zvv = grd.get_xyz(names=["xxx", "yyy", "zzz"])

    tsetup.assert_equal(xvv.name, "xxx", txt="Name of X coord")
    xvv.name = "Xerxes"

    # attach some properties to grid
    grd.props = [xvv, yvv]

    logger.info(grd.props)
    grd.props = [zvv]

    logger.info(grd.props)

    grd.props.append(xvv)
    logger.info(grd.propnames)

    # get the property of name Xerxes
    myx = grd.get_prop_by_name("Xerxes")
    if myx is None:
        logger.info(myx)
    else:
        logger.info("Got nothing!")
Example #13
0
def test_operations_inside_outside_polygon_shortforms():
    """Various shortforms for operations in polygons"""

    # assert values are checked in RMS

    zurf = xtgeo.surface.RegularSurface(SURF1)
    poly = xtgeo.xyz.Polygons(POLY1)

    surf = zurf.copy()
    surf.add_inside(poly, 200)
    tsetup.assert_almostequal(surf.values.mean(), 1759.06, 0.01)

    surf = zurf.copy()
    surf.add_outside(poly, 200)
    tsetup.assert_almostequal(surf.values.mean(), 1838.24, 0.01)

    # add another surface inside polygon (here itself)
    surf = zurf.copy()
    surf2 = zurf.copy()
    surf.add_inside(poly, surf2)
    tsetup.assert_almostequal(surf.values.mean(), 2206.20, 0.01)

    # divide on zero
    surf = zurf.copy()
    surf.div_inside(poly, 0.0)
    surf.to_file("TMP/div2.gri")
    surf.to_file("TMP/div2.fgr", fformat="irap_ascii")

    # set inside
    surf = zurf.copy()
    surf.set_inside(poly, 700)
    tsetup.assert_almostequal(surf.values.mean(), 1402.52, 0.01)

    # eliminate inside
    surf = zurf.copy()
    surf.eli_inside(poly)
    tsetup.assert_almostequal(surf.values.mean(), 1706.52, 0.01)
Example #14
0
def test_cube_get_xy_from_ij(loadsfile1):
    """Import a cube, then report XY for a given IJ"""

    logger.info("Checking get xy from IJ")

    incube = loadsfile1

    # thinning to evey second column and row, but not vertically
    xpos, ypos = incube.get_xy_value_from_ij(0, 0, zerobased=True)
    assert xpos == incube.xori
    assert ypos == incube.yori

    xpos, ypos = incube.get_xy_value_from_ij(1, 1, zerobased=False)
    assert xpos == incube.xori
    assert ypos == incube.yori

    xpos, ypos = incube.get_xy_value_from_ij(0, 0, ixline=True)
    assert xpos == incube.xori
    assert ypos == incube.yori

    xpos, ypos = incube.get_xy_value_from_ij(200, 200, zerobased=True)

    tsetup.assert_almostequal(xpos, 463327.8811957213, 0.01)
    tsetup.assert_almostequal(ypos, 5933633.598034564, 0.01)
Example #15
0
def test_fill():
    """Fill the undefined values for the surface"""

    srf = xtgeo.RegularSurface()
    srf.from_file(TESTSET1, fformat="irap_binary")

    minv1 = srf.values.min()
    tsetup.assert_almostequal(srf.values.mean(), 1698.648, 0.001)

    srf.fill()
    minv2 = srf.values.min()
    tsetup.assert_almostequal(srf.values.mean(), 1705.201, 0.001)
    tsetup.assert_almostequal(minv1, minv2, 0.000001)

    srf = xtgeo.RegularSurface()
    srf.from_file(TESTSET1, fformat="irap_binary")
    srf.fill(444)
    tsetup.assert_almostequal(srf.values.mean(), 1342.10498, 0.001)
Example #16
0
def test_polygon_boundary():
    """Import XYZ polygons from file and test boundary function."""

    mypoly = Polygons()

    mypoly.from_file(PFILE, fformat="xyz")

    boundary = mypoly.get_boundary()

    tsetup.assert_almostequal(boundary[0], 460595.6036, 0.0001)
    tsetup.assert_almostequal(boundary[4], 2025.952637, 0.0001)
    tsetup.assert_almostequal(boundary[5], 2266.996338, 0.0001)
Example #17
0
def test_get_xy_values1d():
    """Get the XY coordinate values"""

    xmap = xtgeo.RegularSurface()

    xcv, _ycv = xmap.get_xy_values1d(activeonly=False, order="C")

    tsetup.assert_almostequal(xcv[1], 0.0, 0.001)

    xcv, _ycv = xmap.get_xy_values1d(activeonly=False, order="F")

    tsetup.assert_almostequal(xcv[1], 25.0, 0.001)

    xcv, _ycv = xmap.get_xy_values1d(activeonly=True, order="C")

    tsetup.assert_almostequal(xcv[1], 0.0, 0.001)

    xcv, _ycv = xmap.get_xy_values1d(activeonly=True, order="F")

    tsetup.assert_almostequal(xcv[1], 25.0, 0.001)
Example #18
0
def test_get_xy_values():
    """Get the XY coordinate values as 2D arrays"""

    xmap = xtgeo.RegularSurface()

    xcv, _ycv = xmap.get_xy_values(order="C")

    xxv = xcv.ravel(order="K")
    tsetup.assert_almostequal(xxv[1], 0.0, 0.001)

    xcv, _ycv = xmap.get_xy_values(order="F")
    xxv = xcv.ravel(order="K")
    tsetup.assert_almostequal(xxv[1], 25.0, 0.001)

    xcv, _ycv = xmap.get_xy_values(order="C", asmasked=True)

    xxv = xcv.ravel(order="K")
    tsetup.assert_almostequal(xxv[1], 0.0, 0.001)

    xcv, _ycv = xmap.get_xy_values(order="F", asmasked=True)

    xxv = xcv.ravel(order="K")
    tsetup.assert_almostequal(xxv[1], 25.0, 0.001)
Example #19
0
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)
Example #20
0
def test_geometrics_reek():
    """Import Reek and test geometrics"""

    grd = Grid(REEKFILE, fformat="egrid")

    geom = grd.get_geometrics(return_dict=True, cellcenter=False)

    for key, val in geom.items():
        logger.info("%s is %s", key, val)

    # compared with RMS info:
    tsetup.assert_almostequal(geom["xmin"], 456510.6, 0.1, "Xmin")
    tsetup.assert_almostequal(geom["ymax"], 5938935.5, 0.1, "Ymax")

    # cellcenter True:
    geom = grd.get_geometrics(return_dict=True, cellcenter=True)
    tsetup.assert_almostequal(geom["xmin"], 456620, 1, "Xmin cell center")
Example #21
0
def test_dataframe_simple():
    """Get a pandas Dataframe object"""

    xmap = xtgeo.RegularSurface(TESTSET1)

    dfrc = xmap.dataframe(ijcolumns=True, order="C", activeonly=True)

    tsetup.assert_almostequal(dfrc["X_UTME"][2], 465956.274, 0.01)

    xmap = xtgeo.surface_from_file(TESTSET2)

    dfrc = xmap.dataframe()

    tsetup.assert_almostequal(dfrc["X_UTME"][2], 461582.562498, 0.01)

    xmap.coarsen(2)
    dfrc = xmap.dataframe()

    tsetup.assert_almostequal(dfrc["X_UTME"][2], 461577.5575, 0.01)
Example #22
0
def test_twosurfaces_oper():
    """Test operations between two surface in more different ways"""

    surf1 = xtgeo.RegularSurface(TESTSET1)
    surf2 = xtgeo.RegularSurface(TESTSET1A)

    iso1 = surf2.copy()
    iso1.values -= surf1.values
    iso1mean = iso1.values.mean()
    tsetup.assert_almostequal(iso1mean, 43.71, 0.01)

    iso2 = surf2.copy()
    iso2.subtract(surf1)
    iso2mean = iso2.values.mean()
    tsetup.assert_almostequal(iso2mean, 43.71, 0.01)
    assert iso1.values.all() == iso2.values.all()

    iso3 = surf2 - surf1
    assert iso1.values.all() == iso3.values.all()
    assert isinstance(iso3, xtgeo.RegularSurface)

    sum1 = surf2.copy()
    sum1.values += surf1.values
    tsetup.assert_almostequal(sum1.values.mean(), 3441.0, 0.01)

    sum2 = surf2.copy()
    sum2.add(surf1)
    assert sum1.values.all() == sum2.values.all()

    sum3 = surf1 + surf2
    assert sum1.values.all() == sum3.values.all()

    zrf2 = surf2.copy()
    zrf1 = surf1.copy()
    newzrf1 = surf1.copy()

    newzrf1.values = zrf2.values / zrf1.values
    assert newzrf1.values.mean() == pytest.approx(1.0257, abs=0.01)
Example #23
0
def test_create_shoebox():
    """Make a shoebox grid from scratch"""

    grd = xtgeo.Grid()
    grd.create_box()
    grd.to_file(join(TMPDIR, "shoebox_default.roff"))

    grd.create_box(flip=-1)
    grd.to_file(join(TMPDIR, "shoebox_default_flipped.roff"))

    timer1 = xtg.timer()
    grd.create_box(origin=(0, 0, 1000),
                   dimension=(300, 200, 30),
                   increment=(20, 20, 1),
                   flip=-1)
    logger.info("Making a a 1,8 mill cell grid took %5.3f secs",
                xtg.timer(timer1))

    dx, dy = grd.get_dxdy()

    tsetup.assert_almostequal(dx.values.mean(), 20.0, 0.0001)
    tsetup.assert_almostequal(dy.values.mean(), 20.0, 0.0001)

    grd.create_box(origin=(0, 0, 1000),
                   dimension=(30, 30, 3),
                   rotation=45,
                   increment=(20, 20, 1))

    x, y, z = grd.get_xyz()

    tsetup.assert_almostequal(x.values1d[0], 0.0, 0.001)
    tsetup.assert_almostequal(y.values1d[0], 20 * math.cos(45 * math.pi / 180),
                              0.001)
    tsetup.assert_almostequal(z.values1d[0], 1000.5, 0.001)

    grd.create_box(
        origin=(0, 0, 1000),
        dimension=(30, 30, 3),
        rotation=45,
        increment=(20, 20, 1),
        oricenter=True,
    )

    x, y, z = grd.get_xyz()

    tsetup.assert_almostequal(x.values1d[0], 0.0, 0.001)
    tsetup.assert_almostequal(y.values1d[0], 0.0, 0.001)
    tsetup.assert_almostequal(z.values1d[0], 1000.0, 0.001)
Example #24
0
def test_import_dualperm_grid_soil():
    """Test grid with flag for dual perm setup (will also mean dual poro also)"""

    grd = xtgeo.grid_from_file(DUALFILE2 + ".EGRID")
    grd._dualactnum.to_file("TMP/dualact.roff")

    sgas = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SGAS",
                                        date=20170121,
                                        fracture=False)
    sgas.describe()
    tsetup.assert_almostequal(sgas.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(sgas.values[0, 1, 0], 0.0, 0.001)

    soil = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SOIL",
                                        date=20170121,
                                        fracture=False)
    soil.describe()
    tsetup.assert_almostequal(soil.values[3, 0, 0], 0.44525, 0.001)
    tsetup.assert_almostequal(soil.values[0, 1, 0], 0.0, 0.001)
    tsetup.assert_almostequal(soil.values[3, 2, 0], 0.0, 0.0001)

    # fractures

    sgas = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SGAS",
                                        date=20170121,
                                        fracture=True)
    tsetup.assert_almostequal(sgas.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(sgas.values[0, 1, 0], 0.0, 0.0001)

    soil = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SOIL",
                                        date=20170121,
                                        fracture=True)
    tsetup.assert_almostequal(soil.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(soil.values[0, 1, 0], 0.011741, 0.0001)
    tsetup.assert_almostequal(soil.values[3, 2, 0], 0.11676, 0.0001)
Example #25
0
def test_import_dualperm_grid_sgas():
    """Test grid with flag for dual perm/poro setup gas/water"""

    grd = xtgeo.grid_from_file(DUALFILE3 + ".EGRID")

    sgas = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SGAS",
                                        date=20170121,
                                        fracture=False)
    sgas.describe()
    tsetup.assert_almostequal(sgas.values[3, 0, 0], 0.06639, 0.001)
    tsetup.assert_almostequal(sgas.values[0, 1, 0], 0.0, 0.001)
    tsetup.assert_almostequal(sgas.values[4, 2, 0], 0.10696, 0.001)
    assert "SGASM in sgas.name"

    swat = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=False)
    swat.describe()
    tsetup.assert_almostequal(swat.values[3, 0, 0], 0.93361, 0.001)
    tsetup.assert_almostequal(swat.values[0, 1, 0], 0.0, 0.001)
    tsetup.assert_almostequal(swat.values[4, 2, 0], 0.89304, 0.001)
    assert "SWATM in swat.name"

    # shall be not soil actually
    soil = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SOIL",
                                        date=20170121,
                                        fracture=False)
    soil.describe()
    tsetup.assert_almostequal(soil.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(soil.values[0, 1, 0], 0.0, 0.001)
    assert "SOILM" in soil.name

    # fractures

    sgas = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SGAS",
                                        date=20170121,
                                        fracture=True)
    sgas.describe()
    tsetup.assert_almostequal(sgas.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(sgas.values[0, 1, 0], 0.0018198, 0.001)
    tsetup.assert_almostequal(sgas.values[4, 2, 0], 0.17841, 0.001)
    assert "SGASF" in sgas.name

    swat = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=True)
    swat.describe()
    tsetup.assert_almostequal(swat.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(swat.values[0, 1, 0], 0.99818, 0.001)
    tsetup.assert_almostequal(swat.values[4, 2, 0], 0.82159, 0.001)
    assert "SWATF" in swat.name

    # shall be not soil actually
    soil = xtgeo.gridproperty_from_file(DUALFILE3 + ".UNRST",
                                        grid=grd,
                                        name="SOIL",
                                        date=20170121,
                                        fracture=True)
    soil.describe()
    tsetup.assert_almostequal(soil.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(soil.values[0, 1, 0], 0.0, 0.001)
    assert "SOILF" in soil.name
Example #26
0
def test_import_dualporo_grid():
    """Test grid with flag for dual porosity setup, oil water"""

    grd = xtgeo.grid_from_file(DUALFILE1 + ".EGRID")

    assert grd.dualporo is True
    assert grd.dualperm is False
    assert grd.dimensions == (5, 3, 1)

    poro = xtgeo.gridproperty_from_file(DUALFILE1 + ".INIT",
                                        grid=grd,
                                        name="PORO")

    tsetup.assert_almostequal(poro.values[0, 0, 0], 0.1, 0.001)
    tsetup.assert_almostequal(poro.values[1, 1, 0], 0.16, 0.001)
    tsetup.assert_almostequal(poro.values[4, 2, 0], 0.24, 0.001)
    assert poro.name == "POROM"
    poro.describe()

    poro = xtgeo.gridproperty_from_file(DUALFILE1 + ".INIT",
                                        grid=grd,
                                        name="PORO",
                                        fracture=True)

    tsetup.assert_almostequal(poro.values[0, 0, 0], 0.25, 0.001)
    tsetup.assert_almostequal(poro.values[4, 2, 0], 0.39, 0.001)
    assert poro.name == "POROF"
    poro.describe()

    swat = xtgeo.gridproperty_from_file(DUALFILE1 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=False)
    swat.describe()
    tsetup.assert_almostequal(swat.values[0, 0, 0], 0.60924, 0.001)

    swat = xtgeo.gridproperty_from_file(DUALFILE1 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=True)
    swat.describe()
    tsetup.assert_almostequal(swat.values[0, 0, 0], 0.989687, 0.001)
    swat.to_file("TMP/swat.roff")
Example #27
0
def test_import_dualperm_grid():
    """Test grid with flag for dual perm setup (hence dual poro also) water/oil"""

    grd = xtgeo.grid_from_file(DUALFILE2 + ".EGRID")

    assert grd.dualporo is True
    assert grd.dualperm is True
    assert grd.dimensions == (5, 3, 1)
    grd.to_file(os.path.join(TMPDIR, "dual2.roff"))

    poro = xtgeo.gridproperty_from_file(DUALFILE2 + ".INIT",
                                        grid=grd,
                                        name="PORO")
    print(poro.values)

    tsetup.assert_almostequal(poro.values[0, 0, 0], 0.1, 0.001)
    tsetup.assert_almostequal(poro.values[1, 1, 0], 0.16, 0.001)
    tsetup.assert_almostequal(poro.values[4, 2, 0], 0.24, 0.001)
    assert poro.name == "POROM"
    poro.describe()

    poro = xtgeo.gridproperty_from_file(DUALFILE2 + ".INIT",
                                        grid=grd,
                                        name="PORO",
                                        fracture=True)

    tsetup.assert_almostequal(poro.values[0, 0, 0], 0.25, 0.001)
    tsetup.assert_almostequal(poro.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(poro.values[4, 2, 0], 0.39, 0.001)
    assert poro.name == "POROF"
    poro.describe()

    perm = xtgeo.gridproperty_from_file(DUALFILE2 + ".INIT",
                                        grid=grd,
                                        name="PERMX")

    tsetup.assert_almostequal(perm.values[0, 0, 0], 100.0, 0.001)
    tsetup.assert_almostequal(perm.values[3, 0, 0], 100.0, 0.001)
    tsetup.assert_almostequal(perm.values[0, 1, 0], 0.0, 0.001)
    tsetup.assert_almostequal(perm.values[4, 2, 0], 100, 0.001)
    assert perm.name == "PERMXM"
    perm.to_file(os.path.join(TMPDIR, "dual2_permxm.roff"))

    perm = xtgeo.gridproperty_from_file(DUALFILE2 + ".INIT",
                                        grid=grd,
                                        name="PERMX",
                                        fracture=True)

    tsetup.assert_almostequal(perm.values[0, 0, 0], 100.0, 0.001)
    tsetup.assert_almostequal(perm.values[3, 0, 0], 0.0, 0.001)
    tsetup.assert_almostequal(perm.values[0, 1, 0], 100.0, 0.001)
    tsetup.assert_almostequal(perm.values[4, 2, 0], 100, 0.001)
    assert perm.name == "PERMXF"
    perm.to_file(os.path.join(TMPDIR, "dual2_permxf.roff"))

    swat = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=False)
    tsetup.assert_almostequal(swat.values[3, 0, 0], 0.55475, 0.001)

    soil = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SOIL",
                                        date=20170121,
                                        fracture=False)
    print(soil.values)
    tsetup.assert_almostequal(soil.values[3, 0, 0], 0.44525, 0.001)
    tsetup.assert_almostequal(soil.values[0, 1, 0], 0.0, 0.001)
    assert np.ma.is_masked(soil.values[1, 2, 0])
    tsetup.assert_almostequal(soil.values[3, 2, 0], 0.0, 0.001)
    tsetup.assert_almostequal(soil.values[4, 2, 0], 0.41271, 0.001)

    swat = xtgeo.gridproperty_from_file(DUALFILE2 + ".UNRST",
                                        grid=grd,
                                        name="SWAT",
                                        date=20170121,
                                        fracture=True)
    swat.describe()
    assert "SWATF" in swat.name

    tsetup.assert_almostequal(swat.values[3, 0, 0], 0.0, 0.001)
    swat.to_file("TMP/swat.roff")