Beispiel #1
0
def test_subvectors():
    """Test that we can ask for a few vectors only"""
    eclfiles = EclFiles(EIGHTCELLS)
    init_df = grid.init2df(eclfiles, "PORO")
    assert "PORO" in init_df
    assert "PERMX" not in init_df
    assert "PORV" not in init_df

    init_df = grid.init2df(eclfiles, "P*")
    assert "PORO" in init_df
    assert "PERMX" in init_df
    assert "PVTNUM" in init_df
    assert "SATNUM" not in init_df

    init_df = grid.init2df(eclfiles, ["P*"])
    assert "PORO" in init_df
    assert "PERMX" in init_df
    assert "PVTNUM" in init_df
    assert "SATNUM" not in init_df

    init_df = grid.init2df(eclfiles, ["P*", "*NUM"])
    assert "PORO" in init_df
    assert "PERMX" in init_df
    assert "PVTNUM" in init_df
    assert "SATNUM" in init_df
    assert "MULTZ" not in init_df
Beispiel #2
0
def test_wrongfile():
    """Test the EclFiles object on nonexistent files"""
    # pylint: disable=invalid-name,redefined-builtin

    # We can initalize this object with bogus:
    eclfiles = EclFiles("FOO.DATA")
    # but when we try to use it, things should fail:
    with pytest.raises(FileNotFoundError):
        grid.init2df(eclfiles)
Beispiel #3
0
def test_wrongfile():
    try:
        FileNotFoundError
    except NameError:
        FileNotFoundError = IOError

    # We can initalize this object with bogus:
    eclfiles = EclFiles("FOO.DATA")
    # but when we try to use it, things should fail:
    with pytest.raises(FileNotFoundError):
        grid.init2df(eclfiles)
Beispiel #4
0
def test_init2df():
    """Test that dataframe with INIT vectors can be produced"""
    eclfiles = EclFiles(DATAFILE)
    init_df = grid.init2df(eclfiles)

    assert isinstance(init_df, pd.DataFrame)
    assert not init_df.empty
    assert "PERMX" in init_df
    assert "PORO" in init_df
    assert "PORV" in init_df
Beispiel #5
0
def test_mergegridframes():
    """Test that we can merge together data for the grid"""
    eclfiles = EclFiles(DATAFILE)
    init_df = grid.init2df(eclfiles)
    grid_geom = grid.gridgeometry2df(eclfiles)

    assert len(init_df) == len(grid_geom)

    merged = grid.merge_gridframes(grid_geom, init_df, pd.DataFrame())
    assert isinstance(merged, pd.DataFrame)
    assert len(merged) == len(grid_geom)

    # Check that PORV is sensible
    assert (abs(sum(merged["PORO"] * merged["VOLUME"] - merged["PORV"])) /
            sum(merged["PORV"]) < 0.00001)
Beispiel #6
0
def test_init2df():
    """Test that dataframe with INIT vectors can be produced"""
    eclfiles = EclFiles(REEK)
    init_df = grid.init2df(eclfiles)

    assert isinstance(init_df, pd.DataFrame)
    assert not init_df.empty
    assert "PERMX" in init_df
    assert "PORO" in init_df
    assert "PORV" in init_df

    # The KRO data from the INIT file in Reek contains only NaN's,
    # but libecl gives out a large negative integer/float.
    # ecl2df should ensure this comes out as a NaN (but it
    # should be allowed later to drop columns which have only NaNs))
    if "KRO" in init_df:
        assert np.isnan(init_df["KRO"].unique()).all()