示例#1
0
def test_to_from_roffgrid(roff_grid):
    xtggrid = Grid()
    xtggrid._actnumsv = roff_grid.xtgeo_actnum()
    xtggrid._coordsv = roff_grid.xtgeo_coord()
    xtggrid._zcornsv = roff_grid.xtgeo_zcorn()
    xtggrid._subgrids = roff_grid.xtgeo_subgrids()
    xtggrid._ncol = roff_grid.nx
    xtggrid._nrow = roff_grid.ny
    xtggrid._nlay = roff_grid.nz

    roffgrid2 = RoffGrid.from_xtgeo_grid(xtggrid)
    assert same_geometry(roffgrid2, roff_grid)
    assert np.array_equal(roffgrid2.subgrids, roff_grid.subgrids)
示例#2
0
def test_to_from_grdeclgrid(grdecl_grid):
    xtggrid = Grid()
    xtggrid._actnumsv = grdecl_grid.xtgeo_actnum()
    xtggrid._coordsv = grdecl_grid.xtgeo_coord()
    xtggrid._zcornsv = grdecl_grid.xtgeo_zcorn()
    nx, ny, nz = grdecl_grid.dimensions
    xtggrid._ncol = nx
    xtggrid._nrow = ny
    xtggrid._nlay = nz
    xtggrid._xtgformat = 2

    grdecl_grid2 = ggrid.GrdeclGrid.from_xtgeo_grid(xtggrid)
    assert grdecl_grid2.xtgeo_actnum().tolist() == xtggrid._actnumsv.tolist()
    assert grdecl_grid2.xtgeo_coord() == pytest.approx(xtggrid._coordsv,
                                                       abs=0.02)
    assert grdecl_grid2.xtgeo_zcorn() == pytest.approx(xtggrid._zcornsv,
                                                       abs=0.02)
示例#3
0
def test_to_from_xtggrid_write(tmp_path, grdecl_grid):
    xtggrid = Grid()
    xtggrid._actnumsv = grdecl_grid.xtgeo_actnum()
    xtggrid._coordsv = grdecl_grid.xtgeo_coord()
    xtggrid._zcornsv = grdecl_grid.xtgeo_zcorn()
    nx, ny, nz = grdecl_grid.dimensions
    xtggrid._ncol = nx
    xtggrid._nrow = ny
    xtggrid._nlay = nz
    xtggrid._xtgformat = 2

    xtggrid.to_file(tmp_path / "xtggrid.grdecl", fformat="grdecl")
    grdecl_grid2 = ggrid.GrdeclGrid.from_file(tmp_path / "xtggrid.grdecl")

    assert grdecl_grid.zcorn == pytest.approx(grdecl_grid2.zcorn, abs=0.02)
    assert grdecl_grid.xtgeo_coord() == pytest.approx(
        grdecl_grid2.xtgeo_coord(), abs=0.02)
    if grdecl_grid.actnum is None:
        assert grdecl_grid2.actnum is None or np.all(grdecl_grid2.actnum)
    else:
        assert grdecl_grid.actnum.tolist() == grdecl_grid2.actnum.tolist()