-
Notifications
You must be signed in to change notification settings - Fork 280
Fix distance calculation in convert_survey_3d_to_2d_lines
#1390
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1390 +/- ##
=======================================
Coverage 82.54% 82.54%
=======================================
Files 168 168
Lines 25706 25706
=======================================
Hits 21220 21220
Misses 4486 4486 ☔ View full report in Codecov by Sentry. |
|
Hi @kehrl-kobold! Thanks a lot for opening this PR. From just reading the code, those changes look right. Did you run into this bug while using this function? Do you have any minimal example that can be used to reproduce the bug? I'm asking this because it would be nice to add some tests checking that this bug has been fixed. Basically, a test function that should fail if we run it with the current code in Thanks again for your contribution, it's greatly appreciated! |
|
@santisoler : just an FYI, the function is used in one tutorial: https://docs.simpeg.xyz/content/tutorials/05-dcr/plot_gen_3_3d_to_2d.html. We should at least rerun the tutorial with the update. |
|
Thanks @thibaut-kobold! You're right, the tutorial will be rerun after we get the updated merged. And in the next release the updated docs will be deployed to the website. I just ran a similar example to the one in the tutorial and can confirm that the fix is correctly setting the first coordinate of the south-north lines (the first coordinate in the 2D survey): instead of setting them to -650 or -1350 (as you can see in the final figures in that tutorial), it's setting them to zero, as described in the docstring. So, a nice test for this would be to create a simple 3d DC survey with a west-east and a south-north lines, and check if the dipoles in the 2D survey are correctly, with the first coordinate of the first dipole being equal to zero. Is this something you are interested in doing @kehrl-kobold? |
|
I ran into the bug when setting up a rather complex survey in UTM coordinates, so it's definitely not a good example for a test case. I'm happy to set up a test case, but it may take me a bit of time. Would this be the correct file for a test? |
I just noticed your PR above with the test case. Thanks! |
|
Sounds great! We don't have any rush to merge this, since it's not super critical, so feel free to take your time.
Yes, that file looks like a nice place for these tests.
Great. Feel free to use those as inspiration. I think these tests will need a more complex 3d survey than the one built in those, but the basic structure of the tests shouldn't be too different. Let me know if you need any assistance. And feel free to push changes while you're working on them. There's no need to wait until the work is done to push them to this branch. And actually, is easier for us to provide help when we can see the code. Thanks again for taking the time to tackle this. |
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>
|
@santisoler I added the tests for |
santisoler
left a comment
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 a lot @kehrl-kobold for pushing these changes. I've run the tests with these new changes against the code in main and it fails, therefore the new tests are able to properly catch the bug. Nicely done.
I think this is ready to be merged. I just left two minor comments below, which are not critical for the PR, just some minor improvements to the style.
Thanks again for your contribution. Looking forward to merge this!
Co-authored-by: Santiago Soler <[email protected]>
Co-authored-by: Santiago Soler <[email protected]>
|
Thanks for the suggestions! I've made the updates. |
|
Thanks @kehrl-kobold! I've just updated this branch to get the latest changes in |
convert_survey_3d_to_2d_lines
|
Merged! 🚀 Thanks again for your contribution @kehrl-kobold! Feel free to open a PR to add yourself to the |
…e_simpeg_021 * commit 'fe444e2d714ab1a3f1541575a9f8c4ad1e74894b': (73 commits) Fix distance calculation in `convert_survey_3d_to_2d_lines` (simpeg#1390) Rename spontaneous potential to self potential (simpeg#1422) Lowercase simpeg for generating coverage on Azure (simpeg#1443) Replace SimPEG for simpeg across docstrings (simpeg#1438) Update copyright year in __init__.py (simpeg#1436) Move to a PEP8 compliant package name. (simpeg#1430) Fix rst syntax in release notes for v0.21.0 (simpeg#1434) Replace use of `refine_tree_xyz` in DCIP tutorials (simpeg#1381) Add new Issue template for making a release (simpeg#1410) Safely run reviewdog on `pull_request_target` events (simpeg#1427) Use reviewdog to annotate PR's with black and flake8 errors. (simpeg#1424) Remove the parameters argument from docstring (simpeg#1417) Add release notes for v0.21.1 (simpeg#1416) Fix hard dask dependency (simpeg#1415) Publish documentation on azure (simpeg#1412) Add release notes for SimPEG v0.21 (simpeg#1409) Bump Black version to 24.3.0 (simpeg#1403) Remove link to "twitter" (simpeg#1406) Add Ying and Williams to AUTHORS.rst (simpeg#1405) Dask MetaSim (simpeg#1199) ... # Conflicts: # simpeg/electromagnetics/base_1d_stitched.py # simpeg/electromagnetics/frequency_domain/simulation_1d_stitched.py # simpeg/electromagnetics/time_domain/receivers.py # simpeg/electromagnetics/time_domain/simulation_1d_stitched.py # simpeg/electromagnetics/utils/em1d_utils.py # simpeg/potential_fields/magnetics/_numba_functions.py # simpeg/regularization/laterally_constrained.py # simpeg/regularization/regularization_mesh_lateral.py # simpeg/regularization/rotated.py # simpeg/utils/__init__.py # simpeg/utils/model_utils.py # tests/base/regularizations/test_full_gradient.py # tests/base/regularizations/test_regularization.py # tests/base/test_mass_matrices.py # tests/base/test_model_utils.py # tests/base/test_utils.py # tests/em/fdem/inverse/adjoint/test_FDEM_adjointEB.py # tests/em/fdem/inverse/derivs/test_FDEM_derivs.py # tests/pf/test_forward_Mag_Linear.py
…ting_strategy * commit 'fe444e2d714ab1a3f1541575a9f8c4ad1e74894b': (86 commits) Fix distance calculation in `convert_survey_3d_to_2d_lines` (simpeg#1390) Rename spontaneous potential to self potential (simpeg#1422) Lowercase simpeg for generating coverage on Azure (simpeg#1443) Replace SimPEG for simpeg across docstrings (simpeg#1438) Update copyright year in __init__.py (simpeg#1436) Move to a PEP8 compliant package name. (simpeg#1430) Fix rst syntax in release notes for v0.21.0 (simpeg#1434) Replace use of `refine_tree_xyz` in DCIP tutorials (simpeg#1381) Add new Issue template for making a release (simpeg#1410) Safely run reviewdog on `pull_request_target` events (simpeg#1427) Use reviewdog to annotate PR's with black and flake8 errors. (simpeg#1424) Remove the parameters argument from docstring (simpeg#1417) Add release notes for v0.21.1 (simpeg#1416) Fix hard dask dependency (simpeg#1415) Publish documentation on azure (simpeg#1412) Add release notes for SimPEG v0.21 (simpeg#1409) Bump Black version to 24.3.0 (simpeg#1403) Remove link to "twitter" (simpeg#1406) Add Ying and Williams to AUTHORS.rst (simpeg#1405) Dask MetaSim (simpeg#1199) ... # Conflicts: # simpeg/utils/__init__.py # simpeg/utils/model_utils.py # tests/base/test_model_utils.py
Summary
Fix a bug in the distance calculation in
convert_survey_3d_to_2d_lines. Distance is calculated along the survey line from the first point,r0. Currently,r0[0], which is just thexcomponent, is being subtracted from both thexandycomponents for all points to calculate the distance. Instead,r0should be subtracted. Update tests so they fail without the bugfix.PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.What does this implement/fix?
See above.