Exemple #1
0
def test_crop_grid_after_copy():
    """Copy a grid, then crop and check number of active cells."""

    logger.info("Read grid...")

    grd = Grid(EMEGFILE2)
    grd.describe()
    zprop = GridProperty(EMEZFILE2, name="Zone", grid=grd)
    grd.describe(details=True)

    logger.info(grd.dimensions)

    grd2 = grd.copy()
    grd2.describe(details=True)

    logger.info("GRD2 props: %s", grd2.props)
    assert grd.propnames == grd2.propnames

    logger.info("GRD2 number of active cells: %s", grd2.nactive)
    act = grd.get_actnum()
    logger.info(act.values.shape)
    logger.info("ZPROP: %s", zprop.values.shape)

    grd2.crop((1, 30), (40, 80), (23, 46))

    grd2.describe(details=True)
Exemple #2
0
def test_get_adjacent_cells(tmp_path):
    """Get the cell indices for discrete value X vs Y, if connected."""
    grid = Grid(EMEGFILE)
    actnum = grid.get_actnum()
    actnum.to_file(tmp_path / "emerald_actnum.roff")
    result = grid.get_adjacent_cells(actnum, 0, 1, activeonly=False)
    result.to_file(tmp_path / "emerald_adj_cells.roff")
def test_avg02():
    """Make average map from Reek Eclipse."""
    grd = Grid()
    grd.from_file(GFILE2, fformat="egrid")

    # get the poro
    po = GridProperty()
    po.from_file(IFILE2, fformat="init", name="PORO", grid=grd)

    # get the dz and the coordinates
    dz = grd.get_dz(mask=False)
    xc, yc, _zc = grd.get_xyz(mask=False)

    # get actnum
    actnum = grd.get_actnum()

    # convert from masked numpy to ordinary
    xcuse = np.copy(xc.values3d)
    ycuse = np.copy(yc.values3d)
    dzuse = np.copy(dz.values3d)
    pouse = np.copy(po.values3d)

    # dz must be zero for undef cells
    dzuse[actnum.values3d < 0.5] = 0.0
    pouse[actnum.values3d < 0.5] = 0.0

    # make a map... estimate from xc and yc
    zuse = np.ones((xcuse.shape))

    avgmap = RegularSurface(
        nx=200,
        ny=250,
        xinc=50,
        yinc=50,
        xori=457000,
        yori=5927000,
        values=np.zeros((200, 250)),
    )

    avgmap.avg_from_3dprop(
        xprop=xcuse,
        yprop=ycuse,
        zoneprop=zuse,
        zone_minmax=(1, 1),
        mprop=pouse,
        dzprop=dzuse,
        truncate_le=None,
    )

    # add the faults in plot
    fau = Polygons(FFILE1, fformat="zmap")
    fspec = {"faults": fau}

    avgmap.quickplot(filename="TMP/tmp_poro2.png",
                     xlabelrotation=30,
                     faults=fspec)
    avgmap.to_file("TMP/tmp.poro.gri", fformat="irap_ascii")

    logger.info(avgmap.values.mean())
    assert avgmap.values.mean() == pytest.approx(0.1653, abs=0.01)
def test_avg03():
    """Make average map from Reek Eclipse, speed up by zone_avg."""
    g = Grid()
    g.from_file(gfile2, fformat="egrid")

    # get the poro
    po = GridProperty()
    po.from_file(ifile2, fformat='init', name='PORO', grid=g)

    # get the dz and the coordinates
    dz = g.get_dz(mask=False)
    xc, yc, zc = g.get_xyz(mask=False)

    # get actnum
    actnum = g.get_actnum()
    actnum = actnum.get_npvalues3d()

    # convert from masked numpy to ordinary
    xcuse = xc.get_npvalues3d()
    ycuse = yc.get_npvalues3d()
    dzuse = dz.get_npvalues3d(fill_value=0.0)
    pouse = po.get_npvalues3d(fill_value=0.0)

    # dz must be zero for undef cells
    dzuse[actnum < 0.5] = 0.0
    pouse[actnum < 0.5] = 0.0

    # make a map... estimate from xc and yc
    zuse = np.ones((xcuse.shape))

    avgmap = RegularSurface(nx=200, ny=250, xinc=50, yinc=50,
                            xori=457000, yori=5927000,
                            values=np.zeros((200, 250)))

    avgmap.avg_from_3dprop(xprop=xcuse, yprop=ycuse, zoneprop=zuse,
                           zone_minmax=(1, 1),
                           mprop=pouse, dzprop=dzuse,
                           truncate_le=None, zone_avg=True)

    # add the faults in plot
    fau = Polygons(ffile1, fformat='zmap')
    fspec = {'faults': fau}

    avgmap.quickplot(filename='TMP/tmp_poro3.png', xlabelrotation=30,
                     faults=fspec)
    avgmap.to_file('TMP/tmp.poro3.gri', fformat='irap_ascii')

    logger.info(avgmap.values.mean())
    assert avgmap.values.mean() == pytest.approx(0.1653, abs=0.01)
Exemple #5
0
def test_eclgrid_import2():
    """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(join(TMPDIR, "reek_new_actnum.roff"))