# mtgeophysics/mtpy architecture

> Architecture diagram of the GitHub repository mtgeophysics/mtpy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mtgeophysics/mtpy
- Repository: https://github.com/mtgeophysics/mtpy

## Overview

MTpy is a scientific toolbox for processing, analyzing, modeling, and visualizing magnetotelluric data. A typical user workflow starts with station data in EDI or time-series formats, creates MT response representations, applies analysis or modeling, and inspects results through plots or GIS-oriented outputs. The repository also contains distinct acquisition-format readers, processing tools, and ModEM/Occam/Winglink/WS3D modeling capabilities. Some major subsystems are represented by directory-level nodes because their implementation files were not sampled; edges are limited to documented capabilities and source-index references.

Main entry points: [`mtpy/core/mt.py`](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/mt.py) (MT station), [`mtpy/modeling/ws3dinv.py`](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/ws3dinv.py) (WS3D inversion), [`mtpy/imaging/plotnresponses.py`](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/plotnresponses.py) (Response plots), [`mtpy/core/z.py`](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/z.py) (Impedance and tipper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and responses"]
  node_edi["EDI files<br/>[edi.py]"]
  node_mt["MT station<br/>[mt.py]"]
  node_impedance["Impedance and tipper<br/>[z.py]"]
  node_timeseries["Time series<br/>[ts.py]"]
  node_instrument_readers["Instrument readers"]
  node_transfer_functions["Transfer functions<br/>[tf.py]"]
end

subgraph group_processing["Signal processing"]
  node_birrp["BIRRP processing<br/>[birrp.py]"]
  node_filters["Filtering<br/>[filter.py]"]
end

subgraph group_analysis["Scientific analysis"]
  node_phase_tensor["Phase tensor<br/>[pt.py]"]
  node_geometry["Geometry analysis<br/>[geometry.py]"]
  node_distortion["Distortion analysis<br/>[distortion.py]"]
  node_static_shift["Static shift<br/>[staticshift.py]"]
end

subgraph group_modeling["Modeling"]
  node_modem["ModEM modeling"]
  node_occam["Occam2D modeling<br/>[occam2d.py]"]
  node_winglink["Winglink modeling<br/>[winglink.py]"]
  node_ws3d["WS3D inversion<br/>[ws3dinv.py]"]
end

subgraph group_visualization["Visualization"]
  node_response_plots["Response plots<br/>[plotnresponses.py]"]
  node_phase_maps["Phase tensor maps"]
  node_depth_plots["Depth slices"]
end

subgraph group_infrastructure["Shared utilities"]
  node_gis["GIS transforms<br/>[gis_tools.py]"]
  node_calculator["Scientific calculations<br/>[calculator.py]"]
end

node_user(("MT researcher"))

node_user -->|"supplies data"| node_edi
node_user -->|"supplies data"| node_timeseries
node_edi -->|"loads station data"| node_mt
node_mt -->|"holds responses"| node_impedance
node_impedance -->|"computes from Z"| node_phase_tensor
node_phase_tensor -->|"uses calculations"| node_calculator
node_geometry -->|"uses tensor analysis"| node_phase_tensor
node_distortion -->|"uses geometry"| node_geometry
node_distortion -->|"uses responses"| node_impedance
node_instrument_readers -->|"reads recordings"| node_timeseries
node_instrument_readers -->|"plots responses"| node_response_plots
node_response_plots -->|"uses analysis"| node_phase_tensor
node_response_plots -->|"plots stations"| node_mt
node_ws3d -->|"uses station data"| node_mt
node_ws3d -->|"uses responses"| node_impedance
node_occam -->|"uses layout"| node_winglink
node_modem -->|"supports inversion"| node_user
node_occam -->|"supports modeling"| node_user
node_winglink -->|"supports modeling"| node_user
node_ws3d -->|"supports inversion"| node_user
node_user -->|"processes recordings"| node_birrp
node_user -->|"processes signals"| node_filters
node_user -->|"estimates functions"| node_transfer_functions
node_user -->|"visualizes analysis"| node_phase_maps
node_user -->|"visualizes models"| node_depth_plots
node_mt -->|"converts coordinates"| node_gis
node_ws3d -->|"uses plot tools"| node_response_plots

click node_edi "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/edi.py"
click node_mt "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/mt.py"
click node_impedance "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/z.py"
click node_timeseries "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/ts.py"
click node_instrument_readers "https://github.com/mtgeophysics/mtpy/tree/develop/mtpy/usgs"
click node_transfer_functions "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/tf.py"
click node_birrp "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/birrp.py"
click node_filters "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/filter.py"
click node_phase_tensor "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/pt.py"
click node_geometry "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/geometry.py"
click node_distortion "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/distortion.py"
click node_static_shift "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/staticshift.py"
click node_modem "https://github.com/mtgeophysics/mtpy/tree/develop/mtpy/modeling/modem"
click node_occam "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/occam2d.py"
click node_winglink "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/winglink.py"
click node_ws3d "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/ws3dinv.py"
click node_response_plots "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/plotnresponses.py"
click node_phase_maps "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/phase_tensor_maps.py"
click node_depth_plots "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/plot_depth_slice.py"
click node_gis "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/utils/gis_tools.py"
click node_calculator "https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/utils/calculator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_edi,node_mt,node_impedance,node_timeseries,node_instrument_readers,node_transfer_functions toneBlue
class node_birrp,node_filters toneAmber
class node_phase_tensor,node_geometry,node_distortion,node_static_shift toneMint
class node_modem,node_occam,node_winglink,node_ws3d toneRose
class node_response_plots,node_phase_maps,node_depth_plots,node_user toneIndigo
class node_gis,node_calculator toneTeal
```

## Components

### Data and responses

- [EDI files](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/edi.py): `mtpy/core/edi.py`
- [MT station](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/mt.py): `mtpy/core/mt.py`
- [Impedance and tipper](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/z.py): `mtpy/core/z.py`
- [Time series](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/core/ts.py): `mtpy/core/ts.py`
- [Instrument readers](https://github.com/mtgeophysics/mtpy/tree/develop/mtpy/usgs): `mtpy/usgs`
- [Transfer functions](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/tf.py): `mtpy/processing/tf.py`

### Signal processing

- [BIRRP processing](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/birrp.py): `mtpy/processing/birrp.py`
- [Filtering](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/processing/filter.py): `mtpy/processing/filter.py`

### Scientific analysis

- [Phase tensor](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/pt.py): `mtpy/analysis/pt.py`
- [Geometry analysis](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/geometry.py): `mtpy/analysis/geometry.py`
- [Distortion analysis](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/distortion.py): `mtpy/analysis/distortion.py`
- [Static shift](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/analysis/staticshift.py): `mtpy/analysis/staticshift.py`

### Modeling

- [ModEM modeling](https://github.com/mtgeophysics/mtpy/tree/develop/mtpy/modeling/modem): `mtpy/modeling/modem`
- [Occam2D modeling](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/occam2d.py): `mtpy/modeling/occam2d.py`
- [Winglink modeling](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/winglink.py): `mtpy/modeling/winglink.py`
- [WS3D inversion](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/modeling/ws3dinv.py): `mtpy/modeling/ws3dinv.py`

### Visualization

- [Response plots](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/plotnresponses.py): `mtpy/imaging/plotnresponses.py`
- [Phase tensor maps](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/phase_tensor_maps.py): `mtpy/imaging/phase_tensor_maps.py`
- [Depth slices](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/imaging/plot_depth_slice.py): `mtpy/imaging/plot_depth_slice.py`

### Shared utilities

- [GIS transforms](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/utils/gis_tools.py): `mtpy/utils/gis_tools.py`
- [Scientific calculations](https://github.com/mtgeophysics/mtpy/blob/develop/mtpy/utils/calculator.py): `mtpy/utils/calculator.py`

### Other components

- **MT researcher**

## Connections

- MT researcher → EDI files: supplies data
- MT researcher → Time series: supplies data
- EDI files → MT station: loads station data (evidence: `mtpy/core/mt.py`)
- MT station → Impedance and tipper: holds responses (evidence: `mtpy/core/mt.py`)
- Impedance and tipper → Phase tensor: computes from Z (evidence: `mtpy/analysis/pt.py`)
- Phase tensor → Scientific calculations: uses calculations (evidence: `mtpy/analysis/pt.py`)
- Geometry analysis → Phase tensor: uses tensor analysis (evidence: `mtpy/analysis/geometry.py`)
- Distortion analysis → Geometry analysis: uses geometry (evidence: `mtpy/analysis/distortion.py`)
- Distortion analysis → Impedance and tipper: uses responses (evidence: `mtpy/analysis/distortion.py`)
- Instrument readers → Time series: reads recordings (evidence: `mtpy/usgs/zen.py`)
- Instrument readers → Response plots: plots responses (evidence: `mtpy/usgs/zonge.py`)
- Response plots → Phase tensor: uses analysis (evidence: `mtpy/imaging/plotnresponses.py`)
- Response plots → MT station: plots stations (evidence: `mtpy/imaging/plotnresponses.py`)
- WS3D inversion → MT station: uses station data (evidence: `mtpy/modeling/ws3dinv.py`)
- WS3D inversion → Impedance and tipper: uses responses (evidence: `mtpy/modeling/ws3dinv.py`)
- Occam2D modeling → Winglink modeling: uses layout (evidence: `mtpy/modeling/occam2d.py`)
- ModEM modeling → MT researcher: supports inversion
- Occam2D modeling → MT researcher: supports modeling
- Winglink modeling → MT researcher: supports modeling
- WS3D inversion → MT researcher: supports inversion
- MT researcher → BIRRP processing: processes recordings
- MT researcher → Filtering: processes signals
- MT researcher → Transfer functions: estimates functions
- MT researcher → Phase tensor maps: visualizes analysis
- MT researcher → Depth slices: visualizes models
- MT station → GIS transforms: converts coordinates (evidence: `mtpy/core/mt.py`)
- WS3D inversion → Response plots: uses plot tools (evidence: `mtpy/modeling/ws3dinv.py`)
