mtpy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

mtpy - Magnetotelluric Analysis

mtpy - 大地电磁分析

Quick Reference

快速参考

python
from mtpy import MT, MTCollection
python
from mtpy import MT, MTCollection

Read single station

读取单个测站数据

mt = MT('station001.edi')
mt = MT('station001.edi')

Access data

访问数据

Z = mt.Z # Complex impedance tensor freq = mt.frequency # Frequency array rho_xy = mt.apparent_resistivity[:, 0, 1] # Apparent resistivity
Z = mt.Z # 复阻抗张量 freq = mt.frequency # 频率数组 rho_xy = mt.apparent_resistivity[:, 0, 1] # 视电阻率

Station info

测站信息

print(mt.station, mt.latitude, mt.longitude)
print(mt.station, mt.latitude, mt.longitude)

Write EDI

写入EDI文件

mt.write_edi('output.edi')
undefined
mt.write_edi('output.edi')
undefined

Key Classes

核心类

ClassPurpose
MT
Single station MT data container
MTCollection
Multiple stations management
PlotMTResponse
Plot impedance, resistivity, phase
PlotPhaseTensor
Phase tensor ellipse visualization
PlotPseudoSection
Profile pseudosection display
PlotStrike
Strike direction analysis
用途
MT
单个测站MT数据容器
MTCollection
多测站数据管理
PlotMTResponse
绘制阻抗、电阻率、相位
PlotPhaseTensor
相位张量椭圆可视化
PlotPseudoSection
剖面拟断面图展示
PlotStrike
走向方向分析

Essential Operations

关键操作

Load and Inspect EDI

加载并检查EDI文件

python
from mtpy import MT

mt = MT('station001.edi')
print(f"Station: {mt.station}")
print(f"Location: ({mt.latitude}, {mt.longitude})")
print(f"Frequencies: {len(mt.frequency)} points")
print(f"Period range: {1/mt.frequency.max():.2f} - {1/mt.frequency.min():.0f} s")
python
from mtpy import MT

mt = MT('station001.edi')
print(f"测站: {mt.station}")
print(f"位置: ({mt.latitude}, {mt.longitude})")
print(f"频率点数: {len(mt.frequency)} 个")
print(f"周期范围: {1/mt.frequency.max():.2f} - {1/mt.frequency.min():.0f} 秒")

Load Multiple Stations

加载多个测站数据

python
from mtpy import MTCollection

mc = MTCollection()
mc.from_edis('survey_data/*.edi')
print(f"Loaded {len(mc)} stations")

for station in mc:
    print(f"  {station.station}: ({station.latitude:.4f}, {station.longitude:.4f})")
python
from mtpy import MTCollection

mc = MTCollection()
mc.from_edis('survey_data/*.edi')
print(f"已加载 {len(mc)} 个测站")

for station in mc:
    print(f"  {station.station}: ({station.latitude:.4f}, {station.longitude:.4f})")

Plot MT Response

绘制MT响应曲线

python
from mtpy import MT
from mtpy.imaging import PlotMTResponse

mt = MT('station001.edi')
plot = PlotMTResponse(mt)
plot.plot()  # Apparent resistivity and phase
python
from mtpy import MT
from mtpy.imaging import PlotMTResponse

mt = MT('station001.edi')
plot = PlotMTResponse(mt)
plot.plot()  # 绘制视电阻率和相位

Phase Tensor Analysis

相位张量分析

python
from mtpy import MT
from mtpy.imaging import PlotPhaseTensor

mt = MT('station001.edi')
python
from mtpy import MT
from mtpy.imaging import PlotPhaseTensor

mt = MT('station001.edi')

Get phase tensor parameters

获取相位张量参数

phi_min = mt.phase_tensor.phimin phi_max = mt.phase_tensor.phimax skew = mt.phase_tensor.skew # 3D indicator
phi_min = mt.phase_tensor.phimin phi_max = mt.phase_tensor.phimax skew = mt.phase_tensor.skew # 三维结构指示值

Plot

绘图

pt = PlotPhaseTensor(mt) pt.plot()
undefined
pt = PlotPhaseTensor(mt) pt.plot()
undefined

Rotate Impedance Tensor

旋转阻抗张量

python
from mtpy import MT

mt = MT('station001.edi')
mt_rotated = mt.rotate(30)        # 30 degrees clockwise
mt.rotate_to_strike()             # Auto-rotate to geoelectric strike
python
from mtpy import MT

mt = MT('station001.edi')
mt_rotated = mt.rotate(30)        # 顺时针旋转30度
mt.rotate_to_strike()             # 自动旋转到地电走向

Create Pseudosection

创建拟断面图

python
from mtpy import MTCollection
from mtpy.imaging import PlotPseudoSection

mc = MTCollection()
mc.from_edis('profile/*.edi')

ps = PlotPseudoSection(mc)
ps.plot(plot_type='apparent_resistivity', mode='te')  # or 'tm', 'det'
python
from mtpy import MTCollection
from mtpy.imaging import PlotPseudoSection

mc = MTCollection()
mc.from_edis('profile/*.edi')

ps = PlotPseudoSection(mc)
ps.plot(plot_type='apparent_resistivity', mode='te')  # 可选 'tm'、'det'

Export Data

导出数据

python
from mtpy import MT
import pandas as pd

mt = MT('station001.edi')
python
from mtpy import MT
import pandas as pd

mt = MT('station001.edi')

Export to CSV

导出为CSV

df = pd.DataFrame({ 'frequency': mt.frequency, 'rho_xy': mt.apparent_resistivity[:, 0, 1], 'rho_yx': mt.apparent_resistivity[:, 1, 0], 'phase_xy': mt.phase[:, 0, 1], 'phase_yx': mt.phase[:, 1, 0] }) df.to_csv('mt_data.csv', index=False)
df = pd.DataFrame({ 'frequency': mt.frequency, 'rho_xy': mt.apparent_resistivity[:, 0, 1], 'rho_yx': mt.apparent_resistivity[:, 1, 0], 'phase_xy': mt.phase[:, 0, 1], 'phase_yx': mt.phase[:, 1, 0] }) df.to_csv('mt_data.csv', index=False)

Export for ModEM

导出为ModEM格式

mt.write_modem('station001.dat')
undefined
mt.write_modem('station001.dat')
undefined

Impedance Tensor Components

阻抗张量分量

ComponentDescriptionMode
ZxxEx/Bx responseDiagonal (usually small)
ZxyEx/By responseTE mode
ZyxEy/Bx responseTM mode
ZyyEy/By responseDiagonal (usually small)
分量描述模式
ZxxEx/Bx响应对角分量(通常值较小)
ZxyEx/By响应TE模式
ZyxEy/Bx响应TM模式
ZyyEy/By响应对角分量(通常值较小)

Phase Tensor Parameters

相位张量参数

ParameterDescriptionInterpretation
phi_minMinimum phaseRelates to resistivity gradient
phi_maxMaximum phaseRelates to resistivity gradient
skewSkew angle>5 suggests 3D structure
ellipticity(phi_max-phi_min)/(phi_max+phi_min)2D/3D indicator
参数描述解释
phi_min最小相位与电阻率梯度相关
phi_max最大相位与电阻率梯度相关
skew偏斜角>5 表明存在三维结构
ellipticity(phi_max-phi_min)/(phi_max+phi_min)二维/三维结构指示值

When to Use vs Alternatives

适用场景与替代工具对比

ToolBest ForLimitations
mtpyFull MT workflow in Python, EDI I/O, visualization, modelling prepComplex API, evolving between v1 and v2
EMTFUSGS time-series to impedance processingFortran-based, processing only
WinGLinkCommercial integrated MT processing and inversionExpensive commercial license
Use mtpy when you need end-to-end MT analysis in Python: reading EDI files, QC, phase tensor analysis, pseudosections, and preparing data for ModEM or other inversion codes.
Consider alternatives when you need time-series to impedance processing from raw field data (use EMTF), or a fully integrated commercial inversion package with GUI (use WinGLink).
工具适用场景局限性
mtpyPython环境下完整MT工作流、EDI文件读写、可视化、建模准备API较复杂,v1与v2版本间存在演进变化
EMTFUSGS时序数据转阻抗处理基于Fortran,仅支持数据处理
WinGLink商业化集成MT处理与反演工具商业许可费用高昂
选择mtpy的场景:需要在Python环境中完成端到端MT分析,包括读取EDI文件、质量控制、相位张量分析、拟断面图绘制,以及为ModEM或其他反演代码准备数据。
考虑替代工具的场景:需要从野外原始时序数据转换为阻抗数据(使用EMTF),或需要带GUI的全集成商业化反演包(使用WinGLink)。

Common Workflows

常见工作流

Load, QC, and analyze MT station data

加载、质量控制与分析MT测站数据

  • Load EDI file(s) with
    MT()
    or
    MTCollection()
  • Inspect station metadata (location, frequency range)
  • Plot apparent resistivity and phase with
    PlotMTResponse
  • Check phase tensor parameters for dimensionality (skew > 5 = 3D)
  • Identify and mask noisy data points using error thresholds
  • Rotate impedance tensor to geoelectric strike if needed
  • Create pseudosection for profile data
  • Export cleaned data for inversion (ModEM format)
  • 使用
    MT()
    MTCollection()
    加载EDI文件
  • 检查测站元数据(位置、频率范围)
  • 使用
    PlotMTResponse
    绘制视电阻率和相位曲线
  • 检查相位张量参数判断结构维数(偏斜角>5=三维结构)
  • 根据误差阈值识别并屏蔽噪声数据点
  • 必要时将阻抗张量旋转到地电走向
  • 为剖面数据创建拟断面图
  • 导出清理后的数据用于反演(ModEM格式)

Common Issues

常见问题

IssueSolution
No tipper dataCheck
mt.has_tipper
before accessing
Bad data pointsUse
mt.Z_err / np.abs(mt.Z) > threshold
to mask
Static shiftApply correction before interpretation
Wrong rotationVerify coordinate system (N vs E convention)
问题解决方案
无倾子数据访问前先检查
mt.has_tipper
不良数据点使用
mt.Z_err / np.abs(mt.Z) > threshold
进行屏蔽
静态偏移解释前先应用校正
旋转方向错误验证坐标系(北/东约定)

References

参考资料

  • EDI Format - EDI file structure and sections
  • Plotting Options - Visualization parameters and styles
  • EDI格式 - EDI文件结构与章节说明
  • 绘图选项 - 可视化参数与样式

Scripts

脚本

  • scripts/mt_analysis.py - MT data analysis and QC
  • scripts/mt_analysis.py - MT数据分析与质量控制脚本