Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
2000 200 2200 /
"""
deck = EclFiles.str2deck(deckstr)
df = equil2df.deck2df(deck)
assert df["OWC"].values == 2200
assert len(df) == 1
assert "IGNORE1" not in df
deckstr = """
GAS
WATER
EQUIL
2000 200 2200 /
"""
deck = EclFiles.str2deck(deckstr)
df = equil2df.deck2df(deck)
assert df["GWC"].values == 2200
assert "OWC" not in df
assert len(df) == 1
assert "IGNORE2" not in df
deckstr = """
GAS
OIL
EQUIL
2000 200 2200 1 2100 3 /
"""
deck = EclFiles.str2deck(deckstr)
df = equil2df.deck2df(deck)
assert df["GOC"].values == 2100
def test_rock():
"""Test parsing of the ROCK keyword from a string"""
deck = """ROCK
100 1.1 /"""
rock_df = pvt.rock_fromdeck(EclFiles.str2deck(deck))
assert len(rock_df) == 1
assert "PRESSURE" in rock_df
assert "COMPRESSIBILITY" in rock_df
dframe_via_string = pvt.rock_fromdeck(pvt.df2ecl_rock(rock_df))
pd.testing.assert_frame_equal(dframe_via_string, rock_df)
# Test emtpy data:
inc = pvt.df2ecl_rock(pvt.df(""))
assert "No data" in inc
assert pvt.df(inc).empty
def test_str2df():
"""Test dataframe extraction from strings"""
wconstr = """
WCONHIST
'FOO' 0 1 /
/
"""
deck = EclFiles.str2deck(wconstr)
wcondf = wcon.deck2df(deck)
assert len(wcondf) == 1
wconstr = """
WCONINJH
'FOO' 0 1 /
/
"""
deck = EclFiles.str2deck(wconstr)
wcondf = wcon.deck2df(deck)
assert len(wcondf) == 1
wconstr = """
WCONINJE
'FOO' 0 1 /
/
density_df = pvt.density_fromdeck(eclfiles.get_ecldeck())
assert len(density_df) == 1
assert "PVTNUM" in density_df
assert "OILDENSITY" in density_df
assert "WATERDENSITY" in density_df
assert "GASDENSITY" in density_df
dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df))
pd.testing.assert_frame_equal(dframe_via_string, density_df)
two_pvtnum_deck = """DENSITY
860 999.04 1.1427 /
800 950 1.05
/
"""
density_df = pvt.density_fromdeck(EclFiles.str2deck(two_pvtnum_deck))
# (a warning will be printed that we cannot guess)
assert len(density_df) == 1
density_df = pvt.density_fromdeck(two_pvtnum_deck)
assert "PVTNUM" in density_df
assert density_df["PVTNUM"].max() == 2
assert density_df["PVTNUM"].min() == 1
assert "OILDENSITY" in density_df
dframe_via_string = pvt.density_fromdeck(pvt.df2ecl_density(density_df))
pd.testing.assert_frame_equal(dframe_via_string, density_df)
# Test emtpy data:
inc = pvt.df2ecl_density(pvt.df(""))
assert "No data" in inc
assert pvt.df(inc).empty
GRUPTREE
'OPWEST' 'OP' /
'OP' 'FIELD' /
'FIELD' 'AREA' /
'AREA' 'NORTHSEA' /
/
TSTEP
1 /
WELSPECS
'OP1' 'OPWEST' 41 125 1759.74 'OIL' 0.0 'STD' 'SHUT' 'YES' 0 'SEG' /
/
"""
deck = EclFiles.str2deck(schstr)
grupdf = gruptree.df(deck)
assert len(grupdf["DATE"].unique()) == 2
print(grupdf)
"""
deck = EclFiles.str2deck(deckstr)
df = equil2df.deck2df(deck)
assert df["GWC"].values == 2200
assert "OWC" not in df
assert len(df) == 1
assert "IGNORE2" not in df
deckstr = """
GAS
OIL
EQUIL
2000 200 2200 1 2100 3 /
"""
deck = EclFiles.str2deck(deckstr)
df = equil2df.deck2df(deck)
assert df["GOC"].values == 2100
assert "GWC" not in df
assert "OWC" not in df
assert len(df) == 1
assert "IGNORE2" not in df
wconstr = """
WCONINJE
'FOO' 0 1 /
/
"""
deck = EclFiles.str2deck(wconstr)
wcondf = wcon.deck2df(deck)
assert len(wcondf) == 1
wconstr = """
WCONPROD
'FOO' 0 1 /
/
"""
deck = EclFiles.str2deck(wconstr)
wcondf = wcon.deck2df(deck)
assert len(wcondf) == 1
def test_str2df():
deckstr = """
FAULTS
'A' 1 2 3 4 5 6 'I' /
'B' 2 3 4 5 6 7 'J' /
/
"""
deck = EclFiles.str2deck(deckstr)
faultsdf = faults.df(deck)
assert len(faultsdf) == 16
def test_multiplestr2df():
"""Test that we support multiple occurences of the FAULTS keyword"""
deckstr = """
FAULTS
'A' 1 2 3 4 5 6 'I' /
'B' 2 3 4 5 6 7 'J' /
/
FAULTS
'C' 1 1 3 3 10 15 'I' /
'D' 2 2 4 4 10 10 'J' /
/
"""
deck = EclFiles.str2deck(deckstr)
faultsdf = faults.df(deck).set_index("NAME")
assert len(faultsdf) == 23
assert len(faultsdf.loc[["D"]]) == 1 # Pass lists to .loc for single row
assert len(faultsdf.loc["C"]) == 6
# Provide TABDIMS in first test.. Infer later
pvto_deck = """TABDIMS
1 2 /
PVTO
0 1 1.0001 1
200 1.000 1.001 /
18 25 1.14 0.59 /
/
1 2 1.0001 1
333 1.000 1.001 /
19 30 1.14 0.59 /
/
"""
dframe = pvt.pvto_fromdeck(EclFiles.str2deck(pvto_deck))
assert len(dframe) == 6
assert "PVTNUM" in dframe
assert set(dframe["PVTNUM"].astype(int).unique()) == {1, 2}
assert len(dframe["RS"].unique()) == 4
assert len(dframe["PRESSURE"].unique()) == 6
assert len(dframe["VOLUMEFACTOR"].unique()) == 3
dframe_via_string = pvt.pvto_fromdeck(pvt.df2ecl_pvto(dframe))
pd.testing.assert_frame_equal(dframe_via_string, dframe)
# Now test the same but without TABDIMS:
pvto_deck = """
PVTO
0 1 1.0001 1
200 1.000 1.001 /
18 25 1.14 0.59 /