Skip to content

Commit 1edeb8f

Browse files
authored
Remove deprecated interpolation code (#228)
1 parent dace715 commit 1edeb8f

6 files changed

Lines changed: 2 additions & 300 deletions

File tree

pyscal/gasoil.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,6 @@ def resetsorg(self):
202202
% (self.swirr, self.sgcr, self.swl, self.sorg, self.krgendanchor)
203203
)
204204

205-
def add_gasoil_fromtable(self, *args, **kwargs):
206-
"""Deprecated. Use ``add_fromtable()``"""
207-
logger.warning("add_gasoil_fromtable() is deprecated, use add_fromtable()")
208-
self.add_fromtable(*args, **kwargs)
209-
210205
def add_fromtable(
211206
self,
212207
dframe,

pyscal/scalrecommendation.py

Lines changed: 1 addition & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -39,136 +39,7 @@ def __init__(self, low, base, high, tag=None, h=0.01):
3939
self.h = h
4040
self.tag = tag
4141

42-
if isinstance(low, dict) and isinstance(base, dict) and isinstance(high, dict):
43-
44-
logger.warning(
45-
(
46-
"Making SCALrecommendation from dicts is deprecated "
47-
"and will not be supported in future versions\n"
48-
)
49-
)
50-
51-
self.defaultshandling("swirr", 0.0, [low, base, high])
52-
self.defaultshandling("swcr", 0.0, [low, base, high])
53-
self.defaultshandling("sorg", 0.0, [low, base, high])
54-
self.defaultshandling("sgcr", 0.0, [low, base, high])
55-
56-
# Special treatment for backwards compatibility:
57-
if "krowend" in low:
58-
logger.error("krowend is deprecated, use kroend")
59-
krowend = "krowend"
60-
else:
61-
krowend = "kroend"
62-
63-
if "krogend" in low:
64-
logger.error("krogend is deprecated, use kroend")
65-
krogend = "krogend"
66-
else:
67-
krogend = "kroend"
68-
69-
self.defaultshandling("kroend", 1.0, [low, base, high])
70-
self.defaultshandling("krwmax", 1.0, [low, base, high])
71-
self.defaultshandling("krgend", 1.0, [low, base, high])
72-
self.defaultshandling("krgmax", 1.0, [low, base, high])
73-
74-
# Initialize saturation ranges for all curves
75-
self.low = WaterOilGas(
76-
swirr=low["swirr"],
77-
swl=low["swl"],
78-
sorw=low["sorw"],
79-
sorg=low["sorg"],
80-
sgcr=low["sgcr"],
81-
swcr=low["swcr"],
82-
h=h,
83-
tag=tag,
84-
)
85-
self.base = WaterOilGas(
86-
swirr=base["swirr"],
87-
swl=base["swl"],
88-
sorw=base["sorw"],
89-
sorg=base["sorg"],
90-
sgcr=base["sgcr"],
91-
swcr=base["swcr"],
92-
h=h,
93-
tag=tag,
94-
)
95-
self.high = WaterOilGas(
96-
swirr=high["swirr"],
97-
swl=high["swl"],
98-
sorw=high["sorw"],
99-
sorg=high["sorg"],
100-
sgcr=high["sgcr"],
101-
swcr=high["swcr"],
102-
h=h,
103-
tag=tag,
104-
)
105-
106-
# Add water and oil curves
107-
self.low.wateroil.add_LET_water(
108-
l=low["Lw"],
109-
e=low["Ew"],
110-
t=low["Tw"],
111-
krwend=low["krwend"],
112-
krwmax=low["krwmax"],
113-
)
114-
self.base.wateroil.add_LET_water(
115-
l=base["Lw"],
116-
e=base["Ew"],
117-
t=base["Tw"],
118-
krwend=base["krwend"],
119-
krwmax=base["krwmax"],
120-
)
121-
self.high.wateroil.add_LET_water(
122-
l=high["Lw"],
123-
e=high["Ew"],
124-
t=high["Tw"],
125-
krwend=high["krwend"],
126-
krwmax=high["krwmax"],
127-
)
128-
129-
self.low.wateroil.add_LET_oil(
130-
l=low["Lo"], e=low["Eo"], t=low["To"], kroend=low[krowend]
131-
)
132-
self.base.wateroil.add_LET_oil(
133-
l=base["Lo"], e=base["Eo"], t=base["To"], kroend=base[krowend]
134-
)
135-
self.high.wateroil.add_LET_oil(
136-
l=high["Lo"], e=high["Eo"], t=high["To"], kroend=high[krowend]
137-
)
138-
139-
# Add gas and oil curves:
140-
self.low.gasoil.add_LET_gas(
141-
l=low["Lg"],
142-
e=low["Eg"],
143-
t=low["Tg"],
144-
krgend=low["krgend"],
145-
krgmax=low["krgmax"],
146-
)
147-
self.base.gasoil.add_LET_gas(
148-
l=base["Lg"],
149-
e=base["Eg"],
150-
t=base["Tg"],
151-
krgend=base["krgend"],
152-
krgmax=base["krgmax"],
153-
)
154-
self.high.gasoil.add_LET_gas(
155-
l=high["Lg"],
156-
e=high["Eg"],
157-
t=high["Tg"],
158-
krgend=high["krgend"],
159-
krgmax=high["krgmax"],
160-
)
161-
self.low.gasoil.add_LET_oil(
162-
l=low["Log"], e=low["Eog"], t=low["Tog"], kroend=low[krogend]
163-
)
164-
self.base.gasoil.add_LET_oil(
165-
l=base["Log"], e=base["Eog"], t=base["Tog"], kroend=base[krogend]
166-
)
167-
self.high.gasoil.add_LET_oil(
168-
l=high["Log"], e=high["Eog"], t=high["Tog"], kroend=high[krogend]
169-
)
170-
self.type = WaterOilGas
171-
elif (
42+
if (
17243
isinstance(low, WaterOilGas)
17344
and isinstance(base, WaterOilGas)
17445
and isinstance(high, WaterOilGas)
@@ -390,15 +261,3 @@ def interpolate(self, parameter, parameter2=None, h=0.02):
390261
interpolant.fast = self.fast
391262

392263
return interpolant
393-
394-
@staticmethod
395-
def defaultshandling(key, value, dicts):
396-
"""Helper function for __init__ to fill out missing values in
397-
dicts with relperm parameter
398-
399-
This function IS DEPRECATED and will be removed
400-
when __init__ no longer supports dicts as arguments.
401-
"""
402-
for dic in dicts:
403-
if key not in dic:
404-
dic[key] = value

pyscal/utils/interpolation.py

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33

44
import logging
55

6-
import pandas as pd
76
from scipy.interpolate import interp1d
87

98
import pyscal
10-
from ..constants import SWINTEGERS
11-
129

1310
logger = logging.getLogger(__name__)
1411

@@ -395,88 +392,3 @@ def weighted_value(a, b):
395392
go_new.tag = _interpolate_tags(go_low, go_high, parameter, tag)
396393

397394
return go_new
398-
399-
400-
def interpolator(
401-
tableobject, wo_low, wo_high, parameter, sat="sw", kr1="krw", kr2="krow", pc="pc"
402-
):
403-
"""Interpolates between two curves.
404-
405-
DEPRECATED FUNCTION!
406-
407-
The interpolation parameter is 0 through 1,
408-
irrespective of phases or low-base/base-high/low-high.
409-
410-
Args:
411-
tabjeobject (WaterOil or GasOil): A partially setup object where
412-
relperm and pc columns are to be filled with numbers.
413-
wo_low (WaterOil or GasOil): "Low" case of interpolation (relates
414-
to interpolation parameter 0). Must be copies, as they
415-
will be modified.
416-
wo_high: Ditto, relates to interpolation parameter 1
417-
parameter (float): Between 0 and 1, what you want to interpolate to.
418-
sat (str): Name of the saturation column, typically 'sw' or 'sg'
419-
kr1 (str): Name of the first relperm column ('krw' or 'krg')
420-
kr2 (str): Name of the second relperm column ('krow' or 'krog')
421-
pc (str): Name of the capillary pressure column ('pc')
422-
423-
Returns:
424-
None, but modifies the first argument.
425-
"""
426-
logger.warning("utils.interpolator() is deprecated and will disappear")
427-
428-
wo_low.table.rename(columns={kr1: kr1 + "_1"}, inplace=True)
429-
wo_high.table.rename(columns={kr1: kr1 + "_2"}, inplace=True)
430-
wo_low.table.rename(columns={kr2: kr2 + "_1"}, inplace=True)
431-
wo_high.table.rename(columns={kr2: kr2 + "_2"}, inplace=True)
432-
wo_low.table.rename(columns={pc: pc + "_1"}, inplace=True)
433-
wo_high.table.rename(columns={pc: pc + "_2"}, inplace=True)
434-
435-
# Result data container:
436-
satresult = pd.DataFrame(data=tableobject.table[sat], columns=[sat])
437-
438-
# Merge swresult with wo_low and wo_high, and interpolate all
439-
# columns in sw:
440-
intdf = (
441-
pd.concat([wo_low.table, wo_high.table, satresult], sort=True)
442-
.set_index(sat)
443-
.sort_index()
444-
.interpolate(method="slinear")
445-
.fillna(method="bfill")
446-
.fillna(method="ffill")
447-
)
448-
449-
# Normalized saturations does not make sense for the
450-
# interpolant, remove:
451-
for col in ["swn", "son", "swnpc", "H", "J"]:
452-
if col in intdf.columns:
453-
del intdf[col]
454-
455-
intdf[kr1] = intdf[kr1 + "_1"] * (1 - parameter) + intdf[kr1 + "_2"] * parameter
456-
intdf[kr2] = intdf[kr2 + "_1"] * (1 - parameter) + intdf[kr2 + "_2"] * parameter
457-
if pc + "_1" in wo_low.table.columns and pc + "_2" in wo_high.table.columns:
458-
intdf[pc] = intdf[pc + "_1"] * (1 - parameter) + intdf[pc + "_2"] * parameter
459-
else:
460-
intdf[pc] = 0
461-
462-
# Slice out the resulting sw values and columns. Slicing on
463-
# floating point indices is not robust so we need to slice on an
464-
# integer version of the sw column
465-
tableobject.table["swint"] = list(
466-
map(int, list(map(round, tableobject.table[sat] * SWINTEGERS)))
467-
)
468-
intdf["swint"] = list(map(int, list(map(round, intdf.index.values * SWINTEGERS))))
469-
intdf = intdf.reset_index()
470-
intdf.drop_duplicates("swint", inplace=True)
471-
intdf.set_index("swint", inplace=True)
472-
intdf = intdf.loc[tableobject.table["swint"].values]
473-
intdf = intdf[[sat, kr1, kr2, pc]].reset_index()
474-
475-
# intdf['swint'] = (intdf['sw'] * SWINTEGERS).astype(int)
476-
# intdf.drop_duplicates('swint', inplace=True)
477-
478-
# Populate the WaterOil object
479-
tableobject.table[kr1] = intdf[kr1]
480-
tableobject.table[kr2] = intdf[kr2]
481-
tableobject.table[pc] = intdf[pc]
482-
tableobject.table.fillna(method="ffill", inplace=True)

pyscal/wateroil.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ def __init__(
173173
"Initialized WaterOil with %s saturation points", str(len(self.table))
174174
)
175175

176-
def add_oilwater_fromtable(self, *args, **kwargs):
177-
"""Deprecated, use ``add_fromtable()``"""
178-
logger.warning("add_oilwater_fromtable() is deprecated, use add_fromtable()")
179-
self.add_fromtable(*args, **kwargs)
180-
181176
def add_fromtable(
182177
self,
183178
dframe,

tests/test_fromtable.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def test_wo_fromtable_simple():
2121
wateroil = WaterOil(h=0.1)
2222
# With wrong names:
2323
with pytest.raises(ValueError):
24-
# Here we also get a deprecation warning
25-
wateroil.add_oilwater_fromtable(df1)
24+
wateroil.add_fromtable(df1)
2625

2726
# Set names:
2827
wateroil.add_fromtable(df1, swcolname="SW")

tests/test_scalrecommendation.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -89,64 +89,6 @@
8989
}
9090

9191

92-
@settings(max_examples=10, deadline=3000)
93-
@given(
94-
st.floats(min_value=-1.1, max_value=1.1), st.floats(min_value=-1.1, max_value=1.1)
95-
)
96-
def test_interpolation_deprecated(param_wo, param_go):
97-
"""Testing deprecated functionality. Remove
98-
this test function when SCALrecommendation class is updated"""
99-
100-
rec = SCALrecommendation(
101-
LOW_SAMPLE_LET, BASE_SAMPLE_LET, HIGH_SAMPLE_LET, "foo", h=0.1
102-
)
103-
104-
rec.add_simple_J() # Add default pc curve
105-
assert rec.type == WaterOilGas
106-
try:
107-
interpolant = rec.interpolate(param_wo, param_go, h=0.1)
108-
except ValueError:
109-
# We get here when interpolation parameters are outside [-1, 1]
110-
return
111-
112-
check_table(interpolant.wateroil.table)
113-
check_table(interpolant.gasoil.table)
114-
115-
assert len(interpolant.gasoil.SGOF()) > 100
116-
assert len(interpolant.gasoil.SGFN()) > 100
117-
assert len(interpolant.wateroil.SWFN()) > 100
118-
assert len(interpolant.SOF3()) > 100
119-
assert len(interpolant.wateroil.SWOF()) > 100
120-
if not interpolant.threephaseconsistency():
121-
print(interpolant.wateroil.SWOF())
122-
print(interpolant.gasoil.SGOF())
123-
assert interpolant.threephaseconsistency()
124-
125-
126-
def test_deprecated_kroend():
127-
"""Testing that the deprecated scalrecommendation can take
128-
both kroend and krogend/krowend"""
129-
130-
low_krowend = dict(LOW_SAMPLE_LET)
131-
low_krowend["krowend"] = low_krowend["kroend"]
132-
del low_krowend["kroend"]
133-
134-
base_krowend = dict(BASE_SAMPLE_LET)
135-
base_krowend["krowend"] = base_krowend["kroend"]
136-
del base_krowend["kroend"]
137-
138-
high_krowend = dict(HIGH_SAMPLE_LET)
139-
high_krowend["krowend"] = high_krowend["kroend"]
140-
del high_krowend["kroend"]
141-
142-
rec = SCALrecommendation(low_krowend, base_krowend, high_krowend, "foo", h=0.1)
143-
144-
rec.add_simple_J() # Add default pc curve
145-
interpolant = rec.interpolate(0.1, 0, h=0.1)
146-
check_table(interpolant.wateroil.table)
147-
print(interpolant.SWOF())
148-
149-
15092
def test_make_scalrecommendation():
15193
"""Test that we can make scal recommendation objects
15294
from three WaterOilGas objects"""

0 commit comments

Comments
 (0)