Skip to content

GEOPY-2490: Parallelize batch 2D inversion#358

Merged
domfournier merged 45 commits intodevelopfrom
GEOPY-2490
Mar 20, 2026
Merged

GEOPY-2490: Parallelize batch 2D inversion#358
domfournier merged 45 commits intodevelopfrom
GEOPY-2490

Conversation

@domfournier
Copy link
Collaborator

@domfournier domfournier commented Mar 9, 2026

GEOPY-2490: Parallelize batch 2D inversion

domfournier and others added 24 commits March 3, 2026 16:03
# Conflicts:
#	simpeg_drivers-assets/uijson/direct_current_2d_forward.ui.json
#	simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json
#	simpeg_drivers-assets/uijson/direct_current_batch2d_inversion.ui.json
#	simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json
#	simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json
#	simpeg_drivers-assets/uijson/induced_polarization_batch2d_inversion.ui.json
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 93.17507% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.78%. Comparing base (d600267) to head (71e91ae).
⚠️ Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
simpeg_drivers/options.py 70.00% 4 Missing and 2 partials ⚠️
simpeg_drivers/utils/regularization.py 63.63% 1 Missing and 3 partials ⚠️
simpeg_drivers/utils/utils.py 93.33% 3 Missing and 1 partial ⚠️
simpeg_drivers/electromagnetics/base_1d_driver.py 72.72% 2 Missing and 1 partial ⚠️
simpeg_drivers/electricals/base_2d.py 97.10% 0 Missing and 2 partials ⚠️
simpeg_drivers/utils/nested.py 94.11% 1 Missing and 1 partial ⚠️
simpeg_drivers/utils/synthetics/driver.py 93.54% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #358      +/-   ##
===========================================
+ Coverage    90.76%   90.78%   +0.01%     
===========================================
  Files          112      112              
  Lines         6388     6389       +1     
  Branches       787      787              
===========================================
+ Hits          5798     5800       +2     
  Misses         405      405              
+ Partials       185      184       -1     
Files with missing lines Coverage Δ
simpeg_drivers/__init__.py 88.88% <ø> (ø)
simpeg_drivers/components/data.py 92.63% <100.00%> (ø)
...drivers/components/factories/directives_factory.py 97.52% <100.00%> (ø)
...g_drivers/components/factories/receiver_factory.py 89.81% <100.00%> (ø)
...drivers/components/factories/simulation_factory.py 98.80% <100.00%> (ø)
simpeg_drivers/components/models.py 90.85% <100.00%> (ø)
simpeg_drivers/components/topography.py 93.65% <100.00%> (ø)
simpeg_drivers/driver.py 85.30% <100.00%> (ø)
...lectricals/direct_current/two_dimensions/driver.py 100.00% <100.00%> (ø)
...ectricals/direct_current/two_dimensions/options.py 100.00% <100.00%> (ø)
... and 15 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@benk-mira benk-mira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice use of utilities for separation of concerns and documenting the drape model handling! Couple suggestions

Copilot AI review requested due to automatic review settings March 13, 2026 22:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR (GEOPY-2490) refactors the 2D DC/IP inversion workflow by consolidating the "batch 2D" (pseudo-3D) approach into the standard 2D driver. Instead of running each survey line independently via a LineSweepDriver, the 2D drivers now internally handle multi-line surveys by creating a merged DrapeModel mesh and splitting tiles per line.

Changes:

  • Removed the LineSweepDriver, BaseBatch2DDriver, and all pseudo-3D option/driver classes, redirecting pseudo-3D inversion types to the 2D drivers with deprecation warnings.
  • Introduced Base2DDriver and Base2DOptions in a new electricals/base_2d.py that handles DrapeModel mesh creation per line and line-based tiling.
  • Refactored mesh/survey utilities (drape_2_tensor, get_drape_model, compute_alongline_distance, get_parts_from_electrodes, create_mesh_by_line_id) and updated nested mesh creation to support 2D tensor meshes.

Reviewed changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
simpeg_drivers/electricals/base_2d.py New base class for 2D DC/IP drivers and options with pseudo-3D deprecation handling
simpeg_drivers/electricals/driver.py Removed old Base2DDriver and BaseBatch2DDriver
simpeg_drivers/electricals/options.py Removed; IPModelOptions moved to simpeg_drivers/options.py
simpeg_drivers/line_sweep/driver.py Removed LineSweepDriver
simpeg_drivers/options.py Added IPModelOptions, made LineSelectionOptions fields optional, updated gradient orientation handling
simpeg_drivers/utils/utils.py Refactored drape_2_tensor for ghost prism handling, moved compute_alongline_distance, removed truncate_locs_depths
simpeg_drivers/utils/surveys.py Added get_parts_from_electrodes, create_mesh_by_line_id, and related helpers
simpeg_drivers/utils/nested.py Added create_nested_2d_tensor for 2D line-based tiling
simpeg_drivers/components/data.py Refactored parts detection, drape location handling, line ID management
simpeg_drivers/driver.py Updated tiling to split per line for 2D; removed SweepParams references
simpeg_drivers/__init__.py Redirected pseudo-3D driver map entries to 2D drivers
simpeg_drivers/utils/regularization.py direction_and_dip now returns Data objects instead of arrays
simpeg_drivers/components/models.py Apply np.deg2rad to gradient direction/dip
simpeg_drivers/components/factories/* Updated simulation/directive factories for 2D changes
simpeg_drivers/utils/synthetics/* Refactored mesh factory, removed tensor mesh module, updated driver caching
simpeg_drivers-assets/uijson/* Removed batch2D UI JSONs, updated 2D UI JSONs with optional line selection
tests/run_tests/* Updated tests for new 2D workflow, removed batch2D tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sebhmg sebhmg changed the title GEOPY-2490 GEOPY-2490: Parallelize batch 2D inversion Mar 16, 2026
benk-mira
benk-mira previously approved these changes Mar 17, 2026
Copy link
Contributor

@benk-mira benk-mira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple small suggestions. I think I caught a couple of typing inconsistencies that mypy should have picked up - is it configured properly?

)
line_id: int | None = None
line_object: IntegerData | ReferencedData | None = None
property: ReferencedData | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name this 'line_selection' property is pretty vague

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because it comes from the uijson directly, as defined by the form

@domfournier domfournier merged commit a9a6e21 into develop Mar 20, 2026
17 checks passed
@domfournier domfournier deleted the GEOPY-2490 branch March 20, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants