[cleanup] code cleanup by PyCharm
This commit is contained in:
1 parent
754d42c8e3
commit
7a0d3486a6
18 files changed
+285
-269
No files matched your search
@@ -94,7 +94,7 @@ class Array_map(QtGui.QWidget):
|
||||
self.comboBox_phase.currentIndexChanged.connect(self._refresh_drawings)
|
||||
self.comboBox_am.currentIndexChanged.connect(self._refresh_drawings)
|
||||
self.canvas.mpl_connect('motion_notify_event', self.mouse_moved)
|
||||
#self.zoom_id = self.basemap.ax.figure.canvas.mpl_connect('scroll_event', self.zoom)
|
||||
# self.zoom_id = self.basemap.ax.figure.canvas.mpl_connect('scroll_event', self.zoom)
|
||||
|
||||
def _from_dict(self, function, key):
|
||||
return function(self.stations_dict.values(), key=lambda x: x[key])[key]
|
||||
@@ -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 = {}
|
||||
@@ -354,7 +353,7 @@ class Array_map(QtGui.QWidget):
|
||||
def add_cbar(self, label):
|
||||
self.cbax_bg = inset_axes(self.main_ax, width="6%", height="75%", loc=5)
|
||||
cbax = inset_axes(self.main_ax, width='2%', height='70%', loc=5)
|
||||
cbar = self.main_ax.figure.colorbar(self.sc_picked, cax = cbax)
|
||||
cbar = self.main_ax.figure.colorbar(self.sc_picked, cax=cbax)
|
||||
cbar.set_label(label)
|
||||
cbax.yaxis.tick_left()
|
||||
cbax.yaxis.set_label_position('left')
|
||||
|
||||
@@ -33,7 +33,7 @@ class Metadata(object):
|
||||
for index, inventory in enumerate(self.inventories):
|
||||
if index < 2 or (ntotal - index) < 3:
|
||||
repr += '{}\n'.format(inventory)
|
||||
if ntotal > 4 and int(ntotal/2) == index:
|
||||
if ntotal > 4 and int(ntotal / 2) == index:
|
||||
repr += '...\n'
|
||||
if ntotal > 4:
|
||||
repr += '\nTotal of {} inventories. Use Metadata.inventories to see all.'.format(ntotal)
|
||||
@@ -79,11 +79,10 @@ class Metadata(object):
|
||||
self.inventories.remove(path_to_inventory)
|
||||
for filename in self.inventory_files.keys():
|
||||
if filename.startswith(path_to_inventory):
|
||||
del(self.inventory_files[filename])
|
||||
del (self.inventory_files[filename])
|
||||
for seed_id in self.seed_ids.keys():
|
||||
if self.seed_ids[seed_id].startswith(path_to_inventory):
|
||||
del(self.seed_ids[seed_id])
|
||||
|
||||
del (self.seed_ids[seed_id])
|
||||
|
||||
def get_metadata(self, seed_id, time=None):
|
||||
"""
|
||||
@@ -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
|
||||
|
||||
@@ -33,8 +33,8 @@ class Thread(QThread):
|
||||
self._executed = False
|
||||
self._executedError = e
|
||||
traceback.print_exc()
|
||||
exctype, value = sys.exc_info ()[:2]
|
||||
self._executedErrorInfo = '{} {} {}'.\
|
||||
exctype, value = sys.exc_info()[:2]
|
||||
self._executedErrorInfo = '{} {} {}'. \
|
||||
format(exctype, value, traceback.format_exc())
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
@@ -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,
|
||||
@@ -82,7 +83,7 @@ class Worker(QRunnable):
|
||||
super(Worker, self).__init__()
|
||||
self.fun = fun
|
||||
self.args = args
|
||||
#self.kwargs = kwargs
|
||||
# self.kwargs = kwargs
|
||||
self.signals = WorkerSignals()
|
||||
self.progressText = progressText
|
||||
self.pb_widget = pb_widget
|
||||
@@ -96,9 +97,9 @@ class Worker(QRunnable):
|
||||
try:
|
||||
result = self.fun(self.args)
|
||||
except:
|
||||
exctype, value = sys.exc_info ()[:2]
|
||||
exctype, value = sys.exc_info()[:2]
|
||||
print(exctype, value, traceback.format_exc())
|
||||
self.signals.error.emit ((exctype, value, traceback.format_exc ()))
|
||||
self.signals.error.emit((exctype, value, traceback.format_exc()))
|
||||
else:
|
||||
self.signals.result.emit(result)
|
||||
finally:
|
||||
@@ -140,13 +141,13 @@ class MultiThread(QThread):
|
||||
|
||||
def run(self):
|
||||
if self.redirect_stdout:
|
||||
sys.stdout = self
|
||||
sys.stdout = self
|
||||
try:
|
||||
if not self.ncores:
|
||||
self.ncores = multiprocessing.cpu_count()
|
||||
pool = multiprocessing.Pool(self.ncores)
|
||||
self.data = pool.map_async(self.func, self.args, callback=self.emitDone)
|
||||
#self.data = pool.apply_async(self.func, self.shotlist, callback=self.emitDone) #emit each time returned
|
||||
# self.data = pool.apply_async(self.func, self.shotlist, callback=self.emitDone) #emit each time returned
|
||||
pool.close()
|
||||
self._executed = True
|
||||
except Exception as e:
|
||||
|
||||
@@ -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'}
|
||||
@@ -41,9 +43,10 @@ def getAutoFilteroptions(phase, parameter):
|
||||
print('autoPickParameter: No filter options for phase {}.'.format(phase))
|
||||
return
|
||||
freqmin, freqmax = parameter.get(filtername[phase])
|
||||
filteroptions = FilterOptions(type='bandpass', freq=[freqmin, freqmax], order=4) # order=4 default from obspy
|
||||
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
|
||||
@@ -679,7 +682,7 @@ def pick_color(picktype, phase, quality=0):
|
||||
bpc = base_phase_colors(picktype, phase) # returns dict like {'modifier': 'g', 'rgba': (0, 0, 255, 255)}
|
||||
rgba = bpc['rgba']
|
||||
modifier = bpc['modifier']
|
||||
intensity = 255.*quality/min_quality
|
||||
intensity = 255. * quality / min_quality
|
||||
rgba = modify_rgba(rgba, modifier, intensity)
|
||||
return rgba
|
||||
|
||||
@@ -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]
|
||||
@@ -1206,8 +1213,8 @@ def check_event_folder(path):
|
||||
folder = path.split('/')[-1]
|
||||
# for pylot: select only folders that start with 'e', containin two dots and have length 12
|
||||
if (folder.startswith('e')
|
||||
and len(folder.split('.')) == 3
|
||||
and len(folder) == 12):
|
||||
and len(folder.split('.')) == 3
|
||||
and len(folder) == 12):
|
||||
ev_type = 'pylot'
|
||||
elif check_obspydmt_eventfolder(folder)[0]:
|
||||
ev_type = 'obspydmt'
|
||||
|
||||
+57
-59
@@ -17,6 +17,7 @@ import time
|
||||
import numpy as np
|
||||
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use('QT4Agg')
|
||||
|
||||
from matplotlib.figure import Figure
|
||||
@@ -381,8 +382,8 @@ class ComparisonWidget(QWidget):
|
||||
ax = axes_dict[phase]['exp']
|
||||
xlims = ax.get_xlim()
|
||||
ylims = ax.get_ylim()
|
||||
#ax.fill_between([xlims[0], 0], ylims[0], ylims[1], color=(0.9, 1.0, 0.9, 0.5), label='earlier than manual')
|
||||
#ax.fill_between([0, xlims[1]], ylims[0], ylims[1], color=(1.0, 0.9, 0.9, 0.5), label='later than manual')
|
||||
# ax.fill_between([xlims[0], 0], ylims[0], ylims[1], color=(0.9, 1.0, 0.9, 0.5), label='earlier than manual')
|
||||
# ax.fill_between([0, xlims[1]], ylims[0], ylims[1], color=(1.0, 0.9, 0.9, 0.5), label='later than manual')
|
||||
legend = ax.legend()
|
||||
legend.draggable()
|
||||
|
||||
@@ -474,7 +475,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
self.pen_linecolor_syn = self.pg.mkPen((100, 0, 255, 255))
|
||||
self.reinitMoveProxy()
|
||||
self._proxy = self.pg.SignalProxy(self.plotWidget.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved)
|
||||
#self.plotWidget.getPlotItem().setDownsampling(auto=True)
|
||||
# self.plotWidget.getPlotItem().setDownsampling(auto=True)
|
||||
|
||||
def reinitMoveProxy(self):
|
||||
self.vLine = self.pg.InfiniteLine(angle=90, movable=False, pen=self.pen_multicursor)
|
||||
@@ -524,7 +525,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
self.syn_checkbox = QtGui.QCheckBox('synthetics')
|
||||
self.addQCboxItem('processed', 'green')
|
||||
self.addQCboxItem('raw', 'black')
|
||||
#self.perm_qcbox_right.setAlignment(2)
|
||||
# self.perm_qcbox_right.setAlignment(2)
|
||||
self.setLayout(self.main_layout)
|
||||
|
||||
def getPlotDict(self):
|
||||
@@ -608,7 +609,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
print('Warning: Could not set zoom limits')
|
||||
|
||||
for n, (network, station, channel) in enumerate(nsc):
|
||||
n+=1
|
||||
n += 1
|
||||
st = st_select.select(network=network, station=station, channel=channel)
|
||||
trace = st[0].copy()
|
||||
st_syn = wfsyn.select(network=network, station=station, channel=channel)
|
||||
@@ -645,10 +646,11 @@ 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 [])
|
||||
if not index % nth_sample] if st_syn else [])
|
||||
plots.append((times, trace.data,
|
||||
times_syn, trace_syn.data))
|
||||
self.setPlotDict(n, (station, channel, network))
|
||||
@@ -665,11 +667,11 @@ class WaveformWidgetPG(QtGui.QWidget):
|
||||
'''
|
||||
npixel = self.orig_parent.width()
|
||||
ndata = len(trace.data)
|
||||
pts_per_pixel = ndata/npixel
|
||||
pts_per_pixel = ndata / npixel
|
||||
if pts_per_pixel < 2:
|
||||
return trace.data, time_ax
|
||||
remaining_samples = ndata%pts_per_pixel
|
||||
npixel = ndata//pts_per_pixel
|
||||
remaining_samples = ndata % pts_per_pixel
|
||||
npixel = ndata // pts_per_pixel
|
||||
if remaining_samples:
|
||||
data = trace.data[:-remaining_samples]
|
||||
else:
|
||||
@@ -849,7 +851,7 @@ class PylotCanvas(FigureCanvas):
|
||||
break
|
||||
if not ax_check: return
|
||||
|
||||
#self.updateCurrentLimits() #maybe put this down to else:
|
||||
# self.updateCurrentLimits() #maybe put this down to else:
|
||||
|
||||
# calculate delta (relative values in axis)
|
||||
old_x, old_y = self.press_rel
|
||||
@@ -902,13 +904,13 @@ class PylotCanvas(FigureCanvas):
|
||||
d_upper = abs(origin - upper_b)
|
||||
|
||||
if positive:
|
||||
d_lower *= 1 - 1/factor
|
||||
d_upper *= 1 - 1/factor
|
||||
d_lower *= 1 - 1 / factor
|
||||
d_upper *= 1 - 1 / factor
|
||||
lower_b += d_lower
|
||||
upper_b -= d_upper
|
||||
else:
|
||||
d_lower /= 1 + 1/factor
|
||||
d_upper /= 1 + 1/factor
|
||||
d_lower /= 1 + 1 / factor
|
||||
d_upper /= 1 + 1 / factor
|
||||
lower_b -= d_lower
|
||||
upper_b += d_upper
|
||||
|
||||
@@ -1133,9 +1135,9 @@ class PylotCanvas(FigureCanvas):
|
||||
if noiselevel is not None:
|
||||
for level in [-noiselevel[channel], noiselevel[channel]]:
|
||||
ax.plot([time_ax[0], time_ax[-1]],
|
||||
[n+level, n+level],
|
||||
color = linecolor,
|
||||
linestyle = 'dashed')
|
||||
[n + level, n + level],
|
||||
color=linecolor,
|
||||
linestyle='dashed')
|
||||
self.setPlotDict(n, (station, channel, network))
|
||||
if plot_additional and additional_channel:
|
||||
compare_stream = wfdata.select(channel=additional_channel)
|
||||
@@ -1217,7 +1219,7 @@ class PylotCanvas(FigureCanvas):
|
||||
def insertLabel(self, pos, text):
|
||||
pos = pos / max(self.axes[0].ylim)
|
||||
axann = self.axes[0].annotate(text, xy=(.03, pos),
|
||||
xycoords='axes fraction')
|
||||
xycoords='axes fraction')
|
||||
axann.set_bbox(dict(facecolor='lightgrey', alpha=.6))
|
||||
|
||||
def setZoomBorders2content(self):
|
||||
@@ -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:
|
||||
@@ -1512,11 +1512,11 @@ class PickDlg(QDialog):
|
||||
checkable=True,
|
||||
shortcut='S')
|
||||
self.autoFilterAction = createAction(parent=self, text='Automatic Filtering',
|
||||
slot=self.toggleAutoFilter,
|
||||
icon=key_a_icon,
|
||||
tip='Filter automatically before initial pick',
|
||||
checkable=True,
|
||||
shortcut='Ctrl+A')
|
||||
slot=self.toggleAutoFilter,
|
||||
icon=key_a_icon,
|
||||
tip='Filter automatically before initial pick',
|
||||
checkable=True,
|
||||
shortcut='Ctrl+A')
|
||||
self.zoomAction = createAction(parent=self, text='Zoom',
|
||||
slot=self.zoom, icon=zoom_icon,
|
||||
tip='Zoom into waveform',
|
||||
@@ -1604,8 +1604,8 @@ class PickDlg(QDialog):
|
||||
_dialtoolbar.addSeparator()
|
||||
est_label = QLabel('Estimated onsets:')
|
||||
est_label.setStyleSheet('QLabel {'
|
||||
'padding:2px;'
|
||||
'padding-left:5px}')
|
||||
'padding:2px;'
|
||||
'padding-left:5px}')
|
||||
_dialtoolbar.addWidget(est_label)
|
||||
_dialtoolbar.addWidget(self.plot_arrivals_button)
|
||||
_dialtoolbar.addSeparator()
|
||||
@@ -1805,16 +1805,15 @@ class PickDlg(QDialog):
|
||||
picksMenu.addSeparator()
|
||||
|
||||
filterOptionsAction = createAction(parent=self, text="&Filter parameter ...",
|
||||
slot=self.filterOptions,
|
||||
shortcut='Ctrl+F',
|
||||
icon=self.orig_parent.filter_icon)
|
||||
slot=self.filterOptions,
|
||||
shortcut='Ctrl+F',
|
||||
icon=self.orig_parent.filter_icon)
|
||||
filterMenu = menuBar.addMenu('Filter')
|
||||
filterMenu.addAction(self.filterActionP)
|
||||
filterMenu.addAction(self.filterActionS)
|
||||
filterMenu.addAction(self.autoFilterAction)
|
||||
filterMenu.addAction(filterOptionsAction)
|
||||
|
||||
|
||||
def filterOptions(self):
|
||||
if self.orig_parent.adjustFilterOptions():
|
||||
phase = None
|
||||
@@ -1953,7 +1952,7 @@ class PickDlg(QDialog):
|
||||
self.draw()
|
||||
else:
|
||||
self.draw()
|
||||
#self.pick_block = self.togglePickBlocker()
|
||||
# self.pick_block = self.togglePickBlocker()
|
||||
self.disconnect_pick_delete()
|
||||
|
||||
def deactivatePicking(self):
|
||||
@@ -2101,7 +2100,7 @@ class PickDlg(QDialog):
|
||||
def calcNoiseScaleFactor(noiselevel, zoomfactor=5., norm=1):
|
||||
# calculate factor to upscale a trace normed to 'norm' in a way that all values
|
||||
# zoomfactor*noiselevel are found within -0.5*norm and 0.5*norm
|
||||
scaleFactor = (norm/2.) / (zoomfactor * noiselevel)
|
||||
scaleFactor = (norm / 2.) / (zoomfactor * noiselevel)
|
||||
return scaleFactor
|
||||
|
||||
def setIniPick(self, gui_event):
|
||||
@@ -2175,7 +2174,7 @@ class PickDlg(QDialog):
|
||||
try:
|
||||
data.detrend('linear')
|
||||
data.filter(**filteroptions)
|
||||
#wfdata.filter(**filteroptions)# MP MP removed filtering of original data
|
||||
# wfdata.filter(**filteroptions)# MP MP removed filtering of original data
|
||||
except ValueError as e:
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Information,
|
||||
'Denied', 'setIniPick{}: Could not filter waveform: {}'.format(phase, e))
|
||||
@@ -2211,7 +2210,7 @@ class PickDlg(QDialog):
|
||||
x_res = getResolutionWindow(np.mean(snr), parameter.get('extent'))
|
||||
|
||||
xlims = [ini_pick - x_res, ini_pick + x_res]
|
||||
ylims = list(np.array([-.5, .5]) + [0, len(data)-1])
|
||||
ylims = list(np.array([-.5, .5]) + [0, len(data) - 1])
|
||||
|
||||
title = self.getStation() + ' picking mode'
|
||||
if filterphase:
|
||||
@@ -2298,8 +2297,8 @@ class PickDlg(QDialog):
|
||||
self.disconnectPressEvent()
|
||||
self.enable_ar_buttons()
|
||||
self.zoomAction.setEnabled(True)
|
||||
#self.pick_block = self.togglPickBlocker()
|
||||
#self.resetZoom()
|
||||
# self.pick_block = self.togglPickBlocker()
|
||||
# self.resetZoom()
|
||||
self.leave_picking_mode()
|
||||
|
||||
def savePick(self, phase, phasepicks):
|
||||
@@ -2335,7 +2334,7 @@ class PickDlg(QDialog):
|
||||
if self.getPicks(picktype):
|
||||
if phase is not None and not phase == 'SPt':
|
||||
if (type(self.getPicks(picktype)[phase]) is dict
|
||||
or type(self.getPicks(picktype)[phase]) is AttribDict):
|
||||
or type(self.getPicks(picktype)[phase]) is AttribDict):
|
||||
picks = self.getPicks(picktype)[phase]
|
||||
elif phase is None:
|
||||
for phase in self.getPicks(picktype):
|
||||
@@ -2368,7 +2367,7 @@ class PickDlg(QDialog):
|
||||
label='{}-Pick (quality: {})'.format(phase, quality), picker=5)
|
||||
self.phaseLines[phase] = vl
|
||||
if spe:
|
||||
ax.fill_between([mpp-spe, mpp+spe], ylims[0], ylims[1],
|
||||
ax.fill_between([mpp - spe, mpp + spe], ylims[0], ylims[1],
|
||||
alpha=.25, color=color, label='{}-SPE'.format(phase))
|
||||
if picks['epp']:
|
||||
linestyle_epp, width_epp = pick_linestyle_plt(picktype, 'epp')
|
||||
@@ -2414,7 +2413,7 @@ class PickDlg(QDialog):
|
||||
def on_motion(self, event):
|
||||
x = event.xdata
|
||||
if x is not None:
|
||||
time_code = 'T = {}, t = {} [s]'.format(self.stime+x, x)
|
||||
time_code = 'T = {}, t = {} [s]'.format(self.stime + x, x)
|
||||
user_help = ' - Left-Click to Drag | Right-Click to Pan-Zoom |' \
|
||||
' Mousewheel to Zoom | Middle-Click to Delete Pick'
|
||||
self.statusbar.showMessage(time_code + user_help)
|
||||
@@ -2516,10 +2515,10 @@ class PickDlg(QDialog):
|
||||
allpicks[picktype].pop(phase)
|
||||
# delete line from vlines dictionary
|
||||
if phase in self.phaseLines.keys():
|
||||
del(self.phaseLines[phase])
|
||||
del (self.phaseLines[phase])
|
||||
# information output
|
||||
msg = 'Deleted {} pick for phase {}, at timestamp {} (relative time: {} s)'
|
||||
print(msg.format(picktype, phase, self.getStartTime()+pick_rel, pick_rel))
|
||||
print(msg.format(picktype, phase, self.getStartTime() + pick_rel, pick_rel))
|
||||
self.setDirty(True)
|
||||
|
||||
def identify_selected_picks(self, x):
|
||||
@@ -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)
|
||||
@@ -2583,7 +2580,7 @@ class PickDlg(QDialog):
|
||||
return
|
||||
self.cur_xlim = self.multicompfig.axes[0].get_xlim()
|
||||
self.cur_ylim = self.multicompfig.axes[0].get_ylim()
|
||||
#self.multicompfig.updateCurrentLimits()
|
||||
# self.multicompfig.updateCurrentLimits()
|
||||
data = self.getWFData().copy()
|
||||
title = self.getStation()
|
||||
if filter:
|
||||
@@ -2677,7 +2674,6 @@ class PickDlg(QDialog):
|
||||
rval = False
|
||||
return rval
|
||||
|
||||
|
||||
def resetPlot(self):
|
||||
self.resetZoom()
|
||||
self.refreshPlot()
|
||||
@@ -2716,8 +2712,8 @@ class PickDlg(QDialog):
|
||||
|
||||
# set channel labels
|
||||
self.multicompfig.setYTickLabels(pos, labels)
|
||||
#self.multicompfig.setXLims(ax, self.getXLims())
|
||||
#self.multicompfig.setYLims(ax, self.getYLims())
|
||||
# self.multicompfig.setXLims(ax, self.getXLims())
|
||||
# self.multicompfig.setYLims(ax, self.getYLims())
|
||||
|
||||
def zoom(self):
|
||||
if self.zoomAction.isChecked() and self.pick_block:
|
||||
@@ -2779,7 +2775,7 @@ class CanvasWidget(QWidget):
|
||||
'''
|
||||
|
||||
def __init__(self, parent, canvas):
|
||||
QtGui.QWidget.__init__(self, parent)#, 1)
|
||||
QtGui.QWidget.__init__(self, parent) # , 1)
|
||||
canvas = canvas
|
||||
self.main_layout = QtGui.QVBoxLayout()
|
||||
self.setLayout(self.main_layout)
|
||||
@@ -2792,6 +2788,7 @@ class MultiEventWidget(QWidget):
|
||||
'''
|
||||
|
||||
'''
|
||||
|
||||
def __init__(self, options=None, parent=None, windowflag=1):
|
||||
QtGui.QWidget.__init__(self, parent, windowflag)
|
||||
|
||||
@@ -2851,7 +2848,7 @@ class MultiEventWidget(QWidget):
|
||||
self.pb.setRange(0, 0)
|
||||
self.pb.setVisible(False)
|
||||
|
||||
#space holder for progressbar
|
||||
# space holder for progressbar
|
||||
self._pb_space = QtGui.QWidget()
|
||||
|
||||
self.rb_layout.addWidget(self.start_button)
|
||||
@@ -2869,7 +2866,7 @@ class MultiEventWidget(QWidget):
|
||||
eventlist = func()
|
||||
if not type(eventlist) == list:
|
||||
eventlist = [eventlist]
|
||||
tooltip=''
|
||||
tooltip = ''
|
||||
for index, event in enumerate(eventlist):
|
||||
if not event:
|
||||
continue
|
||||
@@ -2885,13 +2882,13 @@ class MultiEventWidget(QWidget):
|
||||
for rb in self.rb_dict.values():
|
||||
if rb.isChecked():
|
||||
check_events = (rb.toolTip() == 'No events for this selection')
|
||||
self.start_button.setEnabled(not(check_events))
|
||||
self.start_button.setEnabled(not (check_events))
|
||||
|
||||
def enable(self, bool):
|
||||
for rb in self.rb_dict.values():
|
||||
rb.setEnabled(bool)
|
||||
self.start_button.setEnabled(bool)
|
||||
self.pb.setVisible(not(bool))
|
||||
self.pb.setVisible(not (bool))
|
||||
self._pb_space.setVisible(bool)
|
||||
self.eventbox.setEnabled(bool)
|
||||
self.button_clear.setEnabled(bool)
|
||||
@@ -2973,7 +2970,7 @@ class AutoPickWidget(MultiEventWidget):
|
||||
def reinitEvents2plot(self):
|
||||
for eventID, eventDict in self.events2plot.items():
|
||||
for widget_key, widget in eventDict.items():
|
||||
del(widget)
|
||||
del (widget)
|
||||
self.events2plot = {}
|
||||
self.eventbox.clear()
|
||||
self.refresh_plot_tabs()
|
||||
@@ -3507,7 +3504,7 @@ class TuneAutopicker(QWidget):
|
||||
if hasattr(self, 'pdlg_widget'):
|
||||
if self.pdlg_widget:
|
||||
self.pdlg_widget.setParent(None)
|
||||
del(self.pdlg_widget)
|
||||
del (self.pdlg_widget)
|
||||
if hasattr(self, 'overview'):
|
||||
self.overview.setParent(None)
|
||||
if hasattr(self, 'p_tabs'):
|
||||
@@ -4725,8 +4722,9 @@ class FilterOptionsDialog(QDialog):
|
||||
'S': FilterOptions()}
|
||||
|
||||
self.setWindowTitle(titleString)
|
||||
self.filterOptionWidgets = {'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoFilteroptions('P')),
|
||||
'S': FilterOptionsWidget(self.filterOptions['S'], self.parent().getAutoFilteroptions('S'))}
|
||||
self.filterOptionWidgets = {
|
||||
'P': FilterOptionsWidget(self.filterOptions['P'], self.parent().getAutoFilteroptions('P')),
|
||||
'S': FilterOptionsWidget(self.filterOptions['S'], self.parent().getAutoFilteroptions('S'))}
|
||||
self.setupUi()
|
||||
self.updateUi()
|
||||
self.connectButtons()
|
||||
@@ -5074,7 +5072,7 @@ class HelpForm(QDialog):
|
||||
toolBar.addWidget(self.pageLabel)
|
||||
self.webBrowser = QWebView()
|
||||
self.webBrowser.load(page)
|
||||
#self.webBrowser.load('C:/Shared/code/git/pylot/pylot/core/util/map_test.html')
|
||||
# self.webBrowser.load('C:/Shared/code/git/pylot/pylot/core/util/map_test.html')
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(toolBar)
|
||||
|
||||
Reference in new issue
Block a user