-
Notifications
You must be signed in to change notification settings - Fork 2
GEOPY-2622: Clip limits of topography extent based on mesh extent #344
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
Open
benk-mira
wants to merge
8
commits into
develop
Choose a base branch
from
GEOPY-2622
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
03406c0
mask topo surface before active cells compute
benk-mira 23219b8
restrict topography cells to the mesh extents when calculating the ac…
benk-mira a689684
switching to dev
benk-mira 61f3311
tests passing
benk-mira fdf7fd0
Cleaner octree_extents implementation
benk-mira 4767a2d
Merge branch 'develop' into GEOPY-2622
benk-mira 785d246
fix tests
benk-mira 78700bc
Merge branch 'GEOPY-2622' of github.com:MiraGeoscience/simpeg-drivers…
benk-mira 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
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 |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
| # Copyright (c) 2026 Mira Geoscience Ltd. ' | ||
| # ' | ||
| # This file is part of simpeg-drivers package. ' | ||
| # ' | ||
| # simpeg-drivers is distributed under the terms and conditions of the MIT License ' | ||
| # (see LICENSE file at the root of this source code package). ' | ||
| # ' | ||
| # ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
|
|
||
| import numpy as np | ||
| from geoh5py import Workspace | ||
| from geoh5py.objects import Octree, Points | ||
| from grid_apps.octree_creation.driver import OctreeDriver | ||
| from grid_apps.octree_creation.options import OctreeOptions, RefinementOptions | ||
|
|
||
| from simpeg_drivers.utils.utils import mask_vertices_and_cells, octree_extents | ||
|
|
||
|
|
||
| def test_octree_extents(tmp_path): | ||
| with Workspace(tmp_path / "test.geoh5") as ws: | ||
| X, Y = np.meshgrid(np.linspace(0, 1000, 51), np.linspace(0, 1000, 51)) | ||
| Z = np.zeros_like(X) | ||
| vertices = np.column_stack([X.ravel(), Y.ravel(), Z.ravel()]) | ||
| pts = Points.create(ws, name="points", vertices=vertices) | ||
| options = OctreeOptions( | ||
| geoh5=ws, | ||
| objects=pts, | ||
| refinements=[ | ||
| RefinementOptions( | ||
| refinement_object=pts, levels=[4, 2], horizon=False, distance=100 | ||
| ), | ||
| ], | ||
| ) | ||
| octree = OctreeDriver.octree_from_params(options) | ||
|
|
||
| extents = octree_extents(octree) | ||
| assert np.allclose(extents, [-1112.5, 2087.5, -1112.5, 2087.5, -1062.5, 537.5]) | ||
|
|
||
|
|
||
| def test_mask_vertices_and_cells(): | ||
| X, Y = np.meshgrid(np.arange(3), np.arange(3)) | ||
| Z = np.zeros_like(X) | ||
| vertices = np.column_stack([X.ravel(), Y.ravel(), Z.ravel()]) | ||
| cells = np.array( | ||
| [ | ||
| [0, 1, 3], | ||
| [3, 1, 4], | ||
| [1, 2, 4], | ||
| [4, 2, 5], | ||
| [3, 4, 6], | ||
| [6, 4, 7], | ||
| [4, 5, 7], | ||
| [7, 5, 8], | ||
| ] | ||
| ) | ||
| extent = [0.5, 2, 0, 2, 0, 1] | ||
| masked_vertices, masked_cells = mask_vertices_and_cells(extent, vertices, cells) | ||
| assert len(masked_vertices) == len(vertices) | ||
| assert len(masked_cells) == len(cells) | ||
| extent = [1.5, 2, 0, 2, 0, 1] | ||
| masked_vertices, masked_cells = mask_vertices_and_cells(extent, vertices, cells) | ||
| assert len(masked_vertices) == 6 | ||
| assert len(masked_cells) == 4 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's too bad, we are duplicating a lot of mechanics of geoh5py
surface.copy_by_extent()method.We can migrate this to geoh5py on GEOPY-2714
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I've left some notes regarding the implementation to make sure it can be used for this case