AgentSkillsCN

mtpy

开展大地电磁数据处理与建模。读取EDI文件,分析MT响应,进行反演计算,并可视化电阻率模型。当Claude需要执行以下操作时使用:(1) 读取/写入EDI文件;(2) 处理MT阻抗张量;(3) 分析相位张量与各向异性程度;(4) 绘制视电阻率与相位曲线;(5) 创建伪剖面;(6) 开展走向分析;(7) 运行一维反演;(8) 为二维/三维建模准备数据。

SKILL.md
--- frontmatter
name: mtpy
description: |
  Magnetotelluric data processing and modelling. Read EDI files, analyze MT
  responses, perform inversions, and visualize resistivity models. Use when
  Claude needs to: (1) Read/write EDI files, (2) Process MT impedance tensors,
  (3) Analyze phase tensors and dimensionality, (4) Plot apparent resistivity
  and phase curves, (5) Create pseudosections, (6) Perform strike analysis,
  (7) Run 1D inversions, (8) Prepare data for 2D/3D modelling.

mtpy - Magnetotelluric Analysis

Quick Reference

python
from mtpy import MT, MTCollection

# Read single station
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

# Station info
print(mt.station, mt.latitude, mt.longitude)

# Write EDI
mt.write_edi('output.edi')

Key Classes

ClassPurpose
MTSingle station MT data container
MTCollectionMultiple stations management
PlotMTResponsePlot impedance, resistivity, phase
PlotPhaseTensorPhase tensor ellipse visualization
PlotPseudoSectionProfile pseudosection display
PlotStrikeStrike direction analysis

Essential Operations

Load and Inspect 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")

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})")

Plot MT Response

python
from mtpy import MT
from mtpy.imaging import PlotMTResponse

mt = MT('station001.edi')
plot = PlotMTResponse(mt)
plot.plot()  # Apparent resistivity and phase

Phase Tensor Analysis

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

# Plot
pt = PlotPhaseTensor(mt)
pt.plot()

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

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'

Export Data

python
from mtpy import MT
import pandas as pd

mt = MT('station001.edi')

# Export to 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)

# Export for ModEM
mt.write_modem('station001.dat')

Impedance Tensor Components

ComponentDescriptionMode
ZxxEx/Bx responseDiagonal (usually small)
ZxyEx/By responseTE mode
ZyxEy/Bx responseTM mode
ZyyEy/By responseDiagonal (usually small)

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

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)

References

Scripts