[update] testing min/max plot (WIP)
This commit is contained in:
parent
10c26a8261
commit
ba37d587a6
7
PyLoT.py
7
PyLoT.py
@ -1667,8 +1667,8 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def check_plot_quantity(self):
|
def check_plot_quantity(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
nth_sample = settings.value("nth_sample") if settings.value("nth_sample") else 1
|
nth_sample = int(settings.value("nth_sample")) if settings.value("nth_sample") else 1
|
||||||
npts_max = 1e6
|
npts_max = 1e7
|
||||||
npts = self.get_npts_to_plot()
|
npts = self.get_npts_to_plot()
|
||||||
npts2plot = npts/nth_sample
|
npts2plot = npts/nth_sample
|
||||||
if npts2plot < npts_max:
|
if npts2plot < npts_max:
|
||||||
@ -1677,7 +1677,8 @@ class MainWindow(QMainWindow):
|
|||||||
message = "You are about to plot a huge dataset with {npts} datapoints. With a current setting of " \
|
message = "You are about to plot a huge dataset with {npts} datapoints. With a current setting of " \
|
||||||
"nth_sample = {nth_sample} a total of {npts2plot} points will be plotted which is more " \
|
"nth_sample = {nth_sample} a total of {npts2plot} points will be plotted which is more " \
|
||||||
"than the maximum setting of {npts_max}. " \
|
"than the maximum setting of {npts_max}. " \
|
||||||
"PyLoT recommends to raise nth_sample from {nth_sample} to {nth_sample_new}. Continue?"
|
"PyLoT recommends to raise nth_sample from {nth_sample} to {nth_sample_new}. Do you want "\
|
||||||
|
"to change nth_sample to {nth_sample_new} now?"
|
||||||
|
|
||||||
ans = QMessageBox.question(self, self.tr("Optimize plot performance..."),
|
ans = QMessageBox.question(self, self.tr("Optimize plot performance..."),
|
||||||
self.tr(message.format(npts=npts,
|
self.tr(message.format(npts=npts,
|
||||||
|
@ -379,9 +379,10 @@ class Data(object):
|
|||||||
self.wfsyn = Stream()
|
self.wfsyn = Stream()
|
||||||
wffnames = None
|
wffnames = None
|
||||||
wffnames_syn = None
|
wffnames_syn = None
|
||||||
|
wfdir = 'processed' if 'processed' in [fname.split('/')[-1] for fname in fnames] else 'raw'
|
||||||
if obspy_dmt:
|
if obspy_dmt:
|
||||||
for fpath in fnames:
|
for fpath in fnames:
|
||||||
if fpath.endswith('raw'):
|
if fpath.endswith(wfdir):
|
||||||
wffnames = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
|
wffnames = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
|
||||||
if 'syngine' in fpath.split('/')[-1]:
|
if 'syngine' in fpath.split('/')[-1]:
|
||||||
wffnames_syn = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
|
wffnames_syn = [os.path.join(fpath, fname) for fname in os.listdir(fpath)]
|
||||||
|
@ -25,6 +25,7 @@ except ImportError:
|
|||||||
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
|
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
|
||||||
from matplotlib.widgets import MultiCursor
|
from matplotlib.widgets import MultiCursor
|
||||||
from matplotlib.tight_layout import get_renderer, get_subplotspec_list, get_tight_layout_figure
|
from matplotlib.tight_layout import get_renderer, get_subplotspec_list, get_tight_layout_figure
|
||||||
|
from scipy.signal import argrelmin, argrelmax
|
||||||
|
|
||||||
from PySide import QtCore, QtGui
|
from PySide import QtCore, QtGui
|
||||||
from PySide.QtGui import QAction, QApplication, QCheckBox, QComboBox, \
|
from PySide.QtGui import QAction, QApplication, QCheckBox, QComboBox, \
|
||||||
@ -539,9 +540,9 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
n+=1
|
n+=1
|
||||||
st = st_select.select(network=network, station=station, channel=channel)
|
st = st_select.select(network=network, station=station, channel=channel)
|
||||||
st_syn = wfsyn.select(network=network, station=station, channel=channel)
|
st_syn = wfsyn.select(network=network, station=station, channel=channel)
|
||||||
trace = st[0]
|
trace = st[0].copy()
|
||||||
if st_syn:
|
if st_syn:
|
||||||
trace_syn = st_syn[0]
|
trace_syn = st_syn[0].copy()
|
||||||
if mapping:
|
if mapping:
|
||||||
comp = channel[-1]
|
comp = channel[-1]
|
||||||
n = compclass.getPlotPosition(str(comp))
|
n = compclass.getPlotPosition(str(comp))
|
||||||
@ -552,23 +553,46 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
msg = 'plotting %s channel of station %s' % (channel, station)
|
msg = 'plotting %s channel of station %s' % (channel, station)
|
||||||
print(msg)
|
print(msg)
|
||||||
stime = trace.stats.starttime - self.wfstart
|
stime = trace.stats.starttime - self.wfstart
|
||||||
|
|
||||||
time_ax = prepTimeAxis(stime, trace)
|
time_ax = prepTimeAxis(stime, trace)
|
||||||
if st_syn:
|
if st_syn:
|
||||||
stime_syn = trace_syn.stats.starttime - self.wfstart
|
stime_syn = trace_syn.stats.starttime - self.wfstart
|
||||||
time_ax_syn = prepTimeAxis(stime_syn, trace_syn)
|
time_ax_syn = prepTimeAxis(stime_syn, trace_syn)
|
||||||
if time_ax is not None:
|
|
||||||
|
# TEST TEST max/min plot
|
||||||
|
minsamples = argrelmin(trace.data)
|
||||||
|
maxsamples = argrelmax(trace.data)
|
||||||
|
plot_samples = np.sort(np.append(minsamples, maxsamples))
|
||||||
|
trace.data = trace.data[plot_samples]
|
||||||
|
time_ax = time_ax[plot_samples]
|
||||||
|
if st_syn:
|
||||||
|
minsamples_syn = argrelmin(trace_syn.data)
|
||||||
|
maxsamples_syn = argrelmax(trace_syn.data)
|
||||||
|
plot_samples_syn = np.sort(np.append(minsamples_syn, maxsamples_syn))
|
||||||
|
trace_syn.data = trace_syn.data[plot_samples_syn]
|
||||||
|
time_ax_syn = time_ax_syn[plot_samples_syn]
|
||||||
|
|
||||||
|
# TEST TEST Remove middle of seismograms for overview plot
|
||||||
|
# trace.data = trace.data[abs(trace.data) > 0.1 * max(abs(trace.data))]
|
||||||
|
# if st_syn:
|
||||||
|
# trace.data_syn = trace.data_syn[abs(trace.data_syn) > 0.1 * max(abs(trace.data))]
|
||||||
|
# TEST TEST ------
|
||||||
|
|
||||||
|
if time_ax not in [None, []]:
|
||||||
if not scaleddata:
|
if not scaleddata:
|
||||||
trace.detrend('constant')
|
trace.detrend('constant')
|
||||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||||
if st_syn:
|
if st_syn:
|
||||||
trace_syn.detrend('constant')
|
trace_syn.detrend('constant')
|
||||||
trace_syn.normalize(np.max(np.abs(trace_syn.data)) * 2)
|
trace_syn.normalize(np.max(np.abs(trace_syn.data)) * 2)
|
||||||
times = [time for index, time in enumerate(time_ax) if not index % nth_sample]
|
# TODO: change this to numpy operations instead of lists?
|
||||||
times_syn = [time for index, time in enumerate(time_ax_syn) if not index % nth_sample] if st_syn else []
|
times = np.array([time for index, time in enumerate(time_ax) if not index % nth_sample])
|
||||||
data = [datum + n for index, datum in enumerate(trace.data) 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 [])
|
||||||
data_syn = [datum + n for index, datum in enumerate(trace_syn.data)
|
trace.data = np.array([datum + n for index, datum in enumerate(trace.data) if not index % nth_sample])
|
||||||
if not index % nth_sample] if st_syn else []
|
trace.data_syn = np.array([datum + n for index, datum in enumerate(trace.data_syn)
|
||||||
plots.append((times, data, times_syn, data_syn))
|
if not index % nth_sample] if st_syn else [])
|
||||||
|
plots.append((times, trace.data,
|
||||||
|
times_syn, trace.data_syn))
|
||||||
self.setPlotDict(n, (station, channel, network))
|
self.setPlotDict(n, (station, channel, network))
|
||||||
self.xlabel = 'seconds since {0}'.format(self.wfstart)
|
self.xlabel = 'seconds since {0}'.format(self.wfstart)
|
||||||
self.ylabel = ''
|
self.ylabel = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user