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
|
Convert a MARE2DEM |
- pycsamt.format.adapters.mare2dem.mare2dem_to_pcsf(result, mesh, *, stations=None, survey=None, created_by='', crs=None, description='')[source]
Convert a MARE2DEM
InversionResultto aPCSFModel.- Parameters:
result (InversionResult) – A loaded MARE2DEM working directory with a readable
.resistivityfile (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.polyPSLG) sinceInversionResultdoes not load one itself.mesh.region_idsmust be populated and must match the 1-based region numbering ofresult.model.resistivity.stations (StationTable, optional) – MARE2DEM’s
EMData/EMDataFilereceiver 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. viapycsamt.models.mare2dem.geom.area_of_interest.survey_points()plus the caller’s own naming). Set itslon/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 fieldpycsamt.format.adapters.occam2d.occam2d_to_pcsf()’sstation_lonlatandpycsamt.format.adapters.modem3d.modem3d_to_pcsf()’s ownGG_Lat/GG_Lonpassthrough 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". Canonicalresistivityis the per-triangle array expanded fromresult.model.resistivityviamesh.region_ids; the compact per-region table itself is kept inPCSFModel.resistivity_by_region. MARE2DEM’s.resistivityfile is already linear ohm.m (confirmed against a real compiled binary — seeResistivityFile’s own docstring), so noresistivity_native/encoding conversion applies here.- Return type:
- 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")