MESH TRANsformation utilities for FEMTIC-based magnetotelluric inverse modeling.
MeshTran is an open-source preprocessing toolkit designed to prepare spatial data and computational domains for the Finite Element Magnetotelluric Inversion Code, FEMTIC (Y. Usui, 2015). The objective of this project is not to replace FEMTIC utilities, but to provide a structured preprocessing layer that simplifies tasks such as, coordinate transformations, domain definition, mesh preparation and data manipulation. Steps commonly required before running large-scale MT inversions.
The toolkit focuses on reproducibly preparing FEMTIC input files from observational data and geospatial datasets. In particular, MeshTran aims to reduce the complexity of preparing FEMTIC preprocessing input data by letting a single configuration file control most mesh-preparation steps.
MeshTran is also designed as a component of the broader MTIF (Magnetotelluric Inversion Framework) ecosystem, where it acts as the geometry and preprocessing layer before running the inversion workflow.
Current utilities support the following preprocessing tasks:
- Reading MT station information from EDI files.
- Coordinate transformation (latitude/longitude → UTM → Local mesh coordinates).
- Automatic centering of the computational domain based on the spatial center of MT stations.
- Land-Sea clasification.
- Extraction and simplification of the main coastline from the Digital Elevation Model (DEM).
- Integration of topography, bathymetry, and coastline data.
- Basic validation utilities for domain consistency UTM - local and coast line location.
- Preparation of geometry and inputs for
makeTetraMesh,TetGenandTetGen2Femtic. - Simplified configuration of FEMTIC meshing parameters through a simple input file.
- Flexible treatment of data errors through either an error floor or a user-defined percentage error.
- Option to enhance the response at high frequency by adding a dummy station for the Vertical Transfer Function.
A key goal of MeshTran is to simplify FEMTIC mesh configuration. Instead of manually editing multiple preprocessing files, users can define the required parameters in a single configuration input file, from which MeshTran generates the corresponding FEMTIC input files.
The typical preprocessing pipeline implemented in MeshTran follows these steps:
- Reading configuration file
- Read DEM and EDI files, extracting latitude, longitude, and elevation.
- 1.1 For the study cases involves sea, extracting coast line.
- 1.2 Performing the ray casting algorithm to land-sea classification.
- Convert geographic coordinates from DEM and EDI files to kilometers UTM coordinates
- Transform coordinates into the local mesh reference system
- Read from EDI files, impedance tensor data and choose the error floor or assigned error must be applied to the data
- Write observe data file.
- Validate domain coverage with DEM and asign padding constraints to land only cases.
- Define the computational analysis domain in local mesh coordinates
- Writing topography, bathymetry and coast line files.
- Writing files for surface refinement at site zones and two-dimensional surface mesh
- Generating volumetric refinement file below site zones and file for volumetric iterative refinement.
- Writing files for model parameter mesh getting resistivity_attr file.
- Running a wrapper of makeTetraMesh
- Run wrapped
TetGento get volumetric mesh in*.ele,*.edge,*.node,*.faceand.neighfiles. - Running iterative refinement by
makeMtrfile preparation. - Running wrapped
TetGen2Femticto convert TetGen mesh into Femtic native mesh format. - Generating input files ready for FEMTIC inversion
observe.dat
control.dat→ (surface mesh)topography.datbathymetry.datcoastline.datobserving_site.datanalysis_domain.dat
makeMtr.paramobs_site.dat
output.X.nodeoutput.X.eleoutput.X.faceoutput.X.neighresistivity_attr.dat
resistivity_block_iter0.datmesh.datoutput.*.femtic.vtk
The control.dat file (not generated by MeshTran), which defines the inversion parameters, should be created manually according to the desired configuration.
The repository is organized as follows:
MeshTran/
├─ Makefile
├── readme.md
├── contributing.md
├── LICENSE.md
├── computing/
├── meshTran (executable must be compiled)
├── mod/
├── settingmeshtran.io
│
├── preprocessing/
│ ├── buildMesh/
│ ├── DEM/
│ ├── edi_files/
│ ├── edi_sites/
│ ├── geometry/
│ └── PlotWithPython/
│
└── src/
The structure may evolve as the project matures.
A preprocessing workflow using MeshTran must follows these steps:
-
Download the latest version of MeshTran form Releases section.
-
Change to the extracted directory and compile MeshTran by running:
make
-
After copmpilation the directory structure required by MeshTran will have been created.
-
Put the
DEM.xyzandEDI filesin its corresponding folder insidepreprocessing/folder. -
Provide a configuration file (
*.io) in the project root directory and configure the dataset and meshing parameters. -
Run the MeshTran preprocessing workflow by:
./meshTran
-
After MeshTran execution, the FEMTIC input files inversion will have been written in
computing/folder.
By these simple steps it processes station data, prepares the computational domain, and generates the required input files for FEMTIC inversion.
See the MeshTran Wiki for a detailed example of input file configuratio. Also there is
available an Input File Explanation in the wiki if you want to check the description of each parameter of set_meshtran.io.
MeshTran is designed to function as a preprocessing component within the MTIF (Magnetotelluric Inversion Framework).
Within MTIF, configuration is typically handled using structured configuration files (e.g. TOML), which are more expressive and easier to maintain than the traditional FEMTIC plaintext input files.
MeshTran acts as the intermediate layer that translates these higher-level configuration parameters into the FEMTIC input format required by the meshing and inversion pipeline.
MeshTran is a Linux tool. At build time it only links against the Intel
toolchain below; all geometry/topography processing is delegated to external
CLI tools invoked as subprocesses via Fortran's execute_command_line, which
must be available on $PATH.
- Intel OneAPI HPC Toolkit 2024.0
- Intel ifort 2021.11.1 20231117 (included in the OneAPI described above)
- Intel MKL 2024.0
| Tool | Version Tested | Used For |
|---|---|---|
gdal_contour |
GDAL 3.9.3 (2024-10-07) | Coastline contour extraction from DEM (GeoJSON) |
jq |
1.7.1 | Parse coastline GeoJSON into coordinate CSV |
ogr2ogr |
GDAL 3.9.3 (2024-10-07) | Convert line geometry to Shapefile |
ogrinfo |
GDAL 3.9.3 (2024-10-07) | Inspect Shapefile attributes and IDs |
gnuplot |
6.0 patchlevel 1 | Diagnostic visualization of DEM and coastline |
TetGen |
1.5 (2013-11-04) | Tetrahedral mesh generation |
All the dependencies must be available in $PATH, in order to MeshTran can locate them during its execution.
The TetGen execution parameters can be modified and MeshTran must be recompiled if different meshing behavior is desired.
This project is currently under active development. It continuously adds new features. The current released version already covers the basic preprocessing steps needed to generate the input files for land-only and land-sea magnetotelluric inversions with FEMTIC.
Interfaces and utilities may evolve as the preprocessing workflow matures. The code is primarily developed to support FEMTIC-based magnetotelluric inversions.
Due to the nature of its underlying system calls, MeshTran is a tool focused
primarily on Linux and macOS (Unix-like) systems. For Windows users, a Docker
container is planned to be implemented in the future.
If you use MeshTran, please cite the software using the GitHub "Cite this repository" button or the DOI assigned by Zenodo.