Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def swfn_fromdeck(deck, ntsfun=None):
"""Extract SWFN data from a deck
Args:
deck (str or opm.common Deck)
ntsfun (int): Number of SATNUM regions in deck. Will
be inferred if not present in deck
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTSFUN", deck, ntsfun)
return common.ecl_keyworddata_to_df(
deck, "SWFN", renamer=RENAMERS["SWFN"], recordcountername="SATNUM"
)
def pvdo_fromdeck(deck, ntpvt=None):
"""Extract PVDO from a deck
Args:
deck (str or opm.common Deck)
ntpvt (int): Number of PVT regions in deck. Will
be inferred if not present in deck.
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvdg_df = common.ecl_keyworddata_to_df(
deck, "PVDO", renamer=RENAMERS["PVDO"], recordcountername="PVTNUM"
)
return pvdg_df
def swof_fromdeck(deck, ntsfun=None):
"""Extract SWOF data from a deck
Args:
deck (str or opm.common Deck)
ntsfun (int): Number of SATNUM regions in deck. Will
be inferred if not present in deck
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTSFUN", deck, ntsfun)
return common.ecl_keyworddata_to_df(
deck, "SWOF", renamer=RENAMERS["SWOF"], recordcountername="SATNUM"
)
def slgof_fromdeck(deck, ntsfun=None):
"""Extract SLGOF data from a deck
Args:
deck (str or opm.common Deck)
ntsfun (int): Number of SATNUM regions in deck. Will
be inferred if not present in deck
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTSFUN", deck, ntsfun)
return common.ecl_keyworddata_to_df(
deck, "SLGOF", renamer=RENAMERS["SLGOF"], recordcountername="SATNUM"
)
def pvto_fromdeck(deck, ntpvt=None):
"""Extract PVTO from a deck
Args:
deck (str or opm.common Deck)
ntpvt (int): Number of PVT regions in deck. Will
be inferred if not present in deck.
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
pvto_df = common.ecl_keyworddata_to_df(
deck, "PVTO", renamer=RENAMERS["PVTO"], emptyrecordcountername="PVTNUM"
)
return pvto_df
def sof3_fromdeck(deck, ntsfun=None):
"""Extract SOF3 data from a deck
Args:
deck (str or opm.common Deck)
ntsfun (int): Number of SATNUM regions in deck. Will
be inferred if not present in deck
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTSFUN", deck, ntsfun)
return common.ecl_keyworddata_to_df(
deck, "SOF3", renamer=RENAMERS["SOF3"], recordcountername="SATNUM"
)
def sgof_fromdeck(deck, ntsfun=None):
"""Extract SGOF data from a deck
Args:
deck (str or opm.common Deck)
ntsfun (int): Number of SATNUM regions in deck. Will
be inferred if not present in deck
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTSFUN", deck, ntsfun)
return common.ecl_keyworddata_to_df(
deck, "SGOF", renamer=RENAMERS["SGOF"], recordcountername="SATNUM"
)
def density_fromdeck(deck, ntpvt=None):
"""Extract DENSITY from a deck
Args:
deck (str or opm.common Deck)
ntpvt (int): Number of PVT regions in deck. Will
be inferred if not present in deck.
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
return common.ecl_keyworddata_to_df(
deck, "DENSITY", renamer=RENAMERS["DENSITY"], recordcountername="PVTNUM"
)
if "EQLDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("EQLDIMS", "NTEQUL", deck, ntequl)
phasecount = sum(["OIL" in deck, "GAS" in deck, "WATER" in deck])
phases = phases_from_deck(deck)
if not phases or phases not in RENAMERS:
raise ValueError(
"Could not determine phase configuration, got '{}'".format(phases)
)
columnrenamer = RENAMERS[phases_from_deck(deck)]
if phasecount == 1:
columnrenamer = {"DATUM_DEPTH": "DATUM", "DATUM_PRESSURE": "PRESSURE"}
if not columnrenamer:
raise ValueError("Unsupported phase configuration")
dataframe = common.ecl_keyworddata_to_df(
deck, "EQUIL", renamer=columnrenamer, recordcountername="EQLNUM"
)
# The column handling can be made prettier..
for col in dataframe.columns:
if "IGNORE" in col:
del dataframe[col]
return dataframe
def rock_fromdeck(deck, ntpvt=None):
"""Extract ROCK from a deck
Args:
deck (str or opm.common Deck)
ntpvt (int): Number of PVT regions in deck. Will
be inferred if not present in deck.
"""
if "TABDIMS" not in deck:
deck = inferdims.inject_xxxdims_ntxxx("TABDIMS", "NTPVT", deck, ntpvt)
return common.ecl_keyworddata_to_df(
deck, "ROCK", renamer=RENAMERS["ROCK"], recordcountername="PVTNUM"
)