[bugsearch] trying to fix UnpicklingError by clearing GUI element containing attributes

This commit is contained in:
Sebastian Wehling-Benatelli 2015-11-23 12:11:04 +01:00
parent 1f1d0aa118
commit 4fdcf1cf60
3 changed files with 37 additions and 35 deletions

View File

@ -2,6 +2,7 @@
import sys import sys
import numpy as np import numpy as np
from pylot.core.active import seismicshot from pylot.core.active import seismicshot
from pylot.core.active.surveyUtils import cleanUp
class Survey(object): class Survey(object):
def __init__(self, path, sourcefile, receiverfile, useDefaultParas = False): def __init__(self, path, sourcefile, receiverfile, useDefaultParas = False):
@ -428,6 +429,7 @@ class Survey(object):
def saveSurvey(self, filename = 'survey.pickle'): def saveSurvey(self, filename = 'survey.pickle'):
import cPickle import cPickle
cleanUp(self)
outfile = open(filename, 'wb') outfile = open(filename, 'wb')
cPickle.dump(self, outfile, -1) cPickle.dump(self, outfile, -1)

View File

@ -631,6 +631,9 @@ class SeismicShot(object):
cid = fig.canvas.mpl_connect('button_press_event', onclick) cid = fig.canvas.mpl_connect('button_press_event', onclick)
self.traces4plot[traceID]['cid'] = cid self.traces4plot[traceID]['cid'] = cid
def cleanup(event):
self.traces4plot[traceID] = {}
fig = plt.figure() fig = plt.figure()
ax1 = fig.add_subplot(2,1,1) ax1 = fig.add_subplot(2,1,1)
ax2 = fig.add_subplot(2,1,2, sharex = ax1) ax2 = fig.add_subplot(2,1,2, sharex = ax1)
@ -640,18 +643,10 @@ class SeismicShot(object):
button1.on_clicked(connectButton) button1.on_clicked(connectButton)
button2 = Button(axb2, 'delete', color = 'green', hovercolor = 'grey') button2 = Button(axb2, 'delete', color = 'green', hovercolor = 'grey')
button2.on_clicked(rmPick) button2.on_clicked(rmPick)
fig.canvas.mpl_connect('close_event', cleanup)
if traceID not in self.traces4plot.keys(): self.traces4plot[traceID] = dict(fig=fig, ax1=ax1, ax2=ax2, axb1=axb1, axb2=axb2, button1=button1,
self.traces4plot[traceID] = {} button2=button2, cid=None)
self.traces4plot[traceID] = {'fig': fig,
'ax1': ax1,
'ax2': ax2,
'axb1': axb1,
'axb2': axb2,
'button1': button1,
'button2': button2,
'cid': None}
self._drawStream(traceID) self._drawStream(traceID)
self._drawCFs(traceID, folm) self._drawCFs(traceID, folm)

View File

@ -86,3 +86,8 @@ def findTracesInRanges(shot_dict, distancebin, pickbin):
shots_found[shot.getShotnumber()].append(traceID) shots_found[shot.getShotnumber()].append(traceID)
return shots_found return shots_found
def cleanUp(survey):
for shot in survey.data.values():
shot.traces4plot = {}