Example #1
0
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),
    )
    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)
    assert_equal(fsize, 48900)

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

    mean2 = y.values.mean()

    assert_almostequal(mean1, mean2, 0.0001)
Example #2
0
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])

    assert_equal(valuelist[2], 3.0)
Example #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])

    assert_equal(valuelist[2], 1910.445)
Example #4
0
def test_similarity():
    """Check 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)
    assert_equal(si, 0.0)

    y.values = y.values * 2

    si = x.similarity_index(y)
    assert_equal(si, 1.0)
Example #5
0
def test_create():
    """Create default surface."""
    logger.info("Simple case...")

    x = xtgeo.RegularSurface()
    assert_equal(x.ncol, 5, "NX")
    assert_equal(x.nrow, 3, "NY")
    val = x.values
    xdim, _ydim = val.shape
    assert_equal(xdim, 5, "NX from DIM")
    x.describe()
Example #6
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)

    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

    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)
    assert_equal(y.ncol, 554)

    # semidirect import
    cc = xtgeo.RegularSurface().from_file(mfile)
    assert_equal(cc.ncol, 554)