[fixes #244] parameters passed to pickDlg explicit

This commit is contained in:
Marcel Paffrath 2017-08-30 10:51:20 +02:00
parent 21f02bf675
commit f21fc7bb37
2 changed files with 21 additions and 8 deletions

View File

@ -1799,11 +1799,14 @@ class MainWindow(QMainWindow):
return return
self.update_status('picking on station {0}'.format(station)) self.update_status('picking on station {0}'.format(station))
data = self.get_data().getWFData() data = self.get_data().getWFData()
event = self.get_current_event()
pickDlg = PickDlg(self, parameter=self._inputs, pickDlg = PickDlg(self, parameter=self._inputs,
data=data.select(station=station), data=data.select(station=station),
station=station, network=network, station=station, network=network,
picks=self.getPicksOnStation(station, 'manual'), picks=self.getPicksOnStation(station, 'manual'),
autopicks=self.getPicksOnStation(station, 'auto')) autopicks=self.getPicksOnStation(station, 'auto'),
metadata=self.metadata, event=event,
filteroptions=self.filteroptions)
pickDlg.nextStation.setChecked(nextStation) pickDlg.nextStation.setChecked(nextStation)
if pickDlg.exec_(): if pickDlg.exec_():
if pickDlg._dirty: if pickDlg._dirty:

View File

@ -822,7 +822,8 @@ class PickDlg(QDialog):
update_picks = QtCore.Signal(dict) update_picks = QtCore.Signal(dict)
def __init__(self, parent=None, data=None, station=None, network=None, picks=None, def __init__(self, parent=None, data=None, station=None, network=None, picks=None,
autopicks=None, rotate=False, parameter=None, embedded=False, model='iasp91'): autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None,
event=None, filteroptions=None, model='iasp91'):
super(PickDlg, self).__init__(parent) super(PickDlg, self).__init__(parent)
# initialize attributes # initialize attributes
@ -831,6 +832,8 @@ class PickDlg(QDialog):
self.station = station self.station = station
self.network = network self.network = network
self.rotate = rotate self.rotate = rotate
self.metadata = metadata
self.pylot_event = event
self.components = 'ZNE' self.components = 'ZNE'
self.currentPhase = None self.currentPhase = None
self.phaseText = [] self.phaseText = []
@ -853,8 +856,8 @@ class PickDlg(QDialog):
else: else:
self.autopicks = {} self.autopicks = {}
self._init_autopicks = {} self._init_autopicks = {}
if hasattr(self.parent(), 'filteroptions'): if filteroptions:
self.filteroptions = self.parent().filteroptions self.filteroptions = filteroptions
else: else:
self.filteroptions = FILTERDEFAULTS self.filteroptions = FILTERDEFAULTS
self.pick_block = False self.pick_block = False
@ -915,7 +918,7 @@ class PickDlg(QDialog):
# init expected picks using obspy Taup # init expected picks using obspy Taup
try: try:
if self.parent().metadata: if self.metadata:
self.model = TauPyModel(model) self.model = TauPyModel(model)
self.get_arrivals() self.get_arrivals()
self.drawArrivals() self.drawArrivals()
@ -1080,13 +1083,16 @@ class PickDlg(QDialog):
self._dirty = bool self._dirty = bool
def get_arrivals(self, plot=False): def get_arrivals(self, plot=False):
if not self.metadata:
print('get_arrivals: No metadata given. Return!')
return
func = {True: self.model.get_ray_paths_geo, func = {True: self.model.get_ray_paths_geo,
False: self.model.get_travel_times_geo} False: self.model.get_travel_times_geo}
phases = self.prepare_phases() phases = self.prepare_phases()
station_id = self.data.traces[0].get_id() station_id = self.data.traces[0].get_id()
parser = self.parent().metadata[1] parser = self.metadata[1]
station_coords = parser.get_coordinates(station_id) station_coords = parser.get_coordinates(station_id)
origins = self.parent().get_current_event().origins origins = self.pylot_event.origins
if origins: if origins:
source_origin = origins[0] source_origin = origins[0]
else: else:
@ -1117,7 +1123,7 @@ class PickDlg(QDialog):
else: else:
ylims = self.getPlotWidget().getYLims() ylims = self.getPlotWidget().getYLims()
stime = self.getStartTime() stime = self.getStartTime()
source_origin = self.parent().get_current_event().origins[0] source_origin = self.pylot_event.origins[0]
source_time = source_origin.time source_time = source_origin.time
for arrival in self.arrivals: for arrival in self.arrivals:
arrival_time_abs = source_time + arrival.time arrival_time_abs = source_time + arrival.time
@ -2335,10 +2341,14 @@ class TuneAutopicker(QWidget):
return return
station = self.get_current_station() station = self.get_current_station()
data = self.data.getWFData() data = self.data.getWFData()
metadata = self.parent.metadata
event = self.get_current_event()
filteroptions = self.parent.filteroptions
pickDlg = PickDlg(self, data=data.select(station=station), pickDlg = PickDlg(self, data=data.select(station=station),
station=station, parameter=self.parameter, station=station, parameter=self.parameter,
picks=self.get_current_event_picks(station), picks=self.get_current_event_picks(station),
autopicks=self.get_current_event_autopicks(station), autopicks=self.get_current_event_autopicks(station),
metadata=metadata, event=event, filteroptions=filteroptions,
embedded=True) embedded=True)
pickDlg.update_picks.connect(self.picks_from_pickdlg) pickDlg.update_picks.connect(self.picks_from_pickdlg)
pickDlg.update_picks.connect(self.fill_eventbox) pickDlg.update_picks.connect(self.fill_eventbox)