Skip to content
molivagPublic

About

Open-source preprocessing tool for mesh and model preparation for FEMTIC-based magnetotelluric inversion.

Topics

Resources

Contributing

Stars

12 stars

Watchers

0 watching

Forks

Latest commit

 

History

151 Commits

Folders and files

Repository files navigation

MeshTran

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.


Features (Summary)

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, TetGen and TetGen2Femtic.
  • 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.


Workflow Overview

The typical preprocessing pipeline implemented in MeshTran follows these steps:

  1. Reading configuration file
  2. 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.
  3. Convert geographic coordinates from DEM and EDI files to kilometers UTM coordinates
  4. Transform coordinates into the local mesh reference system
  5. Read from EDI files, impedance tensor data and choose the error floor or assigned error must be applied to the data
  6. Write observe data file.
  7. Validate domain coverage with DEM and asign padding constraints to land only cases.
  8. Define the computational analysis domain in local mesh coordinates
  9. Writing topography, bathymetry and coast line files.
  10. Writing files for surface refinement at site zones and two-dimensional surface mesh
  11. Generating volumetric refinement file below site zones and file for volumetric iterative refinement.
  12. Writing files for model parameter mesh getting resistivity_attr file.
  13. Running a wrapper of makeTetraMesh
  14. Run wrapped TetGen to get volumetric mesh in *.ele,*.edge,*.node,*.face and .neigh files.
  15. Running iterative refinement by makeMtr file preparation.
  16. Running wrapped TetGen2Femtic to convert TetGen mesh into Femtic native mesh format.
  17. Generating input files ready for FEMTIC inversion

Input files generated by MeshTran

Observe data.

  • observe.dat

Geometry.

  • control.dat         →   (surface mesh)
  • topography.dat
  • bathymetry.dat
  • coastline.dat
  • observing_site.dat
  • analysis_domain.dat

Mesh refinement.

  • makeMtr.param
  • obs_site.dat

TetGen and convertion to FEMTIC

  • output.X.node
  • output.X.ele
  • output.X.face
  • output.X.neigh
  • resistivity_attr.dat

FEMTIC inputs

  • resistivity_block_iter0.dat
  • mesh.dat
  • output.*.femtic.vtk

The control.dat file (not generated by MeshTran), which defines the inversion parameters, should be created manually according to the desired configuration.


Repository Structure

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.

Installing and Usage

A preprocessing workflow using MeshTran must follows these steps:

  1. Download the latest version of MeshTran form Releases section.

  2. Change to the extracted directory and compile MeshTran by running:

    make
  3. After copmpilation the directory structure required by MeshTran will have been created.

  4. Put the DEM.xyz and EDI files in its corresponding folder inside preprocessing/ folder.

  5. Provide a configuration file (*.io) in the project root directory and configure the dataset and meshing parameters.

  6. Run the MeshTran preprocessing workflow by:

    ./meshTran
  7. 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.


Example of set_meshtran.io input file.

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.


Integration with MTIF

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.


Dependencies

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.

Build-time

  • Intel OneAPI HPC Toolkit 2024.0
  • Intel ifort 2021.11.1 20231117 (included in the OneAPI described above)
  • Intel MKL 2024.0

Runtime — external CLI tools (invoked via execute_command_line)

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

Required external native Femtic tools (binaries) built/installed separately by the user:

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.


Project Status

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.


Portability

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.


Citation

If you use MeshTran, please cite the software using the GitHub "Cite this repository" button or the DOI assigned by Zenodo.

About

Open-source preprocessing tool for mesh and model preparation for FEMTIC-based magnetotelluric inversion.

Topics

Resources

Contributing

Stars

12 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages