Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes committed Sep 19, 2023
1 parent 5781a70 commit b13b449
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/xtgeo/surface/_regsurf_cube_window_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ def _compute_stats(cref, attr, self, upper):

if attr == "mean":
values = np.nanmean(cref, axis=2)
elif attr == "var":
values = np.nanvar(cref, axis=2)
elif attr == "max":
values = np.nanmax(cref, axis=2)
elif attr == "min":
values = np.nanmin(cref, axis=2)
elif attr == "rms":
values = np.sqrt(np.nanmean(np.square(cref), axis=2))
elif attr == "var":
values = np.var(cref, axis=2)
elif attr == "maxneg":
use = cref.copy()
use[cref >= 0] = np.nan
Expand Down Expand Up @@ -228,12 +228,12 @@ def _compute_stats(cref, attr, self, upper):
use = cref.copy()
use[cref >= 0] = np.nan
values = np.nansum(use, axis=2)
values = np.ma.masked_greater_equal(values, 0.0)
values = np.ma.masked_greater_equal(values, 0.0) # to make undefined map areas
elif attr == "sumpos":
use = cref.copy()
use[cref < 0] = np.nan
values = np.nansum(use, axis=2)
values = np.ma.masked_less_equal(values, 0.0)
values = np.ma.masked_less_equal(values, 0.0) # to make undefined map areas
elif attr == "sumabs":
use = cref.copy()
use = np.abs(use)
Expand Down
57 changes: 37 additions & 20 deletions src/xtgeo/surface/regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# --------------------------------------------------------------------------------------

# pylint: disable=too-many-public-methods
from __future__ import annotations

import functools
import io
Expand All @@ -42,7 +43,7 @@
from collections import OrderedDict
from copy import deepcopy
from types import FunctionType
from typing import List, Optional, Tuple, Type, Union
from typing import Dict, List, Literal, Optional, Tuple, Type, Union

import deprecation
import numpy as np
Expand All @@ -69,6 +70,22 @@
xtg = xtgeo.common.XTGeoDialog()
logger = xtg.functionlogger(__name__)

# valid argumentts for seismic attributes
ValidAttrs = Literal[
"all",
"max",
"min",
"rms",
"mean",
"var",
"maxpos",
"maxneg",
"sumpos",
"sumneg",
"meanabs",
"meanpos",
"meanneg",
]

# ======================================================================================
# METHODS as wrappers to class init + import
Expand Down Expand Up @@ -2541,21 +2558,21 @@ def slice_cube(

def slice_cube_window(
self,
cube,
zsurf=None,
other=None,
other_position="below",
sampling="nearest",
mask=True,
zrange=None,
ndiv=None,
attribute="max",
maskthreshold=0.1,
snapxy=False,
showprogress=False,
deadtraces=True,
algorithm=2,
):
cube: xtgeo.Cube,
zsurf: Optional[xtgeo.RegularSurface] = None,
other: Optional[xtgeo.RegularSurface] = None,
other_position: str = "below",
sampling: Literal["nearest", "cube", "trilinear"] = "nearest",
mask: bool = True,
zrange: Optional[float] = None,
ndiv: Optional[int] = None,
attribute: Union[List[ValidAttrs], ValidAttrs] = "max",
maskthreshold: float = 0.1,
snapxy: bool = False,
showprogress: bool = False,
deadtraces: bool = True,
algorithm: Literal[1, 2, 3] = 2,
) -> Tuple(None, Dict[xtgeo.RegularSurface]):
"""Slice the cube within a vertical window and get the statistical attrubutes.
The statistical attributes can be min, max etc. Attributes are:
Expand Down Expand Up @@ -2590,13 +2607,13 @@ def slice_cube_window(
available.
Args:
cube (Cube): Instance of a Cube()
zsurf (RegularSurface): Instance of a depth (or time) map, which
cube: Instance of a Cube() here
zsurf: Instance of a depth (or time) map, which
is the depth or time map (or...) that is used a slicer.
If None, then the surface instance itself is used a slice
criteria. Note that zsurf must have same map defs as the
surface instance.
other (RegularSurface): Instance of other surface if window is
other: Instance of other surface if window is
between surfaces instead of a static window. The zrange
input is then not applied.
sampling (str): 'nearest'/'trilinear'/'cube' for nearest node (default),
Expand All @@ -2613,7 +2630,7 @@ def slice_cube_window(
means 'auto' sampling, using 0.5 of cube Z increment as basis. If
algorithm = 2 and sampling is 'cube', the cube Z increment
will be used.
attribute (str or list): The requested attribute(s), e.g.
attribute: The requested attribute(s), e.g.
'max' value. May also be a list of attributes, e.g.
['min', 'rms', 'max']. By such, a dict of surface objects is
returned. Note 'all' will make a list of possible attributes
Expand Down

0 comments on commit b13b449

Please sign in to comment.