Miniseed Processor Skill
用于处理miniseed地震波形文件的专业skill,提供完整的波形数据处理流程,包括从远程服务器下载文件和物理参数计算。
核心功能
1. 从远程服务器下载波形文件 ⭐ 关键词触发 ⭐
当用户提到以下关键词时,必须执行此功能:
- 下载、远程、服务器、scp
功能特点:
- 使用SCP协议从远程服务器下载miniseed文件
- 完全交互式配置:运行时询问服务器IP、用户名、密码、远程路径、本地保存路径
- 只下载新文件(根据修改时间和文件大小判断)
- 保持远程目录结构
- 不暴露敏感信息,所有参数在运行时输入
2. 读取miniseed文件
使用obspy的read函数读取miniseed文件,支持debug_headers模式查看详细信息。
3. 生成波形图片
将miniseed文件渲染为png格式的波形图,文件名与原miniseed文件相同(仅扩展名改为.png)。
4. 时间范围分析
检查miniseed文件是否包含特定时间点或时间段的数据,支持UTC时间和北京时间转换。
5. 截取特定时间段数据
从miniseed文件中截取指定时间范围的数据并生成波形图。
6. 批量处理
支持遍历文件夹中的所有miniseed文件进行批量处理。
7. 物理参数计算 ⭐ 关键词触发 ⭐
当用户提到以下关键词时,必须执行此功能:
- PGA、PGV、PGD、烈度
- 加速度、速度、位移
- count/g、灵敏度
- 峰值加速度、峰值速度、峰值位移
- 地震烈度、MMI烈度
计算内容:
- PGA (峰值地面加速度) - 单位:g、m/s²、gal
- PGV (峰值地面速度) - 单位:m/s、cm/s
- PGD (峰值地面位移) - 单位:m、cm
- 烈度 - 基于PGA和PGV的MMI烈度
文件命名规则
波形图命名
- 完整波形图:
原文件名.png - 特定时间段波形图:
原文件名+时间段标识.png(如:YN.XJ04R.40.EIZ.D.2026.0901540.png)
文件夹命名
按日期命名文件夹,格式:前缀+月日(如:XJ0326、YN0331)
使用指南
基本工作流
1. 读取文件
from obspy import read
st = read("file_path.mseed", debug_headers=True)
2. 生成完整波形图
st.plot(outfile="output.png")
3. 检查时间范围
from obspy.core import UTCDateTime
target_time = UTCDateTime("2026-03-31T15:40:33")
for tr in st:
if tr.stats.starttime <= target_time <= tr.stats.endtime:
print("包含目标时间")
4. 截取时间段
start_time = UTCDateTime("2026-03-31T15:40:33")
end_time = UTCDateTime("2026-03-31T15:50:33")
st_cut = st.slice(start_time, end_time)
st_cut.plot(outfile="output.png")
5. 北京时间转UTC
from datetime import datetime, timedelta
dt_cn = datetime.strptime("2026-03-31 23:40:33", "%Y-%m-%d %H:%M:%S")
dt_utc = dt_cn - timedelta(hours=8)
utc_time = UTCDateTime(dt_utc)
6. 计算PGA、PGV、PGD、烈度 ⭐
当用户提到相关关键词时,必须使用此功能!
import numpy as np
from scipy.integrate import cumtrapz
def calculate_physical_parameters(st, sensitivity=16384):
"""
计算PGA、PGV、PGD和烈度
Args:
st: obspy Stream对象
sensitivity: 灵敏度,默认16384 count/g
Returns:
包含所有参数的字典列表
"""
results = []
for tr in st:
station = tr.stats.station
channel = tr.stats.channel
# 1. 转换为物理单位
# count/g -> g -> m/s²
acceleration_g = tr.data / sensitivity
acceleration_ms2 = acceleration_g * 9.81
# 2. 计算PGA
pga_g = np.max(np.abs(acceleration_g))
pga_ms2 = np.max(np.abs(acceleration_ms2))
pga_gal = pga_ms2 * 100
# 3. 积分得到速度
dt = tr.stats.delta
velocity = cumtrapz(acceleration_ms2, dx=dt, initial=0)
velocity = velocity - np.mean(velocity)
pgv_ms = np.max(np.abs(velocity))
pgv_cms = pgv_ms * 100
# 4. 再次积分得到位移
displacement = cumtrapz(velocity, dx=dt, initial=0)
displacement = displacement - np.mean(displacement)
pgd_m = np.max(np.abs(displacement))
pgd_cm = pgd_m * 100
# 5. 计算烈度
intensity_pga = pga_to_intensity(pga_ms2)
intensity_pgv = pgv_to_intensity(pgv_ms)
results.append({
'station': station,
'channel': channel,
'pga_g': pga_g,
'pga_ms2': pga_ms2,
'pga_gal': pga_gal,
'pgv_ms': pgv_ms,
'pgv_cms': pgv_cms,
'pgd_m': pgd_m,
'pgd_cm': pgd_cm,
'intensity_pga': intensity_pga,
'intensity_pgv': intensity_pgv
})
return results
def pga_to_intensity(pga_ms2):
"""根据PGA计算烈度(MMI烈度表)"""
pga_gal = pga_ms2 * 100
if pga_gal < 1:
return "I"
elif pga_gal < 2:
return "II-III"
elif pga_gal < 5:
return "IV"
elif pga_gal < 10:
return "V"
elif pga_gal < 20:
return "VI"
elif pga_gal < 40:
return "VII"
elif pga_gal < 80:
return "VIII"
elif pga_gal < 160:
return "IX"
else:
return "X+"
def pgv_to_intensity(pgv_ms):
"""根据PGV计算烈度(MMI烈度表,更准确)"""
pgv_cms = pgv_ms * 100
if pgv_cms < 0.1:
return "I"
elif pgv_cms < 0.3:
return "II-III"
elif pgv_cms < 1:
return "IV"
elif pgv_cms < 3:
return "V"
elif pgv_cms < 10:
return "VI"
elif pgv_cms < 30:
return "VII"
elif pgv_cms < 100:
return "VIII"
elif pgv_cms < 300:
return "IX"
else:
return "X+"
常见文件扩展名
miniseed文件常见扩展名:
.085,.086,.087,.088,.089(天序号).090,.091,.092,.093(天序号).mseed
目录结构处理
典型的miniseed文件目录结构
YN/
├── HH01M/
│ ├── EIE.D/
│ │ └── YN.HH01M.40.EIE.D.2026.090
│ ├── EIN.D/
│ │ └── YN.HH01M.40.EIN.D.2026.090
│ └── EIZ.D/
│ └── YN.HH01M.40.EIZ.D.2026.090
└── ...
批量遍历文件夹
import os
for root, dirs, files in os.walk(folder_path):
for file_name in files:
if file_name.endswith(('.085', '.086', '.087', '.088', '.089', '.090', '.091', '.092', '.093', '.mseed')):
# 处理文件
脚本工具
此skill包含以下Python脚本工具(位于scripts/目录):
plot_miniseed.py- 生成单个或批量miniseed文件的波形图check_time_inclusion.py- 检查文件是否包含特定时间点plot_time_range.py- 截取特定时间段并生成波形图batch_processor.py- 批量处理文件夹中的所有miniseed文件calculate_parameters.py- 计算PGA、PGV、PGD和烈度 ⭐
最佳实践
- 始终使用UTCDateTime处理时间,避免时区混淆
- 北京时间转UTC时减去8小时
- 批量处理时使用try-except捕获异常,避免单个文件错误导致整个流程中断
- 生成图片时保存在与原文件相同的目录中
- 检查时间范围时,确认目标时间在文件的starttime和endtime之间
- 计算物理参数时:
- 确认灵敏度值正确(默认16384 count/g)
- 积分前进行去趋势处理
- 推荐使用带通滤波(0.1-20Hz)去除噪声
- PGV通常比PGA更可靠地用于烈度计算
错误处理
常见错误及解决方案:
- Empty stream object - 截取的时间段内没有数据,检查时间范围是否正确
- Not a SEED record - 文件格式问题,使用debug_headers=True查看详细信息
- Matplotlib backend错误 - 确保matplotlib正确安装,可能需要设置backend为Agg
- 积分结果异常 - 确保进行了去趋势处理
依赖要求
- Python 3.x
- obspy
- matplotlib
- numpy
- scipy
安装命令:
pip install obspy matplotlib numpy scipy
关键词触发列表
当用户提到以下关键词时,必须使用此skill:
- miniseed、地震波形、obspy
- 生图、波形图、生成图片
- 时间范围、时间段、截取
- PGA、PGV、PGD、烈度 ⭐
- 加速度、速度、位移 ⭐
- count/g、灵敏度 ⭐
- 峰值加速度、峰值速度、峰值位移 ⭐
- 地震烈度、MMI烈度 ⭐




