Skip to content

Commit

Permalink
ecl_str -> deck_str
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen committed Nov 15, 2023
1 parent 122a111 commit cd31c43
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 84 deletions.
12 changes: 6 additions & 6 deletions res2df/vfp/_vfpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ def _write_vfp_range(
if var_type != "UNDEFINED":
var_type_str = var_type

ecl_str = f"-- {var_type_str} units - {unit_type} ( {len(values)} values )\n"
deck_str = f"-- {var_type_str} units - {unit_type} ( {len(values)} values )\n"
for i, value in enumerate(values):
ecl_str += format % value
deck_str += format % value
if (i + 1) % values_per_line == 0 and i < len(values) - 1:
ecl_str += "\n"
ecl_str += " /\n"
ecl_str += "\n"
deck_str += "\n"
deck_str += " /\n"
deck_str += "\n"

return ecl_str
return deck_str
70 changes: 35 additions & 35 deletions res2df/vfp/_vfpinj.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ def _write_basic_record(
if unit_type != "DEFAULT":
unit_type_str = unit_type

ecl_str = "-- Table Datum Depth Rate Type THP Type UNITS TAB Type\n"
ecl_str += "-- ----- ----------- --------- -------- -------- --------\n"
ecl_str += f" {tableno:5d}"
ecl_str += f" {datum:11.1f}"
ecl_str += f" {flo_type:>9s}"
ecl_str += f" {pressure_type:>8s}"
ecl_str += f" {unit_type_str:>8s}"
ecl_str += f" {tab_type:>8s} /\n\n"
return ecl_str
deck_str = "-- Table Datum Depth Rate Type THP Type UNITS TAB Type\n"
deck_str += "-- ----- ----------- --------- -------- -------- --------\n"
deck_str += f" {tableno:5d}"
deck_str += f" {datum:11.1f}"
deck_str += f" {flo_type:>9s}"
deck_str += f" {pressure_type:>8s}"
deck_str += f" {unit_type_str:>8s}"
deck_str += f" {tab_type:>8s} /\n\n"
return deck_str


def _write_table(
Expand All @@ -589,23 +589,23 @@ def _write_table(
values_per_line: Number of values per line in output
"""

ecl_str = ""
deck_str = ""
for idx, row in table.iterrows():
ecl_str += f"{idx:2d}"
deck_str += f"{idx:2d}"
no_flo = len(table.loc[idx].to_list())
for n, value in enumerate(table.loc[idx].to_list()):
ecl_str += format % value
deck_str += format % value
if (n + 1) % values_per_line == 0:
if n < no_flo - 1:
ecl_str += "\n"
ecl_str += " " * 2
deck_str += "\n"
deck_str += " " * 2
else:
ecl_str += "\n"
deck_str += "\n"
elif n == no_flo - 1:
ecl_str += "\n"
ecl_str += "/\n"
deck_str += "\n"
deck_str += "/\n"

return ecl_str
return deck_str


def _write_table_records(
Expand All @@ -624,7 +624,7 @@ def _write_table_records(
values_per_line: Number of values per line in output
"""

ecl_str = ""
deck_str = ""
no_records = len(thp_indices)
no_flow_values = table.size // no_records
if table.size % no_records > 0:
Expand All @@ -634,21 +634,21 @@ def _write_table_records(

for row in range(0, no_records):
thp = thp_indices[row]
ecl_str += f"{thp:2d}"
deck_str += f"{thp:2d}"
for n, value in enumerate(table[row, :]):
ecl_str += format % value
deck_str += format % value
if (n + 1) % values_per_line == 0:
if n < no_flow_values - 1:
ecl_str += "\n"
ecl_str += " " * 2
deck_str += "\n"
deck_str += " " * 2
else:
ecl_str += "\n"
deck_str += "\n"
elif n == no_flow_values - 1:
ecl_str += "\n"
deck_str += "\n"

ecl_str += "/\n"
deck_str += "/\n"

return ecl_str
return deck_str


def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
Expand All @@ -670,39 +670,39 @@ def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
unit_type = vfpinj_data["UNIT_TYPE"]

# Write dataframe to string with Eclipse format for VFPINJ
ecl_str = "VFPINJ\n"
deck_str = "VFPINJ\n"
if comment:
ecl_str += common.comment_formatter(comment)
deck_str += common.comment_formatter(comment)
else:
ecl_str += "\n"
deck_str += "\n"

unit_value = vfpinj_data["UNIT_TYPE"].value
if vfpinj_data["UNIT_TYPE"] == UNITTYPE.DEFAULT:
unit_value = "1*"
ecl_str += _write_basic_record(
deck_str += _write_basic_record(
vfpinj_data["TABLE_NUMBER"],
vfpinj_data["DATUM"],
vfpinj_data["RATE_TYPE"].value,
vfpinj_data["THP_TYPE"].value,
unit_value,
vfpinj_data["TAB_TYPE"].value,
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpinj_data["FLOW_VALUES"],
rate_type.value,
VFPINJ_UNITS[unit_type.value]["FLO"][rate_type.value],
"%10.6g",
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpinj_data["THP_VALUES"],
thp_type.value,
VFPINJ_UNITS[unit_type.value]["THP"][thp_type.value],
"%10.6g",
)
ecl_str += _write_table_records(
deck_str += _write_table_records(
vfpinj_data["THP_INDICES"],
vfpinj_data["BHP_TABLE"],
"%10.6g",
)

return ecl_str
return deck_str
86 changes: 43 additions & 43 deletions res2df/vfp/_vfpprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,20 +834,20 @@ def _write_basic_record(
if alq_type != "UNDEFINED":
alq_type_str = alq_type

ecl_str = "-- Table Datum Depth Rate Type WFR Type "
ecl_str += "GFR Type THP Type ALQ Type UNITS TAB Type\n"
ecl_str += "-- ----- ----------- --------- -------- "
ecl_str += "-------- -------- -------- ------ --------\n"
ecl_str += f" {tableno:5d}"
ecl_str += f" {datum:11.1f}"
ecl_str += f" {flo_type:>8s}"
ecl_str += f" {wfr_type:>8s}"
ecl_str += f" {gfr_type:>8s}"
ecl_str += f" {pressure_type:>8s}"
ecl_str += f" {alq_type_str:>8s}"
ecl_str += f" {unit_type:>6s}"
ecl_str += f" {tab_type:>8s} /\n\n"
return ecl_str
deck_str = "-- Table Datum Depth Rate Type WFR Type "
deck_str += "GFR Type THP Type ALQ Type UNITS TAB Type\n"
deck_str += "-- ----- ----------- --------- -------- "
deck_str += "-------- -------- -------- ------ --------\n"
deck_str += f" {tableno:5d}"
deck_str += f" {datum:11.1f}"
deck_str += f" {flo_type:>8s}"
deck_str += f" {wfr_type:>8s}"
deck_str += f" {gfr_type:>8s}"
deck_str += f" {pressure_type:>8s}"
deck_str += f" {alq_type_str:>8s}"
deck_str += f" {unit_type:>6s}"
deck_str += f" {tab_type:>8s} /\n\n"
return deck_str


def _write_table(
Expand All @@ -864,23 +864,23 @@ def _write_table(
values_per_line: Number of values per line in output
"""

ecl_str = ""
deck_str = ""
for idx, row in table.iterrows():
ecl_str += f"{idx[0]:2d} {idx[1]:2d} {idx[2]:2d} {idx[3]:2d}"
deck_str += f"{idx[0]:2d} {idx[1]:2d} {idx[2]:2d} {idx[3]:2d}"
no_flo = len(table.loc[idx].to_list())
for n, value in enumerate(table.loc[idx].to_list()):
ecl_str += format % value
deck_str += format % value
if (n + 1) % values_per_line == 0:
if n < no_flo - 1:
ecl_str += "\n"
ecl_str += " " * 11
deck_str += "\n"
deck_str += " " * 11
else:
ecl_str += "\n"
deck_str += "\n"
elif n == no_flo - 1:
ecl_str += "\n"
ecl_str += "/\n"
deck_str += "\n"
deck_str += "/\n"

return ecl_str
return deck_str


def _write_table_records(
Expand All @@ -905,7 +905,7 @@ def _write_table_records(
values_per_line: Number of values per line in output
"""

ecl_str = ""
deck_str = ""
no_records = len(thp_indices)
no_flow_values = table.size // no_records
if table.size % no_records > 0:
Expand All @@ -918,21 +918,21 @@ def _write_table_records(
wfr = wfr_indices[row]
gfr = gfr_indices[row]
alq = alq_indices[row]
ecl_str += f"{thp:2d} {wfr:2d} {gfr:2d} {alq:2d}"
deck_str += f"{thp:2d} {wfr:2d} {gfr:2d} {alq:2d}"
for n, value in enumerate(table[row, :]):
ecl_str += format % value
deck_str += format % value
if (n + 1) % values_per_line == 0:
if n < no_flow_values - 1:
ecl_str += "\n"
ecl_str += " " * 11
deck_str += "\n"
deck_str += " " * 11
else:
ecl_str += "\n"
deck_str += "\n"
elif n == no_flow_values - 1:
ecl_str += "\n"
deck_str += "\n"

ecl_str += "/\n"
deck_str += "/\n"

return ecl_str
return deck_str


def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
Expand All @@ -957,16 +957,16 @@ def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
unit_type = vfpprod_data["UNIT_TYPE"]

# Write dataframe to string with Eclipse format for VFPPROD
ecl_str = "VFPPROD\n"
deck_str = "VFPPROD\n"
if comment:
ecl_str += common.comment_formatter(comment)
deck_str += common.comment_formatter(comment)
else:
ecl_str += "\n"
deck_str += "\n"

unit_value = vfpprod_data["UNIT_TYPE"].value
if vfpprod_data["UNIT_TYPE"] == UNITTYPE.DEFAULT:
unit_value = "1*"
ecl_str += _write_basic_record(
deck_str += _write_basic_record(
vfpprod_data["TABLE_NUMBER"],
vfpprod_data["DATUM"],
vfpprod_data["RATE_TYPE"].value,
Expand All @@ -977,37 +977,37 @@ def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
unit_value,
vfpprod_data["TAB_TYPE"].value,
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpprod_data["FLOW_VALUES"],
rate_type.value,
VFPPROD_UNITS[unit_type.value]["FLO"][rate_type.value],
"%10.6g",
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpprod_data["THP_VALUES"],
thp_type.value,
VFPPROD_UNITS[unit_type.value]["THP"][thp_type.value],
"%10.6g",
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpprod_data["WFR_VALUES"],
wfr_type.value,
VFPPROD_UNITS[unit_type.value]["WFR"][wfr_type.value],
"%10.6g",
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpprod_data["GFR_VALUES"],
gfr_type.value,
VFPPROD_UNITS[unit_type.value]["GFR"][gfr_type.value],
"%10.6g",
)
ecl_str += _write_vfp_range(
deck_str += _write_vfp_range(
vfpprod_data["ALQ_VALUES"],
alq_type.value,
VFPPROD_UNITS[unit_type.value]["ALQ"][alq_type.value],
"%10.6g",
)
ecl_str += _write_table_records(
deck_str += _write_table_records(
vfpprod_data["THP_INDICES"],
vfpprod_data["WFR_INDICES"],
vfpprod_data["GFR_INDICES"],
Expand All @@ -1016,4 +1016,4 @@ def df2res(dframe: pd.DataFrame, comment: Optional[str] = None) -> str:
"%10.6g",
)

return ecl_str
return deck_str

0 comments on commit cd31c43

Please sign in to comment.