Merge branch 'develop' into filterOptions

This commit is contained in:
2017-06-22 11:26:02 +02:00
17 changed files with 1258 additions and 430 deletions

View File

@@ -169,7 +169,8 @@ def read_metadata(path_to_inventory):
dlfile = list()
invfile = list()
respfile = list()
inv = dict(dless=dlfile, xml=invfile, resp=respfile)
# possible file extensions specified here:
inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile)
if os.path.isfile(path_to_inventory):
ext = os.path.splitext(path_to_inventory)[1].split('.')[1]
inv[ext] += [path_to_inventory]

View File

@@ -56,27 +56,55 @@ OUTPUTFORMATS = {'.xml': 'QUAKEML',
LOCTOOLS = dict(nll=nll, hyposat=hyposat, velest=velest, hypo71=hypo71, hypodd=hypodd)
class SetChannelComponents:
def getdefaultCompPosition():
class SetChannelComponents(object):
def __init__(self):
self.setDefaultCompPosition()
def setDefaultCompPosition(self):
# default component order
CompPosition_Map = dict(Z=2, N=1, E=0)
CompPosition_Map['1'] = 1
CompPosition_Map['2'] = 0
CompPosition_Map['3'] = 2
CompName_Map = dict(Z='3', N='1', E='2')
CompName_Map['1'] = str(1)
CompName_Map['2'] = str(2)
CompName_Map['3'] = str(3)
return CompPosition_Map, CompName_Map
self.compPosition_Map = dict(Z=2, N=1, E=0)
self.compName_Map = {'3': 'Z',
'1': 'N',
'2': 'E'}
def _getCurrentPosition(self, component):
for key, value in self.compName_Map.items():
if value == component:
return key, value
errMsg = 'getCurrentPosition: Could not find former position of component {}.'.format(component)
raise ValueError(errMsg)
CompPosition_Map, CompName_Map = getdefaultCompPosition()
def _switch(self, component, component_alter):
# Without switching, multiple definitions of the same alter_comp are possible
old_alter_comp, _ = self._getCurrentPosition(component)
old_comp = self.compName_Map[component_alter]
if not old_alter_comp == component_alter and not old_comp == component:
self.compName_Map[old_alter_comp] = old_comp
print('switch: Automatically switched component {} to {}'.format(old_alter_comp, old_comp))
def setCompPosition(self, component, position):
self.CompPosition_Map[component] = position
self.CompName_Map[component] = str(position)
def setCompPosition(self, component_alter, component, switch=True):
component_alter = str(component_alter)
if not component_alter in self.compName_Map.keys():
errMsg='setCompPosition: Unrecognized alternative component {}. Expecting one of {}.'
raise ValueError(errMsg.format(component_alter, self.compName_Map.keys()))
if not component in self.compPosition_Map.keys():
errMsg='setCompPosition: Unrecognized target component {}. Expecting one of {}.'
raise ValueError(errMsg.format(component, self.compPosition_Map.keys()))
print('setCompPosition: set component {} to {}'.format(component_alter, component))
if switch:
self._switch(component, component_alter)
self.compName_Map[component_alter] = component
def getCompPosition(self, component):
self.comppos = self.CompPosition_Map[component]
self.compname = self.CompName_Map[component]
return self.comppos, self.compname
def getCompPosition(self, component):
return self._getCurrentPosition(component)[0]
def getPlotPosition(self, component):
component = str(component)
if component in self.compPosition_Map.keys():
return self.compPosition_Map[component]
elif component in self.compName_Map.keys():
return self.compPosition_Map[self.compName_Map[component]]
else:
errMsg='getCompPosition: Unrecognized component {}. Expecting one of {} or {}.'
raise ValueError(errMsg.format(component, self.compPosition_Map.keys(), self.compName_Map.keys()))

View File

@@ -43,7 +43,7 @@ class map_projection(QtGui.QWidget):
return
data = self._parent.get_data().getWFData()
for index in ind:
station=str(self.station_names[index])
station=str(self.station_names[index].split('.')[-1])
try:
pickDlg = PickDlg(self, parameter=self._parent._inputs,
data=data.select(station=station),
@@ -51,7 +51,7 @@ class map_projection(QtGui.QWidget):
picks=self._parent.get_current_event().getPick(station),
autopicks=self._parent.get_current_event().getAutopick(station))
except Exception as e:
message = 'Could not generate Plot for station {st}.\n{er}'.format(st=station, er=e)
message = 'Could not generate Plot for station {st}.\n {er}'.format(st=station, er=e)
self._warn(message)
print(message, e)
return
@@ -120,8 +120,9 @@ class map_projection(QtGui.QWidget):
lon=[]
for station in parser.stations:
station_name=station[0].station_call_letters
network=station[0].network_code
if not station_name in station_names:
station_names.append(station_name)
station_names.append(network+'.'+station_name)
lat.append(station[0].latitude)
lon.append(station[0].longitude)
return station_names, lat, lon
@@ -137,6 +138,7 @@ class map_projection(QtGui.QWidget):
picks=[]
for station in station_names:
try:
station=station.split('.')[-1]
picks.append(self.picks_dict[station][phase]['mpp'])
except:
picks.append(np.nan)
@@ -234,9 +236,9 @@ class map_projection(QtGui.QWidget):
self.picks_no_nan, (self.latgrid, self.longrid), method='linear') ##################
def draw_contour_filled(self, nlevel='50'):
levels = np.linspace(min(self.picks_rel), max(self.picks_rel), nlevel)
levels = np.linspace(min(self.picks_no_nan), max(self.picks_no_nan), nlevel)
self.contourf = self.basemap.contourf(self.longrid, self.latgrid, self.picksgrid_no_nan,
levels, latlon=True, zorder=9)
levels, latlon=True, zorder=9, alpha=0.5)
def scatter_all_stations(self):
self.sc = self.basemap.scatter(self.lon, self.lat, s=50, facecolor='none', latlon=True,

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import sys, os
from PySide.QtCore import QThread, Signal, Qt
from PySide.QtGui import QDialog, QProgressBar, QLabel, QHBoxLayout
@@ -64,7 +64,9 @@ class Thread(QThread):
except Exception as e:
self._executed = False
self._executedError = e
print(e)
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
sys.stdout = sys.__stdout__
def __del__(self):

View File

@@ -10,7 +10,7 @@ import re
import warnings
import subprocess
from obspy import UTCDateTime, read
from pylot.core.io.inputs import AutoPickParameter
from pylot.core.io.inputs import PylotParameter
def _pickle_method(m):
@@ -497,7 +497,7 @@ def which(program, infile=None):
bpath = os.path.join(os.path.expanduser('~'), '.pylot', infile)
if os.path.exists(bpath):
nllocpath = ":" + AutoPickParameter(bpath).get('nllocbin')
nllocpath = ":" + PylotParameter(bpath).get('nllocbin')
os.environ['PATH'] += nllocpath
except ImportError as e:
print(e.message)

File diff suppressed because it is too large Load Diff