Example #1
0
def test_getwell_and_find_ijk_gfb2():
    """Get well from a RMS project, and find IJK from grid."""

    if not os.path.isdir(BPROJ[roxv]):
        pass

    logger.info("GFB case, reading a wells from RMS well folder")

    xwell = xtgeo.well.Well()
    xwell.from_roxar(
        BPROJ[roxv],
        "34_10-A-15",
        trajectory="Drilled trajectory",
        logrun="data",
        lognames=["ZONELOG"],
    )

    tsetup.assert_equal(xwell.nrow, 3250, "NROW of well")
    tsetup.assert_equal(xwell.rkb, 82.20, "RKB of well")

    # now read a grid
    grd = xtgeo.grid_from_roxar(BPROJ[roxv], "gfb_sim")

    xwell.make_ijk_from_grid(grd)

    print(xwell.dataframe.head())
    xwell.to_file(join(TMPD, "gfb2_well_ijk.rmswell"))
def test_irapasc_export_and_import():
    """Export Irap ASCII and binary and import again."""

    logger.info("Export to Irap Classic and Binary")

    x = xtgeo.RegularSurface(
        ncol=120,
        nrow=100,
        xori=1000,
        yori=5000,
        xinc=40,
        yinc=20,
        values=np.random.rand(120, 100),
    )
    tsetup.assert_equal(x.ncol, 120)

    mean1 = x.values.mean()

    x.to_file("TMP/irap2_a.fgr", fformat="irap_ascii")
    x.to_file("TMP/irap2_b.gri", fformat="irap_binary")

    fsize = os.path.getsize("TMP/irap2_b.gri")
    logger.info(fsize)
    tsetup.assert_equal(fsize, 48900)

    # import irap ascii
    y = xtgeo.RegularSurface()
    y.from_file("TMP/irap2_a.fgr", fformat="irap_ascii")

    mean2 = y.values.mean()

    tsetup.assert_almostequal(mean1, mean2, 0.0001)
Example #3
0
def test_getwell():
    """Get a well from a RMS project."""

    print(roxv)

    if not os.path.isdir(PROJ[roxv]):
        raise RuntimeError(
            "RMS test project is missing for roxar version {}".format(roxv))

    logger.info("Simple case, reading a well from RMS well folder")

    xwell = xtgeo.well.Well()
    xwell.from_roxar(
        PROJ[roxv],
        "WI_3_RKB2",
        trajectory="Drilled trajectory",
        logrun="LOG",
        lognames=["Zonelog", "Poro", "Facies"],
    )

    logger.info("Dataframe\n %s ", xwell.dataframe)

    tsetup.assert_equal(xwell.nrow, 10081, "NROW of well")
    tsetup.assert_equal(xwell.rkb, -10, "RKB of well")

    df = xwell.dataframe

    tsetup.assert_almostequal(df.Poro.mean(), 0.191911, 0.001)

    xwell.to_file(join(TMPD, "roxwell_export.rmswell"))
Example #4
0
def test_get_zonation_holes():
    """get a report of holes in the zonation, some samples with -999"""

    mywell = Well(WFILE_HOLES, zonelogname="Zonelog")
    report = mywell.report_zonation_holes()

    logger.info("\n%s", report)

    tsetup.assert_equal(report.iat[0, 0], 4193)  # first value for INDEX
    tsetup.assert_equal(report.iat[1, 3], 1609.5800)  # second value for Z
def test_get_xy_value_lists_small():
    """Get the xy list and value list from small test case"""

    x = xtgeo.RegularSurface()  # default instance

    xylist, valuelist = x.get_xy_value_lists(valuefmt="8.3f", xyfmt="12.2f")

    logger.info(xylist[2])
    logger.info(valuelist[2])

    tsetup.assert_equal(valuelist[2], 3.0)
def test_get_xy_value_lists_reek():
    """Get the xy list and value list"""

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

    xylist, valuelist = x.get_xy_value_lists(valuefmt="8.3f", xyfmt="12.2f")

    logger.info(xylist[2])
    logger.info(valuelist[2])

    tsetup.assert_equal(valuelist[2], 1910.445)
def test_similarity():
    """Testing similarity of two surfaces. 0.0 means identical in
    terms of mean value.
    """

    logger.info("Test if surfaces are similar...")

    mfile = TESTSET1

    x = xtgeo.RegularSurface(mfile)
    y = xtgeo.RegularSurface(mfile)

    si = x.similarity_index(y)
    tsetup.assert_equal(si, 0.0)

    y.values = y.values * 2

    si = x.similarity_index(y)
    tsetup.assert_equal(si, 1.0)
