How hkexgroup/resipy works
Purpose and entry points
ResIPy is a Python desktop/API wrapper for R2, cR2, R3t, and cR3t geoelectrical DC/IP forward-modeling and inversion engines. The primary GUI entry point is src/ui.py; the programmatic API is centered on project and survey objects in src/resipy/Project.py and src/resipy/Survey.py. Jupyter workflows are represented by notebooks under jupyter-notebook/.
User-interface and application layer
The standalone GUI drives the same Python project workflow exposed to notebooks. src/ui.py is the main application shell; selection/interactive data operations are separated in src/resipy/SelectPoints.py, while persistent user/application settings are handled by src/resipy/Settings.py. GUI packaging specifications target directory, executable, and macOS distributions: src/ui-dir.spec, src/ui-exe.spec, and src/ui-osx.spec.
Project orchestration and survey model
src/resipy/Project.py is the central control boundary: it assembles surveys, inversion settings, meshes, external solver inputs, and results into a project lifecycle. src/resipy/Survey.py represents imported measurement datasets and their processing state. DC/IP-specific calculations are supported by src/resipy/DCA.py; time-lapse, 2D/3D, forward, and cross-borehole workflows are expressed as project/survey configurations rather than separate applications.
Import, normalization, and quality processing
Raw instrument and protocol formats enter through src/resipy/parsers.py, which supports the instrument families documented in the README. Imported observations are normalized into survey data structures, then filtered/error-processed before solver preparation. Reciprocal-measurement handling is implemented in compiled extension source src/resipy/recipCalc.pyx; interpolation support is in src/resipy/interpolation.py. Representative source datasets and parser compatibility fixtures live under src/examples/parser/.
Electrode protocols and modeling inputs
Acquisition configurations and electrode quadrupoles can be generated or manipulated through src/resipy/protocol.py and src/resipy/seqGen.py. The project layer combines these with electrode coordinates, topography, data/error models, and inversion controls to construct solver-ready configurations. Example 2D, 3D, IP, and time-lapse input layouts are organized under src/examples/dc-2d/, src/examples/dc-3d/, and src/examples/ip-2d/.
Mesh generation and spatial boundary
Mesh construction is a distinct boundary between geophysical survey geometry and numerical inversion. src/resipy/gmshWrap.py integrates Gmsh-based mesh generation, while src/resipy/meshTools.py and compiled src/resipy/meshCalc.pyx support mesh operations. The bundled mesher is src/resipy/exe/gmsh.exe; users may also supply mesh assets such as those in src/examples/mesh/. Mesh slicing/export-oriented operations are separated in src/resipy/sliceMesh.py.
External solver execution and results
Python does not implement the principal inversion engine; it generates inputs, launches bundled R-family executables, and consumes their outputs. Solver input serialization is concentrated in src/resipy/r2in.py, with solver support utilities in src/resipy/r2help.py. Material executables are under src/resipy/exe/R2.exe, src/resipy/exe/cR2.exe, src/resipy/exe/R3t.exe, and src/resipy/exe/cR3t.exe. They are Windows binaries; Linux/macOS execution requires Wine. Results and project artifacts are written via src/resipy/saveData.py.
Runtime, distribution, and documentation
The runtime is Python with Cython extension sources and Windows solver/meshing executables. Source builds and Python package publication are driven from src/setup.py, src/build.sh, and src/build-pypi.sh; application bundling is supported by src/build-app.sh. Documentation and executable notebook examples are maintained in doc/ and jupyter-notebook/, providing the main API-facing integration path.
Main entry points: Project.py Project Lifecycle · gmshWrap.py Mesh Generation · ui.py Desktop GUI · Survey.py Survey Data
Components 18
User Interfaces
- Desktop GUI · Standalone interface for the project workflow.
src/ui.py - Jupyter Workflows
- Point Selection
src/resipy/SelectPoints.py - Application Settings
src/resipy/Settings.py
Project & Data Core
- Project Lifecycle · Coordinates surveys, mesh, solver setup, execution, and results.
src/resipy/Project.py - Survey Data · Imported observations and their processing state.
src/resipy/Survey.py - Instrument Parsers
src/resipy/parsers.py - Quality Processing
src/resipy/recipCalc.pyx - DC/IP Calculations
src/resipy/DCA.py
Preparation & Mesh
- Protocols & Sequences
src/resipy/protocol.py - Mesh Generation · Builds numerical meshes from survey geometry and spatial inputs.
src/resipy/gmshWrap.py - Mesh Operations
src/resipy/meshTools.py - Bundled Gmsh
src/resipy/exe/gmsh.exe
Solver Execution
- Solver Input Writer
src/resipy/r2in.py - R-family Solvers · Bundled R2, cR2, R3t, and cR3t Windows executables.
src/resipy/exe/R2.exe - Results & Artifacts
src/resipy/saveData.py
Distribution & Learning
- Build & Packaging · Builds Python packages and desktop application bundles.
src/setup.py - Documentation
Connections 20
- Desktop GUI → Project Lifecycle: drives
- Desktop GUI → Point Selection: uses
- Desktop GUI → Application Settings: persists preferences
- Jupyter Workflows → Project Lifecycle: uses API
- Instrument Parsers → Survey Data: imports and normalizes
- Survey Data → Quality Processing: provides observations
- Quality Processing → Project Lifecycle: processed data
- DC/IP Calculations → Project Lifecycle: supports DC/IP workflows
- Project Lifecycle → Survey Data: assembles
- Protocols & Sequences → Project Lifecycle: electrode configurations
- Project Lifecycle → Mesh Generation: requests mesh
- Mesh Generation → Mesh Operations: uses
- Mesh Generation → Bundled Gmsh: launches
- Project Lifecycle → Solver Input Writer: prepares controls and data
- Mesh Generation → Solver Input Writer: provides mesh
- Solver Input Writer → R-family Solvers: serializes inputs and launches
- R-family Solvers → Results & Artifacts: produces outputs
- Results & Artifacts → Project Lifecycle: loads results
- Documentation → Jupyter Workflows: complements examples
- Build & Packaging → Desktop GUI: packages