[add] finished remove picks feature, testing needed

This commit is contained in:
Marcel Paffrath 2017-07-18 14:34:09 +02:00
parent dbb3fab6d0
commit 37875d5c87
5 changed files with 24 additions and 11 deletions

View File

@ -1751,7 +1751,7 @@ class MainWindow(QMainWindow):
autopicks=self.getPicksOnStation(station, 'auto')) autopicks=self.getPicksOnStation(station, 'auto'))
pickDlg.nextStation.setChecked(nextStation) pickDlg.nextStation.setChecked(nextStation)
if pickDlg.exec_(): if pickDlg.exec_():
if pickDlg.getPicks(): if pickDlg._dirty:
self.setDirty(True) self.setDirty(True)
self.update_status('picks accepted ({0})'.format(station)) self.update_status('picks accepted ({0})'.format(station))
replot = self.addPicks(station, pickDlg.getPicks()) replot = self.addPicks(station, pickDlg.getPicks())
@ -1864,12 +1864,12 @@ class MainWindow(QMainWindow):
def addPicks(self, station, picks, type='manual'): def addPicks(self, station, picks, type='manual'):
stat_picks = self.getPicksOnStation(station, type) stat_picks = self.getPicksOnStation(station, type)
if not stat_picks: if not stat_picks and picks:
rval = False rval = False
else: else:
rval = True
# set picks (ugly syntax?) # set picks (ugly syntax?)
self.getPicks(type=type)[station] = picks self.getPicks(type=type)[station] = picks
rval = True
return rval return rval
# if not stat_picks: # if not stat_picks:
# stat_picks = picks # stat_picks = picks

View File

@ -1 +1 @@
1918-dirty dbb3-dirty

View File

@ -83,6 +83,11 @@ 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
else:
try:
self.pylot_picks.pop(station)
except Exception as e:
print('Could not remove pick {} from station {}: {}'.format(pick, station, e))
self.picks = picks_from_picksdict(self.pylot_picks) self.picks = picks_from_picksdict(self.pylot_picks)
def setPicks(self, picks): def setPicks(self, picks):

View File

@ -370,7 +370,7 @@ def key_for_set_value(d):
return r return r
def prepTimeAxis(stime, trace): def prepTimeAxis(stime, trace, verbosity=0):
''' '''
takes a starttime and a trace object and returns a valid time axis for takes a starttime and a trace object and returns a valid time axis for
plotting plotting
@ -384,9 +384,11 @@ def prepTimeAxis(stime, trace):
etime = stime + nsamp / srate etime = stime + nsamp / srate
time_ax = np.arange(stime, etime, tincr) time_ax = np.arange(stime, etime, tincr)
if len(time_ax) < nsamp: if len(time_ax) < nsamp:
if verbosity:
print('elongate time axes by one datum') print('elongate time axes by one datum')
time_ax = np.arange(stime, etime + tincr, tincr) time_ax = np.arange(stime, etime + tincr, tincr)
elif len(time_ax) > nsamp: elif len(time_ax) > nsamp:
if verbosity:
print('shorten time axes by one datum') print('shorten time axes by one datum')
time_ax = np.arange(stime, etime - tincr, tincr) time_ax = np.arange(stime, etime - tincr, tincr)
if len(time_ax) != nsamp: if len(time_ax) != nsamp:

View File

@ -753,6 +753,7 @@ class PickDlg(QDialog):
settings = QSettings() settings = QSettings()
pylot_user = getpass.getuser() pylot_user = getpass.getuser()
self._user = settings.value('user/Login', pylot_user) self._user = settings.value('user/Login', pylot_user)
self._dirty = False
if picks: if picks:
self.picks = picks self.picks = picks
self._init_picks = copy.deepcopy(picks) self._init_picks = copy.deepcopy(picks)
@ -952,6 +953,9 @@ class PickDlg(QDialog):
self.setLayout(_outerlayout) self.setLayout(_outerlayout)
self.resize(1280, 720) self.resize(1280, 720)
def setDirty(self, bool):
self._dirty = bool
def get_arrivals(self): def get_arrivals(self):
phases = self.prepare_phases() phases = self.prepare_phases()
station_id = self.data.traces[0].get_id() station_id = self.data.traces[0].get_id()
@ -1558,6 +1562,7 @@ class PickDlg(QDialog):
self.zoomAction.setEnabled(True) self.zoomAction.setEnabled(True)
self.pick_block = self.togglePickBlocker() self.pick_block = self.togglePickBlocker()
self.leave_picking_mode() self.leave_picking_mode()
self.setDirty(True)
def drawAllPicks(self): def drawAllPicks(self):
self.removePhaseText() self.removePhaseText()
@ -1654,6 +1659,7 @@ class PickDlg(QDialog):
# information output # information output
msg = 'Deleted pick for phase {}, {}[s] from starttime {}' msg = 'Deleted pick for phase {}, {}[s] from starttime {}'
print(msg.format(phase, pick_rel, starttime)) print(msg.format(phase, pick_rel, starttime))
self.setDirty(True)
def drawPhaseText(self): def drawPhaseText(self):
return self.drawPicks(picktype='manual', textOnly=True) return self.drawPicks(picktype='manual', textOnly=True)