下载地震连续数据及数据预处理

4 篇文章 0 订阅
2 篇文章 0 订阅

写在前面

这篇文章发布之后,收到的反馈还是蛮多的,没想到搞地震的新同学还挺多的。反馈主要是不能一次下载多个台站的数据,以及下载的不是SAC格式的地震数据,因此做了一点更新。如果大家对代码有什么建议,欢迎反馈<( ̄▽ ̄)>

重要更新

DownloadSeisData,托管在Github上:https://github.com/SeisPiano/DownloadSeisData
如果对你有帮助,欢迎点击star🌟,谢谢(◍•ᴗ•◍)

Bash版本的DownloadSeisData已经不再维护。

请使用基于Obspy的Python版本的DownloadSeisData,它对用户非常友好,并且简洁易读。

也可以使用DownloadSeisData app:

DownloadSeisData app 使用方法的介绍在哔哩哔哩

在这里插入图片描述

最近对这个程序做了一些更新(基本重写了整个代码)使其更加自动化,例如通过FetchMetaData来自动获取台站的信息。并且增加了去除仪器响应和基本的数据预处理

英文版手册在项目主页的README中,中文版介绍如下:
被动源OBS数据处理(1):下载地震数据
被动源OBS数据处理(2):地震数据预处理

下载FetchData

