提交 0f5cab3f 编辑于 作者: Mijian Xu's avatar Mijian Xu 😷
浏览文件

Add a argument of station location

上级 cd6c1482
......@@ -12,12 +12,13 @@
def Usage():
print('Usage:')
print('python bqmail.py -Nnetwork -Sstation -Yyear1/month1/day1/year2/month2/day2 -Bsec_begin/sec_end -Cchannel -cdatetimefile -Fformat head.cfg')
print('python bqmail.py -Nnetwork -Sstation -Yyear1/month1/day1/year2/month2/day2 -Bsec_begin/sec_end -Cchannel -Llocation -cdatetimefile -Fformat head.cfg')
print('-N -- Network.')
print('-S -- Station.')
print('-Y -- Date range.')
print('-B -- Time before/after origal time of events in seconds.')
print('-C -- Channel (e.g., ?H?, HHZ, BH?). Default: BH?')
print('-L -- Location identifier.')
print('-c -- Directory of date time file. formaat: "2015,01,04,1,0,0 2015,01,04,10,0,0"')
print('-F -- File format (SEED or miniseed). Default: SEED')
print('head.cfg -- Config file.')
......@@ -38,7 +39,7 @@ except:
try:
opts,args = getopt.getopt(sys.argv[1:], "hN:S:C:Y:B:c:F:")
opts,args = getopt.getopt(sys.argv[1:], "hN:S:C:Y:B:L:c:F:")
except:
print('Arguments are not found!')
Usage()
......@@ -52,6 +53,7 @@ iscustom = 0
isyrange = 0
chan = "BH?"
fformat = "seed"
loca = ''
for op, value in opts:
if op == "-N":
network = value
......@@ -67,6 +69,8 @@ for op, value in opts:
timerange = value
elif op == "-C":
chan = value
elif op == "-L":
loca = value
elif op == "-F":
fformat = value
elif op == "-h":
......@@ -97,9 +101,7 @@ if isyrange:
datemin=datetime.datetime(year1,mon1,day1)
datemax=datetime.datetime(year2,mon2,day2)
event=[]
config.read(head)
eventlst = config.get("lst","eventlst")
NAME = config.get("info","NAME")
......@@ -110,7 +112,14 @@ ALTERNATEMEDIA = MEDIA
hosts = config.get("smtp","hosts")
port = config.get("smtp","port")
passwd = config.get("smtp","passwd")
recipient = 'breq_fast@iris.washington.edu'
if fformat.lower() == 'seed':
recipient = 'breq_fast@iris.washington.edu'
elif fformat.lower() == 'miniseed':
recipient = 'miniseed@iris.washington.edu'
else:
print('Invalid file format!')
sys.exit(1)
if isyrange:
LABEL = 'IRIS_'+str(year1)+"_"+str(year2)+"_"+network+"_"+station
else:
......@@ -140,10 +149,10 @@ else:
lon=float(evenum_split[8])
dep=float(evenum_split[9])
mw=float(evenum_split[10])
date = datetime.datetime(year,mon,day,hour,min) + datetime.timedelta(seconds=btime)
dateend = datetime.datetime(year,mon,day,hour,min) + datetime.timedelta(seconds=etime)
date = datetime.datetime(year,mon,day,hour,min,sec) + datetime.timedelta(seconds=btime)
dateend = datetime.datetime(year,mon,day,hour,min,sec) + datetime.timedelta(seconds=etime)
if datemin <= date <= datemax:
event.append([date.strftime('%Y'),date.strftime('%m'),date.strftime('%d'),date.strftime('%H'),date.strftime('%M'),dateend.strftime('%Y'),dateend.strftime('%m'),dateend.strftime('%d'),dateend.strftime('%H'),dateend.strftime('%M')])
event.append([date.strftime('%Y'),date.strftime('%m'),date.strftime('%d'),date.strftime('%H'),date.strftime('%M'),date.strftime('%S'),dateend.strftime('%Y'),dateend.strftime('%m'),dateend.strftime('%d'),dateend.strftime('%H'),dateend.strftime('%M'),dateend.strftime('%S')])
head = ("From: %s\r\nTo: %s\r\n\r\n" % (EMAIL, recipient))
......@@ -159,23 +168,13 @@ msg += '.ALTERNATE MEDIA '+ALTERNATEMEDIA+'\n'
msg += '.ALTERNATE MEDIA '+ALTERNATEMEDIA+'\n'
msg += '.LABEL '+LABEL+'\n'
msg += '.END\n'
if not iscustom:
for row in event:
msg += station+' '+network+' '+row[0]+' '+row[1]+' '+row[2]+' '+row[3]+' '+row[4]+' 00.0 '+row[5]+' '+row[6]+' '+row[7]+' '+row[8]+' '+row[9]+' 00.0 1 '+chan+'\n'
else:
for row in event:
msg += station+' '+network+' '+row[0]+' '+row[1]+' '+row[2]+' '+row[3]+' '+row[4]+' '+row[5]+' '+row[6]+' '+row[7]+' '+row[8]+' '+row[9]+' '+row[10]+' '+row[11]+' 1 '+chan+'\n'
for row in event:
msg += station+' '+network+' '+row[0]+' '+row[1]+' '+row[2]+' '+row[3]+' '+row[4]+' '+row[5]+' '+row[6]+' '+row[7]+' '+row[8]+' '+row[9]+' '+row[10]+' '+row[11]+' 1 '+chan+' '+loca+'\n'
smtp = SMTP(host=hosts, port=port)
smtp.set_debuglevel(0)
smtp.login(EMAIL, passwd)
if fformat.lower() == 'seed':
smtp.sendmail(EMAIL, 'breq_fast@iris.washington.edu', msg)
elif fformat.lower() == 'miniseed':
smtp.sendmail(EMAIL, 'miniseed@iris.washington.edu', msg)
else:
print('Invalid file format!')
sys.exit(1)
smtp.sendmail(EMAIL, recipient, msg)
smtp.quit()
print("Successful sending the mail of "+network+"."+station+" to IRIS DMC!!!")
......@@ -93,20 +93,28 @@ ALTERNATEMEDIA = MEDIA
hosts = config.get("smtp","hosts")
port = config.get("smtp","port")
passwd = config.get("smtp","passwd")
recipient = 'breq_fast@iris.washington.edu'
if fformat.lower() == 'seed':
recipient = 'breq_fast@iris.washington.edu'
elif fformat.lower() == 'miniseed':
recipient = 'miniseed@iris.washington.edu'
else:
print('Invalid file format!')
sys.exit(1)
sta = []
fid = open(infile,'r')
for stainfo in fid.readlines():
stainfo = stainfo.strip()
stainfo_sp = stainfo.split()
sta.append([stainfo_sp[0], stainfo_sp[1]])
if len(stainfo_sp) == 3:
sta.append([stainfo_sp[0], stainfo_sp[1], stainfo_sp[2]])
else:
sta.append([stainfo_sp[0], stainfo_sp[1], ''])
smtp = SMTP(host=hosts, port=port)
smtp.set_debuglevel(0)
smtp.login(EMAIL, passwd)
nowtime = datemin
while 1:
if nowtime >= datemax:
......@@ -127,14 +135,8 @@ while 1:
msg += '.LABEL '+LABEL+'\n'
msg += '.END\n'
for sta_row in sta:
msg += sta_row[1]+' '+sta_row[0]+' '+nowtime.strftime('%Y')+' '+nowtime.strftime('%m')+' '+nowtime.strftime('%d')+' '+nowtime.strftime('%H')+' '+nowtime.strftime('%M')+' 00.0 '+endtime.strftime('%Y')+' '+endtime.strftime('%m')+' '+endtime.strftime('%d')+' '+endtime.strftime('%H')+' '+endtime.strftime('%M')+' 00.0 1 '+chan+'\n'
if fformat.lower() == 'seed':
smtp.sendmail(EMAIL, 'breq_fast@iris.washington.edu', msg)
elif fformat.lower() == 'miniseed':
smtp.sendmail(EMAIL, 'miniseed@iris.washington.edu', msg)
else:
print('Invalid file format!')
sys.exit(1)
msg += sta_row[1]+' '+sta_row[0]+' '+nowtime.strftime('%Y')+' '+nowtime.strftime('%m')+' '+nowtime.strftime('%d')+' '+nowtime.strftime('%H')+' '+nowtime.strftime('%M')+' 00.0 '+endtime.strftime('%Y')+' '+endtime.strftime('%m')+' '+endtime.strftime('%d')+' '+endtime.strftime('%H')+' '+endtime.strftime('%M')+' 00.0 1 '+chan+' '+sta_row[2]+'\n'
smtp.sendmail(EMAIL, recipient, msg)
print("Successful sending the mail between "+nowtime.strftime('%Y')+'.'+nowtime.strftime('%m')+'.'+nowtime.strftime('%d')+'.'+nowtime.strftime('%H')+" and "+endtime.strftime('%Y')+'.'+endtime.strftime('%m')+'.'+endtime.strftime('%d')+'.'+endtime.strftime('%H')+"!!!")
nowtime = nowtime + datetime.timedelta(hours=timeval)
smtp.quit()
无法预览此类型文件
......@@ -37,9 +37,9 @@
%===================================%
\chapter{Introduction}
BQMail is a open source software package for requesting seismic data from Incorporated Research Institutions for Seismology (IRIS) Data Management Center (DMC) using BREQ\_FAST service (\url{http://ds.iris.edu/ds/nodes/dmc/manuals/breq_fast/}). BREQ\_FAST is a wildly used method for batch accessing to the IRIS DMC archive via electronically mailing a specially formatted file to IRIS DMC. User could input parameters (e.g., station name, date range, file format) in command lines, and then the package will automatically create the formatted file and send to IRIS DMC. Meanwhile, User can also use it to search station information by inputing parameters in command lines.
BQMail is an open source software package for requesting seismic data from Incorporated Research Institutions for Seismology (IRIS) Data Management Center (DMC) with the BREQ\_FAST service (\url{http://ds.iris.edu/ds/nodes/dmc/manuals/breq_fast/}). BREQ\_FAST is a popular method for accessing to the IRIS DMC archive via electronically mailings. Users first set parameters (e.g., station name, date range, file format) in command lines, and then create formatted files and send to the IRIS DMC automatically with the BQMail package. Meanwhile, users can use it for searching stations with necessary parameters in command lines.
Scripts included in BQMail were developed by Python programming language (\url{https://www.python.org}) on OSX 10.10 platform. The package runs on OSX and Linux/Unix platform. it is not sure that the package can (or cannot) run on Windows platform. BQMail is compatible between Python 2.7 and Python 3.x. The package is distributed under the GNU General Public License Version 3 (GPLv3) as published by the Free Software Foundation (\url{http://www.gnu.org/licenses/gpl.html}).
Scripts in the BQMail package were developed with Python programming language (\url{https://www.python.org}) on OSX 10.10 platform. They are compatible with both Python 2.7 and Python 3.x. The BQMail package runs on OSX and Linux/Unix platform, but is not tested under Windows. It is distributed under the GNU General Public License Version 3 (GPLv3) as published by the Free Software Foundation (\url{http://www.gnu.org/licenses/gpl.html}).
%===================================%
%------------ Chapter 2 ------------%
......@@ -48,7 +48,7 @@ Scripts included in BQMail were developed by Python programming language (\url{h
%----------- Section 2.1 -----------%
\section{Dependencies}
BQMail depend on standard libraries of Python 2.7 or higher versions, which include datetime, os, re, smtplib, urllib, sys, getopt, glob, ConfigParser/configParser and math.
BQMail depends on standard libraries of Python 2.7 or higher versions, which include datetime, os, re, smtplib, urllib, sys, getopt, glob, ConfigParser/configParser and math.
%----------- Section 2.2 -----------%
\section{Installation}
......@@ -58,7 +58,7 @@ After opening a terminal, run the following commands:
git clone git://github.com/xumi1993/bqmail.git
\end{lstlisting}
\subsection{Install BQMail}
Entering the root directory of the BQMail, Users can run scripts to use this package. If users wish to use this package in any directory, run following commands:
In the root directory of BQMail, users may use the package by running the scripts. To use it in any other directory, just run:
\begin{lstlisting}
cd bqmail
./install.sh
......@@ -70,43 +70,44 @@ Entering the root directory of the BQMail, Users can run scripts to use this pac
\chapter{Tutorial}
%----------- Section 3.1 -----------%
\section{bqmail}
bqmail - Request seismic waveform data of events.
bqmail - Request seismic waveform data.
\subsection{Synopsis}
{\tb bqmail} [{\ti configfile}] {\tb -N}{\ti network} {\tb -S}{\ti station} {\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}\\\
{\tb -B}{\ti sec\_before/sec\_after} [{\tb -C}{\ti channel}] [{\tb -c}{\ti datetimefile}] [{\tb -F[{\ti seed}|{\ti miniseed}]}]
{\tb -B}{\ti sec\_before/sec\_after} [{\tb -C}{\ti channel}] [{\tb -L}{\ti location}] [{\tb -c}{\ti datetimefile}] [{\tb -F[{\ti seed}|{\ti miniseed}]}]
\subsection{Required Arguments}
\begin{description}
\item[{\ti configfile}] Specify the directory of config file. the config file contains a events list, options of BREQ\_FAST token lines and informations of electronic mail server. The table \ref{tab31} lists options in the config file.
\item[{\ti configfile}] Specify directory of config file, which contains a events list, BREQ\_FAST options, and information of electronic mail server. The table \ref{tab31} lists options in the config file.
\begin{table}
\caption{Options in the config file}
\caption{Options in config file}
\centering
\begin{tabular}{c|c}\toprule[1.5 pt]
Option & Function \\ \midrule[1 pt]
{\C eventlst} & The directory of a formatted events list.\\
{\C NAME} & The folder name at IRIS DMC ftp site.\\
{\C eventlst} & Directory of the formatted events list.\\
{\C NAME} & Folder name at IRIS DMC ftp site.\\
{\C INST} & Institution.\\
{\C EMAIL} & The Email address to send and receive related mail.\\
{\C EMAIL} & Email address to send and receive related mail.\\
{\C MEDIA} & Media for accessing data. [Default is {\C Electronic (FTP)}.]\\
{\C hosts} & The host name of the smtp server.\\
{\C port} & The port of the smtp server. [Default is {\C 25}.]\\
{\C hosts} & Host name of SMTP server.\\
{\C port} & Port of the SMTP server. [Default is {\C 25}.]\\
{\C passwd} & Clear text password of the {\C EMAIL}.\\
\bottomrule[1.5 pt]
\end{tabular}
\label{tab31}
\end{table}
\item[{\tb -N}{\ti network}] Specify a code of network.
\item[{\tb -S}{\ti station}] Select a station under the network Specified by {\tb -N}
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time of the station.
\item[{\tb -B}{\ti sec\_before/sec\_after}] Set the time duration of each seismogram from {\ti sec\_before} before event time to {\ti sec\_after} after event time in seconds
\item[{\tb -N}{\ti network}] Specify network code.
\item[{\tb -S}{\ti station}] Select a station of specified network by {\tb -N}
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time.
\item[{\tb -B}{\ti sec\_before/sec\_after}] Set time duration of each seismogram from {\ti sec\_before} before to {\ti sec\_after} after event time in seconds
\end{description}
\subsection{Optional Arguments}
\begin{description}
\item[{\tb -C}{\ti channel}] Specify channels like "{\ti ?H?}" or "{\ti HHZ}". [Default is "{\ti BH?}"].
\item[{\tb -c}{\ti datetimefile}] If this argument is specified, {\tb -Y} will be futile. the time range will be specified as a table file with 12 column as following format: [{\ti year1 month1 day1 hour1 minute1 sec1 year2 month2 day2 hour2 minute2 sec2}].
\item[{\tb -L}{\ti location}] Location identifier
\item[{\tb -c}{\ti datetimefile}] If this argument is specified, {\tb -Y} will be futile. The time range will be specified in a table file with 12 column as: [{\ti year1 month1 day1 hour1 minute1 sec1 year2 month2 day2 hour2 minute2 sec2}].
\item[{\tb -F[{\ti seed}|{\ti miniseed}]}] Select a format (seed or miniseed) to retrieve [Default is {\ti seed}].
\end{description}
\subsection{Example}
To request waveform data by events of CB.NJ2 station from 2013 to 2014, try
To request waveform data by events of CB.NJ2 station from 2013 to 2014, try:
\begin{lstlisting}
bqmail head.cfg -NCB -SNJ2 -Y2013/1/1/2014/12/31 -B0/3600
\end{lstlisting}
......@@ -118,9 +119,9 @@ bqmail\_raw - Request continuous seismic waveform data by hours.
{\tb bqmail\_raw} [{\ti configfile}] {\tb -I}{\ti stationlist} {\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax} {\tb -H}{\ti hours} [{\tb -C}{\ti channel}] [{\tb -F[{\ti seed}|{\ti miniseed}]}]
\subsection{Required Arguments}
\begin{description}
\item[{\ti configfile}] Specify the directory of config file. the config file contains a events list, options of BREQ\_FAST token lines and informations of electronic mail server. The table \ref{tab31} lists options in the config file.
\item[{\tb -I}{\ti stationlist}] Select a text file including informations of networks and stations as following format:[{\ti network station}]
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time of the station.
\item[{\ti configfile}] Specify directory of config file. The config file contains a events list, BREQ\_FAST options, and information of electronic mail server. Table \ref{tab31} lists options in the config file.
\item[{\tb -I}{\ti stationlist}] Select a text file including network \& station information as:[{\ti network station [location]}]
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time.
\item[{\tb -H}{\ti hours}] Specify a time duration of each retrieving data file in hours.
\end{description}
\subsection{Optional Arguments}
......@@ -129,7 +130,7 @@ bqmail\_raw - Request continuous seismic waveform data by hours.
\item[{\tb -F[{\ti seed}|{\ti miniseed}]}] Select a format (seed or miniseed) of retrieving data file. [Default is {\ti seed}].
\end{description}
\subsection{Example}
To request continuous seismic waveform data with format of miniseed from 1 Jan. 2015 to 1 Jan. 2015 every 1 day, try
To request continuous seismic waveform data with format of miniseed from 1 Jan. 2015 to 1 Jan. 2015 every 1 day, try:
\begin{lstlisting}
bqmail_raw head.cfg -Ista.lst -Y2015/1/1/2015/1/5 -H24 \
-Fminiseed
......@@ -138,24 +139,24 @@ this is a record of the {\ti sta.lst}
\begin{lstlisting}
CB NJ2
CB TNC
IC BJT
IC BJT 00
\end{lstlisting}
%----------- Section 3.3 -----------%
\section{searchDMC}
searchDMC - Find stations in IRIS DMC. Stations can be found in different criterions. First, Using {\tb -R} find stations in a box region. Second, Using {\tb -D} find stations in a specified region by epicentral distance. Third, Using {\tb -N [-S]} find stations under a specified network.
searchDMC - Find stations in IRIS DMC. Stations defined by different criterions. First, using {\tb -R} to find stations in a box region. Second, using {\tb -D} to find stations in a specified region by epicentral distance. Third, using {\tb -N [-S]} to find stations under a specified network.
\subsection{Synopsis}
{\tb searchDMC} [{\tb -N}{\ti network}] [{\tb -S}{\ti station}] [{\tb -R}{\ti lonmin/lonmax/latmin/latmax}] \\\
[{\tb -D}{\ti lon/lat/dismin/dismax}] [{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] [{\tb -C}{\ti channel}] [{\tb -K}]
\subsection{Arguments}
\begin{description}
\item[{\tb -N}{\ti network}] Specify a code of network.
\item[{\tb -S}{\ti station}] Select a station under the network Specified by {\tb -N}
\item[{\tb -R}{\ti lonmin/lonmax/latmin/latmax}] Limits stations in a box region. Latitude goes from -90 to 90 and longitude goes from -180 to 180.
\item[{\tb -D}{\ti lon/lat/dismin/dismax}] Limits station in a specified region by epicentral distance between {\ti dismin} and {\ti dismax} from a center at {\ti lat, lon}. The distance goes from 0 to 180.
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time of the station.
\item[{\tb -C}{\ti channel}] Specify a channel like "{\ti BHZ}". This argument with unsupported wildcard is different from the one in {\tb bqmail} (or {\tb bqmail\_raw}).
\item[{\tb -K}] Generates a KML file in current directory. which is used by Google Earth to display station locations and related information based on IRIS DMC metadata. The argument of {\tb -D} cannot support this function.
\item[{\tb -N}{\ti network}] Specify a network code.
\item[{\tb -S}{\ti station}] Select a station under the specified network by {\tb -N}
\item[{\tb -R}{\ti lonmin/lonmax/latmin/latmax}] Limits stations in a box region. Latitude is from -90$^\circ$ to 90$^\circ$ and longitude is from -180$^\circ$ to 180$^\circ$.
\item[{\tb -D}{\ti lon/lat/dismin/dismax}] Limits station in a specified region by epicentral distance between {\ti dismin} and {\ti dismax} from a center at {\ti lat, lon}. The distance is from 0 to 180 degrees.
\item[{\tb -Y}{\ti ymin/mmin/dmin/ymax/mmax/dmax}] Select a date range during the archive time.
\item[{\tb -C}{\ti channel}] Specify a channel like "{\ti BHZ}". This argument with unsupported wildcard is different from that in {\tb bqmail} (or {\tb bqmail\_raw}).
\item[{\tb -K}] Generates a KML file in current directory. which is used by Google Earth to display stations and related information based on IRIS DMC metadata. The argument of {\tb -D} does not support this function.
\end{description}
\subsection{Example}
To find stations in a box region from 2002 to 2004, use
......@@ -173,16 +174,16 @@ To find stations under network {\C IC} with channel of {\C HHZ} and Generate a K
%----------- Section 3.4 -----------%
\section{updateCatalog}
updateCatalog - Automatically update the the events list from Harvard CMT Catalog.
updateCatalog - Automatically update the events list from Harvard CMT Catalog.
\subsection{Synopsis}
{\tb ubdateCatalog} {\tb -I}{\ti inputfile} [{\tb -O}{\ti outputfile}]
\subsection{Required Arguments}
\begin{description}
\item[{\tb -I}{\ti inputfile}] Specify the directory of events list that will be updated.
\item[{\tb -I}{\ti inputfile}] Specify the directory of events list.
\end{description}
\subsection{Optional Arguments}
\begin{description}
\item[{\tb -O}{\ti outputfile}] Specify a output directory of the updated events list. If this argument is not specified, the {\ti inputfile} will be overwritten as a updated events list.
\item[{\tb -O}{\ti outputfile}] Specify a directory of the updated events list. If it is not specified, the {\ti inputfile} will be overwritten as a updated events list.
\end{description}
\subsection{Example}
To update the the events list, use
......
YA MC01
YA MC02
YA MC02 00
......@@ -58,7 +58,8 @@ if inlog != outlog:
else:
fid_new = open(outlog,'a+')
i=0
maxsharp = 80
maxcol = os.popen('stty size').read().strip().split()[1]
maxsharp = int(maxcol*0.8)
print('Writing station info to '+outlog)
for info in find_re.findall(html):
num = len(find_re.findall(html))
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册