Commit 3c29a655 authored by Mijian Xu's avatar Mijian Xu 😷
Browse files

update download

parent 4a884856
This diff is collapsed.
......@@ -31,7 +31,7 @@ def Usage():
print('-F -- File format (SEED or miniseed). Default: SEED')
print('-M -- Magnitude range.')
print('head.cfg -- Config file.')
print('Example: ./bqmail.py -NCB -SNJ2 -b2015-2-3 -e2015-4-3 -B0/1000 head.cfg')
print('Example: ./bqmail.py -NCB -SNJ2 -b2015-2-3 -e2015-4-3 -P32.05/118.85/P -B-200/1000 head.cfg')
print(' ./bqmail.py -NIC -SBJT -b2015-2-3T00:12:23 -e2015-4-3 -B-100/600 -L10 -Fminiseed head.cfg')
......@@ -179,18 +179,19 @@ else:
etime = float(trange_sp[1])
EVENT = open(eventlst,'r')
for evenum in EVENT:
evenum_split = evenum.split()
year=int(evenum_split[0])
mon=int(evenum_split[1])
day=int(evenum_split[2])
jjj=int(evenum_split[3])
hour=int(evenum_split[4])
min=int(evenum_split[5])
sec=int(evenum_split[6])
lat=float(evenum_split[7])
lon=float(evenum_split[8])
dep=float(evenum_split[9])
mw=float(evenum_split[10])
evenum = evenum.strip()
(year, mon, day, jjj, hour, min, sec, lat, lon, dep, mw) = evenum.split()
year = int(year)
mon = int(mon)
day = int(day)
jjj = int(jjj)
hour = int(hour)
min = int(min)
sec = int(sec)
lat = float(lat)
lon = float(lon)
dep = float(dep)
mw = float(mw)
if mw < magmin or mw > magmax:
continue
evt_time = datetime.datetime(year,mon,day,hour,min,sec)
......@@ -200,7 +201,7 @@ else:
arr = mod.get_travel_times(source_depth_in_km=dep, distance_in_degree=dis, phase_list=[phase])
if len(arr) != 0:
arr_time = evt_time + datetime.timedelta(seconds=arr[0].time)
date = arr_time - datetime.timedelta(seconds=btime)
date = arr_time + datetime.timedelta(seconds=btime)
dateend = arr_time + datetime.timedelta(seconds=etime)
else:
date = evt_time + datetime.timedelta(seconds=btime)
......
......@@ -19,7 +19,7 @@ import sys
import getopt
def Usage():
print("Usage: download_seed.py -n<thread-num> -u<user-name> [-P<out-path>]")
print("Usage: download_seed.py -u<user-name> [-n<thread-num>] [-P<out-path>] [filename]")
print(" -P Specify out path of downloaded seed files.")
print(" Default: current dirctory")
print(" -n Specify thread number at parallel downloading")
......@@ -36,6 +36,7 @@ if argv == []:
Usage()
sys.exit(1)
path = "./"
filename = None
try:
opts, args = getopt.getopt(argv, "u:n:P:")
except:
......@@ -53,20 +54,30 @@ for op, value in opts:
Usage()
sys.exit(1)
for op in argv:
if op[0] != '-':
thread = 1
filename = op
url = "http://ds.iris.edu/pub/userdata/"+username
html = rq.urlopen(url)
content = html.read().decode()
lst = []
find_re = re.compile(r'href=.+?>',re.DOTALL)
for line in find_re.findall(content):
if line.find("seed") > 0:
lst.append(line[6:-2])
if filename == None:
find_re = re.compile(r'href=.+?>',re.DOTALL)
for line in find_re.findall(content):
if line.find("seed") > 0:
lst.append(line[6:-2])
else:
lst.append(filename)
lstpath = os.path.join(os.path.expanduser("~"),".IRIS.lst")
print(lstpath)
if not os.path.exists(lstpath):
os.mknod(lstpath)
with open(lstpath, "r+") as f:
oldlst = [line.strip() for line in f.readlines()]
oldlst = []
else:
with open(lstpath, "r+") as f:
oldlst = [line.strip() for line in f.readlines()]
with open(lstpath, "w+") as f:
for line in lst:
f.write(line+"\n")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment