diff --git a/QtPyLoT.py b/QtPyLoT.py index 582f41e1..39d79e90 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -39,7 +39,7 @@ from PySide.QtCore import QCoreApplication, QSettings, Signal, QFile, \ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \ QWidget, QHBoxLayout, QVBoxLayout, QStyle, QKeySequence, QLabel, QFrame, QAction, \ QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \ - QActionGroup, QListWidget, QDockWidget, QLineEdit, QListView, QAbstractItemView, \ + QActionGroup, QListWidget, QLineEdit, QListView, QAbstractItemView, \ QTreeView, QComboBox, QTabWidget, QPushButton, QGridLayout import numpy as np from obspy import UTCDateTime @@ -68,7 +68,7 @@ from pylot.core.pick.utils import symmetrize_error, getQualityFromUncertainty from pylot.core.io.phases import picksdict_from_picks import pylot.core.loc.nll as nll from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents -from pylot.core.util.errors import FormatError, DatastructureError, \ +from pylot.core.util.errors import DatastructureError, \ OverwriteError from pylot.core.util.connection import checkurl from pylot.core.util.dataprocessing import read_metadata, restitute_data @@ -801,12 +801,8 @@ class MainWindow(QMainWindow): settings = QSettings() return settings.value("data/dataRoot") - def load_autopicks(self, fname=None): - self.load_data(fname, type='auto') - def load_loc(self, fname=None): - type = getDataType(self) - self.load_data(fname, type=type, loc=True) + self.load_data(fname, loc=True) def load_pilotevent(self): filt = "PILOT location files (*LOC*.mat)" @@ -821,10 +817,8 @@ class MainWindow(QMainWindow): filter=filt, dir=loc_dir) fn_phases = fn_phases[0] - type = getDataType(self) - fname_dict = dict(phasfn=fn_phases, locfn=fn_loc) - self.load_data(fname_dict, type=type) + self.load_data(fname_dict) def load_multiple_data(self): if not self.okToContinue(): @@ -1355,6 +1349,8 @@ class MainWindow(QMainWindow): self.cmpw.show() def compareMulti(self): + if not self.compareoptions: + return for key, func, color in self.compareoptions: if self.cmpw.rb_dict[key].isChecked(): # if radio button is checked break for loop and use func @@ -1863,27 +1859,27 @@ class MainWindow(QMainWindow): self.checkFilterOptions() - def updateFilterOptions(self): - try: - settings = QSettings() - if settings.value("filterdefaults", - None) is None and not self.getFilters(): - for key, value in FILTERDEFAULTS.items(): - self.setFilterOptions(FilterOptions(**value), key) - elif settings.value("filterdefaults", None) is not None: - for key, value in settings.value("filterdefaults"): - self.setFilterOptions(FilterOptions(**value), key) - except Exception as e: - self.update_status('Error ...') - emsg = QErrorMessage(self) - emsg.showMessage('Error: {0}'.format(e)) - else: - self.update_status('Filter loaded ... ' - '[{0}: {1} Hz]'.format( - self.getFilterOptions().getFilterType(), - self.getFilterOptions().getFreq())) - if self.filterAction.isChecked(): - self.filterWaveformData() + # def updateFilterOptions(self): + # try: + # settings = QSettings() + # if settings.value("filterdefaults", + # None) is None and not self.getFilters(): + # for key, value in FILTERDEFAULTS.items(): + # self.setFilterOptions(FilterOptions(**value), key) + # elif settings.value("filterdefaults", None) is not None: + # for key, value in settings.value("filterdefaults"): + # self.setFilterOptions(FilterOptions(**value), key) + # except Exception as e: + # self.update_status('Error ...') + # emsg = QErrorMessage(self) + # emsg.showMessage('Error: {0}'.format(e)) + # else: + # self.update_status('Filter loaded ... ' + # '[{0}: {1} Hz]'.format( + # self.getFilterOptions().getFilterType(), + # self.getFilterOptions().getFreq())) + # if self.filterAction.isChecked(): + # self.filterWaveformData() def getSeismicPhase(self): return self.seismicPhase @@ -2114,6 +2110,8 @@ class MainWindow(QMainWindow): self.apw.show() def start_autopick(self): + if not self.pickoptions: + return for key, func, _ in self.pickoptions: if self.apw.rb_dict[key].isChecked(): # if radio button is checked break for loop and use func @@ -2341,6 +2339,7 @@ class MainWindow(QMainWindow): pen = make_pen(picktype, phaseID, 'lpp', quality) pw.plot([lpp, lpp], ylims, alpha=.25, pen=pen, name='LPP') + pen = make_pen(picktype, phaseID, 'mpp', quality) if spe: # pen = make_pen(picktype, phaseID, 'spe', quality) # spe_l = pg.PlotDataItem([mpp - spe, mpp - spe], ylims, pen=pen, @@ -2357,7 +2356,6 @@ class MainWindow(QMainWindow): # fb = pw.addItem(fill) # except: # print('Warning: drawPicks: Could not create fill for symmetric pick error.') - pen = make_pen(picktype, phaseID, 'mpp', quality) pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick'.format(phase)) else: pw.plot([mpp, mpp], ylims, pen=pen, name='{}-Pick (NO PICKERROR)'.format(phase)) @@ -2802,7 +2800,7 @@ class MainWindow(QMainWindow): # raise ProcessingError('Restitution of waveform data failed!') if type == 'ML': local_mag = LocalMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('sstop'), - verbosity=True) + verbosity=True) ## MP MP missing parameter wascaling in function call! return local_mag.updated_event() elif type == 'Mw': moment_mag = MomentMagnitude(corr_wf, self.get_data().get_evt_data(), self.inputs.get('vp'), @@ -3201,8 +3199,8 @@ def create_window(): app_created = True # set aplication/organization name, domain (important to do this BEFORE setupUI is called for correct QSettings) app.setOrganizationName("Ruhr-University Bochum / BESTEC") - app.setOrganizationDomain("rub.de"); - app.setApplicationName("PyLoT"); + app.setOrganizationDomain("rub.de") + app.setApplicationName("PyLoT") app.references = set() # app.references.add(window) # window.show() diff --git a/autoPyLoT.py b/autoPyLoT.py index 44b2bd4e..509d8211 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -311,7 +311,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even # calculate seismic moment Mo and moment magnitude Mw moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), parameter.get('Qp'), - parameter.get('rho'), True, \ + parameter.get('rho'), True, iplot) # update pick with moment property values (w0, fc, Mo) for stats, props in moment_mag.moment_props.items(): @@ -374,7 +374,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even for key in picks: if picks[key]['P']['weight'] >= 4 or picks[key]['S']['weight'] >= 4: badpicks.append([key, picks[key]['P']['mpp']]) - print("autoPyLoT: After iteration No. %d: %d bad onsets found ..." % (nlloccounter, \ + print("autoPyLoT: After iteration No. %d: %d bad onsets found ..." % (nlloccounter, len(badpicks))) if len(badpicks) == 0: print("autoPyLoT: No more bad onsets found, stop iterative picking!") @@ -384,7 +384,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even # calculate seismic moment Mo and moment magnitude Mw moment_mag = MomentMagnitude(corr_dat, evt, parameter.get('vp'), parameter.get('Qp'), - parameter.get('rho'), True, \ + parameter.get('rho'), True, iplot) # update pick with moment property values (w0, fc, Mo) for stats, props in moment_mag.moment_props.items(): @@ -502,4 +502,4 @@ if __name__ == "__main__": picks = autoPyLoT(inputfile=str(cla.inputfile), fnames=str(cla.fnames), eventid=str(cla.eventid), savepath=str(cla.spath), - ncores=cla.ncores, iplot=str(cla.iplot)) + ncores=cla.ncores, iplot=int(cla.iplot)) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 51093aab..fced1570 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -617,9 +617,9 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence, p3, = plt.loglog(F, YYcor, 'r') p4, = plt.loglog(F, fit, 'g') plt.loglog([fc, fc], [w0 / 100, w0], 'g') - plt.legend([p1, p2, p3, p4], ['Raw Spectrum', \ - 'Used Raw Spectrum', \ - 'Q-Corrected Spectrum', \ + plt.legend([p1, p2, p3, p4], ['Raw Spectrum', + 'Used Raw Spectrum', + 'Q-Corrected Spectrum', 'Fit to Spectrum']) plt.title('Source Spectrum from P Pulse, w0=%e m/Hz, fc=%6.2f Hz' \ % (w0, fc)) diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index 7356b0da..5d15b1f9 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -240,8 +240,8 @@ class Data(object): mstation = picks[i].waveform_id.station_code mstation_ext = mstation + '_' for k in range(len(picks_copy)): - if ((picks_copy[k].waveform_id.station_code == mstation) or \ - (picks_copy[k].waveform_id.station_code == mstation_ext)) and \ + if ((picks_copy[k].waveform_id.station_code == mstation) or + (picks_copy[k].waveform_id.station_code == mstation_ext)) and \ (picks_copy[k].method_id == 'auto'): del picks_copy[k] break @@ -442,7 +442,6 @@ class Data(object): else: if self.get_evt_data().picks: raise OverwriteError('Existing picks would be overwritten!') - break else: picks = picks_from_picksdict(picks) break diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index fd89df4c..6e4a920d 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -865,8 +865,8 @@ def merge_picks(event, picks): if p.waveform_id.station_code == station\ and p.waveform_id.network_code == network\ and p.phase_hint == phase\ - and (str(p.method_id) in str(method)\ - or str(method) in str(p.method_id)): + and (str(p.method_id) in str(method) + or str(method) in str(p.method_id)): p.time, p.time_errors, p.waveform_id.network_code, p.method_id = time, err, network, method del time, err, phase, station, network, method return event @@ -907,15 +907,15 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1): for mpick in arrivals_copy: phase = identifyPhase(loopIdentifyPhase(Pick.phase_hint)) if phase == 'P': - if ((mpick.waveform_id.station_code == mstation) or \ - (mpick.waveform_id.station_code == mstation_ext)) and \ + if ((mpick.waveform_id.station_code == mstation) or + (mpick.waveform_id.station_code == mstation_ext)) and \ ((mpick.method_id).split('/')[1] == 'auto') and \ (mpick.time_errors['uncertainty'] <= ErrorsP[3]): del mpick break elif phase == 'S': - if ((mpick.waveform_id.station_code == mstation) or \ - (mpick.waveform_id.station_code == mstation_ext)) and \ + if ((mpick.waveform_id.station_code == mstation) or + (mpick.waveform_id.station_code == mstation_ext)) and \ ((mpick.method_id).split('/')[1] == 'auto') and \ (mpick.time_errors['uncertainty'] <= ErrorsS[3]): del mpick diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index e558b124..3f95be7c 100644 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -859,7 +859,7 @@ def autopickstation(wfstream, pickparam, verbose=False, hdat += ndat else: - print('autopickstation: No horizontal component data available or ' \ + print('autopickstation: No horizontal component data available or ' 'bad P onset, skipping S picking!') ############################################################## diff --git a/pylot/core/pick/charfuns.py b/pylot/core/pick/charfuns.py index a6fb5841..980eb749 100644 --- a/pylot/core/pick/charfuns.py +++ b/pylot/core/pick/charfuns.py @@ -26,7 +26,7 @@ class CharacteristicFunction(object): SuperClass for different types of characteristic functions. ''' - def __init__(self, data, cut, t2=None, order=None, t1=None, fnoise=None, stealthMode=False): + def __init__(self, data, cut, t2=None, order=None, t1=None, fnoise=None): ''' Initialize data type object with information from the original Seismogram. @@ -63,7 +63,6 @@ class CharacteristicFunction(object): self.calcCF(self.getDataArray()) self.arpara = np.array([]) self.xpred = np.array([]) - self._stealthMode = stealthMode def __str__(self): return '''\n\t{name} object:\n @@ -137,9 +136,6 @@ class CharacteristicFunction(object): def getXCF(self): return self.xcf - def _getStealthMode(self): - return self._stealthMode() - def getDataArray(self, cut=None): ''' If cut times are given, time series is cut from cut[0] (start time) @@ -224,8 +220,6 @@ class AICcf(CharacteristicFunction): def calcCF(self, data): - # if self._getStealthMode() is False: - # print 'Calculating AIC ...' x = self.getDataArray() xnp = x[0].data nn = np.isnan(xnp) @@ -264,13 +258,9 @@ class HOScf(CharacteristicFunction): if len(nn) > 1: xnp[nn] = 0 if self.getOrder() == 3: # this is skewness - # if self._getStealthMode() is False: - # print 'Calculating skewness ...' y = np.power(xnp, 3) y1 = np.power(xnp, 2) elif self.getOrder() == 4: # this is kurtosis - # if self._getStealthMode() is False: - # print 'Calculating kurtosis ...' y = np.power(xnp, 4) y1 = np.power(xnp, 2) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 3cafc490..015b1406 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -94,7 +94,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, verbosity=1, fig=None, linecol # get earliest possible pick - EPick = np.nan; + EPick = np.nan count = 0 pis = isignal diff --git a/pylot/core/pick/utils.py.orig b/pylot/core/pick/utils.py.orig index c455682e..10153946 100644 --- a/pylot/core/pick/utils.py.orig +++ b/pylot/core/pick/utils.py.orig @@ -71,7 +71,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=0, stealthMode=False): # get earliest possible pick - EPick = np.nan; + EPick = np.nan count = 0 pis = isignal diff --git a/pylot/testing/test_autopick.py b/pylot/testing/test_autopick.py index 6b8bf3f2..6ff5a7d7 100644 --- a/pylot/testing/test_autopick.py +++ b/pylot/testing/test_autopick.py @@ -200,7 +200,7 @@ def run_makeCF(project, database, event, iplot, station=None): plt.ylim([-1.5, 1.5]) plt.xlabel('Time [s]') plt.ylabel('Normalized Counts') - plt.title('%s, %s, CF-SNR=%7.2f, CF-Slope=%12.2f' % (tr.stats.station, \ + plt.title('%s, %s, CF-SNR=%7.2f, CF-Slope=%12.2f' % (tr.stats.station, tr.stats.channel, aicpick.getSNR(), aicpick.getSlope())) plt.suptitle(tr.stats.starttime) @@ -223,9 +223,9 @@ def run_makeCF(project, database, event, iplot, station=None): plt.plot([arhpick.getpick() - 0.5, arhpick.getpick() + 0.5], [-1, -1], 'r') plt.plot([arhELpick.getLpick(), arhELpick.getLpick()], [-0.8, 0.8], 'r--') plt.plot([arhELpick.getEpick(), arhELpick.getEpick()], [-0.8, 0.8], 'r--') - plt.plot([arhpick.getpick() + arhELpick.getPickError(), arhpick.getpick() + arhELpick.getPickError()], \ + plt.plot([arhpick.getpick() + arhELpick.getPickError(), arhpick.getpick() + arhELpick.getPickError()], [-0.2, 0.2], 'r--') - plt.plot([arhpick.getpick() - arhELpick.getPickError(), arhpick.getpick() - arhELpick.getPickError()], \ + plt.plot([arhpick.getpick() - arhELpick.getPickError(), arhpick.getpick() - arhELpick.getPickError()], [-0.2, 0.2], 'r--') plt.yticks([]) plt.ylim([-1.5, 1.5]) @@ -245,9 +245,9 @@ def run_makeCF(project, database, event, iplot, station=None): plt.plot([arhpick.getpick() - 0.5, arhpick.getpick() + 0.5], [-1, -1], 'r') plt.plot([arhELpick.getLpick(), arhELpick.getLpick()], [-0.8, 0.8], 'r--') plt.plot([arhELpick.getEpick(), arhELpick.getEpick()], [-0.8, 0.8], 'r--') - plt.plot([arhpick.getpick() + arhELpick.getPickError(), arhpick.getpick() + arhELpick.getPickError()], \ + plt.plot([arhpick.getpick() + arhELpick.getPickError(), arhpick.getpick() + arhELpick.getPickError()], [-0.2, 0.2], 'r--') - plt.plot([arhpick.getpick() - arhELpick.getPickError(), arhpick.getpick() - arhELpick.getPickError()], \ + plt.plot([arhpick.getpick() - arhELpick.getPickError(), arhpick.getpick() - arhELpick.getPickError()], [-0.2, 0.2], 'r--') plt.title([trH2_filt.stats.station, trH2_filt.stats.channel]) plt.yticks([]) diff --git a/setup.py b/setup.py index e2a9b8b4..f4f27cbd 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( packages=['pylot', 'pylot.core', 'pylot.core.loc', 'pylot.core.pick', 'pylot.core.io', 'pylot.core.util', 'pylot.core.active', 'pylot.core.analysis', 'pylot.testing'], - requires=['obspy', 'PySide'], + requires=['obspy', 'PySide', 'matplotlib', 'numpy'], url='dummy', license='LGPLv3', author='Sebastian Wehling-Benatelli',