How to use the ecl2df.satfunc.df function in ecl2df

To help you get started, we’ve selected a few ecl2df examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github equinor / ecl2df / tests / test_satfunc.py View on Github external
def test_sof3():
    """Test parsing of SOF3"""
    string = """
SOF3
  0 1 1
  1 0 0
/
"""
    sof3_df = satfunc.df(string)
    assert len(sof3_df) == 2
    assert "SO" in sof3_df
    assert "KROW" in sof3_df
    assert "KROG" in sof3_df
    inc = satfunc.df2ecl(sof3_df)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(sof3_df, df_from_inc)
github equinor / ecl2df / tests / test_satfunc.py View on Github external
def test_slgof(tmpdir):
    """Test parsing of SLGOF"""
    tmpdir.chdir()
    string = """
SLGOF
  0 1 1 0
  1 0 0 0
/
"""
    slgof_df = satfunc.df(string)
    assert len(slgof_df) == 2
    assert "SL" in slgof_df
    assert "KRG" in slgof_df
    assert "KRO" in slgof_df
    assert "PCOG" in slgof_df
    inc = satfunc.df2ecl(slgof_df, filename="slgof.inc")
    assert os.path.exists("slgof.inc")
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(slgof_df, df_from_inc)
github equinor / ecl2df / tests / test_satfunc.py View on Github external
def test_sof2():
    """Test parsing of SOF2"""
    string = """
SOF2
  0 1
  1 0
/
"""
    sof2_df = satfunc.df(string)
    assert len(sof2_df) == 2
    assert "SO" in sof2_df
    assert "KRO" in sof2_df
    inc = satfunc.df2ecl(sof2_df)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(sof2_df, df_from_inc)
github equinor / ecl2df / tests / test_satfunc.py View on Github external
SWOF
 0 0 1 1
 1 1 0 0
/
 0 0 1 1
 0.5 0.5 0.5 0.5
 1 1 0 0
/
"""
    satdf2 = satfunc.df(swofstr2)
    assert "SATNUM" in satdf
    assert len(satdf2["SATNUM"].unique()) == 2
    assert len(satdf2) == 5

    inc = satfunc.df2ecl(satdf)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(satdf, df_from_inc)

    # Try empty/bogus data:
    bogusdf = satfunc.deck2df("SWRF\n 0 /\n")
    # (warnings should be issued)
    assert bogusdf.empty

    # Test with bogus E100 keywords:
    tricky = satfunc.deck2df("FOO\n\nSWOF\n 0 0 0 1/ 1 1 1 0\n/\n")
    assert not tricky.empty
    assert len(tricky["SATNUM"].unique()) == 1
github equinor / ecl2df / tests / test_satfunc.py View on Github external
tmpdir.chdir()
    string = """
SLGOF
  0 1 1 0
  1 0 0 0
/
"""
    slgof_df = satfunc.df(string)
    assert len(slgof_df) == 2
    assert "SL" in slgof_df
    assert "KRG" in slgof_df
    assert "KRO" in slgof_df
    assert "PCOG" in slgof_df
    inc = satfunc.df2ecl(slgof_df, filename="slgof.inc")
    assert os.path.exists("slgof.inc")
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(slgof_df, df_from_inc)
github equinor / ecl2df / tests / test_satfunc.py View on Github external
def test_str2df():
    """Test parsing of a direct string"""
    swofstr = """
SWOF
 0 0 1 1
 1 1 0 0
 /
"""
    satdf = satfunc.df(swofstr)
    assert len(satdf) == 2
    inc = satfunc.df2ecl_swof(satdf)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(satdf, df_from_inc)

    swofstr2 = """
-- RUNSPEC -- (this line is optional)

TABDIMS
  2 /

-- PROPS -- (optional)

SWOF
 0 0 1 1
 1 1 0 0
github equinor / ecl2df / tests / test_satfunc.py View on Github external
assert not satdf.empty
    assert "KEYWORD" in satdf  # for all data
    assert "SATNUM" in satdf  # for all data

    assert "SWOF" in satdf["KEYWORD"].unique()
    assert "SGOF" in satdf["KEYWORD"].unique()
    assert "SW" in satdf
    assert "KRW" in satdf
    assert "KROW" in satdf
    assert "SG" in satdf
    assert "KROG" in satdf
    assert satdf["SATNUM"].unique() == [1]

    inc = satfunc.df2ecl(satdf)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(
        satdf.sort_values(["SATNUM", "KEYWORD"]),
        df_from_inc.sort_values(["SATNUM", "KEYWORD"]),
    )
github equinor / ecl2df / tests / test_satfunc.py View on Github external
TABDIMS
  2 /

-- PROPS -- (optional)

SWOF
 0 0 1 1
 1 1 0 0
/
 0 0 1 1
 0.5 0.5 0.5 0.5
 1 1 0 0
/
"""
    satdf2 = satfunc.df(swofstr2)
    assert "SATNUM" in satdf
    assert len(satdf2["SATNUM"].unique()) == 2
    assert len(satdf2) == 5

    inc = satfunc.df2ecl(satdf)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(satdf, df_from_inc)

    # Try empty/bogus data:
    bogusdf = satfunc.deck2df("SWRF\n 0 /\n")
    # (warnings should be issued)
    assert bogusdf.empty

    # Test with bogus E100 keywords:
    tricky = satfunc.deck2df("FOO\n\nSWOF\n 0 0 0 1/ 1 1 1 0\n/\n")
    assert not tricky.empty
github equinor / ecl2df / tests / test_satfunc.py View on Github external
0.5 0.5 0.5 0.5
  1 1 0 0
/
  0 0 1 0
  0.1 0.1 0.1 0.1
  1 1 0 0
/
"""
    tmpdir.chdir()
    assert inferdims.guess_dim(sgofstr, "TABDIMS", 0) == 3
    sgofdf = satfunc.df(sgofstr)
    assert "SATNUM" in sgofdf
    assert len(sgofdf["SATNUM"].unique()) == 3
    assert len(sgofdf) == 8
    inc = satfunc.df2ecl(sgofdf)
    df_from_inc = satfunc.df(inc)
    pd.testing.assert_frame_equal(sgofdf, df_from_inc)

    # Write to file and try to parse it with command line:
    sgoffile = "__sgof_tmp.txt"
    with open(sgoffile, "w") as sgof_f:
        sgof_f.write(sgofstr)

    sys.argv = ["ecl2csv", "satfunc", "-v", sgoffile, "-o", sgoffile + ".csv"]
    ecl2csv.main()
    parsed_sgof = pd.read_csv(sgoffile + ".csv")
    assert len(parsed_sgof["SATNUM"].unique()) == 3
github equinor / ecl2df / tests / test_satfunc.py View on Github external
sys.argv = ["satfunc2csv", DATAFILE, "-o", tmpcsvfile]
    satfunc.main()

    assert os.path.exists(tmpcsvfile)
    disk_df = pd.read_csv(tmpcsvfile)
    assert not disk_df.empty

    # Write back to include file:
    incfile = str(tmpdir.join("relperm.inc"))
    sys.argv = ["csv2ecl", "satfunc", "-v", tmpcsvfile, "-o", incfile]
    csv2ecl.main()

    # Reparse the include file on disk back to dataframe
    # and check dataframe equality
    assert os.path.exists(incfile)
    disk_inc_df = satfunc.df(open(incfile).read())
    pd.testing.assert_frame_equal(
        disk_df.sort_values(["SATNUM", "KEYWORD"]).reset_index(drop=True),
        disk_inc_df.sort_values(["SATNUM", "KEYWORD"]).reset_index(drop=True),
    )