FetchData是IRIS提供的下载连续时间数据的脚本。可以去IRIS官网(http://service.iris.edu/clients/)下载。
这里也提供一个百度网盘链接下载
提取码:rzk6

下载完成后,将FetchData移动到需要下载地震数据的文件夹,在该文件夹下调出Terminal,使用chmod给执行权限。

chmod +x ./FetchData 

这时,在Terminal输入./FetchData,若出现以下内容则说明脚本已经可以使用。

wuyc@wuyc:~/Downloads/fdata$ ./FetchData
FetchData: collect time series and related metadata (version 2018.337)
http://service.iris.edu/clients/

Usage: FetchData [options]

 Options:
 -v                Increase verbosity, may be specified multiple times
 -h                Print this help message, if multiple print more help
 -q                Be quiet, do not print anything but errors
 -N,--net          Network code, list and wildcards (* and ?) accepted
 -S,--sta          Station code, list and wildcards (* and ?) accepted
 -L,--loc          Location ID, list and wildcards (* and ?) accepted
 -C,--chan         Channel codes, list and wildcards (* and ?) accepted
 -Q,--qual         Quality indicator, by default no quality is specified
 -s starttime      Specify start time (YYYY-MM-DD,HH:MM:SS.ssssss)
 -e endtime        Specify end time (YYYY-MM-DD,HH:MM:SS.ssssss or #[SMHD])
 --lat min:max     Specify a minimum and/or maximum latitude range
 --lon min:max     Specify a minimum and/or maximum longitude range
 --radius lat:lon:maxradius[:minradius]
                     Specify circular region with optional minimum radius
 -l listfile       Read list of selections from file
 -b bfastfile      Read list of selections from BREQ_FAST file
 -a user:pass      User and password for access to restricted data

 -F [DC1[,DC2]]    Federate the request to multiple data centers if needed
                     Federation may be limited to an optional list of DCs
                     Output files are prefixed by data center identifiers

 -o outfile        Fetch time series data and write to output file
 -sd sacpzdir      Fetch SAC P&Zs and write files to sacpzdir
 -rd respdir       Fetch RESP and write files to respdir
 -m metafile       Write basic metadata to specified file
 -X SXMLfile       Write response-level StationXML to specified file

使用bash脚本调用FetchData下载地震数据

这时,只需要一些简单的命令来调用FetchData即可下载地震数据了。
network表示台网,station表示台站,可以IRIS官网MetaData Aggregator查找。

startdate和enddate分别表示数据的开始日期和结束日期,脚本会按照一天一个文件,将地震数据以mseed格式保存到指定文件夹。
PZs是仪器响应文件。

#!/bin/bash
# Download miniseed data from iris
#
# Yuechu WU
# 2022-01-09
# updated in 2022-05-10 Downloading data from multiple stations


network=IC    
stations=(ENH SSE QIZ)
workPath=${PWD}

startdate=20200101
enddate=20200102
channel=BH? # Sometimes need to use HH?, refer to the specific station on MDA
pressure=?DH
location=00
OBS=false   # for OBS, OBS=true; for land stations, OBS=others

### end user input parameters ###

datadir="$workPath/mseedData"
PZdir="$workPath/PZs"

# make mseed data and PZs file
for station in ${stations[@]}
do
if [ -d "$datadir/$network/$station" ];then
    echo "Station mseed directory exists!"
else
    mkdir -p "$datadir/$network/$station"
fi
if [ -d "$PZdir/$network/$station" ];then
    echo "Station PZs directory exists!"
else
    mkdir -p "$PZdir/$network/$station"
fi
done   

for station in ${stations[@]}
do
stdate=$startdate
eddate=$enddate
while [ "$stdate" -le "$eddate" ]
do

mkdir $PZdir/$network/$station/$stdate # make PZs daily file

# Download seismic data and PZs
echo Start Date: $stdate
echo Downloading seismic data and PZs of station: $station From: `date -d $stdate +%Y-%m-%d`T00:00:00 To `date -d "1 day $stdate" +%Y-%m-%d`T00:00:00
./FetchData -N $network -S $station -L $location -C $channel -s `date -d $stdate +%Y-%m-%d`T00:00:00 -e `date -d "1 day $stdate" +%Y-%m-%d`T00:00:00 -o $datadir/$network/$station/$stdate.mseed -sd $PZdir/$network/$station/$stdate

# For OBS, download pressure data(DPG) and PZs
if [ "$OBS"x = "true"x ];then
echo Start Date: $stdate
echo Downloading pressure and PZs of station: $station From: `date -d $stdate +%Y-%m-%d`T00:00:00 To `date -d "1 day $stdate" +%Y-%m-%d`T00:00:00
./FetchData -N $network -S $station -L $location -C $pressure -s `date -d $stdate +%Y-%m-%d`T00:00:00 -e `date -d "1 day $stdate" +%Y-%m-%d`T00:00:00 -o $datadir/$network/$station/$stdate.pressure.mseed -sd $PZdir/$network/$station/$stdate
fi
let stdate=`date -d "1 day ${stdate}" +%Y%m%d`

done

done

执行上述脚本会显示以下内容,则表示成功下载时间为2020-01-01-2020-01-02,台网为IC,台站为ENH SSE QIZ的地震数据。

wuyc@wuyc-obs:/data/FetchData$ bash 1.download_data.v1.bash 
Start Date: 20200101
Downloading seismic data and PZs of station: ENH From: 2020-01-01T00:00:00 To 2020-01-02T00:00:00
Received 306 Bytes of metadata in 0.5 seconds (634 Bytes/s)
Processed metadata for 3 channel epochs in 0.5 seconds
Received 9.5 MB of time series data in 126.7 seconds (76.7 KB/s) - written to /data/FetchData/mseedData/IC/ENH/20200101.mseed
Received 3.1 KB of SAC P&Zs in 1.5 seconds (2.0 KB/s)
DONE at 2022-05-10 18:40:39
Start Date: 20200102
Downloading seismic data and PZs of station: ENH From: 2020-01-02T00:00:00 To 2020-01-03T00:00:00
Received 306 Bytes of metadata in 0.5 seconds (625 Bytes/s)
Processed metadata for 3 channel epochs in 0.5 seconds
Received 9.6 MB of time series data in 127.6 seconds (76.8 KB/s) - written to /data/FetchData/mseedData/IC/ENH/20200102.mseed
Received 3.1 KB of SAC P&Zs in 1.5 seconds (2.0 KB/s)
DONE at 2022-05-10 18:42:49
Start Date: 20200101
Downloading seismic data and PZs of station: SSE From: 2020-01-01T00:00:00 To 2020-01-02T00:00:00
Received 296 Bytes of metadata in 0.5 seconds (609 Bytes/s)
Processed metadata for 3 channel epochs in 0.5 seconds
Received 9.0 MB of time series data in 124.2 seconds (74.0 KB/s) - written to /data/FetchData/mseedData/IC/SSE/20200101.mseed
Received 3.4 KB of SAC P&Zs in 1.5 seconds (2.3 KB/s)
DONE at 2022-05-10 18:44:55

……

下载并安装mseed2sac

下载完成后,得到的是mseed格式的地震数据,如果需要SAC格式的地震数据,则需要使用mseed2sac
安装mseed2sac过程如下:

wuyc@wuyc-obs:/data/program/mseed2sac_v2.3$ tar -zxvf mseed2sac-2.3.tar.gz
wuyc@wuyc-obs:/data/program/mseed2sac_v2.3$ cd mseed2sac-2.3/
wuyc@wuyc-obs:/data/program/mseed2sac_v2.3/mseed2sac-2.3$ make
wuyc@wuyc-obs:/data/program/mseed2sac_v2.3/mseed2sac-2.3$ sudo cp mseed2sac /usr/local/bin/

安装完成之后,输入mseed2sac会显示:

wuyc@wuyc-obs:~$ mseed2sac
No input files were specified

mseed2sac version 2.3

Try mseed2sac -h for usage

使用bash脚本将mseed数据转成SAC数据

类似于下载数据的脚本,稍作修改即可实现转换格式的功能。

#!/bin/bash
# Converts miniSEED waveform data to SAC format
#
# Yuechu WU
# 2022-05-10


network=IC    
stations=(ENH SSE QIZ)
workPath=${PWD}

startdate=20200101
enddate=20200102
channel=BH? # Sometimes need to use HH?, refer to the specific station on MDA
pressure=?DH
OBS=false   # for OBS, OBS=true; for land stations, OBS=others

### end user input parameters ###
datadir="$workPath/mseedData"
SACDatadir="$workPath/SACData"

# make SAC data file
for station in ${stations[@]}
do
if [ -d "$SACDatadir/$network/$station" ];then
    echo "SAC directory exists!"
else
    mkdir -p "$SACDatadir/$network/$station"
fi
done   

for station in ${stations[@]}
do

stdate=$startdate
eddate=$enddate
while [ "$stdate" -le "$eddate" ]

do

# mseed2sac
cd $datadir/$network/$station
echo mseed2sac $stdate.mseed
mseed2sac $stdate.mseed
echo move *.SAC to SACData/$network/$station
mv *.SAC $SACDatadir/$network/$station

# For OBS, mseed2sac pressure data(DPG)
if [ "$OBS"x = "true"x ];then
cd $datadir/$network/$station
echo mseed2sac $stdate.pressure.mseed
mseed2sac $stdate.pressure.mseed
echo move *.SAC to SACData/$network/$station
mv *.SAC $SACDatadir/$network/$station
fi

let stdate=`date -d "1 day ${stdate}" +%Y%m%d`

done

done

运行之后显示如下:

wuyc@wuyc-obs:/data/FetchData$ bash 2.mseed2sac.v1.bash 
mseed2sac 20200101.mseed
Wrote 1728000 samples to IC.ENH.00.BH1.M.2020.001.000000.SAC
Wrote 1728000 samples to IC.ENH.00.BH2.M.2020.001.000000.SAC
Wrote 1728000 samples to IC.ENH.00.BHZ.M.2020.001.000000.SAC
move IC.ENH.00.BH1.M.2020.001.000000.SAC IC.ENH.00.BH2.M.2020.001.000000.SAC IC.ENH.00.BHZ.M.2020.001.000000.SAC to SACData/IC/ENH
mseed2sac 20200102.mseed
Wrote 1728000 samples to IC.ENH.00.BH1.M.2020.002.000000.SAC
Wrote 1728000 samples to IC.ENH.00.BH2.M.2020.002.000000.SAC
Wrote 1728000 samples to IC.ENH.00.BHZ.M.2020.002.000000.SAC
move IC.ENH.00.BH1.M.2020.002.000000.SAC IC.ENH.00.BH2.M.2020.002.000000.SAC IC.ENH.00.BHZ.M.2020.002.000000.SAC to SACData/IC/ENH
mseed2sac 20200101.mseed
Wrote 1728000 samples to IC.SSE.00.BH1.M.2020.001.000000.SAC
Wrote 1728000 samples to IC.SSE.00.BH2.M.2020.001.000000.SAC
Wrote 1728000 samples to IC.SSE.00.BHZ.M.2020.001.000000.SAC
move IC.SSE.00.BH1.M.2020.001.000000.SAC IC.SSE.00.BH2.M.2020.001.000000.SAC IC.SSE.00.BHZ.M.2020.001.000000.SAC to SACData/IC/SSE

……
  • 10
    点赞
  • 42
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值