Skip to content
View MooSobh's full-sized avatar

Block or report MooSobh

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Content in all repositories owned by your account will be closed.
Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. Markdown is supported. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
MooSobh/README.md

Wadi Ghadir gravity and magnetic survey – processing chains

Prepared by Dr. Mohamed Sobh, LIAG (Leibniz Institute for Applied Geophysics)

Reproducible processing of the January 2026 Wadi Ghadir (Eastern Desert, Egypt) survey:

  • Gravity: two Scintrex CG-6 meters (#0640 and #0313), GNSS station coordinates, Copernicus GLO-30 DEM and EGM2008 geoid. Products: free-air, simple and complete (terrain-corrected) Bouguer anomalies relative to base 100 for ρ = 2.0–3.0 g/cm³, and Nettleton density analysis.
  • Magnetics: diurnally corrected total field. Products: QC and despiking, IGRF-14 anomaly, grids and reduction to the pole.

The technical report is report/REPORT.md. An HTML version with embedded figures is in report/REPORT.html.

1 Installation

With conda or mamba (recommended: rasterio and pyproj come with their binary libraries):

conda env create -f environment.yml
conda activate wghadir
python -m pytest -q              # 18 tests, about 10 s

With pip, using an existing Python ≥ 3.10:

python -m pip install -r requirements.txt
python -m pip install -e .       # optional: makes `import wghadir` work from anywhere

2 Running the chains

Step by step in Jupyter (recommended for checking every intermediate result):

jupyter lab notebooks/
  • notebooks/01_Gravity_Processing.ipynb: gravity, steps 1–14, from loading the CG-6 files to the maps.
  • notebooks/02_Magnetic_Processing.ipynb: magnetics, steps 1–8, from loading the workbook to the RTP map.
  • notebooks/03_Gravity_OpenSource_Workflow.ipynb: gravity from readings to maps with the open-source stack: pygtide/ETERNA (tide), Boule (normal gravity, gravity disturbance), Harmonica and Choclo (Bouguer and terrain prisms, equivalent sources, filters), Verde (gridding), SGTool (derivatives, tilt angle) and PyGMT (maps). Results go to outputs/open_source/.
  • notebooks/04_Section_Modelling_pyGIMLi_SimPEG.ipynb: a cross-section A–B through the residual Bouguer anomaly of notebook 03, 2-D forward modelling with polygons and a depth-weighted 2-D inversion with pyGIMLi (with L-curve), and a 3-D inversion of the gridded residual with SimPEG. Results go to outputs/modelling/.
  • notebooks/05_Magnetic_Modelling_pyGIMLi_SimPEG.ipynb: the strongest magnetic anomaly (south-west) in 3-D: a best-fitting block and a depth-weighted inversion with pyGIMLi (MagneticsModelling, Holstein kernels) and a susceptibility inversion with χ ≥ 0 with SimPEG, cut along a north–south section. Results go to outputs/modelling_magnetic/.
  • notebooks/06_SimPEG_Gravity_Inversion.ipynb, 07_SimPEG_Magnetic_Inversion.ipynb and 08_SimPEG_Joint_Inversion.ipynb: 3-D inversions of the whole survey with SimPEG on one common mesh below the Copernicus topography: density contrast from the residual complete Bouguer stations (06), susceptibility with χ ≥ 0 from the magnetic readings (07), and both together coupled by a cross-gradient term (08), with data fits, slices, sections, structural similarity and a joint classification. All three are compact inversions: sparse norms (p = 0 on the model, p = 1 on its gradients) solved by iteratively re-weighted least squares (IRLS) within realistic bounds (Δρ ±0.3 g/cm³, χ 0–0.3 SI); the smooth L2 models are run first and kept for comparison. Shared code: wghadir/inversion.py; results in outputs/inversion/ (NumPy, UBC-GIF, CSV). The executed notebooks are also in notebooks/html/ as stand-alone web pages.

Each step has a ✏️ PARAMETERS cell (thresholds, densities, grid spacing and so on, all editable), a ▶ PROCESSING cell that calls the wghadir functions directly, and a 📊 RESULT cell with tables and plots made in the notebook. After a change, re-run that step and the steps below it. The default parameters reproduce the delivered results.

Interactive lab in the browser: open web/Wadi_Ghadir_Gravity_Lab.html in any browser (no installation). It runs the gravity chain in JavaScript on the raw CG-6 files, with every parameter adjustable, and accepts your own CG-6 exports and station table (chapter 2.1). After gridding (5.1) it offers 16 filters and the power spectrum (5.2), cross-sections drawn on the map (6.1), 2-D forward modelling with draggable polygons (6.2), a depth-weighted 2-D inversion with L-curve (6.3), the pyGIMLi and SimPEG results of notebook 04 (6.4), and exports (7.2).

Interactive magnetic lab: web/Wadi_Ghadir_Magnetic_Lab.html runs the magnetic chain the same way, from the readings (workbook or CSV, chapter 2.1) through day segments, Hampel despike, IGRF-14, crossovers, gridding and reduction to the pole to filters and the power spectrum, cross-sections, 2-D magnetic forward modelling (polygons with susceptibility and remanence), a 2-D susceptibility inversion with χ ≥ 0 and the pyGIMLi and SimPEG results of notebook 05. Rebuild it with python scripts/build_magnetic_lab.py. Rebuild it after changing the Python results with python scripts/build_gravity_lab.py; its sources are in web/src/.

Inversion explorer: web/Wadi_Ghadir_Inversion_Explorer.html shows the SimPEG inversions of notebooks 06–08 interactively: horizontal slices at any elevation, vertical sections along preset or hand-drawn lines, a 3-D view of the anomalous cells under the terrain, side-by-side comparison of any two models (compact, smooth, joint, joint units), the data fit of every model (maps, cross-plot, residual histogram) and the convergence of every run. Rebuild it with python scripts/build_inversion_explorer.py after running the notebooks.

From the command line:

python scripts/run_all.py                # gravity, then magnetics (~5 min incl. 400 dpi maps)
python scripts/run_gravity.py            # gravity only   (--no-figures: ~1 min)
python scripts/run_magnetics.py          # magnetics only (~1 min)
python scripts/build_gravity_lab.py      # rebuild web/Wadi_Ghadir_Gravity_Lab.html
python scripts/build_magnetic_lab.py     # rebuild web/Wadi_Ghadir_Magnetic_Lab.html
python scripts/build_inversion_explorer.py  # rebuild web/Wadi_Ghadir_Inversion_Explorer.html

From Python:

from wghadir.chains import GravityChain, MagneticChain

g = GravityChain(raw_dir="data/raw", external_dir="data/external", out_dir="outputs")
g.step01_inventory()          # ... each step can be run and inspected separately
g.run_all()                   # or all 14 steps

m = MagneticChain(mag_file="data/raw/magnetics/All_Data_Corrected_Total_Intensity.xlsx", out_dir="outputs")
m.run_all()

Gravity step 7 needs the Copernicus GLO-30 DEM window (12 MB) and the EGM2008 geoid window in data/external/. Both are in the repository. In the code-only zip (Wadi_Ghadir_Processing_Chains.zip) the DEM is left out to keep the download small, and step 7 downloads it automatically on the first run (internet needed once; it is then cached).

3 The processing steps

Gravity (GravityChain) Magnetics (MagneticChain)
1 inventory, SHA-256, CG-6 metadata 1 load rows, UTM 36N, survey days
2 check CorrGrav = Raw + Tide + Tilt + Temp + Drift 2 despike (Hampel filter per day)
3 Longman tide at the GPS position (UTC) 3 IGRF-14 → anomaly TMA = TMI − IGRF
4 row QC (StdDev, tilt, overflow, frozen sensor, repeats) 4 day summary, crossovers, IGRF date sensitivity
5 station occupations 5 gridding of TMI and TMA
6 GNSS parsing, datum check, day mapping, matching 6 reduction to the pole (FFT)
7 EGM2008 orthometric heights, DEM comparison 7 maps: points and grids
8 base-100 control, drift model, closures 8 export: tables, grids, workbook
9 instrument scale factor and re-ties
10 free-air and simple Bouguer anomalies
11 DEM terrain correction, complete Bouguer anomalies
12 Nettleton density (profiles, windows, consensus)
13 summary and deliverables (xlsx, csv, geojson, kml)
14 QC figures, maps, grids, Nettleton sheets

All tunable values are in wghadir/gravity/settings.py and wghadir/magnetic/settings.py.

4 Layout

environment.yml, requirements.txt, pyproject.toml   installation
notebooks/                 01_Gravity_Processing, 02_Magnetic_Processing, 03_Gravity_OpenSource_Workflow,
                           04_Section_Modelling_pyGIMLi_SimPEG, 05_Magnetic_Modelling_pyGIMLi_SimPEG,
                           06/07/08_SimPEG_{Gravity,Magnetic,Joint}_Inversion (.ipynb); html/ (web versions)
web/                       Wadi_Ghadir_Gravity_Lab.html, Wadi_Ghadir_Magnetic_Lab.html (interactive labs), Wadi_Ghadir_Inversion_Explorer.html, sources in web/src/
third_party/sgtool/        SGTool filter engine (MIT, vendored unchanged; see its README)
scripts/                   run_all.py, run_gravity.py, run_magnetics.py, build_report_html.py, make_package.py
wghadir/
  chains/gravity.py        GravityChain   – the gravity chain, steps 1-14
  chains/magnetic.py       MagneticChain  – the magnetic chain, steps 1-8
  gravity/                 settings, cg6 reader, tide, qc, gnss, inventory, positioning, base_control,
                           instruments, reduce, terrain, reductions, nettleton, density,
                           figures, maps, nettleton_figs, export
  magnetic/                settings, processing (QC, IGRF, gridding, RTP), maps, export
  common/                  geodata (DEM, geoid), mapping (map style), excel, display (notebooks)
tests/                     regression tests (python -m pytest -q)
data/raw/                  supplied files, unchanged (SHA-256 in outputs/tables/01_file_inventory.csv)
data/external/             Copernicus GLO-30 and EGM2008 windows used (with provenance)
outputs/                   results: deliverables/, tables/, maps/, grids/, figures/, nettleton/, magnetics/,
                           open_source/ (notebook 03), modelling/ (notebook 04), modelling_magnetic/ (notebook 05),
                           inversion/ (notebooks 06-08)
report/                    REPORT.md and REPORT.html
reference_results/         (zip only) delivered result sheets and summaries, to compare a local run with

5 Status of the products

Product Status
Δg relative to base 100, per station, with QC and drift control ready (985 field stations)
Free-air, simple Bouguer and complete (terrain-corrected) Bouguer anomalies relative to base 100, ρ = 2.0–3.0 g/cm³ ready (EGM2008 orthometric heights; Copernicus GLO-30 terrain correction)
Maps (11), Nettleton sheets (22 profiles), grids (NetCDF/XYZ), Excel workbook, GeoJSON, KML ready
Ground magnetics: total field (points and grid), IGRF-14 anomaly, reduced-to-pole, Excel workbook ready (IGRF date assumed: 20 Jan 2026)
Absolute anomalies not possible without an absolute gravity tie
Bouguer density working value 2.67 g/cm³; robust Nettleton profiles 2.71–2.96 g/cm³ (report §4.3)

Popular repositories Loading

  1. GHF_Germany GHF_Germany Public

    Jupyter Notebook 1

  2. MooSobh MooSobh Public

    Config files for my GitHub profile.

    HTML

  3. Wei-and-Sun-2021-uncertainty Wei-and-Sun-2021-uncertainty Public

    Forked from simpeg-research/Wei-and-Sun-2021-uncertainty

    Python

  4. PlateFlex PlateFlex Public

    Forked from paudetseis/PlateFlex

    Estimating effective elastic thickness of the lithosphere

    Jupyter Notebook

  5. awesome-open-geoscience awesome-open-geoscience Public

    Forked from softwareunderground/awesome-open-geoscience

    Curated from repositories that make our lives as geoscientists, hackers and data wranglers easier or just more awesome

    1

  6. Aq1 Aq1 Public

    Forked from TobbeTripitaka/Aq1

    Antarctic heat flow models

    Jupyter Notebook