[bugsearch] trying to fix UnpicklingError by clearing GUI element containing attributes
This commit is contained in:
parent
1f1d0aa118
commit
4fdcf1cf60
@ -2,6 +2,7 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
from pylot.core.active import seismicshot
|
||||
from pylot.core.active.surveyUtils import cleanUp
|
||||
|
||||
class Survey(object):
|
||||
def __init__(self, path, sourcefile, receiverfile, useDefaultParas = False):
|
||||
@ -127,11 +128,11 @@ class Survey(object):
|
||||
shot.setPickwindow(traceID, pickwin_used)
|
||||
shot.pickTraces(traceID, windowsize, folm, HosAic) # picker
|
||||
|
||||
shot.setSNR(traceID)
|
||||
shot.setSNR(traceID)
|
||||
#if shot.getSNR(traceID)[0] < snrthreshold:
|
||||
if shot.getSNR(traceID)[0] < shot.getSNRthreshold(traceID):
|
||||
shot.removePick(traceID)
|
||||
|
||||
|
||||
# set epp and lpp if SNR > 1 (else earllatepicker cant set values)
|
||||
if shot.getSNR(traceID)[0] > 1:
|
||||
shot.setEarllatepick(traceID)
|
||||
@ -314,10 +315,10 @@ class Survey(object):
|
||||
# shotnumbers.append(shot.getShotnumber())
|
||||
|
||||
# shotnumbers = [shotnumbers for (shotnumbers, shotnames) in sorted(zip(shotnumbers, shotnames))]
|
||||
|
||||
|
||||
for shotnumber in self.getShotlist():
|
||||
if index <= figPerSubplot:
|
||||
#ax = fig.add_subplot(3,3,i, projection = '3d', title = 'shot:'
|
||||
#ax = fig.add_subplot(3,3,i, projection = '3d', title = 'shot:'
|
||||
#+str(shot_dict[shotnumber].getShotnumber()), xlabel = 'X', ylabel = 'Y', zlabel = 'traveltime')
|
||||
#shot_dict[shotnumber].plot3dttc(ax = ax, plotpicks = True)
|
||||
ax = fig.add_subplot(3, 4, index)
|
||||
@ -374,7 +375,7 @@ class Survey(object):
|
||||
for shot in self.data.values():
|
||||
for traceID in shot.getTraceIDlist():
|
||||
if plotRemoved == False:
|
||||
if shot.getFlag(traceID) is not 0 or plotRemoved == True:
|
||||
if shot.getFlag(traceID) is not 0 or plotRemoved == True:
|
||||
dist.append(shot.getDistance(traceID))
|
||||
pick.append(shot.getPick(traceID))
|
||||
snrlog.append(math.log10(shot.getSNR(traceID)[0]))
|
||||
@ -428,6 +429,7 @@ class Survey(object):
|
||||
|
||||
def saveSurvey(self, filename = 'survey.pickle'):
|
||||
import cPickle
|
||||
cleanUp(self)
|
||||
outfile = open(filename, 'wb')
|
||||
|
||||
cPickle.dump(self, outfile, -1)
|
||||
|
@ -151,7 +151,7 @@ class SeismicShot(object):
|
||||
|
||||
def getSymmetricPickError(self, traceID):
|
||||
pickerror = self.pick[traceID]['spe']
|
||||
if np.isnan(pickerror) == True:
|
||||
if np.isnan(pickerror) == True:
|
||||
print "SPE is NaN for shot %s, traceID %s"%(self.getShotnumber(), traceID)
|
||||
return pickerror
|
||||
|
||||
@ -276,7 +276,7 @@ class SeismicShot(object):
|
||||
|
||||
:param: traceID
|
||||
:type: int
|
||||
|
||||
|
||||
:param: cutwindow (equals HOScf 'cut' variable)
|
||||
:type: tuple
|
||||
|
||||
@ -313,10 +313,10 @@ class SeismicShot(object):
|
||||
(self.pick[traceID]['epp'],
|
||||
self.pick[traceID]['lpp'],
|
||||
self.pick[traceID]['spe']) = earllatepicker(self.getSingleStream(traceID),
|
||||
nfac, (tnoise, tgap, tsignal),
|
||||
nfac, (tnoise, tgap, tsignal),
|
||||
self.getPickIncludeRemoved(traceID),
|
||||
stealthMode = True)
|
||||
|
||||
|
||||
# TEST OF 1/2 PICKERROR
|
||||
# self.pick[traceID]['spe'] *= 0.5
|
||||
# TEST OF 1/2 PICKERROR
|
||||
@ -630,7 +630,10 @@ class SeismicShot(object):
|
||||
def connectButton(event = None):
|
||||
cid = fig.canvas.mpl_connect('button_press_event', onclick)
|
||||
self.traces4plot[traceID]['cid'] = cid
|
||||
|
||||
|
||||
def cleanup(event):
|
||||
self.traces4plot[traceID] = {}
|
||||
|
||||
fig = plt.figure()
|
||||
ax1 = fig.add_subplot(2,1,1)
|
||||
ax2 = fig.add_subplot(2,1,2, sharex = ax1)
|
||||
@ -640,18 +643,10 @@ class SeismicShot(object):
|
||||
button1.on_clicked(connectButton)
|
||||
button2 = Button(axb2, 'delete', color = 'green', hovercolor = 'grey')
|
||||
button2.on_clicked(rmPick)
|
||||
fig.canvas.mpl_connect('close_event', cleanup)
|
||||
|
||||
if traceID not in self.traces4plot.keys():
|
||||
self.traces4plot[traceID] = {}
|
||||
|
||||
self.traces4plot[traceID] = {'fig': fig,
|
||||
'ax1': ax1,
|
||||
'ax2': ax2,
|
||||
'axb1': axb1,
|
||||
'axb2': axb2,
|
||||
'button1': button1,
|
||||
'button2': button2,
|
||||
'cid': None}
|
||||
self.traces4plot[traceID] = dict(fig=fig, ax1=ax1, ax2=ax2, axb1=axb1, axb2=axb2, button1=button1,
|
||||
button2=button2, cid=None)
|
||||
|
||||
self._drawStream(traceID)
|
||||
self._drawCFs(traceID, folm)
|
||||
@ -664,7 +659,7 @@ class SeismicShot(object):
|
||||
stime = getGlobalTimes(stream)[0]
|
||||
timeaxis = prepTimeAxis(stime, stream[0])
|
||||
timeaxis -= stime
|
||||
|
||||
|
||||
if ax is None:
|
||||
ax = self.traces4plot[traceID]['ax1']
|
||||
|
||||
@ -678,18 +673,18 @@ class SeismicShot(object):
|
||||
ax.set_title('Shot: %s, traceID: %s, pick: %s'
|
||||
%(self.getShotnumber(), traceID, self.getPick(traceID)))
|
||||
ax.plot(timeaxis, stream[0].data, 'k', label = 'trace')
|
||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'r', label = 'most likely')
|
||||
if self.getEarliest(traceID) is not None:
|
||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'g:', label = 'earliest')
|
||||
if self.getLatest(traceID) is not None:
|
||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'b:', label = 'latest')
|
||||
|
||||
@ -710,18 +705,18 @@ class SeismicShot(object):
|
||||
|
||||
ax.plot(hoscf.getTimeArray(), hoscf.getCF(), 'b', label = 'HOS')
|
||||
ax.plot(hoscf.getTimeArray(), aiccf.getCF(), 'g', label = 'AIC')
|
||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'r', label = 'most likely')
|
||||
if self.getEarliest(traceID) is not None:
|
||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'g:', label = 'earliest')
|
||||
if self.getLatest(traceID) is not None:
|
||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||
[ax.get_ylim()[0],
|
||||
ax.get_ylim()[1]],
|
||||
'b:', label = 'latest')
|
||||
ax.plot([0, self.getPick(traceID)],
|
||||
@ -784,7 +779,7 @@ class SeismicShot(object):
|
||||
plotmethod = {'2d': self.plot2dttc, '3d': self.plot3dttc}
|
||||
|
||||
plotmethod[method](*args)
|
||||
|
||||
|
||||
def matshow(self, ax = None, step = 0.5, method = 'linear', plotRec = True, annotations = True, colorbar = True):
|
||||
'''
|
||||
Plots a 2D matrix of the interpolated traveltimes. This needs less performance than plot3dttc
|
||||
|
@ -86,3 +86,8 @@ def findTracesInRanges(shot_dict, distancebin, pickbin):
|
||||
shots_found[shot.getShotnumber()].append(traceID)
|
||||
|
||||
return shots_found
|
||||
|
||||
def cleanUp(survey):
|
||||
|
||||
for shot in survey.data.values():
|
||||
shot.traces4plot = {}
|
||||
|
Loading…
Reference in New Issue
Block a user