Example #8
0
def test_eclgrid_import3(tmp_path):
    """Eclipse GRDECL import and translate."""
    grd = Grid(BRILGRDECL, fformat="grdecl")

    mylist = grd.get_geometrics()

    xori1 = mylist[0]

    # translate the coordinates
    grd.translate_coordinates(translate=(100, 100, 10), flip=(1, 1, 1))

    mylist = grd.get_geometrics()

    xori2 = mylist[0]

    # check if origin is translated 100m in X
    tsetup.assert_equal(xori1 + 100, xori2, txt="Translate X distance")

    grd.to_file(tmp_path / "g1_translate.roff", fformat="roff_binary")

    grd.to_file(tmp_path / "g1_translate.bgrdecl", fformat="bgrdecl")
Example #9
0
def test_get_carr(loadwell1):
    """Get a C array pointer"""

    mywell = loadwell1

    dummy = mywell.get_carray("NOSUCH")

    tsetup.assert_equal(dummy, None, "Wrong log name")

    cref = mywell.get_carray("X_UTME")

    xref = str(cref)
    swig = False
    if "Swig" in xref and "double" in xref:
        swig = True

    tsetup.assert_equal(swig, True, "carray from log name, double")

    cref = mywell.get_carray("Zonelog")

    xref = str(cref)
    swig = False
    if "Swig" in xref and "int" in xref:
        swig = True

    tsetup.assert_equal(swig, True, "carray from log name, int")
Example #10
0
def test_import_guess(load_gfile1):
    """Import with guessing fformat, and also test name attribute."""
    grd = load_gfile1

    tsetup.assert_equal(grd.ncol, 70)
    tsetup.assert_equal(grd.name, "emerald_hetero_grid")

    grd.name = "xxx"
    tsetup.assert_equal(grd.name, "xxx")
Example #11
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!")
def test_create():
    """Create default surface."""
    logger.info("Simple case...")

    x = xtgeo.RegularSurface()
    tsetup.assert_equal(x.ncol, 5, "NX")
    tsetup.assert_equal(x.nrow, 3, "NY")
    val = x.values
    xdim, _ydim = val.shape
    tsetup.assert_equal(xdim, 5, "NX from DIM")
    x.describe()
Example #13
0
def test_import(loadwell1):
    """Import well from file."""

    mywell = loadwell1

    logger.debug("True well name: %s", mywell.truewellname)
    tsetup.assert_equal(mywell.xpos, 461809.59, "XPOS")
    tsetup.assert_equal(mywell.ypos, 5932990.36, "YPOS")
    tsetup.assert_equal(mywell.wellname, "OP_1", "WNAME")

    logger.info(mywell.get_logtype("Zonelog"))
    logger.info(mywell.get_logrecord("Zonelog"))
    logger.info(mywell.lognames_all)
    logger.info(mywell.dataframe)

    # logger.info the numpy string of Poro...
    logger.info(type(mywell.dataframe["Poro"].values))
Example #14
0
def test_import(loadwell1):
    """Import well from file."""

    mywell = loadwell1

    print(mywell.dataframe)

    logger.debug("True well name:", mywell.truewellname)
    tsetup.assert_equal(mywell.xpos, 461809.6, "XPOS")
    tsetup.assert_equal(mywell.ypos, 5932990.4, "YPOS")
    tsetup.assert_equal(mywell.wellname, "OP_1", "WNAME")

    logger.info(mywell.get_logtype("Facies"))
    logger.info(mywell.get_logrecord("Facies"))

    # logger.info the numpy string of Poro...
    logger.info(type(mywell.dataframe["Poro"].values))

    dfr = mywell.dataframe
    tsetup.assert_almostequal(dfr["Poro"][4], 0.224485, 0.0001)
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 #16
0
def test_eclgrid_import2(tmp_path):
    """Eclipse EGRID import, also change ACTNUM."""
    grd = Grid()
    logger.info("Import Eclipse GRID...")
    grd.from_file(REEKFILE, fformat="egrid")

    tsetup.assert_equal(grd.ncol, 40, txt="EGrid NX from Eclipse")
    tsetup.assert_equal(grd.nrow, 64, txt="EGrid NY from Eclipse")
    tsetup.assert_equal(grd.nactive, 35838, txt="EGrid NTOTAL from Eclipse")
    tsetup.assert_equal(grd.ntotal, 35840, txt="EGrid NACTIVE from Eclipse")

    actnum = grd.get_actnum()
    print(actnum.values[12:13, 22:24, 5:6])
    tsetup.assert_equal(actnum.values[12, 22, 5], 0, txt="ACTNUM 0")

    actnum.values[:, :, :] = 1
    actnum.values[:, :, 4:6] = 0
    grd.set_actnum(actnum)
    newactive = grd.ncol * grd.nrow * grd.nlay - 2 * (grd.ncol * grd.nrow)
    tsetup.assert_equal(grd.nactive, newactive, txt="Changed ACTNUM")
    grd.to_file(tmp_path / "reek_new_actnum.roff")
Example #17
0
def test_import_wrong():
    """Importing wrong fformat, etc."""
    with pytest.raises(ValueError):
        grd = Grid()
        grd.from_file(EMEGFILE, fformat="stupid_wrong_name")
        tsetup.assert_equal(grd.ncol, 70)