-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add layer_id to each well connection and update _grid_cell_bounding_b…
…oxes() (#279) * layers added to input yaml and parsed by the config parser * config layers variable passed to from_flow * Update _grid_cell_bounding_boxes to allow layering filters * Minor fixes * Added value errors for layers input * Added layer id to well connections * fix pylint issues * Add tests + fixes * Made test model agnostic * Remove assert True statement * Change path * Typo * Modify path * Fix version conflict * Allow multiple paths to test data * Typo * Add leading underscore to dunction * synchronize changes after merging branch i276-grid-cell-bounding-box * merge updated branch grid_cell_bounding_box * merge updated branch grid_cell_bounding_box * Revert to no changes in perforation strategy * change layer_id from None to 0 when no layering is defined * Apply suggestions from code review Accepted all suggestions. Only layering to layers still has to be changed. Co-authored-by: Wouter J. de Bruin <9119793+wouterjdb@users.noreply.github.com> * layering changed to layers * forgot to change one layering to layers Co-authored-by: Ubuntu <LonnekevB@Flownet.gwfddzla5snuvfeg5bcr4imt2c.ax.internal.cloudapp.net> Co-authored-by: Wouter J. de Bruin <wouterjdb@hotmail.com> Co-authored-by: Wouter J. de Bruin <9119793+wouterjdb@users.noreply.github.com>
- Loading branch information
1 parent
d1c534a
commit 6eb0fd5
Showing
5 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import glob | ||
import operator | ||
from pathlib import Path | ||
|
||
from numpy.testing import assert_almost_equal | ||
from ecl.grid import EclRegion | ||
|
||
from flownet.data.from_flow import FlowData | ||
|
||
|
||
def _locate_test_case() -> Path: | ||
""" | ||
This function will try to find the test data. On the CI/CD this will be | ||
any case. Locally, the Norne case will be used. If not found, a | ||
FileNotFoundError will be raised. | ||
Raises: | ||
FileNotFoundError: The test data was not found. | ||
Returns: | ||
Path to the .DATA file. | ||
""" | ||
cicd_str = "./flownet-testdata/*/input_model/*/*.DATA" | ||
home_path = Path.home() / Path( | ||
"flownet-testdata/norne/input_model/norne/NORNE_ATW2013.DATA" | ||
) | ||
flow_path = ( | ||
Path.cwd() / "../flownet-testdata/norne/input_model/norne/NORNE_ATW2013.DATA" | ||
) | ||
|
||
if len(glob.glob(cicd_str)) > 0: | ||
# CI/CD | ||
data_file = Path(glob.glob(cicd_str)[0]) | ||
elif home_path.exists(): | ||
# Test-data repository located in home directory | ||
data_file = home_path | ||
elif flow_path.exists(): | ||
# Test-data repositry located in the same location as the flownet repository | ||
data_file = flow_path | ||
else: | ||
raise FileNotFoundError( | ||
"To be able to run the tests one needs to clone the flownet-testdata from \ | ||
https://github.com/equinor/flownet-testdata. The test-data needs to be located \ | ||
in your home folder OR in the folder containing the flownet repository." | ||
) | ||
|
||
return data_file | ||
|
||
|
||
# pylint: disable=protected-access | ||
def test_grid_cell_bounding_boxes() -> None: | ||
layers = () | ||
flowdata = FlowData( | ||
_locate_test_case(), | ||
layers, | ||
"multiple_based_on_workovers", | ||
) | ||
|
||
# Test no argument and entire field being equal | ||
flowdata._layers = ((1, flowdata.grid.nz),) | ||
assert_almost_equal( | ||
flowdata._grid_cell_bounding_boxes(), flowdata._grid_cell_bounding_boxes(0) | ||
) | ||
|
||
# Test zero'th layer id | ||
flowdata._layers = ((1, 2), (3, 4)) | ||
result = flowdata._grid_cell_bounding_boxes(0) | ||
active_cells = EclRegion(flowdata.grid, True) | ||
active_cells.select_kslice( | ||
*tuple(map(operator.sub, flowdata._layers[0], (1, 1))), intersect=True | ||
) | ||
active_cells.select_active(intersect=True) | ||
assert result.shape[0] == active_cells.active_size() | ||
assert result.shape[1] == 6 | ||
|
||
# Test last layer id | ||
flowdata._layers = ((1, 2), (3, 4)) | ||
result = flowdata._grid_cell_bounding_boxes(1) | ||
active_cells = EclRegion(flowdata.grid, True) | ||
active_cells.select_kslice( | ||
*tuple(map(operator.sub, flowdata._layers[-1], (1, 1))), intersect=True | ||
) | ||
active_cells.select_active(intersect=True) | ||
assert result.shape[0] == active_cells.active_size() | ||
assert result.shape[1] == 6 |