Skip to content

Commit

Permalink
Fix issues for report gridmatch (#411)
Browse files Browse the repository at this point in the history
* Add keys perlogrange and filterlogrange

* fix: handling conversion to int unless nan

* typo in HISTORY
  • Loading branch information
jcrivenaes authored Aug 26, 2020
1 parent 9c3197b commit ed03a20
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Version 2

### 2.11.0
* New features:
* Added keys ``perflogrange`` and ``filterlogrange`` in Grid report_zone_mismatch()


### 2.10.0
* New features:
* Added interpolation option in xsection when plotting 3D grids #401
Expand Down
31 changes: 24 additions & 7 deletions src/xtgeo/grid3d/_grid_wellzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def report_zone_mismatch(
zonelogshift=0,
depthrange=None,
perflogname=None,
perflogrange=(1, 9999),
filterlogname=None,
filterlogrange=(1e-32, 9999.0),
resultformat=1,
): # pylint: disable=too-many-locals
"""
Expand Down Expand Up @@ -73,18 +75,23 @@ def report_zone_mismatch(
skiprange = list(range(zmin, z1)) + list(range(z2 + 1, zmax + 1))

for zname in (zonelogname, zmodel):
df[zname].replace(skiprange, -888, inplace=True)
if skiprange: # needed check; du to a bug in pandas version 0.21 .. 0.23
df[zname].replace(skiprange, -888, inplace=True)
df[zname].fillna(-999, inplace=True)
if perflogname:
if perflogname in df.columns:
df[perflogname].replace(np.nan, -1, inplace=True)
df[zname] = np.where(df[perflogname] <= 0, -899, df[zname])
pfr1, pfr2 = perflogrange
df[zname] = np.where(df[perflogname] < pfr1, -899, df[zname])
df[zname] = np.where(df[perflogname] > pfr2, -899, df[zname])
else:
return None
if filterlogname:
if filterlogname in df.columns:
df[filterlogname].replace(np.nan, -1, inplace=True)
df[zname] = np.where(df[filterlogname] <= 0, -919, df[zname])
ffr1, ffr2 = filterlogrange
df[zname] = np.where(df[filterlogname] < ffr1, -919, df[zname])
df[zname] = np.where(df[filterlogname] > ffr2, -919, df[zname])
else:
return None

Expand All @@ -98,15 +105,25 @@ def report_zone_mismatch(
dfuse1 = dfuse1.loc[dfuse1[zonelogname] > -888]

dfuse1["zmatch1"] = np.where(dfuse1[zmodel] == dfuse1[zonelogname], 1, 0)
mcount1 = int(dfuse1["zmatch1"].sum())
tcount1 = int(dfuse1["zmatch1"].count())
mcount1 = dfuse1["zmatch1"].sum()
tcount1 = dfuse1["zmatch1"].count()
if not np.isnan(mcount1):
mcount1 = int(mcount1)
if not np.isnan(tcount1):
tcount1 = int(tcount1)

res1 = dfuse1["zmatch1"].mean() * 100

dfuse2 = df.copy(deep=True)
dfuse2 = dfuse2.loc[(df[zmodel] > -888) | (df[zonelogname] > -888)]
dfuse2["zmatch2"] = np.where(dfuse2[zmodel] == dfuse2[zonelogname], 1, 0)
mcount2 = int(dfuse2["zmatch2"].sum())
tcount2 = int(dfuse2["zmatch2"].count())
mcount2 = dfuse2["zmatch2"].sum()
tcount2 = dfuse2["zmatch2"].count()
if not np.isnan(mcount2):
mcount2 = int(mcount2)
if not np.isnan(tcount2):
tcount2 = int(tcount2)

res2 = dfuse2["zmatch2"].mean() * 100

# update Well() copy (segment only)
Expand Down
13 changes: 11 additions & 2 deletions src/xtgeo/grid3d/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,9 @@ def report_zone_mismatch(
zonelogshift=0,
depthrange=None,
perflogname=None,
perflogrange=(1, 9999),
filterlogname=None,
filterlogrange=(1e-32, 9999.0),
resultformat=1,
):
"""Reports mismatch between wells and a zone.
Expand All @@ -1731,10 +1733,14 @@ def report_zone_mismatch(
zonation
zonelogrange (tuple): zone log range, from - to (inclusive)
onelayergrid (Grid): Redundant from version 2.8, please skip!
zonelogshift (int): Deviation (numerical shift) between grid and zonelog
zonelogshift (int): Deviation (numerical shift) between grid and zonelog,
e.g. if Zone property starts with 1 and this corresponds to a zonelog
index of 3 in the well, the shift shall be -2.
depthrange (tuple): Interval for search in TVD depth, to speed up
perflogname (str): Name of perforation log to filter on (> 0).
perflogname (str): Name of perforation log to filter on (> 0 default).
perflogrange (tuple): Range of values where perforations are present.
filterlogname (str): General filter, work as perflog, filter on values > 0
filterlogrange (tuple): Range of values where filter shall be present.
resultformat (int): If 1, consider the zonelogrange in the well as
basis for match ratio, return (percent, match count, total count).
If 2 then a dictionary is returned with various result members
Expand Down Expand Up @@ -1774,6 +1780,7 @@ def report_zone_mismatch(
print(response)
.. versionchanged:: 2.8.0 Added several new keys and better precision in result
.. versionchanged:: 2.11.0 Added ``perflogrange`` and ``filterlogrange``
"""

reports = _grid_wellzone.report_zone_mismatch(
Expand All @@ -1786,7 +1793,9 @@ def report_zone_mismatch(
zonelogshift=zonelogshift,
depthrange=depthrange,
perflogname=perflogname,
perflogrange=perflogrange,
filterlogname=filterlogname,
filterlogrange=filterlogrange,
resultformat=resultformat,
)

Expand Down

0 comments on commit ed03a20

Please sign in to comment.