-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SED-EEW/gitlab-catchupwith-github
Adds info prints, SC3 logs backups, db exports, specific SC3 install …
- Loading branch information
Showing
5 changed files
with
275 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
Select event ID from time and magnitude intervals. | ||
""" | ||
from __future__ import print_function | ||
import sys | ||
from obspy import UTCDateTime | ||
from obspy.clients.fdsn import Client | ||
import argparse | ||
from datetime import datetime, timedelta | ||
|
||
def event(baseurl='IRIS', | ||
starttime=None, | ||
endtime=None, | ||
minmag=3., | ||
maxmag=10., | ||
maxnumber=10, | ||
catalog=None): | ||
|
||
try : | ||
client = Client(baseurl) | ||
print("Using "+baseurl+"...",file=sys.stderr) | ||
except : | ||
print("fdsn client failed") | ||
from obspy.clients.fdsn.header import URL_MAPPINGS | ||
for key in sorted(URL_MAPPINGS.keys()): | ||
print("{0:<7} {1}".format(key, URL_MAPPINGS[key]),file=sys.stderr) | ||
|
||
sys.exit() | ||
|
||
try : | ||
starttime = UTCDateTime(starttime) | ||
endtime = UTCDateTime(endtime) | ||
except : | ||
starttime = UTCDateTime()-365*24*60*60 | ||
endtime = UTCDateTime() | ||
print('Auto time limit:',file=sys.stderr) | ||
print(starttime,file=sys.stderr) | ||
print(endtime,file=sys.stderr) | ||
#print("time conversion failed") | ||
#sys.exit() | ||
|
||
if catalog: | ||
cat = client.get_events(limit=maxnumber, orderby="magnitude",starttime=starttime, endtime=endtime, minmagnitude=minmag, maxmagnitude=maxmag, catalog=catalog) | ||
else: | ||
cat = client.get_events(limit=maxnumber, orderby="magnitude",starttime=starttime, endtime=endtime, minmagnitude=minmag, maxmagnitude=maxmag) | ||
print(cat.__str__(print_all=True),file=sys.stderr) | ||
for e in cat: | ||
print(e.resource_id) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description=__doc__, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
parser.add_argument('-b', '--baseurl', help='base URL of any FDSN web service or with a shortcut name which will be mapped to a FDSN URL.', default="IRIS") | ||
parser.add_argument('-t', '--starttime', help='end time', default=str(datetime.now()-timedelta(days=365.))) | ||
parser.add_argument('-T', '--endtime' , help='start time', default=str(datetime.now())) | ||
parser.add_argument('-m', '--minmag', help='Minimum magnitude', default="2.") | ||
parser.add_argument('-M', '--maxmag', help='Maximum magnitude', default="10.") | ||
parser.add_argument('-N', '--maxnumber', help='Maximum number of event', default="10") | ||
parser.add_argument('-c', '--catalog', help='catalog to request', default=None) | ||
|
||
args = parser.parse_args() | ||
#try: | ||
event(baseurl=args.baseurl, starttime=args.starttime, endtime=args.endtime, minmag=args.minmag, maxmag=args.maxmag, maxnumber=args.maxnumber, catalog=args.catalog) | ||
#except : | ||
# print("event failed") | ||
# sys.exit() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Plots playback. | ||
Created on Dec 11, 2016 | ||
@author: fmassin | ||
""" | ||
import matplotlib.pyplot as plt | ||
from obspy import UTCDateTime | ||
|
||
|
||
def plot_vsreports(vsreport_pb=None, | ||
vsreport_rt=None, | ||
vsreport=None, | ||
mag=None, | ||
lon=None, | ||
lat=None, | ||
dep=None, | ||
to=None): | ||
separator = '|' | ||
figsizes=[(14,6),(16,6)] | ||
colors = ['b', 'g', 'r','c', 'm', 'y', 'k'] | ||
code = ['', 'RT', 'Pb'] | ||
fig, (ax1, ax2, ax3) = plt.subplots(3,1, sharex=True)#, figsize=figsizes[0]) | ||
f=-1 | ||
for f,file in enumerate([vsreport, vsreport_rt, vsreport_pb]): | ||
if file: | ||
print(file) | ||
m=f | ||
vsfile = [x.split(separator) for x in open(file).readlines()] | ||
vsfile.append(vsfile[-1])#.copy()) | ||
if mag: | ||
vsfile[-1][0]=mag | ||
if lat: | ||
vsfile[-1][1]=lat | ||
if lon: | ||
vsfile[-1][2]=lon | ||
if dep: | ||
vsfile[-1][4]=dep | ||
if to: | ||
vsfile[-1][6]=to | ||
lab1 = 'Mvs' | ||
for o,origin in enumerate(vsfile): | ||
if o>1: | ||
for v,val in enumerate(origin): | ||
if 'Z' in str(val): | ||
pass | ||
else: | ||
vsfile[o][v]=float(val) | ||
|
||
for o,origin in enumerate(vsfile): | ||
if o>1 :#and o<len(vsfile)-1: | ||
if o>2: | ||
lab1 = None | ||
lab2 = None | ||
lab3 = None | ||
lab4 = None | ||
else: | ||
lab1 = code[f]+' Mvs' | ||
lab2 = code[f]+' locsat' | ||
lab3 = code[f]+' arrivals' | ||
lab4 = code[f]+' amplitudes' | ||
origin[5] = UTCDateTime(origin[5]) | ||
origin[6] = UTCDateTime(origin[6]) | ||
delays = origin[5] - UTCDateTime(vsfile[-1][6]) # origin[6] | ||
ax1.plot(delays, origin[0], marker='o', label=lab1, color=colors[f]) | ||
ax2.plot(delays, | ||
(((origin[1]-vsfile[-1][1])*110.)**2+((origin[2]-vsfile[-1][2])*110.)**2+(origin[4]-vsfile[-1][4])**2)**.5, | ||
label=lab2, marker='o', color=colors[f]) | ||
ax3.plot(delays, origin[-2], marker='o', label=lab3, color=colors[f]) | ||
ax3.plot(delays, origin[-1], marker='d', label=lab4, color=colors[f]) | ||
|
||
if o==len(vsfile)-1: | ||
ax1.plot([UTCDateTime(vsfile[2][5]) - UTCDateTime(vsfile[-1][6]) , UTCDateTime(origin[5])-UTCDateTime(vsfile[-1][6])], [origin[0],origin[0]], color='g') | ||
#ax2.plot([vsfile[2][5]-vsfile[2][6] ,origin[5] - origin[6]], | ||
# [(((origin[1]-vsfile[-1][1])*110.)**2+((origin[2]-vsfile[-1][2])*110.)**2+(origin[4]-vsfile[-1][4])**2)**.5, | ||
# (((origin[1]-vsfile[-1][1])*110.)**2+((origin[2]-vsfile[-1][2])*110.)**2+(origin[4]-vsfile[-1][4])**2)**.5], | ||
# color='g') | ||
#ax3.plot(delays, origin[-2], marker='o', label=lab3, color=colors[f]) | ||
#ax3.plot(delays, origin[-1], marker='d', label=lab4, color=colors[f]) | ||
|
||
ax1.set_title('M'+str(vsfile[-1][0])+' on '+str(vsfile[-1][6])) | ||
ax1.grid() | ||
ax2.grid() | ||
ax3.grid() | ||
ax1.set_xscale('log') | ||
ax2.set_xscale('log') | ||
ax3.set_xscale('log') | ||
ax1.set_ylim(top=ax1.get_ylim()[1]+0.1) | ||
ax2.set_ylim(bottom=ax2.get_ylim()[0]-1) | ||
ax1.set_ylabel('Magnitude') | ||
ax2.set_ylabel('Location error (km)') | ||
ax3.set_ylabel('Observations') | ||
ax3.set_xlabel('Alert time since origin [s]') | ||
|
||
ax1.legend(loc=4, fancybox=True, framealpha=0.5) | ||
ax2.legend(loc=3, fancybox=True, framealpha=0.5) | ||
ax3.legend(loc=5, fancybox=True, framealpha=0.5) | ||
print(file[:-3]+'pdf') | ||
plt.savefig(file[:-3]+'pdf', bbox_inches='tight') | ||
plt.show() | ||
|
||
if __name__ == '__main__': | ||
import argparse | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("-v", "--vsreport", help="VS report file.", type=str) | ||
parser.add_argument("-r", "--vsreport_rt", help="RT VS report file.", type=str) | ||
parser.add_argument("-p", "--vsreport_pb", help="Pb VS report file.", type=str) | ||
parser.add_argument("-x", "--xml", help="xml file.", type=str) | ||
parser.add_argument("-m", "--mag", help="final magnitude.", type=str) | ||
parser.add_argument("-l", "--lon", help="final longitude.", type=str) | ||
parser.add_argument("-L", "--lat", help="final latitude.", type=str) | ||
parser.add_argument("-d", "--dep", help="final depth.", type=str) | ||
parser.add_argument("-t", "--to", help="final origin time.", type=str) | ||
|
||
args = parser.parse_args() | ||
|
||
plot_vsreports(vsreport=args.vsreport, | ||
vsreport_pb=args.vsreport_pb, | ||
vsreport_rt=args.vsreport_rt, | ||
mag=args.mag, | ||
lon=args.lon, | ||
lat=args.lat, | ||
dep=args.dep, | ||
to=args.to) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.