[change] renamed picks attribute for pylot to pylot_picks, picks attribute of events will now be used exclusively for ObsPy picks
This commit is contained in:
		
							parent
							
								
									d08bd4cc9e
								
							
						
					
					
						commit
						b10b79ea79
					
				
							
								
								
									
										69
									
								
								QtPyLoT.py
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								QtPyLoT.py
									
									
									
									
									
								
							| @ -70,8 +70,9 @@ from pylot.core.util.errors import FormatError, DatastructureError, \ | |||||||
|     OverwriteError, ProcessingError |     OverwriteError, ProcessingError | ||||||
| from pylot.core.util.connection import checkurl | from pylot.core.util.connection import checkurl | ||||||
| from pylot.core.util.dataprocessing import read_metadata, restitute_data | from pylot.core.util.dataprocessing import read_metadata, restitute_data | ||||||
| from pylot.core.util.utils import Event, fnConstructor, getLogin, \ | from pylot.core.util.utils import fnConstructor, getLogin, \ | ||||||
|     full_range |     full_range | ||||||
|  | from pylot.core.util.event import Event | ||||||
| from pylot.core.io.location import create_creation_info, create_event | from pylot.core.io.location import create_creation_info, create_event | ||||||
| from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ | from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ | ||||||
|     WaveformWidget, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \ |     WaveformWidget, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \ | ||||||
| @ -174,8 +175,8 @@ class MainWindow(QMainWindow): | |||||||
|         self.setupUi() |         self.setupUi() | ||||||
| 
 | 
 | ||||||
|         self.filteroptions = {} |         self.filteroptions = {} | ||||||
|         self.picks = {} |         self.pylot_picks = {} | ||||||
|         self.autopicks = {} |         self.pylot_autopicks = {} | ||||||
|         self.loc = False |         self.loc = False | ||||||
| 
 | 
 | ||||||
|     def setupUi(self): |     def setupUi(self): | ||||||
| @ -654,7 +655,7 @@ class MainWindow(QMainWindow): | |||||||
|                 refresh=True |                 refresh=True | ||||||
|         if not refresh: |         if not refresh: | ||||||
|             return |             return | ||||||
|         if self.get_current_event().picks: |         if self.get_current_event().pylot_picks: | ||||||
|             self.plotWaveformDataThread() |             self.plotWaveformDataThread() | ||||||
|         self.drawPicks(picktype=type) |         self.drawPicks(picktype=type) | ||||||
|         self.draw() |         self.draw() | ||||||
| @ -675,7 +676,7 @@ class MainWindow(QMainWindow): | |||||||
|         if not loc: |         if not loc: | ||||||
|             self.updatePicks(type=type, event=event) |             self.updatePicks(type=type, event=event) | ||||||
|         if draw: |         if draw: | ||||||
|             if self.get_current_event().picks: |             if self.get_current_event().pylot_picks: | ||||||
|                 self.plotWaveformDataThread() |                 self.plotWaveformDataThread() | ||||||
|             self.drawPicks(picktype=type) |             self.drawPicks(picktype=type) | ||||||
|             self.draw() |             self.draw() | ||||||
| @ -702,8 +703,8 @@ class MainWindow(QMainWindow): | |||||||
|     def getWFFnames(self): |     def getWFFnames(self): | ||||||
|         try: |         try: | ||||||
|             evt = self.get_data().get_evt_data() |             evt = self.get_data().get_evt_data() | ||||||
|             if evt.picks: |             if evt.pylot_picks: | ||||||
|                 for pick in evt.picks: |                 for pick in evt.pylot_picks: | ||||||
|                     try: |                     try: | ||||||
|                         if pick.waveform_id is not None: |                         if pick.waveform_id is not None: | ||||||
|                             fname = pick.waveform_id.getSEEDstring() |                             fname = pick.waveform_id.getSEEDstring() | ||||||
| @ -906,10 +907,10 @@ class MainWindow(QMainWindow): | |||||||
|             event_path = event.path |             event_path = event.path | ||||||
|             event_npicks = 0 |             event_npicks = 0 | ||||||
|             event_nautopicks = 0 |             event_nautopicks = 0 | ||||||
|             if event.picks: |             if event.pylot_picks: | ||||||
|                 event_npicks = len(event.picks) |                 event_npicks = len(event.pylot_picks) | ||||||
|             if event.autopicks: |             if event.pylot_autopicks: | ||||||
|                 event_nautopicks = len(event.autopicks) |                 event_nautopicks = len(event.pylot_autopicks) | ||||||
|             event_ref = event.isRefEvent() |             event_ref = event.isRefEvent() | ||||||
|             event_test = event.isTestEvent() |             event_test = event.isTestEvent() | ||||||
| 
 | 
 | ||||||
| @ -1013,7 +1014,7 @@ class MainWindow(QMainWindow): | |||||||
|         fbasename = self.getEventFileName() |         fbasename = self.getEventFileName() | ||||||
|         exform = settings.value('data/exportFormat', 'QUAKEML') |         exform = settings.value('data/exportFormat', 'QUAKEML') | ||||||
|         try: |         try: | ||||||
|             self.get_data().applyEVTData(self.getPicks()) |             self.get_data().applyEVTData(self.get_current_event(), typ='event')#getPicks()) | ||||||
|         except OverwriteError: |         except OverwriteError: | ||||||
|         #     msgBox = QMessageBox() |         #     msgBox = QMessageBox() | ||||||
|         #     msgBox.setText("Picks have been modified!") |         #     msgBox.setText("Picks have been modified!") | ||||||
| @ -1083,7 +1084,7 @@ class MainWindow(QMainWindow): | |||||||
|             return self.get_current_event().getPicks() |             return self.get_current_event().getPicks() | ||||||
|         if type == 'auto': |         if type == 'auto': | ||||||
|             return self.get_current_event().getAutopicks() |             return self.get_current_event().getAutopicks() | ||||||
|         # rdict = dict(auto=self.autopicks, manual=self.picks) |         # rdict = dict(auto=self.pylot_autopicks, manual=self.pylot_picks) | ||||||
|         # return rdict[type] |         # return rdict[type] | ||||||
| 
 | 
 | ||||||
|     def getPicksOnStation(self, station, type='manual'): |     def getPicksOnStation(self, station, type='manual'): | ||||||
| @ -1157,7 +1158,7 @@ class MainWindow(QMainWindow): | |||||||
|         if event: |         if event: | ||||||
|             self.ref_event_button.setChecked(event.isRefEvent()) |             self.ref_event_button.setChecked(event.isRefEvent()) | ||||||
|             self.test_event_button.setChecked(event.isTestEvent()) |             self.test_event_button.setChecked(event.isTestEvent()) | ||||||
|             self.enableRefTestButtons(bool(self.get_current_event().picks)) |             self.enableRefTestButtons(bool(self.get_current_event().pylot_picks)) | ||||||
|             return |             return | ||||||
|         self.ref_event_button.setChecked(False) |         self.ref_event_button.setChecked(False) | ||||||
|         self.test_event_button.setChecked(False) |         self.test_event_button.setChecked(False) | ||||||
| @ -1216,14 +1217,14 @@ class MainWindow(QMainWindow): | |||||||
|             if not event: |             if not event: | ||||||
|                 return |                 return | ||||||
|             # update picks saved in GUI mainwindow (to be changed in future!!) MP MP |             # update picks saved in GUI mainwindow (to be changed in future!!) MP MP | ||||||
|             if not event.picks: |             if not event.pylot_picks: | ||||||
|                 self.picks = {} |                 self.pylot_picks = {} | ||||||
|             else: |             else: | ||||||
|                 self.picks = event.picks |                 self.pylot_picks = event.pylot_picks | ||||||
|             if not event.autopicks: |             if not event.pylot_autopicks: | ||||||
|                 self.autopicks = {} |                 self.pylot_autopicks = {} | ||||||
|             else: |             else: | ||||||
|                 self.autopicks = event.autopicks |                 self.pylot_autopicks = event.pylot_autopicks | ||||||
|         # if current tab is waveformPlot-tab and the data in this tab was not yet refreshed |         # if current tab is waveformPlot-tab and the data in this tab was not yet refreshed | ||||||
|         if self.tabs.currentIndex() == 0: |         if self.tabs.currentIndex() == 0: | ||||||
|             if self._eventChanged[0]: |             if self._eventChanged[0]: | ||||||
| @ -1369,12 +1370,12 @@ class MainWindow(QMainWindow): | |||||||
|         self.openautopicksaction.setEnabled(True) |         self.openautopicksaction.setEnabled(True) | ||||||
|         self.loadpilotevent.setEnabled(True) |         self.loadpilotevent.setEnabled(True) | ||||||
|         event = self.get_current_event() |         event = self.get_current_event() | ||||||
|         if event.picks: |         if event.pylot_picks: | ||||||
|             self.picks = event.picks |             self.pylot_picks = event.pylot_picks | ||||||
|             self.drawPicks(picktype='manual') |             self.drawPicks(picktype='manual') | ||||||
|             self.enableSaveManualPicksAction() |             self.enableSaveManualPicksAction() | ||||||
|         if event.autopicks: |         if event.pylot_autopicks: | ||||||
|             self.autopicks = event.autopicks |             self.pylot_autopicks = event.pylot_autopicks | ||||||
|             self.drawPicks(picktype='auto') |             self.drawPicks(picktype='auto') | ||||||
|             self.compare_action.setEnabled(True) |             self.compare_action.setEnabled(True) | ||||||
|         self.draw() |         self.draw() | ||||||
| @ -1755,10 +1756,10 @@ class MainWindow(QMainWindow): | |||||||
|         picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data()) |         picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data()) | ||||||
|         if type == 'manual': |         if type == 'manual': | ||||||
|             event.addPicks(picks) |             event.addPicks(picks) | ||||||
|             self.picks.update(picks) |             self.pylot_picks.update(picks) | ||||||
|         elif type == 'auto': |         elif type == 'auto': | ||||||
|             event.addAutopicks(picks)             |             event.addAutopicks(picks)             | ||||||
|             self.autopicks.update(picks) |             self.pylot_autopicks.update(picks) | ||||||
|         self.check4Comparison() |         self.check4Comparison() | ||||||
| 
 | 
 | ||||||
|     def drawPicks(self, station=None, picktype='manual'): |     def drawPicks(self, station=None, picktype='manual'): | ||||||
| @ -1909,8 +1910,8 @@ class MainWindow(QMainWindow): | |||||||
|         finally: |         finally: | ||||||
|             os.remove(phasepath) |             os.remove(phasepath) | ||||||
| 
 | 
 | ||||||
|         self.get_data().applyEVTData(lt.read_location(locpath), type='event') |         self.get_data().applyEVTData(lt.read_location(locpath), typ='event') | ||||||
|         self.get_data().applyEVTData(self.calc_magnitude(), type='event') |         self.get_data().applyEVTData(self.calc_magnitude(), typ='event') | ||||||
| 
 | 
 | ||||||
|     def init_array_tab(self): |     def init_array_tab(self): | ||||||
|         ''' |         ''' | ||||||
| @ -2074,10 +2075,10 @@ class MainWindow(QMainWindow): | |||||||
|         for index, event in enumerate(eventlist): |         for index, event in enumerate(eventlist): | ||||||
|             event_npicks = 0 |             event_npicks = 0 | ||||||
|             event_nautopicks = 0 |             event_nautopicks = 0 | ||||||
|             if event.picks: |             if event.pylot_picks: | ||||||
|                 event_npicks = len(event.picks) |                 event_npicks = len(event.pylot_picks) | ||||||
|             if event.autopicks: |             if event.pylot_autopicks: | ||||||
|                 event_nautopicks = len(event.autopicks) |                 event_nautopicks = len(event.pylot_autopicks) | ||||||
|             item_path = QtGui.QTableWidgetItem() |             item_path = QtGui.QTableWidgetItem() | ||||||
|             item_time = QtGui.QTableWidgetItem() |             item_time = QtGui.QTableWidgetItem() | ||||||
|             item_lat = QtGui.QTableWidgetItem() |             item_lat = QtGui.QTableWidgetItem() | ||||||
| @ -2111,7 +2112,7 @@ class MainWindow(QMainWindow): | |||||||
|             set_enabled(item_path, True, False) |             set_enabled(item_path, True, False) | ||||||
|             set_enabled(item_nmp, True, False) |             set_enabled(item_nmp, True, False) | ||||||
|             set_enabled(item_nap, True, False) |             set_enabled(item_nap, True, False) | ||||||
|             if event.picks: |             if event.pylot_picks: | ||||||
|                 set_enabled(item_ref, True, True) |                 set_enabled(item_ref, True, True) | ||||||
|                 set_enabled(item_test, True, True) |                 set_enabled(item_test, True, True) | ||||||
|             else: |             else: | ||||||
| @ -2376,7 +2377,7 @@ class MainWindow(QMainWindow): | |||||||
|         self.setDirty(True) |         self.setDirty(True) | ||||||
|          |          | ||||||
|     def setDirty(self, value): |     def setDirty(self, value): | ||||||
|         self.saveProjectAction.setEnabled(value) |         self.saveProjectAction.setEnabled(bool(self.get_current_event().picks)) | ||||||
|         self.saveProjectAsAction.setEnabled(True) |         self.saveProjectAsAction.setEnabled(True) | ||||||
|         self.project.setDirty(value) |         self.project.setDirty(value) | ||||||
|         self.dirty = value |         self.dirty = value | ||||||
|  | |||||||
| @ -10,7 +10,8 @@ from obspy.core.event import Event as ObsPyEvent | |||||||
| from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \ | from pylot.core.io.phases import readPILOTEvent, picks_from_picksdict, \ | ||||||
|     picksdict_from_pilot, merge_picks |     picksdict_from_pilot, merge_picks | ||||||
| from pylot.core.util.errors import FormatError, OverwriteError | from pylot.core.util.errors import FormatError, OverwriteError | ||||||
| from pylot.core.util.utils import Event, fnConstructor, full_range | from pylot.core.util.utils import fnConstructor, full_range | ||||||
|  | from pylot.core.util.event import Event | ||||||
| 
 | 
 | ||||||
| class Data(object): | class Data(object): | ||||||
|     """ |     """ | ||||||
| @ -279,12 +280,12 @@ class Data(object): | |||||||
|     def setEvtData(self, event): |     def setEvtData(self, event): | ||||||
|         self.evtdata = event |         self.evtdata = event | ||||||
| 
 | 
 | ||||||
|     def applyEVTData(self, data, type='pick', authority_id='rub'): |     def applyEVTData(self, data, typ='pick', authority_id='rub'): | ||||||
| 
 | 
 | ||||||
|         """ |         """ | ||||||
| 
 | 
 | ||||||
|         :param data: |         :param data: | ||||||
|         :param type: |         :param typ: | ||||||
|         :param authority_id: |         :param authority_id: | ||||||
|         :raise OverwriteError: |         :raise OverwriteError: | ||||||
|         """ |         """ | ||||||
| @ -338,7 +339,7 @@ class Data(object): | |||||||
|         applydata = {'pick': applyPicks, |         applydata = {'pick': applyPicks, | ||||||
|                      'event': applyEvent} |                      'event': applyEvent} | ||||||
| 
 | 
 | ||||||
|         applydata[type](data) |         applydata[typ](data) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class GenericDataStructure(object): | class GenericDataStructure(object): | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ import os | |||||||
| import scipy.io as sio | import scipy.io as sio | ||||||
| import warnings | import warnings | ||||||
| from obspy.core import UTCDateTime | from obspy.core import UTCDateTime | ||||||
|  | from obspy.core.util import AttribDict | ||||||
| 
 | 
 | ||||||
| from pylot.core.io.inputs import PylotParameter | from pylot.core.io.inputs import PylotParameter | ||||||
| from pylot.core.io.location import create_arrival, create_event, \ | from pylot.core.io.location import create_arrival, create_event, \ | ||||||
| @ -231,7 +232,7 @@ def picks_from_picksdict(picks, creation_info=None): | |||||||
|     picks_list = list() |     picks_list = list() | ||||||
|     for station, onsets in picks.items(): |     for station, onsets in picks.items(): | ||||||
|         for label, phase in onsets.items(): |         for label, phase in onsets.items(): | ||||||
|             if not isinstance(phase, dict): |             if not isinstance(phase, dict) and not isinstance(phase, AttribDict): | ||||||
|                 continue |                 continue | ||||||
|             onset = phase['mpp'] |             onset = phase['mpp'] | ||||||
|             try: |             try: | ||||||
|  | |||||||
| @ -7,6 +7,8 @@ from obspy import UTCDateTime | |||||||
| from obspy.core.event import Event as ObsPyEvent | from obspy.core.event import Event as ObsPyEvent | ||||||
| from obspy.core.event import Origin, Magnitude, ResourceIdentifier | from obspy.core.event import Origin, Magnitude, ResourceIdentifier | ||||||
| 
 | 
 | ||||||
|  | from pylot.core.io.phases import picks_from_picksdict | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class Event(ObsPyEvent): | class Event(ObsPyEvent): | ||||||
|     ''' |     ''' | ||||||
| @ -65,8 +67,13 @@ class Event(ObsPyEvent): | |||||||
|         if bool: self._refEvent = False |         if bool: self._refEvent = False | ||||||
| 
 | 
 | ||||||
|     def addPicks(self, picks): |     def addPicks(self, picks): | ||||||
|  |         ''' | ||||||
|  |         add pylot picks and overwrite existing | ||||||
|  |         ''' | ||||||
|         for station in picks: |         for station in picks: | ||||||
|             self.pylot_picks[station] = picks[station] |             self.pylot_picks[station] = picks[station] | ||||||
|  |         #add ObsPy picks | ||||||
|  |         self.picks = picks_from_picksdict(self.pylot_picks) | ||||||
|          |          | ||||||
|     def addAutopicks(self, autopicks): |     def addAutopicks(self, autopicks): | ||||||
|         for station in autopicks: |         for station in autopicks: | ||||||
| @ -75,10 +82,15 @@ class Event(ObsPyEvent): | |||||||
|     def setPick(self, station, pick): |     def setPick(self, station, pick): | ||||||
|         if pick: |         if pick: | ||||||
|             self.pylot_picks[station] = pick |             self.pylot_picks[station] = pick | ||||||
| 
 |         self.picks = picks_from_picksdict(self.pylot_picks) | ||||||
|     def setPicks(self, picks): |  | ||||||
|         self.pylot_picks = picks |  | ||||||
|          |          | ||||||
|  |     def setPicks(self, picks): | ||||||
|  |         ''' | ||||||
|  |         set pylot picks and delete and overwrite all existing | ||||||
|  |         ''' | ||||||
|  |         self.pylot_picks = picks | ||||||
|  |         self.picks = picks_from_picksdict(self.pylot_picks) | ||||||
|  |                  | ||||||
|     def getPick(self, station): |     def getPick(self, station): | ||||||
|         if station in self.pylot_picks.keys(): |         if station in self.pylot_picks.keys(): | ||||||
|             return self.pylot_picks[station] |             return self.pylot_picks[station] | ||||||
|  | |||||||
| @ -1646,7 +1646,7 @@ class TuneAutopicker(QWidget): | |||||||
|         model = self.stationBox.model() |         model = self.stationBox.model() | ||||||
|         for network, station in stations: |         for network, station in stations: | ||||||
|             item = QtGui.QStandardItem(network+'.'+station) |             item = QtGui.QStandardItem(network+'.'+station) | ||||||
|             if station in self.get_current_event().picks: |             if station in self.get_current_event().pylot_picks: | ||||||
|                 item.setBackground(self.parent._colors['ref']) |                 item.setBackground(self.parent._colors['ref']) | ||||||
|             model.appendRow(item) |             model.appendRow(item) | ||||||
| 
 | 
 | ||||||
| @ -1698,13 +1698,13 @@ class TuneAutopicker(QWidget): | |||||||
| 
 | 
 | ||||||
|     def get_current_event_picks(self, station): |     def get_current_event_picks(self, station): | ||||||
|         event = self.get_current_event() |         event = self.get_current_event() | ||||||
|         if station in event.picks.keys(): |         if station in event.pylot_picks.keys(): | ||||||
|             return event.picks[station] |             return event.pylot_picks[station] | ||||||
|          |          | ||||||
|     def get_current_event_autopicks(self, station): |     def get_current_event_autopicks(self, station): | ||||||
|         event = self.get_current_event() |         event = self.get_current_event() | ||||||
|         if event.autopicks: |         if event.pylot_autopicks: | ||||||
|             return event.autopicks[station] |             return event.pylot_autopicks[station] | ||||||
|          |          | ||||||
|     def get_current_station(self): |     def get_current_station(self): | ||||||
|         return str(self.stationBox.currentText()).split('.')[-1] |         return str(self.stationBox.currentText()).split('.')[-1] | ||||||
| @ -1917,8 +1917,8 @@ class TuneAutopicker(QWidget): | |||||||
|             self._warn('Could not execute picker:\n{}'.format( |             self._warn('Could not execute picker:\n{}'.format( | ||||||
|                 self.ap_thread._executedError)) |                 self.ap_thread._executedError)) | ||||||
|             return |             return | ||||||
|         self.picks = self.ap_thread.data |         self.pylot_picks = self.ap_thread.data | ||||||
|         if not self.picks: |         if not self.pylot_picks: | ||||||
|             self._warn('No picks found. See terminal output.') |             self._warn('No picks found. See terminal output.') | ||||||
|             return |             return | ||||||
|         #renew tabs |         #renew tabs | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user