[cleanup] code cleanup by PyCharm
This commit is contained in:
parent
754d42c8e3
commit
7a0d3486a6
13
PyLoT.py
13
PyLoT.py
@ -48,7 +48,6 @@ from obspy.core.util import AttribDict
|
||||
|
||||
from pylot.core.util.obspyDMT_interface import check_obspydmt_structure
|
||||
|
||||
|
||||
try:
|
||||
import pyqtgraph as pg
|
||||
except Exception as e:
|
||||
@ -195,7 +194,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.loc = False
|
||||
|
||||
|
||||
def init_config_files(self, infile):
|
||||
pylot_config_dir = os.path.join(os.path.expanduser('~'), '.pylot')
|
||||
if not os.path.exists(pylot_config_dir):
|
||||
@ -210,7 +208,6 @@ class MainWindow(QMainWindow):
|
||||
self._inputs.export2File(infile)
|
||||
self.infile = infile
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
try:
|
||||
self.startTime = min(
|
||||
@ -471,7 +468,6 @@ class MainWindow(QMainWindow):
|
||||
checkable=True)
|
||||
self.e_action.setEnabled(False)
|
||||
|
||||
|
||||
componentActions = (self.z_action, self.n_action, self.e_action)
|
||||
|
||||
self.auto_tune = self.createAction(parent=self, text='autoTune',
|
||||
@ -546,13 +542,11 @@ class MainWindow(QMainWindow):
|
||||
self.openProjectAction, self.saveProjectAction,
|
||||
self.saveProjectAsAction)
|
||||
|
||||
|
||||
eventToolActions = (self.addEventDataAction,
|
||||
self.openEventAction, self.openEventsAutoAction,
|
||||
self.saveEventAction, self.loadlocationaction,
|
||||
self.loadpilotevent)
|
||||
|
||||
|
||||
toolbars_keys = [
|
||||
"FileTools",
|
||||
"EventTools",
|
||||
@ -1494,7 +1488,6 @@ class MainWindow(QMainWindow):
|
||||
if len(eventdict) < 1:
|
||||
return
|
||||
|
||||
|
||||
# init event selection options for autopick
|
||||
self.compareoptions = [('tune events', self.get_ref_events, self._style['ref']['rgba']),
|
||||
('test events', self.get_test_events, self._style['test']['rgba']),
|
||||
@ -1521,7 +1514,6 @@ class MainWindow(QMainWindow):
|
||||
compare_widget = self.buildMultiCompareWidget(eventlist_overlap)
|
||||
compare_widget.show()
|
||||
|
||||
|
||||
def buildMultiCompareWidget(self, eventlist):
|
||||
global_comparison = Comparison(eventlist=eventlist)
|
||||
compare_widget = ComparisonWidget(global_comparison, self)
|
||||
@ -2091,7 +2083,8 @@ class MainWindow(QMainWindow):
|
||||
elif self.filterActionS.isChecked():
|
||||
phase = 'S'
|
||||
if self.getFilterOptions():
|
||||
if (phase == 'P' and self.filterActionP.isChecked()) or (phase == 'S' and self.filterActionS.isChecked()):
|
||||
if (phase == 'P' and self.filterActionP.isChecked()) or (
|
||||
phase == 'S' and self.filterActionS.isChecked()):
|
||||
kwargs = self.getFilterOptions()[phase].parseFilterOptions()
|
||||
self.pushFilterWF(kwargs)
|
||||
else:
|
||||
@ -3164,7 +3157,6 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
set_inv(settings)
|
||||
|
||||
|
||||
def calc_magnitude(self, type='ML'):
|
||||
self.init_metadata()
|
||||
if not self.metadata:
|
||||
@ -3350,7 +3342,6 @@ class MainWindow(QMainWindow):
|
||||
self.dataPlot.setPermText(1)
|
||||
self.dataPlot.setPermText(0, '| Number of traces: {} |'.format(len(self.getPlotWidget().getPlotDict())))
|
||||
|
||||
|
||||
def _setDirty(self):
|
||||
self.setDirty(True)
|
||||
|
||||
|
@ -17,6 +17,7 @@ from pylot.core.util.utils import common_range, fit_curve
|
||||
from scipy import integrate, signal
|
||||
from scipy.optimize import curve_fit
|
||||
|
||||
|
||||
def richter_magnitude_scaling(delta):
|
||||
distance = np.array([0, 10, 20, 25, 30, 35, 40, 45, 50, 60, 70, 75, 85, 90, 100, 110,
|
||||
120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 230, 240, 250,
|
||||
@ -261,11 +262,12 @@ class LocalMagnitude(Magnitude):
|
||||
ax.set_xlabel('Time [s]')
|
||||
ax.set_ylabel('Displacement [mm]')
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
return wapp, fig
|
||||
|
||||
def calc(self):
|
||||
|
@ -17,6 +17,7 @@ from pylot.core.util.utils import fnConstructor, full_range, remove_underscores,
|
||||
import pylot.core.loc.velest as velest
|
||||
from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT
|
||||
|
||||
|
||||
class Data(object):
|
||||
"""
|
||||
Data container with attributes wfdata holding ~obspy.core.stream.
|
||||
@ -416,7 +417,6 @@ class Data(object):
|
||||
self.dirty = False
|
||||
return True
|
||||
|
||||
|
||||
def appendWFData(self, fnames, synthetic=False):
|
||||
"""
|
||||
Read waveform data from fnames and append it to current wf data
|
||||
|
@ -346,6 +346,7 @@ def picks_from_picksdict(picks, creation_info=None):
|
||||
picks_list.append(pick)
|
||||
return picks_list
|
||||
|
||||
|
||||
def reassess_pilot_db(root_dir, db_dir, out_dir=None, fn_param=None, verbosity=0):
|
||||
import glob
|
||||
|
||||
|
@ -133,7 +133,8 @@ def call_autopickstation(input_tuple):
|
||||
print('Running in interactive mode')
|
||||
# multiprocessing not possible with interactive plotting
|
||||
try:
|
||||
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata, origin=origin)
|
||||
return autopickstation(wfstream, pickparam, verbose, fig_dict=fig_dict, iplot=iplot, metadata=metadata,
|
||||
origin=origin)
|
||||
except Exception as e:
|
||||
return e, wfstream[0].stats.station
|
||||
|
||||
|
@ -264,7 +264,8 @@ class AICPicker(AutoPicker):
|
||||
& (self.Tcf >= self.Pick)) # TODO: put this in a seperate function like getsignalwin
|
||||
else:
|
||||
islope = np.where((self.Tcf <= min([self.Pick + tslope, self.Tcf[-1]])) \
|
||||
& (self.Tcf >= self.Pick + tsafety)) # TODO: put this in a seperate function like getsignalwin
|
||||
& (
|
||||
self.Tcf >= self.Pick + tsafety)) # TODO: put this in a seperate function like getsignalwin
|
||||
# find maximum within slope determination window
|
||||
# 'cause slope should be calculated up to first local minimum only!
|
||||
try:
|
||||
@ -306,8 +307,10 @@ class AICPicker(AutoPicker):
|
||||
ax.set_title(self.Data[0].stats.station)
|
||||
if plt_flag in [1, 2]:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
return
|
||||
iislope = islope[0][0:imax + 1]
|
||||
@ -368,7 +371,8 @@ class AICPicker(AutoPicker):
|
||||
label='Signal Window')
|
||||
ax2.axvspan(self.Tcf[iislope[0]], self.Tcf[iislope[-1]], color='g', alpha=0.2, lw=0,
|
||||
label='Slope Window')
|
||||
ax2.plot(self.Tcf[pickindex : iaicmax], datafit, 'g', linewidth=2, label='Slope') # MP MP changed temporarily!
|
||||
ax2.plot(self.Tcf[pickindex: iaicmax], datafit, 'g', linewidth=2,
|
||||
label='Slope') # MP MP changed temporarily!
|
||||
|
||||
if self.slope is not None:
|
||||
ax1.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
|
||||
@ -384,8 +388,10 @@ class AICPicker(AutoPicker):
|
||||
|
||||
if plt_flag in [1, 2]:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
if plt_flag == 3:
|
||||
stats = self.Data[0].stats
|
||||
@ -519,15 +525,18 @@ class PragPicker(AutoPicker):
|
||||
ax.plot(Tcfpick, cfipick, color=self._linecolor, linewidth=0.7, label='CF')
|
||||
ax.plot(Tcfpick, cfsmoothipick, 'r', label='Smoothed CF')
|
||||
if pickflag > 0:
|
||||
ax.plot([self.Pick, self.Pick], [min(cfipick), max(cfipick)], self._pickcolor_p, linewidth=2, label='Pick')
|
||||
ax.plot([self.Pick, self.Pick], [min(cfipick), max(cfipick)], self._pickcolor_p, linewidth=2,
|
||||
label='Pick')
|
||||
ax.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||
ax.set_yticks([])
|
||||
ax.set_title(self.Data[0].stats.station)
|
||||
ax.legend(loc=1)
|
||||
if plt_flag == 1:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
return
|
||||
|
||||
|
@ -16,7 +16,6 @@ from obspy.core import Stream, UTCDateTime
|
||||
from pylot.core.util.utils import real_Bool, real_None
|
||||
|
||||
|
||||
|
||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None, linecolor='k'):
|
||||
"""
|
||||
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
|
||||
@ -143,13 +142,16 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None, linecol
|
||||
ax.plot(t, x, color=linecolor, linewidth=0.7, label='Data')
|
||||
ax.axvspan(t[inoise[0]], t[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
|
||||
ax.axvspan(t[isignal[0]], t[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
|
||||
ax.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], color=linecolor, linewidth=0.7, linestyle='dashed', label='Noise Level')
|
||||
ax.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], color=linecolor, linewidth=0.7, linestyle='dashed',
|
||||
label='Noise Level')
|
||||
ax.plot(t[pis[zc]], np.zeros(len(zc)), '*g',
|
||||
markersize=14, label='Zero Crossings')
|
||||
ax.plot([t[0], t[int(len(t)) - 1]], [-nlevel, -nlevel], color=linecolor, linewidth=0.7, linestyle='dashed')
|
||||
ax.plot([Pick1, Pick1], [max(x), -max(x)], 'b', linewidth=2, label='mpp')
|
||||
ax.plot([LPick, LPick], [max(x) / 2, -max(x) / 2], color=linecolor, linewidth=0.7, linestyle='dashed', label='lpp')
|
||||
ax.plot([EPick, EPick], [max(x) / 2, -max(x) / 2], color=linecolor, linewidth=0.7, linestyle='dashed', label='epp')
|
||||
ax.plot([LPick, LPick], [max(x) / 2, -max(x) / 2], color=linecolor, linewidth=0.7, linestyle='dashed',
|
||||
label='lpp')
|
||||
ax.plot([EPick, EPick], [max(x) / 2, -max(x) / 2], color=linecolor, linewidth=0.7, linestyle='dashed',
|
||||
label='epp')
|
||||
ax.plot([Pick1 + PickError, Pick1 + PickError],
|
||||
[max(x) / 2, -max(x) / 2], 'r--', label='spe')
|
||||
ax.plot([Pick1 - PickError, Pick1 - PickError],
|
||||
@ -162,8 +164,10 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None, linecol
|
||||
ax.legend(loc=1)
|
||||
if plt_flag == 1:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
|
||||
return EPick, LPick, PickError
|
||||
@ -359,8 +363,10 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'):
|
||||
ax2.set_yticks([])
|
||||
if plt_flag == 1:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
|
||||
return FM
|
||||
@ -828,8 +834,10 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi
|
||||
ax.set_yticks([])
|
||||
if plt_flag == 1:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
|
||||
return returnflag
|
||||
@ -1064,7 +1072,6 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None, linecolor='k'):
|
||||
else:
|
||||
iplot = 0
|
||||
|
||||
|
||||
assert isinstance(X, Stream), "%s is not a stream object" % str(X)
|
||||
|
||||
print("Check for spuriously picked S onset instead of P onset ...")
|
||||
@ -1165,8 +1172,10 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None, linecolor='k'):
|
||||
ax.set_xlabel('Time [s] since %s' % zdat[0].stats.starttime)
|
||||
if plt_flag == 1:
|
||||
fig.show()
|
||||
try: input()
|
||||
except SyntaxError: pass
|
||||
try:
|
||||
input()
|
||||
except SyntaxError:
|
||||
pass
|
||||
plt.close(fig)
|
||||
return returnflag
|
||||
|
||||
@ -1204,6 +1213,7 @@ def getQualityFromUncertainty(uncertainty, Errors):
|
||||
|
||||
return quality
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
|
||||
|
@ -159,7 +159,6 @@ class Array_map(QtGui.QWidget):
|
||||
self.main_box.addWidget(self.canvas, 1)
|
||||
self.main_box.addWidget(self.status_label, 0)
|
||||
|
||||
|
||||
def init_stations(self):
|
||||
def stat_info_from_parser(parser):
|
||||
stations_dict = {}
|
||||
|
@ -84,7 +84,6 @@ class Metadata(object):
|
||||
if self.seed_ids[seed_id].startswith(path_to_inventory):
|
||||
del (self.seed_ids[seed_id])
|
||||
|
||||
|
||||
def get_metadata(self, seed_id, time=None):
|
||||
"""
|
||||
Get metadata for seed id at time. When time is not specified, metadata for current time is fetched.
|
||||
@ -123,7 +122,6 @@ class Metadata(object):
|
||||
fname = self.seed_ids[seed_id]
|
||||
return self.inventory_files[fname]
|
||||
|
||||
|
||||
def read_all(self):
|
||||
"""
|
||||
Read all metadata files found in all inventories
|
||||
@ -134,7 +132,6 @@ class Metadata(object):
|
||||
if not self.read_single_file(inv_fname):
|
||||
continue
|
||||
|
||||
|
||||
def read_single_file(self, inv_fname):
|
||||
"""
|
||||
Try to read a single file as Parser/Inventory and add its dictionary to inventory files if reading sudceeded.
|
||||
@ -157,7 +154,6 @@ class Metadata(object):
|
||||
'data': robj}
|
||||
return True
|
||||
|
||||
|
||||
def get_coordinates(self, seed_id, time=None):
|
||||
"""
|
||||
Get coordinates of given seed id.
|
||||
@ -176,7 +172,6 @@ class Metadata(object):
|
||||
return
|
||||
return metadata['data'].get_coordinates(seed_id, time)
|
||||
|
||||
|
||||
def get_paz(self, seed_id, time):
|
||||
"""
|
||||
|
||||
@ -195,13 +190,11 @@ class Metadata(object):
|
||||
resp = metadata['data'].get_response(seed_id, time)
|
||||
return resp.get_paz(seed_id)
|
||||
|
||||
|
||||
def _read_inventory_data(self, seed_id=None):
|
||||
for inventory in self.inventories:
|
||||
if self._read_metadata_iterator(path_to_inventory=inventory, station_seed_id=seed_id):
|
||||
return
|
||||
|
||||
|
||||
def _read_metadata_iterator(self, path_to_inventory, station_seed_id):
|
||||
"""
|
||||
Search for metadata for a specific station iteratively.
|
||||
@ -236,7 +229,6 @@ class Metadata(object):
|
||||
continue
|
||||
print('Could not find metadata for station_seed_id {} in path {}'.format(station_seed_id, path_to_inventory))
|
||||
|
||||
|
||||
def _read_metadata_file(self, path_to_inventory_filename):
|
||||
"""
|
||||
function reading metadata files (either dataless seed, xml or resp)
|
||||
@ -262,7 +254,6 @@ class Metadata(object):
|
||||
return file_type, robj
|
||||
return None, None
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _read_dless(path_to_inventory):
|
||||
exc = None
|
||||
@ -272,7 +263,6 @@ class Metadata(object):
|
||||
parser = None
|
||||
return parser, exc
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _read_inventory_file(path_to_inventory):
|
||||
exc = None
|
||||
@ -283,7 +273,6 @@ class Metadata(object):
|
||||
return inv, exc
|
||||
|
||||
|
||||
|
||||
def time_from_header(header):
|
||||
"""
|
||||
Function takes in the second line from a .gse file and takes out the date and time from that line.
|
||||
@ -494,7 +483,6 @@ def read_metadata(path_to_inventory):
|
||||
# return metadata_objects
|
||||
|
||||
|
||||
|
||||
def restitute_trace(input_tuple):
|
||||
def no_metadata(tr, seed_id):
|
||||
print('no metadata file found '
|
||||
|
@ -16,7 +16,6 @@ from pylot.core.loc import hyposat
|
||||
from pylot.core.loc import nll
|
||||
from pylot.core.loc import velest
|
||||
|
||||
|
||||
# determine system dependent path separator
|
||||
system_name = platform.system()
|
||||
if system_name in ["Linux", "Darwin"]:
|
||||
|
@ -4,6 +4,7 @@
|
||||
import os
|
||||
from obspy import UTCDateTime
|
||||
|
||||
|
||||
def check_obspydmt_structure(path):
|
||||
'''
|
||||
Check path for obspyDMT event structure.
|
||||
@ -16,6 +17,7 @@ def check_obspydmt_structure(path):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def check_obspydmt_eventfolder(folder):
|
||||
try:
|
||||
time = folder.split('.')[0]
|
||||
@ -25,6 +27,7 @@ def check_obspydmt_eventfolder(folder):
|
||||
except Exception as e:
|
||||
return False, e
|
||||
|
||||
|
||||
def qml_from_obspyDMT(path):
|
||||
import pickle
|
||||
from obspy.core.event import Event, Magnitude, Origin
|
||||
@ -41,4 +44,3 @@ def qml_from_obspyDMT(path):
|
||||
ev.magnitudes.append(mag)
|
||||
ev.origins.append(origin)
|
||||
return ev
|
||||
|
||||
|
@ -75,6 +75,7 @@ class Worker(QRunnable):
|
||||
'''
|
||||
Worker class to be run by MultiThread(QThread).
|
||||
'''
|
||||
|
||||
def __init__(self, fun, args,
|
||||
progressText=None,
|
||||
pb_widget=None,
|
||||
|
@ -28,12 +28,14 @@ except Exception as e:
|
||||
print('PyLoT: Could not import pyqtgraph. {}'.format(e))
|
||||
pg = None
|
||||
|
||||
|
||||
def _pickle_method(m):
|
||||
if m.im_self is None:
|
||||
return getattr, (m.im_class, m.im_func.func_name)
|
||||
else:
|
||||
return getattr, (m.im_self, m.im_func.func_name)
|
||||
|
||||
|
||||
def getAutoFilteroptions(phase, parameter):
|
||||
filtername = {'P': 'bpz2',
|
||||
'S': 'bph2'}
|
||||
@ -44,6 +46,7 @@ def getAutoFilteroptions(phase, parameter):
|
||||
filteroptions = FilterOptions(type='bandpass', freq=[freqmin, freqmax], order=4) # order=4 default from obspy
|
||||
return filteroptions
|
||||
|
||||
|
||||
def readDefaultFilterInformation(fname):
|
||||
"""
|
||||
Read default filter information from pylot.in file
|
||||
@ -791,6 +794,7 @@ def base_phase_colors(picktype, phase):
|
||||
phasecolors = style_settings.phasecolors
|
||||
return phasecolors[picktype][phase]
|
||||
|
||||
|
||||
def transform_colors_mpl_str(colors, no_alpha=False):
|
||||
"""
|
||||
Transforms rgba color values to a matplotlib string of color values with a range of [0, 1]
|
||||
@ -809,6 +813,7 @@ def transform_colors_mpl_str(colors, no_alpha=False):
|
||||
colors_mpl = '({}, {}, {}, {})'.format(*colors_mpl)
|
||||
return colors_mpl
|
||||
|
||||
|
||||
def transform_colors_mpl(colors):
|
||||
"""
|
||||
Transform rgba colors from [0, 255] to [0, 1]
|
||||
@ -821,6 +826,7 @@ def transform_colors_mpl(colors):
|
||||
colors_mpl = tuple([color / 255. for color in colors])
|
||||
return colors_mpl
|
||||
|
||||
|
||||
def remove_underscores(data):
|
||||
"""
|
||||
takes a `obspy.core.stream.Stream` object and removes all underscores
|
||||
@ -976,7 +982,8 @@ def check4rotated(data, metadata=None, verbosity=1):
|
||||
wfstream[2], azimuts[2], dips[2])
|
||||
print('check4rotated: rotated trace {} to ZNE'.format(trace_id))
|
||||
# replace old data with rotated data, change the channel code to ZNE
|
||||
z_index = dips.index(min(dips)) # get z-trace index, z has minimum dip of -90 (dip is measured from 0 to -90, with -90 being vertical)
|
||||
z_index = dips.index(min(
|
||||
dips)) # get z-trace index, z has minimum dip of -90 (dip is measured from 0 to -90, with -90 being vertical)
|
||||
wfstream[z_index].data = z
|
||||
wfstream[z_index].stats.channel = wfstream[z_index].stats.channel[0:-1] + 'Z'
|
||||
del trace_ids[z_index]
|
||||
|
@ -17,6 +17,7 @@ import time
|
||||
import numpy as np
|
||||
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use('QT4Agg')
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
@ -645,7 +646,8 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
trace_syn.normalize(np.max(np.abs(trace_syn.data)) * 2)
|
||||
# TODO: change this to numpy operations instead of lists?
|
||||
times = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample])
|
||||
times_syn = np.array([time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else [])
|
||||
times_syn = np.array(
|
||||
[time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else [])
|
||||
trace.data = np.array([datum + n for index, datum in enumerate(trace.data) if not index % nth_sample])
|
||||
trace_syn.data = np.array([datum + n for index, datum in enumerate(trace_syn.data)
|
||||
if not index % nth_sample] if st_syn else [])
|
||||
@ -1441,7 +1443,6 @@ class PickDlg(QDialog):
|
||||
self.multicompfig.draw()
|
||||
self.multicompfig.setFocus()
|
||||
|
||||
|
||||
# set plot labels
|
||||
self.setPlotLabels()
|
||||
|
||||
@ -1467,7 +1468,6 @@ class PickDlg(QDialog):
|
||||
self.setWindowTitle('Pickwindow on station: {}'.format(self.getStation()))
|
||||
self.setWindowState(QtCore.Qt.WindowMaximized)
|
||||
|
||||
|
||||
def setupUi(self):
|
||||
menuBar = QtGui.QMenuBar(self)
|
||||
if not self._embedded:
|
||||
@ -1814,7 +1814,6 @@ class PickDlg(QDialog):
|
||||
filterMenu.addAction(self.autoFilterAction)
|
||||
filterMenu.addAction(filterOptionsAction)
|
||||
|
||||
|
||||
def filterOptions(self):
|
||||
if self.orig_parent.adjustFilterOptions():
|
||||
phase = None
|
||||
@ -2545,8 +2544,6 @@ class PickDlg(QDialog):
|
||||
pick_rel, phase, picktype = X[index]
|
||||
return allpicks, pick_rel, phase, picktype
|
||||
|
||||
|
||||
|
||||
def drawPhaseText(self):
|
||||
self.drawPicks(picktype='manual', textOnly=True)
|
||||
self.drawPicks(picktype='auto', textOnly=True)
|
||||
@ -2677,7 +2674,6 @@ class PickDlg(QDialog):
|
||||
rval = False
|
||||
return rval
|
||||
|
||||
|
||||
def resetPlot(self):
|
||||
self.resetZoom()
|
||||
self.refreshPlot()
|
||||
@ -2792,6 +2788,7 @@ class MultiEventWidget(QWidget):
|
||||
'''
|
||||
|
||||
'''
|
||||
|
||||
def __init__(self, options=None, parent=None, windowflag=1):
|
||||
QtGui.QWidget.__init__(self, parent, windowflag)
|
||||
|
||||
@ -4725,7 +4722,8 @@ class FilterOptionsDialog(QDialog):
|
||||
'S': FilterOptions()}
|
||||
|
||||
self.setWindowTitle(titleString)
|
||||
self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoFilteroptions('P')),
|
||||
self.filterOptionWidgets = {
|
||||
'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoFilteroptions('P')),
|
||||
'S': FilterOptionsWidget(self.filterOptions['S'], self.parent().getAutoFilteroptions('S'))}
|
||||
self.setupUi()
|
||||
self.updateUi()
|
||||
|
@ -67,4 +67,3 @@ stylecolors = {
|
||||
'filename': 'bright.qss'}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ from obspy.io.xseed import Parser
|
||||
from pylot.core.util.dataprocessing import Metadata
|
||||
from tests.utils import HidePrints
|
||||
|
||||
|
||||
class TestMetadata(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -16,9 +17,12 @@ class TestMetadata(unittest.TestCase):
|
||||
self.m = Metadata(metadata_folder)
|
||||
|
||||
def test_get_coordinates_sucess(self):
|
||||
expected = {'Z': {u'elevation': 607.0, u'longitude': 12.87571, u'local_depth': 0.0, u'azimuth': 0.0, u'latitude': 49.14502, u'dip': -90.0},
|
||||
'E': {u'azimuth': 90.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0, u'longitude': 12.87571},
|
||||
'N': {u'azimuth': 0.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0, u'longitude': 12.87571}
|
||||
expected = {'Z': {u'elevation': 607.0, u'longitude': 12.87571, u'local_depth': 0.0, u'azimuth': 0.0,
|
||||
u'latitude': 49.14502, u'dip': -90.0},
|
||||
'E': {u'azimuth': 90.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502,
|
||||
u'local_depth': 0.0, u'longitude': 12.87571},
|
||||
'N': {u'azimuth': 0.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0,
|
||||
u'longitude': 12.87571}
|
||||
}
|
||||
result = {}
|
||||
for channel in ('Z', 'N', 'E'):
|
||||
@ -28,9 +32,12 @@ class TestMetadata(unittest.TestCase):
|
||||
self.assertDictEqual(result[channel], expected[channel])
|
||||
|
||||
def test_get_coordinates_sucess_no_time(self):
|
||||
expected = {'Z': {u'elevation': 607.0, u'longitude': 12.87571, u'local_depth': 0.0, u'azimuth': 0.0, u'latitude': 49.14502, u'dip': -90.0},
|
||||
'E': {u'azimuth': 90.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0, u'longitude': 12.87571},
|
||||
'N': {u'azimuth': 0.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0, u'longitude': 12.87571}
|
||||
expected = {'Z': {u'elevation': 607.0, u'longitude': 12.87571, u'local_depth': 0.0, u'azimuth': 0.0,
|
||||
u'latitude': 49.14502, u'dip': -90.0},
|
||||
'E': {u'azimuth': 90.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502,
|
||||
u'local_depth': 0.0, u'longitude': 12.87571},
|
||||
'N': {u'azimuth': 0.0, u'dip': 0.0, u'elevation': 607.0, u'latitude': 49.14502, u'local_depth': 0.0,
|
||||
u'longitude': 12.87571}
|
||||
}
|
||||
result = {}
|
||||
for channel in ('Z', 'N', 'E'):
|
||||
@ -63,8 +70,10 @@ class TestMetadataAdding(unittest.TestCase):
|
||||
fpath = os.path.join(self.metadata_folders[0], 'DATALESS.BW.WETR..HHZ')
|
||||
self.m.add_inventory_file(fpath)
|
||||
# adding an inventory file should append its folder to the list of inventories and the file to the
|
||||
self.assertEqual([os.path.join(self.metadata_folders[0], 'DATALESS.BW.WETR..HHZ')], self.m.inventory_files.keys()) # does the filename exist in inventory files?
|
||||
self.assertEqual(['data', 'invtype'], self.m.inventory_files[os.path.join(self.metadata_folders[0], 'DATALESS.BW.WETR..HHZ')].keys()) # is the required information attacht to the filename?
|
||||
self.assertEqual([os.path.join(self.metadata_folders[0], 'DATALESS.BW.WETR..HHZ')],
|
||||
self.m.inventory_files.keys()) # does the filename exist in inventory files?
|
||||
self.assertEqual(['data', 'invtype'], self.m.inventory_files[os.path.join(self.metadata_folders[0],
|
||||
'DATALESS.BW.WETR..HHZ')].keys()) # is the required information attacht to the filename?
|
||||
self.assertDictEqual({}, self.m.seed_ids)
|
||||
self.assertEqual([self.metadata_folders[0]], self.m.inventories)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user