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

bqmail 1.2.0

上级 88101b1d
......@@ -6,11 +6,19 @@
# 2014/11/06
# 2015/01/05
# 2015/02/11
# 2015/04/29
#
def Usage():
print('Usage:')
print('python bqmail.py -Nnetwork -Sstation -Yyear1/month1/day1/year2/month2/day2 -Bsec_begin/sec_end -Cdatetimefile head.cfg')
print('python bqmail.py -Nnetwork -Sstation -Yyear1/month1/day1/year2/month2/day2 -Bsec_begin/sec_end -Cdatetimefile -s head.cfg')
print('-N -- Network.')
print('-S -- Station.')
print('-Y -- Date range.')
print('-B -- Time fefore/after origal time of events in seconds.')
print('-C -- Directory date time file. formaat:2015,01,04,1,0,0 2015,01,04,10,0,0')
print('-s -- Dequest continuous wave by one day.')
print('head.cfg -- Config file.')
import datetime
......@@ -26,14 +34,19 @@ except:
try:
opts,args = getopt.getopt(sys.argv[1:], "hN:S:C:Y:B:")
opts,args = getopt.getopt(sys.argv[1:], "hN:S:C:Y:B:s")
except:
print('Arguments are not found!')
Usage()
sys.exit(1)
if opts == []:
Usage()
sys.exit(1)
iscustom = 0
isyrange = 0
iscontinue = 0
for op, value in opts:
if op == "-N":
network = value
......@@ -47,6 +60,8 @@ for op, value in opts:
iscustom = 1
elif op == "-B":
timerange = value
elif op == "-s":
iscontinue = 1
elif op == "-h":
Usage()
sys.exit(1)
......@@ -60,9 +75,10 @@ for o in sys.argv[1:]:
head = o
break
if head == []:
print("Arguments or head file are not exist!")
print("Head file are not exist!")
Usage()
sys.exit(1)
if isyrange:
y_split = yrange.split('/')
year1 = int(y_split[0])
......@@ -99,6 +115,15 @@ if iscustom:
evenum_sp = re.split(',|\s',evenum)
event.append(evenum_sp)
elif iscontinue:
nowtime = datemin - datetime.timedelta(days=1)
while 1:
if nowtime >= datemax:
break
nowtime = nowtime + datetime.timedelta(days=1)
endtime = nowtime + datetime.timedelta(days=1)
event.append([nowtime.strftime('%Y'),nowtime.strftime('%m'),nowtime.strftime('%d'),nowtime.strftime('%H'),nowtime.strftime('%M'),endtime.strftime('%Y'),endtime.strftime('%m'),endtime.strftime('%d'),endtime.strftime('%H'),endtime.strftime('%M')])
else:
trange_sp = timerange.split('/')
btime = float(trange_sp[0])
......@@ -143,6 +168,7 @@ 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 BH?\n'
#print(msg)
smtp = SMTP(host=hosts, port=port)
smtp.set_debuglevel(0)
smtp.login(EMAIL, passwd)
......
文件已添加
[lst]
eventlst = /Users/xumj/Documents/GitHub/bqmail/EventCMT.dat
[info]
NAME = MijianXu
INST = NJU
EMAIL = gomijianxu@163.com
MEDIA = Electronic (FTP)
ALTERNATEMEDIA = Electronic (FTP)
#!/usr/bin/env python
#
#
#
import urllib.request as rq
import os
import re
import sys, getopt
def Usage():
print('Usage:')
print('python matchsta.py -Nnetwork -Rlon1/lon2/lat1/lat2 -K > network.lst')
try:
opts,args = getopt.getopt(sys.argv[1:], "hN:R:K")
except:
print('arguments are not found!')
Usage()
sys.exit(1)
islalo = 0
ismap = 0
for op, value in opts:
if op == "-N":
network = value
elif op == "-R":
lat_lon = value
islalo = 1
elif op == "-K":
ismap = 1
elif op == "-h":
Usage()
sys.exit(1)
else:
Usage()
sys.exit(1)
if islalo:
lalo_split = lat_lon.split('/')
lon1 = float(lalo_split[0])
lon2 = float(lalo_split[1])
lat1 = float(lalo_split[2])
lat2 = float(lalo_split[3])
url = 'http://ds.iris.edu/mda/'+network
response = rq.urlopen(url)
html = str(response.read())
find_re = re.compile(r'TITLE.+?</A></TD>.+?</TR>',re.DOTALL)
for info in find_re.findall(html):
find_sta = re.compile('\w+</A></TD>.+?</TR>',re.DOTALL)
sta_info = find_sta.findall(info)
if sta_info == []:
continue
sta_info = sta_info[0]
info_s1 = sta_info.split('<')
staname = info_s1[0]
info_s2 = re.split('</TD>.+?>',sta_info)
stlat = float(info_s2[2])
stlon = float(info_s2[3])
stel = float(info_s2[4])
yrange1 = info_s2[5]
yrange2 = info_s2[6]
if islalo:
if lat1<=stlat<=lat2 and lon1<=stlon<=lon2:
print(staname+' '+str(stlat)+' '+str(stlon)+' '+info_s2[4]+' '+yrange1+' '+yrange2)
else:
print(staname+' '+str(stlat)+' '+str(stlon)+' '+info_s2[4]+' '+yrange1+' '+yrange2)
if ismap:
google = open(network+'.kml','w+')
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>'+network+'</description><Link><href>http://www.iris.edu/cgi-bin/kmlstationinfo/'+network+'</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
#!/usr/bin/env python
#
# Author: Mijian Xu at NJU
#
#
# Revision History:
# 2014/11/06
# 2015/01/05
# 2015/02/11
# 2015/04/29
import distaz, math
import urllib.request as rq
try:
import urllib.request as rq
except:
import urllib as rq
import os
import re
import sys, getopt
import glob
def Usage():
print('Usage: python searchlalo.py -Rlon1/lon2/lat1/lat2 -Dlon/lat/dis1/dis2 -Yyear1/mon1/day1/year2/mon2/day2 -Cchannel -K')
print('Usage: python searchlalo.py -NNetwork -Sstation -Rlon1/lon2/lat1/lat2 -Dlon/lat/dis1/dis2 -Yyear1/mon1/day1/year2/mon2/day2 -Cchannel -K')
print('-N -- Network')
print('-S -- Station')
print('-R -- Search range.')
print('-D -- Search by distance.')
print('-Y -- Date range')
......@@ -20,20 +31,32 @@ def Usage():
try:
opts,args = getopt.getopt(sys.argv[1:], "hR:D:KO:Y:C:")
opts,args = getopt.getopt(sys.argv[1:], "hR:D:KY:C:N:S:")
except:
print('arguments are not found!')
print('Arguments are not found!')
Usage()
sys.exit(1)
if opts == []:
Usage()
sys.exit(1)
iskml = 0
islalo = 0
isyrange = 0
ischan = 0
lat_lon = ''
yrange = ''
chan = ''
network = ''
station = ''
lalo_label = ''
for op, value in opts:
if op == "-R":
lat_lon = value
islalo = 1
elif op == "-N":
network = 'net='+value+'&'
elif op == "-S":
station = 'sta='+value+'&'
elif op == "-K":
iskml = 1
elif op == "-D":
......@@ -42,37 +65,39 @@ for op, value in opts:
yrange = value
isyrange = 1
elif op == "-C":
chan = value
ischan = 1
chan = 'chan='+value+'&'
elif op == "-h":
Usage()
sys.exit(1)
else:
Usage()
sys.exit(1)
lat_lon_split = lat_lon.split('/')
if islalo:
lon1 = lat_lon_split[0]
lon2 = lat_lon_split[1]
lat1 = lat_lon_split[2]
lat2 = lat_lon_split[3]
lalo = lon1+'_'+lon2+'_'+lat1+'_'+lat2
else:
lon = lat_lon_split[0]
lat = lat_lon_split[1]
dis1 = float(lat_lon_split[2])
dis2 = float(lat_lon_split[3])
if lat_lon != '':
lat_lon_split = lat_lon.split('/')
if islalo:
lon1 = lat_lon_split[0]
lon2 = lat_lon_split[1]
lat1 = lat_lon_split[2]
lat2 = lat_lon_split[3]
lalo = lon1+'_'+lon2+'_'+lat1+'_'+lat2
lalo_label = 'minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&'
else:
lon = lat_lon_split[0]
lat = lat_lon_split[1]
dis1 = float(lat_lon_split[2])
dis2 = float(lat_lon_split[3])
# print(lon,lat,dis)
# [lat1,lon1] = distaz.latlon_from(float(lat),float(lon),225,dis*math.sqrt(2))
# [lat2,lon2] = distaz.latlon_from(float(lat),float(lon),45,dis*math.sqrt(2))
# print(lon1,lon2,lat1,lat2)
lon1 = str(0)
lat1 = str(-90)
lon2 = str(0)
lat2 = str(90)
lalo = lon+'_'+lat+'_'+lat_lon_split[2]
lon1 = str(0)
lat1 = str(-90)
lon2 = str(0)
lat2 = str(90)
lalo = lon+'_'+lat+'_'+lat_lon_split[2]
url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?'
if isyrange:
yrange_sp = yrange.split("/")
year1 = yrange_sp[0]
......@@ -81,14 +106,19 @@ if isyrange:
year2 = yrange_sp[3]
mon2 = yrange_sp[4]
day2 = yrange_sp[5]
if ischan:
url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&timewindow='+year1+'/'+mon1+'/'+day1+'-'+year2+'/'+mon2+'/'+day2+'&chan='+chan
else:
url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&timewindow='+year1+'/'+mon1+'/'+day1+'-'+year2+'/'+mon2+'/'+day2
elif ischan:
url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&chan='+chan
else:
url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2
yrange = 'timewindow='+year1+'/'+mon1+'/'+day1+'-'+year2+'/'+mon2+'/'+day2+'&'
url += network+station+lalo_label+yrange+chan
url = url[0:-1]
# if ischan:
# url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&timewindow='+year1+'/'+mon1+'/'+day1+'-'+year2+'/'+mon2+'/'+day2+'&chan='+chan
# else:
# url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&timewindow='+year1+'/'+mon1+'/'+day1+'-'+year2+'/'+mon2+'/'+day2
#elif ischan:
# url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2+'&chan='+chan
#else:
# url = 'http://ds.iris.edu/cgi-bin/xmlstationinfo?minlat='+lat1+'&maxlat='+lat2+'&minlon='+lon1+'&maxlon='+lon2
response = rq.urlopen(url)
html = str(response.read())
......@@ -107,7 +137,7 @@ for info in find_re.findall(html):
continue
yrange1 = sta_info[-5]
yrange2 = sta_info[-4]
if not islalo:
if not islalo and lat_lon != '':
delta = distaz.distaz(float(lat),float(lon),float(stlat),float(stlon))
if dis1 < delta.delta < dis2:
print(network+' '+staname+' '+stlat+' '+stlon+' '+yrange1+' '+yrange2)
......@@ -118,6 +148,8 @@ for info in find_re.findall(html):
if iskml:
google = open('Station_'+lalo+'.kml','w+')
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>Station List</description><Link><href>http://www.iris.edu/cgi-bin/kmlstationinfo?minlat='+lat1+'&amp;maxlat='+lat2+'&amp;minlon='+lon1+'&amp;maxlon='+lon2+'&amp;kmz=1</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
if islalo:
google = open('Station_'+lalo+'.kml','w+')
google.write('<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.google.com/earth/kml/2.0"><NetworkLink><name>Selected stations</name><description>Station List</description><Link><href>http://www.iris.edu/cgi-bin/kmlstationinfo?minlat='+lat1+'&amp;maxlat='+lat2+'&amp;minlon='+lon1+'&amp;maxlon='+lon2+'&amp;kmz=1</href><refreshMode>onInterval</refreshMode><refreshInterval>86400</refreshInterval></Link></NetworkLink></kml>')
else:
print('Cannot creat the .kml file, "-R" is required.')
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册