def test_slice_trilinear_nosnapxy(tmpdir, load_cube_rsgy1): """Slice a cube with a surface, nearest node, algorithm 1 + 2, other map layout""" kube = load_cube_rsgy1 # kube.swapaxes() xs1 = xtgeo.RegularSurface( yori=5927600, xori=457000, xinc=50, yinc=50, ncol=200, nrow=220, values=1670 ) xs2 = xs1.copy() t1 = xtg.timer() xs1.slice_cube(kube, algorithm=1, snapxy=False, sampling="trilinear") logger.info("Slicing alg 1...done in {} seconds".format(xtg.timer(t1))) t1 = xtg.timer() xs2.slice_cube(kube, algorithm=2, snapxy=False, sampling="trilinear") logger.info("Slicing alg 2...done in {} seconds".format(xtg.timer(t1))) xs1.quickplot( filename=join(tmpdir, "surf_slice_cube_tri_nosnapxy_v1.png"), colortable="seismic", minmax=(-1, 1), title="Reek", infotext="Method: trilinear, nosnapxy, algorithm 1", ) xs2.quickplot( filename=join(tmpdir, "surf_slice_cube_tri_nosnapxy_v2.png"), colortable="seismic", minmax=(-1, 1), title="Reek", infotext="Method: trilinear, nosnapxy, algorithm 2", ) logger.info("%s vs %s", xs1.values.mean(), xs2.values.mean()) tsetup.assert_almostequal(xs1.values.mean(), xs2.values.mean(), 0.0001)
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)
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()
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"))
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)
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)
def test_slice_attr_window_max(load_cube_rsgy1): """Slice a cube within a window, get max, using trilinear interpol.""" logger.info("Loading surface") xs1 = RegularSurface(RTOP1) logger.info("Loading cube") kube = load_cube_rsgy1 ret = xs1.slice_cube_window( kube, attribute="max", sampling="trilinear", algorithm=2 ) logger.info(xs1.values.mean()) assert ret is None tsetup.assert_almostequal(xs1.values.mean(), 0.08619, 0.001) # one attribute but in a list context shall return a dict xs1 = RegularSurface(RTOP1) ret = xs1.slice_cube_window( kube, attribute=["max"], sampling="trilinear", algorithm=2 ) assert isinstance(ret, dict) tsetup.assert_almostequal(ret["max"].values.mean(), 0.08619, 0.001)
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_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)
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)
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)
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)
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")
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)
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)
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)
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.with_suffix(".EGRID")) grd._dualactnum.to_file("TMP/dualact.roff") sgas = xtgeo.gridproperty_from_file( DUALFILE2.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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_create_shoebox(tmp_path): """Make a shoebox grid from scratch.""" grd = xtgeo.Grid() grd.create_box() grd.to_file(tmp_path / "shoebox_default.roff") grd.create_box(flip=-1) grd.to_file(tmp_path / "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)
def test_import_dualperm_grid_sgas(): """Test grid with flag for dual perm/poro setup gas/water""" grd = xtgeo.grid_from_file(DUALFILE3.with_suffix(".EGRID")) sgas = xtgeo.gridproperty_from_file( DUALFILE3.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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
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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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")
def test_import_dualporo_grid(): """Test grid with flag for dual porosity setup, oil water""" grd = xtgeo.grid_from_file(DUALFILE1.with_suffix(".EGRID")) assert grd.dualporo is True assert grd.dualperm is False assert grd.dimensions == (5, 3, 1) poro = xtgeo.gridproperty_from_file(DUALFILE1.with_suffix(".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.with_suffix(".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.with_suffix(".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.with_suffix(".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")