-
Notifications
You must be signed in to change notification settings - Fork 280
Add shift to discrete topography for NSEM #1683
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1683 +/- ##
==========================================
- Coverage 81.47% 81.45% -0.02%
==========================================
Files 418 419 +1
Lines 54763 54932 +169
Branches 5200 5224 +24
==========================================
+ Hits 44617 44746 +129
- Misses 8753 8786 +33
- Partials 1393 1400 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I feel like this should just be moved to a utility function outside of any of the |
agreed |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
I noticed something important about these projections functions. When originally developed for DC/IP, the projection ensured the final electrode locations didn't end up on an 'exposed' edge or corner of a mesh cell. This was accomplished by shifting the horizontal position of the original locations to lie over the nearest cell centers. This is somewhat necessary for electric field measurements but not necessarily for magnetic field measurements. Does anyone have any opinions on this? |
It’s definitely useful for the CC dc simulation, as shifting it to the centers is consistent with the 0 Neumann BC at the top. For the nodal formulation, this is less of an issue as the nodes (which are where the interpolated values live) lay directly on the boundary faces. |
In the original implementation, forcing shifted locations over cell centers only happened for tree meshes. I added a "shift_horizontal" option to the new utilities. By default it is set to True since we mostly use this for electric dipole receivers. |
|
I'm not sure I like the kwarg 'option' for setting discrete surface topography base on the top or center of cells. In the original utilities it was fine because the number of input arguments was small. We may want to choose something more descriptive? Although it might mean I need to change the deprecation of the original functionality. Thoughts? |
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.
Thanks for putting this together, @dccowan. I left a few comments below. Nothing too big. Let me know what do you think.
simpeg/utils/mesh_utils.py
Outdated
| (n, dim) numpy.ndarray | ||
| xy[z] topography. |
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.
By reading the code I noticed that for a TensorMesh, the function returns a mesh and an array. While for the TreeMesh case, it returns two arrays.
Would it be possible to stay with only one type of output? Also, we should update the docstrings so the returns match the output of the function.
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.
For the TensorMesh, it looks like we are leveraging the closest_points_index method. But the TreeMesh class also appears to have the method closest_points_index. I'll need to think a little bit more about what we want the outputs to be for functionality that users will interact with.
What about naming it to something like shift_to_discrete_topography(
mesh,
pts,
active_cells,
shift_vertically_on="top",
shift_horizontal=shift_horizontal,
heights=heights,
)If we are going for a change in the signature of the function (and not just renaming it), I think we could avoid using the simpeg/simpeg/potential_fields/gravity/survey.py Lines 109 to 133 in cba34e9
Just note that we import it through simpeg/simpeg/potential_fields/gravity/survey.py Lines 5 to 11 in cba34e9
|
…impeg into nsem-project-to-surface
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Bump version in which we'll remove the deprecated functions to v0.27.0. We want to keep deprecated functions at least during two minor releases since their deprecation.
There's no point in changing the argument name here. We deprecated the function already, let's keep it as is, we'll remove it in two minor releases anyways.
There's no point in removing the kwargs and the error after invalid argument. We'll remove this function in two minor releases anyways.
Add deprecated admonition to docstring.
Restore the tests for deprecated indActive argument. Reuse the same fixtures for both tests. Filter warnings when gettopoCC is called in the other deprecated function, so users don't get warnings they cannot address.
This branch requires functionalities that became available in discretize v0.12.
Change wording: it's testing for a warning instead of an error.
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.
@dccowan, I just pushed a few changes. Mostly related to the deprecation warnings, admonitions and tests. We remove deprecated bits of code after two minor releases since the deprecation is released. So, since these functions will be deprecated in v0.25.0 (upcoming release), we should remove them in v0.27.0.
I also restored the old ind_active argument in the deprecated gettopoCC function. Renaming arguments introduces a breaking change. For example, if any user has a code calling that function like: gettopoCC(mesh=mesh, ind_active=active_cells), it will fail if we rename ind_active to active_cells. Since we are going to remove that function in two minor releases anyways I don't think we should care about that.
I also bumped the minimum required version of discretize to v0.12, since we need to use the point2index method here.
I left a few comments below. Check them out and let me know what do you think.
Remove the `dim` argument when calling the `_closest_grid_indices` function.
Summary
The PR adds a utility for shifting locations relative to discrete surface topography.
Squash and Merge Summary
Add new
shift_to_discrete_topographyfunction that shifts locations relative to discrete surface topography. Add also a newget_discrete_topographyfunction that generates discrete topography locations out of a mesh and its active cells. We measure electric fields at the Earth's surface when performing MT surveys. Like DC/IP, the original measurement locations of the electric fields can end up in air cells when we define discrete surface topography. These functions allow the user to shift locations relative to discrete topography on Tensor and Tree meshes. For Airborne NSEM, they also allow the user to preserve the original flight heights. Deprecate the following functions:gettopoCC,drapeTopotoLoc, andclosestPointsGrid.PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.What does this implement/fix?
We measure electric fields at the Earth's surface when performing MT surveys. Like DC/IP, the original measurement locations of the electric fields can end up in air cells when we define discrete surface topography. This utility allows the user to shift locations relative to discrete topography on Tensor and Tree meshes. For Airborne NSEM, this utility also allows the user to preserve the original flight heights.
Additional information
Unlike the DC/IP utility that alters a survey object, this utility is inputs the original locations and outputs the shifted ones. I could see us needing similar functionality for NSEM survey objects if they are created directly by loading some type of data file (like DC/IP).