pycsamt.format.adapters.mare2dem#

MARE2DEM -> PCSF adapter (Phase 4 of the PCSF format plan).

Converts a completed pycsamt.models.mare2dem.results.InversionResult into a backend-neutral PCSFModel with a mesh_unstructured geometry — MARE2DEM’s real triangular FEM mesh is preserved as-is, never forced onto a rectilinear grid (unlike pycsamt.interp._base.ResistivityModel.from_any, which explicitly raises NotImplementedError for MARE2DEM today).

Unlike Occam2D/ModEM, InversionResult never loads a mesh at all — only the per-region resistivity table (see pycsamt/models/mare2dem/results.py: InversionResult._scan, which scans for .log/.resistivity/.emdata files but no .poly/.node/.ele mesh). Building the actual TriMesh is therefore a separate, already-existing concern (pycsamt.models.mare2dem.tri_mesh.build_survey_mesh() / tri_mesh_from_poly(), both of which need a real Triangle run) — this adapter’s job is only to fold a mesh the caller already has together with the result’s resistivity table, matching the geometry/resistivity split every other adapter in this package follows.

Functions

mare2dem_to_pcsf(result, mesh, *[, ...])

Convert a MARE2DEM InversionResult to a PCSFModel.

pycsamt.format.adapters.mare2dem.mare2dem_to_pcsf(result, mesh, *, stations=None, survey=None, created_by='', crs=None, description='')[source]

Convert a MARE2DEM InversionResult to a PCSFModel.

Parameters:
  • result (InversionResult) – A loaded MARE2DEM working directory with a readable .resistivity file (result.model).

  • mesh (TriMesh) – The real triangular mesh paired with result — the caller provides it (e.g. from pycsamt.models.mare2dem.tri_mesh.tri_mesh_from_poly(), or an in-process constrained triangulation of the run’s own .poly PSLG) since InversionResult does not load one itself. mesh.region_ids must be populated and must match the 1-based region numbering of result.model.resistivity.

  • stations (StationTable, optional) – MARE2DEM’s EMData/EMDataFile receiver geometry has no single reliable per-point name across its MT/CSEM/DC variants, so station identity is not auto-derived here — pass a pre-built table when the caller already has one (e.g. via pycsamt.models.mare2dem.geom.area_of_interest.survey_points() plus the caller’s own naming). Set its lon/lat (e.g. from the same EDI headers the receiver positions were derived from) to make the file self-sufficiently geo-referenced too — the same field pycsamt.format.adapters.occam2d.occam2d_to_pcsf()’s station_lonlat and pycsamt.format.adapters.modem3d.modem3d_to_pcsf()’s own GG_Lat/GG_Lon passthrough populate.

  • survey (SurveyMeta or mapping, optional) – Survey-level metadata, stored the same way as in the other adapters in this package.

  • created_by (str, optional) – Passed straight through to PCSFModel.

  • crs (str, optional) – Passed straight through to PCSFModel.

  • description (str, optional) – Passed straight through to PCSFModel.

Returns:

geometry.kind == "mesh_unstructured". Canonical resistivity is the per-triangle array expanded from result.model.resistivity via mesh.region_ids; the compact per-region table itself is kept in PCSFModel.resistivity_by_region. MARE2DEM’s .resistivity file is already linear ohm.m (confirmed against a real compiled binary — see ResistivityFile’s own docstring), so no resistivity_native/encoding conversion applies here.

Return type:

PCSFModel

Raises:

ValueError – If result has no resistivity model, mesh has no region_ids, a region id falls outside the resistivity table’s range, or the source is anisotropic (only isotropic MARE2DEM models are supported by this adapter today).

Examples

>>> from pycsamt.models.mare2dem.results import InversionResult
>>> from pycsamt.models.mare2dem.tri_mesh import tri_mesh_from_poly
>>> from pycsamt.format.adapters.mare2dem import mare2dem_to_pcsf
>>> from pycsamt.format import write_pcsf
>>> result = InversionResult("mare2dem_run")
>>> mesh = tri_mesh_from_poly("mare2dem_run/mesh.1.poly")
>>> model = mare2dem_to_pcsf(result, mesh)
>>> write_pcsf(model, "mare2dem_run.pcsf")