autoPyLoT: figure beautification
also added nav toolbar to TuneAutopicker
This commit is contained in:
parent
77b076d560
commit
4d9c7b02cf
16
QtPyLoT.py
16
QtPyLoT.py
@ -556,12 +556,14 @@ class MainWindow(QMainWindow):
|
|||||||
self.drawPicks(picktype=type)
|
self.drawPicks(picktype=type)
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def getCurrentEvent(self):
|
def getCurrentEvent(self, eventlist=None):
|
||||||
for event in self.project.eventlist:
|
if not eventlist:
|
||||||
if event.path == self.getCurrentEventPath():
|
eventlist = self.project.eventlist
|
||||||
|
for event in eventlist:
|
||||||
|
if event.path == self.getCurrentEventPath(eventlist):
|
||||||
return event
|
return event
|
||||||
|
|
||||||
def getCurrentEventPath(self):
|
def getCurrentEventPath(self, eventlist=None):
|
||||||
return str(self.eventBox.currentText().split('|')[0]).strip()
|
return str(self.eventBox.currentText().split('|')[0]).strip()
|
||||||
|
|
||||||
def getLastEvent(self):
|
def getLastEvent(self):
|
||||||
@ -604,10 +606,10 @@ class MainWindow(QMainWindow):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
def getWFFnames_from_eventlist(self):
|
def getWFFnames_from_eventlist(self, eventlist=None):
|
||||||
if self.dataStructure:
|
if self.dataStructure:
|
||||||
searchPath = self.dataStructure.expandDataPath()
|
searchPath = self.dataStructure.expandDataPath()
|
||||||
directory = self.getCurrentEventPath()
|
directory = self.getCurrentEventPath(eventlist)
|
||||||
self.fnames = [os.path.join(directory, f) for f in os.listdir(directory)]
|
self.fnames = [os.path.join(directory, f) for f in os.listdir(directory)]
|
||||||
else:
|
else:
|
||||||
raise DatastructureError('not specified')
|
raise DatastructureError('not specified')
|
||||||
@ -940,7 +942,7 @@ class MainWindow(QMainWindow):
|
|||||||
# ans = self.data.setWFData(self.getWFFnames())
|
# ans = self.data.setWFData(self.getWFFnames())
|
||||||
# else:
|
# else:
|
||||||
# ans = False
|
# ans = False
|
||||||
self.data.setWFData(self.getWFFnames_from_eventlist())
|
self.data.setWFData(self.getWFFnames_from_eventlist(self.project.eventlist))
|
||||||
self._stime = full_range(self.get_data().getWFData())[0]
|
self._stime = full_range(self.get_data().getWFData())[0]
|
||||||
|
|
||||||
def connectWFplotEvents(self):
|
def connectWFplotEvents(self):
|
||||||
|
@ -1 +1 @@
|
|||||||
12e6-dirty
|
77b07-dirty
|
||||||
|
@ -700,7 +700,7 @@ def autopickstation(wfstream, pickparam, verbose=False, iplot=0, fig_dict=None):
|
|||||||
|
|
||||||
if len(edat[0]) > 1 and len(ndat[0]) > 1 and Sflag == 1:
|
if len(edat[0]) > 1 and len(ndat[0]) > 1 and Sflag == 1:
|
||||||
# plot horizontal traces
|
# plot horizontal traces
|
||||||
ax2 = fig.add_subplot(312)
|
ax2 = fig.add_subplot(3,1,2,sharex=ax1)
|
||||||
th1data = np.arange(0,
|
th1data = np.arange(0,
|
||||||
trH1_filt.stats.npts /
|
trH1_filt.stats.npts /
|
||||||
trH1_filt.stats.sampling_rate,
|
trH1_filt.stats.sampling_rate,
|
||||||
@ -749,7 +749,7 @@ def autopickstation(wfstream, pickparam, verbose=False, iplot=0, fig_dict=None):
|
|||||||
ax2.set_ylabel('Normalized Counts')
|
ax2.set_ylabel('Normalized Counts')
|
||||||
#fig.suptitle(trH1_filt.stats.starttime)
|
#fig.suptitle(trH1_filt.stats.starttime)
|
||||||
|
|
||||||
ax3 = fig.add_subplot(313)
|
ax3 = fig.add_subplot(3,1,3, sharex=ax1)
|
||||||
th2data = np.arange(0,
|
th2data = np.arange(0,
|
||||||
trH2_filt.stats.npts /
|
trH2_filt.stats.npts /
|
||||||
trH2_filt.stats.sampling_rate,
|
trH2_filt.stats.sampling_rate,
|
||||||
|
@ -268,22 +268,28 @@ class AICPicker(AutoPicker):
|
|||||||
ax1.plot([self.Pick, self.Pick], [-0.1, 0.5], 'b', linewidth=2, label='AIC-Pick')
|
ax1.plot([self.Pick, self.Pick], [-0.1, 0.5], 'b', linewidth=2, label='AIC-Pick')
|
||||||
ax1.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
ax1.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
ax1.set_yticks([])
|
ax1.set_yticks([])
|
||||||
ax1.set_title(self.Data[0].stats.station)
|
|
||||||
ax1.legend()
|
ax1.legend()
|
||||||
|
|
||||||
if self.Pick is not None:
|
if self.Pick is not None:
|
||||||
ax2 = fig.add_subplot(212)
|
ax2 = fig.add_subplot(2,1,2, sharex=ax1)
|
||||||
ax2.plot(self.Tcf, x, 'k', label='Data')
|
ax2.plot(self.Tcf, x, 'k', label='Data')
|
||||||
ax2.plot(self.Tcf[inoise], self.Data[0].data[inoise], label='Noise Window')
|
ax1.axvspan(self.Tcf[inoise[0]],self.Tcf[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
|
||||||
ax2.plot(self.Tcf[isignal], self.Data[0].data[isignal], 'r', label='Signal Window')
|
ax1.axvspan(self.Tcf[isignal[0]],self.Tcf[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
|
||||||
ax2.plot(self.Tcf[islope], dataslope, 'g--', label='Slope Window')
|
ax1.axvspan(self.Tcf[islope[0]],self.Tcf[islope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')
|
||||||
|
|
||||||
|
ax2.axvspan(self.Tcf[inoise[0]],self.Tcf[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
|
||||||
|
ax2.axvspan(self.Tcf[isignal[0]],self.Tcf[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
|
||||||
|
ax2.axvspan(self.Tcf[islope[0]],self.Tcf[islope[-1]], color='g', alpha=0.2, lw=0, label='Slope Window')
|
||||||
ax2.plot(self.Tcf[islope], datafit, 'g', linewidth=2, label='Slope')
|
ax2.plot(self.Tcf[islope], datafit, 'g', linewidth=2, label='Slope')
|
||||||
ax2.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
|
|
||||||
|
ax1.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
|
||||||
self.SNR, self.slope))
|
self.SNR, self.slope))
|
||||||
ax2.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
ax2.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
ax2.set_ylabel('Counts')
|
ax2.set_ylabel('Counts')
|
||||||
ax2.set_yticks([])
|
ax2.set_yticks([])
|
||||||
ax2.legend()
|
ax2.legend()
|
||||||
|
else:
|
||||||
|
ax1.set_title(self.Data[0].stats.station)
|
||||||
|
|
||||||
if self.Pick == None:
|
if self.Pick == None:
|
||||||
print('AICPicker: Could not find minimum, picking window too short?')
|
print('AICPicker: Could not find minimum, picking window too short?')
|
||||||
|
@ -105,12 +105,11 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=Non
|
|||||||
|
|
||||||
if iplot > 1:
|
if iplot > 1:
|
||||||
if not fig:
|
if not fig:
|
||||||
print('New Figure.........................')
|
|
||||||
fig = plt.figure()#iplot)
|
fig = plt.figure()#iplot)
|
||||||
ax = fig.add_subplot(111)
|
ax = fig.add_subplot(111)
|
||||||
ax.plot(t, x, 'k', label='Data')
|
ax.plot(t, x, 'k', label='Data')
|
||||||
ax.plot(t[inoise], x[inoise], label='Noise Window')
|
ax.axvspan(t[inoise[0]], t[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
|
||||||
ax.plot(t[isignal], x[isignal], 'r', label='Signal 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], '--k', label='Noise Level')
|
ax.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], '--k', label='Noise Level')
|
||||||
ax.plot(t[isignal[zc]], np.zeros(len(zc)), '*g',
|
ax.plot(t[isignal[zc]], np.zeros(len(zc)), '*g',
|
||||||
markersize=14, label='Zero Crossings')
|
markersize=14, label='Zero Crossings')
|
||||||
@ -292,7 +291,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None, fig=None):
|
|||||||
ax1.set_title('First-Motion Determination, %s, Unfiltered Data' % Xraw[
|
ax1.set_title('First-Motion Determination, %s, Unfiltered Data' % Xraw[
|
||||||
0].stats.station)
|
0].stats.station)
|
||||||
|
|
||||||
ax2=fig.add_subplot(212)
|
ax2=fig.add_subplot(2,1,2, sharex=ax1)
|
||||||
ax2.set_title('First-Motion Determination, Filtered Data')
|
ax2.set_title('First-Motion Determination, Filtered Data')
|
||||||
ax2.plot(t, xfilt, 'k')
|
ax2.plot(t, xfilt, 'k')
|
||||||
ax2.plot([Pick, Pick], [max(xfilt), -max(xfilt)], 'b',
|
ax2.plot([Pick, Pick], [max(xfilt), -max(xfilt)], 'b',
|
||||||
@ -693,8 +692,8 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi
|
|||||||
fig = plt.figure()#iplot)
|
fig = plt.figure()#iplot)
|
||||||
ax = fig.add_subplot(111)
|
ax = fig.add_subplot(111)
|
||||||
ax.plot(t, rms, 'k', label='RMS Data')
|
ax.plot(t, rms, 'k', label='RMS Data')
|
||||||
ax.plot(t[inoise], rms[inoise], 'c', label='RMS Noise Window')
|
ax.axvspan(t[inoise[0]], t[inoise[-1]], color='y', alpha=0.2, lw=0, label='Noise Window')
|
||||||
ax.plot(t[isignal], rms[isignal], 'r', label='RMS Signal Window')
|
ax.axvspan(t[isignal[0]], t[isignal[-1]], color='b', alpha=0.2, lw=0, label='Signal Window')
|
||||||
ax.plot([t[isignal[0]], t[isignal[len(isignal) - 1]]],
|
ax.plot([t[isignal[0]], t[isignal[len(isignal) - 1]]],
|
||||||
[minsiglevel, minsiglevel], 'g', linewidth=2, label='Minimum Signal Level')
|
[minsiglevel, minsiglevel], 'g', linewidth=2, label='Minimum Signal Level')
|
||||||
ax.plot([pick, pick], [min(rms), max(rms)], 'b', linewidth=2, label='Onset')
|
ax.plot([pick, pick], [min(rms), max(rms)], 'b', linewidth=2, label='Onset')
|
||||||
@ -964,11 +963,10 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None):
|
|||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
ax = fig.add_subplot(111)
|
ax = fig.add_subplot(111)
|
||||||
ax.plot(tz, z / max(z), 'k')
|
ax.plot(tz, z / max(z), 'k')
|
||||||
ax.plot(tz[isignal], z[isignal] / max(z), 'r')
|
ax.axvspan(tz[isignal[0]], tz[isignal[-1]], color='b', alpha=0.2,
|
||||||
|
lw=0, label='Signal Window')
|
||||||
ax.plot(te, edat[0].data / max(edat[0].data) + 1, 'k')
|
ax.plot(te, edat[0].data / max(edat[0].data) + 1, 'k')
|
||||||
ax.plot(te[isignal], edat[0].data[isignal] / max(edat[0].data) + 1, 'r')
|
|
||||||
ax.plot(tn, ndat[0].data / max(ndat[0].data) + 2, 'k')
|
ax.plot(tn, ndat[0].data / max(ndat[0].data) + 2, 'k')
|
||||||
ax.plot(tn[isignal], ndat[0].data[isignal] / max(ndat[0].data) + 2, 'r')
|
|
||||||
ax.plot([tz[isignal[0]], tz[isignal[len(isignal) - 1]]],
|
ax.plot([tz[isignal[0]], tz[isignal[len(isignal) - 1]]],
|
||||||
[minsiglevel / max(z), minsiglevel / max(z)], 'g',
|
[minsiglevel / max(z), minsiglevel / max(z)], 'g',
|
||||||
linewidth=2, label='Minimum Signal Level')
|
linewidth=2, label='Minimum Signal Level')
|
||||||
|
@ -1294,8 +1294,8 @@ class TuneAutopicker(QWidget):
|
|||||||
self.trace_layout = QtGui.QHBoxLayout()
|
self.trace_layout = QtGui.QHBoxLayout()
|
||||||
self.parameter_layout = QtGui.QVBoxLayout()
|
self.parameter_layout = QtGui.QVBoxLayout()
|
||||||
|
|
||||||
self.main_layout.addLayout(self.tune_layout)
|
|
||||||
self.main_layout.addLayout(self.trace_layout)
|
self.main_layout.addLayout(self.trace_layout)
|
||||||
|
self.main_layout.addLayout(self.tune_layout)
|
||||||
self.setLayout(self.main_layout)
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
def init_eventlist(self):
|
def init_eventlist(self):
|
||||||
@ -1360,10 +1360,8 @@ class TuneAutopicker(QWidget):
|
|||||||
self.stb_names = ['aicARHfig', 'refSpick', 'el_S1pick', 'el_S2pick']
|
self.stb_names = ['aicARHfig', 'refSpick', 'el_S1pick', 'el_S2pick']
|
||||||
|
|
||||||
def fill_tabs(self, canvas_dict):
|
def fill_tabs(self, canvas_dict):
|
||||||
try:
|
id = self.main_tabs.addTab(self.gen_tab_widget('Overview', canvas_dict['mainFig']), 'Overview')
|
||||||
self.main_tabs.addTab(canvas_dict['mainFig'], 'Overview')
|
self.main_tabs.setTabEnabled(id, bool(self.fig_dict['mainFig'].axes))
|
||||||
except Exception as e:
|
|
||||||
self.main_tabs.addTab(QtGui.QWidget(), 'Overview')
|
|
||||||
self.main_tabs.addTab(self.p_tabs, 'P')
|
self.main_tabs.addTab(self.p_tabs, 'P')
|
||||||
self.main_tabs.addTab(self.s_tabs, 'S')
|
self.main_tabs.addTab(self.s_tabs, 'S')
|
||||||
self.fill_p_tabs(canvas_dict)
|
self.fill_p_tabs(canvas_dict)
|
||||||
@ -1375,7 +1373,7 @@ class TuneAutopicker(QWidget):
|
|||||||
|
|
||||||
def fill_p_tabs(self, canvas_dict):
|
def fill_p_tabs(self, canvas_dict):
|
||||||
for name in self.ptb_names:
|
for name in self.ptb_names:
|
||||||
id = self.p_tabs.addTab(canvas_dict[name], name)
|
id = self.p_tabs.addTab(self.gen_tab_widget(name, canvas_dict[name]), name)
|
||||||
self.p_tabs.setTabEnabled(id, bool(self.fig_dict[name].axes))
|
self.p_tabs.setTabEnabled(id, bool(self.fig_dict[name].axes))
|
||||||
try:
|
try:
|
||||||
self.fig_dict[name].tight_layout()
|
self.fig_dict[name].tight_layout()
|
||||||
@ -1384,14 +1382,22 @@ class TuneAutopicker(QWidget):
|
|||||||
|
|
||||||
def fill_s_tabs(self, canvas_dict):
|
def fill_s_tabs(self, canvas_dict):
|
||||||
for name in self.stb_names:
|
for name in self.stb_names:
|
||||||
figure = self.fig_dict[name]
|
id = self.s_tabs.addTab(self.gen_tab_widget(name, canvas_dict[name]), name)
|
||||||
id = self.s_tabs.addTab(canvas_dict[name], name)
|
|
||||||
self.s_tabs.setTabEnabled(id, bool(self.fig_dict[name].axes))
|
self.s_tabs.setTabEnabled(id, bool(self.fig_dict[name].axes))
|
||||||
try:
|
try:
|
||||||
self.fig_dict[name].tight_layout()
|
self.fig_dict[name].tight_layout()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def gen_tab_widget(self, name, canvas):
|
||||||
|
widget = QtGui.QWidget()
|
||||||
|
v_layout = QtGui.QVBoxLayout()
|
||||||
|
v_layout.addWidget(canvas)
|
||||||
|
v_layout.addWidget(NavigationToolbar2QT(canvas, self))
|
||||||
|
widget.setLayout(v_layout)
|
||||||
|
return widget
|
||||||
|
|
||||||
|
|
||||||
class PropertiesDlg(QDialog):
|
class PropertiesDlg(QDialog):
|
||||||
def __init__(self, parent=None, infile=None):
|
def __init__(self, parent=None, infile=None):
|
||||||
super(PropertiesDlg, self).__init__(parent)
|
super(PropertiesDlg, self).__init__(parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user