Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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(
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
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
)
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)
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"
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(
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()
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"
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)
"""Get statistics for one realisation, poro/perm filtered on facies.
But note that values here are unweighted as total volume is not present.
"""
# read grid
grd = xtgeo.grid_from_file(GRIDFILE)
# read facies (to be used as filter)
facies = xtgeo.gridproperty_from_file(FACIESFILE, name=FACIES, grid=grd)
print("Facies codes are: {}".format(facies.codes))
for propname in PROPS:
pfile = ojn(EXPATH1, ROOT + "--" + propname + EXT)
pname = "geogrid--" + propname
prop = xtgeo.gridproperty_from_file(pfile, name=pname, grid=grd)
print("Working with {}".format(prop.name))
# now find statistics for each facies, and all facies
for key, fname in facies.codes.items():
avg = prop.values[facies.values == key].mean()
std = prop.values[facies.values == key].std()
print(
"For property {} in facies {}, avg is {:10.3f} and "
"stddev is {:9.3f}".format(propname, fname, avg, std)
)
avg = prop.values.mean()
std = prop.values.std()
print(
"For property {} in ALL facies, avg is {:10.3f} and "
"stddev is {:9.3f}".format(propname, avg, std)