用于处理miniseed地震波形文件的专业skill,提供完整的波形数据处理流程,包括从远程服务器下载文件和物理参数计算。
当用户提到以下关键词时,必须执行此功能:
功能特点:
使用obspy的read函数读取miniseed文件,支持debug_headers模式查看详细信息。
将miniseed文件渲染为png格式的波形图,文件名与原miniseed文件相同(仅扩展名改为.png)。
检查miniseed文件是否包含特定时间点或时间段的数据,支持UTC时间和北京时间转换。
从miniseed文件中截取指定时间范围的数据并生成波形图。
支持遍历文件夹中的所有miniseed文件进行批量处理。
当用户提到以下关键词时,必须执行此功能:
计算内容:
原文件名.png原文件名+时间段标识.png(如:YN.XJ04R.40.EIZ.D.2026.0901540.png)按日期命名文件夹,格式:前缀+月日(如:XJ0326、YN0331)
from obspy import read
st = read("file_path.mseed", debug_headers=True)
st.plot(outfile="output.png")
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("包含目标时间")
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")
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)
当用户提到相关关键词时,必须使用此功能!
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 (天序号).mseedYN/
├── 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和烈度 ⭐常见错误及解决方案:
安装命令:
pip install obspy matplotlib numpy scipy
当用户提到以下关键词时,必须使用此skill:
共 1 个版本