-
Notifications
You must be signed in to change notification settings - Fork 20
swfunction Add new method for height above FFL and refactoring
#300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,9 @@ | |
| logger = logging.getLogger(__name__) | ||
|
|
||
| ALLOWED_METHODS = [ | ||
| "cell_center", | ||
| "cell_center_above_ffl", | ||
| "cell_corners_above_ffl", | ||
| "truncated_cell_corners_above_ffl", | ||
| ] | ||
|
|
||
|
|
||
|
|
@@ -67,8 +67,6 @@ class SwFunction: | |
| is called several time for the same grid. | ||
| hbot: Optional. May speed up computation if provided, in case the function | ||
| is called several time for the same grid. | ||
| debug: If True, several "check parameters" will we given, either as grid | ||
| properties (if working in RMS) or as ROFF files (if working outside RMS). | ||
| tag: Optional string to identify debug parameters. | ||
|
|
||
|
|
||
|
|
@@ -92,13 +90,12 @@ class SwFunction: | |
| invert: bool = False # if the SwJ function is on "reverse" form | ||
|
|
||
| # if None they will be computed here; otherwise they can be given explicitly: | ||
| hcenter: xtgeo.GridProperty = None | ||
| htop: xtgeo.GridProperty = None | ||
| hbot: xtgeo.GridProperty = None | ||
| hcenter: xtgeo.GridProperty | None = None | ||
| htop: xtgeo.GridProperty | None = None | ||
| hbot: xtgeo.GridProperty | None = None | ||
|
|
||
| # debug flag for additional parameters. Given in RMS if project is given; otherwise | ||
| # as files on your working folder | ||
| debug: bool = False | ||
| tag: str = "" # identification tag to add to debug params | ||
|
|
||
| # derived and internal | ||
|
|
@@ -118,12 +115,6 @@ def __post_init__(self) -> None: | |
| else: | ||
| self._compute_htop_hbot() | ||
|
|
||
| if self.debug: | ||
| if self.project: | ||
| self.grid.to_roxar(self.project, "DEBUG_" + self.gridname) | ||
| else: | ||
| self.grid.to_file("debug_grid.roff") | ||
|
|
||
| def _process_input(self) -> None: | ||
| """Work with a, b, x, ie. inversing and convert from float.""" | ||
| logger.info("Process a, b, etc") | ||
|
|
@@ -181,20 +172,6 @@ def _compute_htop_hbot(self) -> None: | |
| self.hcenter = hmid | ||
| logger.info("Use method %s", self.method) | ||
|
|
||
| if self.debug: | ||
| htop.name = "TOP_SW" + self.tag | ||
| hbot.name = "BOT_SW" + self.tag | ||
| hmid.name = "CENTER_SW" + self.tag | ||
| if self.project: | ||
| logger.debug("TAG is ", self.tag) | ||
| htop.to_roxar(self.project, self.gridname, "HTOP" + self.tag) | ||
| hbot.to_roxar(self.project, self.gridname, "HBOT" + self.tag) | ||
| hmid.to_roxar(self.project, self.gridname, "HCENTER" + self.tag) | ||
| else: | ||
| htop.to_file(f"debug_htop{self.tag}.roff") | ||
| hbot.to_file(f"debug_hbot{self.tag}.roff") | ||
| hmid.to_file(f"debug_hcenter{self.tag}.roff") | ||
|
|
||
| def _sw_function_direct(self) -> None: | ||
| """Use function on form Sw = A*(M + X*h)^B; generic function!""" | ||
| assert isinstance(self.a, xtgeo.GridProperty) # mypy | ||
|
|
@@ -203,6 +180,7 @@ def _sw_function_direct(self) -> None: | |
| assert isinstance(self.m, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.swira, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.swmax, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.hcenter, xtgeo.GridProperty) | ||
|
|
||
| # the direct function is mostly used to compare with integrated approach, as QC | ||
| height = self.hcenter.values | ||
|
|
@@ -237,20 +215,16 @@ def _sw_function_integrate_w_mterm(self) -> None: | |
| assert isinstance(self.m, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.swira, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.swmax, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.htop, xtgeo.GridProperty) # mypy | ||
| assert isinstance(self.hbot, xtgeo.GridProperty) # mypy | ||
|
|
||
| ht = ( | ||
| ((1.0 / self.a.values) ** (1.0 / self.b.values)) - self.m.values | ||
| ) / self.x.values # threshold height | ||
|
|
||
| h2 = self.htop.values.copy() # h_top or H2 in integration | ||
| h1 = self.hbot.values.copy() # h_bot or H1 in integration | ||
|
|
||
| if self.debug: | ||
| tmp = xtgeo.GridProperty(self.grid, values=ht, name="HT" + self.tag) | ||
| if self.project: | ||
| tmp.to_roxar(self.project, self.gridname, "THRESHOLD HEIGHT" + self.tag) | ||
| else: | ||
| tmp.to_file(f"debug_ht{self.tag}.roff") | ||
|
|
||
| water = h2 * 0.0 | ||
| water = np.ma.where(h2 < ht, 1.0, water) | ||
| water = np.ma.where(h2 <= 0.0, 1.0, water) # may occur for negative ht | ||
|
|
@@ -317,7 +291,9 @@ def _compute_direct(self) -> None: | |
| if self._sw.values.min() < 0.0: | ||
| raise RuntimeError(f"SW min out of range: {self._sw.values.min()}") | ||
|
|
||
| def compute(self, compute_method: str = "integrated") -> xtgeo.GridProperty: | ||
| def compute( | ||
| self, compute_method: str = "integrated" | ||
| ) -> dict[str, xtgeo.GridProperty]: | ||
|
Comment on lines
+294
to
+296
|
||
| """Common compute function for saturation, and returns the Sw property""" | ||
| if compute_method == "integrated": | ||
| self._compute_integrated() | ||
|
|
@@ -331,4 +307,11 @@ def compute(self, compute_method: str = "integrated") -> xtgeo.GridProperty: | |
| "Bug: Grid mask and Sw mask are not equal, contact developer!" | ||
| ) | ||
|
|
||
| return self._sw | ||
| output_props = [self._sw, self.htop, self.hbot, self.hcenter] | ||
| output_props_name = ["SW", "HTOP", "HBOT", "HCENTER"] | ||
|
|
||
| for prop, prop_name in zip(output_props, output_props_name): | ||
| assert isinstance(prop, xtgeo.GridProperty) | ||
| prop.name = self.tag + prop_name | ||
|
|
||
| return dict(zip(output_props_name, output_props)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.