diff --git a/QtPyLoT.py b/QtPyLoT.py index 4a386fd1..c04c8e1e 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -23,10 +23,11 @@ https://www.iconfinder.com/iconsets/flavour (http://www.gnu.org/copyleft/lesser.html) """ -import os -import sys -import platform import argparse +import os +import platform +import sys + import matplotlib matplotlib.use('Qt4Agg') @@ -66,10 +67,10 @@ from pylot.core.pick.compare import Comparison from pylot.core.pick.utils import symmetrize_error from pylot.core.io.phases import picksdict_from_picks import pylot.core.loc.nll as nll -from pylot.core.util.defaults import FILTERDEFAULTS, OUTPUTFORMATS, SetChannelComponents, \ +from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents, \ readFilterInformation from pylot.core.util.errors import FormatError, DatastructureError, \ - OverwriteError, ProcessingError + OverwriteError from pylot.core.util.connection import checkurl from pylot.core.util.dataprocessing import read_metadata, restitute_data from pylot.core.util.utils import fnConstructor, getLogin, \ @@ -81,7 +82,7 @@ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ getDataType, ComparisonDialog, TuneAutopicker, PylotParaBox from pylot.core.util.map_projection import map_projection from pylot.core.util.structure import DATASTRUCTURE -from pylot.core.util.thread import AutoPickThread, Thread, Worker +from pylot.core.util.thread import Thread, Worker from pylot.core.util.version import get_git_version as _getVersionString if sys.version_info.major == 3: @@ -270,7 +271,7 @@ class MainWindow(QMainWindow): quitIcon = self.style().standardIcon(QStyle.SP_MediaStop) helpIcon = self.style().standardIcon(QStyle.SP_DialogHelpButton) newFolderIcon = self.style().standardIcon(QStyle.SP_FileDialogNewFolder) - + # create resource icons newIcon = QIcon() newIcon.addPixmap(QPixmap(':/icons/newfile.png')) @@ -1149,8 +1150,8 @@ class MainWindow(QMainWindow): # return False # export to given path - #self.get_data().exportEvent(fbasename, exform, upperErrors=[uppererrorP[3], uppererrorS[3]]) - #try: + # self.get_data().exportEvent(fbasename, exform, upperErrors=[uppererrorP[3], uppererrorS[3]]) + # try: self.get_data().exportEvent(fbasename, exform[0], fcheck=fcheck, upperErrors=[uppererrorP[3], uppererrorS[3]]) self.get_data().exportEvent(fbasename, exform[1], fcheck=fcheck, @@ -1159,7 +1160,7 @@ class MainWindow(QMainWindow): # QMessageBox.warning(self, "PyLoT Warning", # "Could not save event: {}".format(e)) # return - #self.get_data().exportEvent(fbasename, exform[2], upperErrors=[uppererrorP[3], uppererrorS[3]]) + # self.get_data().exportEvent(fbasename, exform[2], upperErrors=[uppererrorP[3], uppererrorS[3]]) # all files save (ui clean) self.update_status('Picks saved as %s, %s, and %s' % (fbasename + exform[0], fbasename + exform[1], fbasename + exform[2])) @@ -1322,7 +1323,7 @@ class MainWindow(QMainWindow): if self.tabs.currentIndex() == 2: self.init_event_table() self.refreshRefTestButtons() - + # only refresh first/second tab when an event was changed. if self._eventChanged[0] or self._eventChanged[1]: event = self.get_current_event() @@ -1888,7 +1889,7 @@ class MainWindow(QMainWindow): args = {'parameter': self._inputs, 'station': 'all', 'fnames': 'None', - 'eventid': self.get_current_event_path (), + 'eventid': self.get_current_event_path(), 'iplot': 0, 'fig_dict': None, 'locflag': 0} @@ -1900,7 +1901,7 @@ class MainWindow(QMainWindow): self.addListItem(str(self._inputs)) self.mp_worker.signals.message.connect(self.addListItem) - #self.mp_thread.finished.connect(self.finalizeAutoPick) + # self.mp_thread.finished.connect(self.finalizeAutoPick) def finalizeAutoPick(self): self.drawPicks(picktype='auto') @@ -2348,7 +2349,7 @@ class MainWindow(QMainWindow): if type(item) == QtGui.QTableWidgetItem: self.event_table.setItem(r_index, c_index, item) elif type(item) in [QtGui.QWidget, QtGui.QPushButton]: - self.event_table.setCellWidget(r_index, c_index, item) + self.event_table.setCellWidget(r_index, c_index, item) header = self.event_table.horizontalHeader() header.setResizeMode(QtGui.QHeaderView.ResizeToContents) @@ -2674,7 +2675,7 @@ class Project(object): if eventID in str(event.resource_id): self.remove_event(event) break - + def read_eventfile_info(self, filename, separator=','): ''' Try to read event information from file (:param:filename) comparing specific event datetimes. diff --git a/autoPyLoT.py b/autoPyLoT.py index 0c38c72e..10bc4489 100755 --- a/autoPyLoT.py +++ b/autoPyLoT.py @@ -4,35 +4,37 @@ from __future__ import print_function import argparse +import datetime import glob import os -import datetime -from obspy import read_events -from obspy.core.event import ResourceIdentifier -import pylot.core.loc.hyposat as hyposat -import pylot.core.loc.hypo71 as hypo71 -import pylot.core.loc.velest as velest -import pylot.core.loc.hypodd as hypodd + import pylot.core.loc.focmec as focmec import pylot.core.loc.hash as hash +import pylot.core.loc.hypo71 as hypo71 +import pylot.core.loc.hypodd as hypodd +import pylot.core.loc.hyposat as hyposat import pylot.core.loc.nll as nll -#from PySide.QtGui import QWidget, QInputDialog +import pylot.core.loc.velest as velest +from obspy import read_events +from obspy.core.event import ResourceIdentifier +# from PySide.QtGui import QWidget, QInputDialog from pylot.core.analysis.magnitude import MomentMagnitude, LocalMagnitude from pylot.core.io.data import Data from pylot.core.io.inputs import PylotParameter from pylot.core.pick.autopick import autopickevent, iteratepicker from pylot.core.util.dataprocessing import restitute_data, read_metadata, \ remove_underscores -from pylot.core.util.structure import DATASTRUCTURE -from pylot.core.util.version import get_git_version as _getVersionString -from pylot.core.util.event import Event -from pylot.core.util.utils import real_None from pylot.core.util.defaults import SEPARATOR +from pylot.core.util.event import Event +from pylot.core.util.structure import DATASTRUCTURE +from pylot.core.util.utils import real_None +from pylot.core.util.version import get_git_version as _getVersionString __version__ = _getVersionString() -def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, eventid=None, savepath=None, station='all', iplot=0): +def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, eventid=None, savepath=None, station='all', + iplot=0): """ Determine phase onsets automatically utilizing the automatic picking algorithms by Kueperkoch et al. 2010/2012. @@ -108,7 +110,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even 'dbase': parameter.get('database')} exf = ['root', 'dpath', 'dbase'] - + if parameter['eventID'] is not '*' and fnames == 'None': dsfields['eventID'] = parameter['eventID'] exf.append('eventID') @@ -176,7 +178,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even events[index] = event for event in events: - pylot_event = Event(event) #event should be path to event directory + pylot_event = Event(event) # event should be path to event directory data.setEvtData(pylot_event) if fnames == 'None': data.setWFData(glob.glob(os.path.join(datapath, event, '*'))) @@ -196,10 +198,10 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even parameter.setParam(eventID=eventID) else: data.setWFData(fnames) - + event = events[0] - #now = datetime.datetime.now() - #evID = '%d%02d%02d%02d%02d' % (now.year, + # now = datetime.datetime.now() + # evID = '%d%02d%02d%02d%02d' % (now.year, # now.month, # now.day, # now.hour, @@ -210,13 +212,13 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even wfdat = wfdat.select(station=station) if not wfdat: print('Could not find station {}. STOP!'.format(station)) - return + return wfdat = remove_underscores(wfdat) - metadata = read_metadata(parameter.get('invdir')) + metadata = read_metadata(parameter.get('invdir')) print("Restitute data ...") corr_dat = restitute_data(wfdat.copy(), *metadata) if not corr_dat and locflag: - locflag = 2 + locflag = 2 print('Working on event %s. Stations: %s' % (event, station)) print(wfdat) ########################################################## @@ -277,12 +279,12 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even WAscaling = parameter.get('WAscaling') magscaling = parameter.get('magscaling') local_mag = LocalMagnitude(corr_dat, evt, - parameter.get('sstop'), + parameter.get('sstop'), WAscaling, True, iplot) for station, amplitude in local_mag.amplitudes.items(): picks[station]['S']['Ao'] = amplitude.generic_amplitude print("Local station magnitudes scaled with:") - print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], + print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], WAscaling[1], WAscaling[2])) evt = local_mag.updated_event(magscaling) @@ -310,7 +312,8 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even if input_dict: if 'fig_dict' in input_dict: fig_dict = input_dict['fig_dict'] - picks = iteratepicker(wfdat, nllocfile, picks, badpicks, parameter, fig_dict=fig_dict) + picks = iteratepicker(wfdat, nllocfile, picks, badpicks, parameter, + fig_dict=fig_dict) else: picks = iteratepicker(wfdat, nllocfile, picks, badpicks, parameter) # write phases to NLLoc-phase file @@ -349,12 +352,12 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even WAscaling = parameter.get('WAscaling') magscaling = parameter.get('magscaling') local_mag = LocalMagnitude(corr_dat, evt, - parameter.get('sstop'), + parameter.get('sstop'), WAscaling, True, iplot) for station, amplitude in local_mag.amplitudes.items(): picks[station]['S']['Ao'] = amplitude.generic_amplitude print("Local station magnitudes scaled with:") - print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], + print("log(Ao) + %f * log(r) + %f * r + %f" % (WAscaling[0], WAscaling[1], WAscaling[2])) evt = local_mag.updated_event(magscaling) @@ -420,16 +423,16 @@ if __name__ == "__main__": autoregressive prediction and AIC followed by locating the seismic events using NLLoc''') - #parser.add_argument('-d', '-D', '--input_dict', type=str, + # parser.add_argument('-d', '-D', '--input_dict', type=str, # action='store', # help='''optional, dictionary containing processing parameters''') - #parser.add_argument('-p', '-P', '--parameter', type=str, + # parser.add_argument('-p', '-P', '--parameter', type=str, # action='store', # help='''parameter file, default=None''') parser.add_argument('-i', '-I', '--inputfile', type=str, action='store', help='''full path to the file containing the input - parameters for autoPyLoT''') + parameters for autoPyLoT''') parser.add_argument('-f', '-F', '--fnames', type=str, action='store', help='''optional, list of data file names''') @@ -439,11 +442,11 @@ if __name__ == "__main__": parser.add_argument('-s', '-S', '--spath', type=str, action='store', help='''optional, save path for autoPyLoT output''') - #parser.add_argument('-v', '-V', '--version', action='version', + # parser.add_argument('-v', '-V', '--version', action='version', # version='autoPyLoT ' + __version__, # help='show version information and exit') cla = parser.parse_args() - + picks = autoPyLoT(inputfile=str(cla.inputfile), fnames=str(cla.fnames), eventid=str(cla.eventid), savepath=str(cla.spath)) diff --git a/help/index.html b/help/index.html index 2ce2ef02..5716709b 100644 --- a/help/index.html +++ b/help/index.html @@ -1,17 +1,19 @@ -
PyLoT is a program which is capable of picking seismic phases, -exporting these as numerous standard phase format and localize the corresponding -seismic event with external software as, e.g.:
+ exporting these as numerous standard phase format and localize the corresponding + seismic event with external software as, e.g.:Read more on the -PyLoT WikiPage.
+ PyLoT WikiPage.Bug reports are very much appreciated and can also be delivered on our -PyLoT TracPage after -successful registration.
- + PyLoT TracPage after + successful registration. + +