pycsamt.map.inversion#

Import geophysical inversion results into MapData.

A ModEM run inverts one 3-D resistivity volume for the whole survey — individual lines are not separate model files, they are paths of stations through that one volume. load_modem_lines() slices that volume into one 2-D vertical curtain per survey line (see pycsamt.models.modem.section) and returns a MapData carrying real station coordinates plus the precomputed sections, so the existing 3-D fence/depth builders in pycsamt.map.volume render inversion-sourced lines exactly like EDI-sourced ones — same real-geometry line placement, same UI.

Geo-referencing station coordinates#

Three sources are tried, in order, for each ModEM station:

  1. known_stations — a previously-loaded EDI MapData’s stations, matched by station id. Recommended: works for any inversion backend and lets a matched station’s line/elevation override the (less complete) values recoverable from the ModEM files alone.

  2. The ModEM .dat file’s own GG_Lat/GG_Lon columns (see pycsamt.models.modem.data.ModEmData.site_lonlat).

  3. Neither — the station keeps latitude=longitude=None and the 3-D builder falls back to synthetic index-based line spacing for that line (see pycsamt.map.geometry).

Functions

group_modem_stations(station_names, *[, ...])

Group ModEM station names into survey lines.

load_modem_lines(folder, *[, ...])

Load a ModEM 3-D inversion result folder as a multi-line MapData.

pycsamt.map.inversion.group_modem_stations(station_names, *, known_stations=None)[source]#

Group ModEM station names into survey lines.

Prefers matching each name against known_stations (e.g. previously loaded EDI stations) and using their line tag. Falls back to parsing the line token out of the station-name convention {survey}-{line}-{station}{suffix} (e.g. 23-18-001A -> line 18) — a heuristic, used only when a station has no match in known_stations.

Parameters:
Return type:

dict[str, list[str]]

pycsamt.map.inversion.load_modem_lines(folder, *, known_stations=None, fetch_elevation=True, verbose=0)[source]#

Load a ModEM 3-D inversion result folder as a multi-line MapData.

Parameters:
  • folder (path-like) – A ModEM output directory. The matching final-iteration .rho/.dat pair is auto-detected by pycsamt.models.modem.results.InversionResult.

  • known_stations (iterable of StationRecord, optional) – Previously-loaded EDI stations (e.g. existing_map_data.stations) used to geo-reference and group ModEM stations by real coordinates/line name — see the module docstring.

  • fetch_elevation (bool, default True) – ModEM output carries no real elevation (unlike EDI, where it’s already in the file header, so “Drape topography” just works). When True, any station still missing an elevation after known_stations matching gets a best-effort online lookup (Open-Meteo) so topography isn’t silently flat by default. Failures (offline, API error, …) are swallowed — elevation simply stays unset, same as passing False.

  • verbose (int, default 0) – Verbosity forwarded to the ModEM readers.

Returns:

sites=None (no EDI backing); stations carries one StationRecord per ModEM station with coordinates resolved where possible; metadata["sections"] carries the precomputed per-line (x, z, rho) curtains consumed directly by pycsamt.map.volume.

Return type:

MapData