[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 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):
|
||||||
@ -127,11 +128,11 @@ class Survey(object):
|
|||||||
shot.setPickwindow(traceID, pickwin_used)
|
shot.setPickwindow(traceID, pickwin_used)
|
||||||
shot.pickTraces(traceID, windowsize, folm, HosAic) # picker
|
shot.pickTraces(traceID, windowsize, folm, HosAic) # picker
|
||||||
|
|
||||||
shot.setSNR(traceID)
|
shot.setSNR(traceID)
|
||||||
#if shot.getSNR(traceID)[0] < snrthreshold:
|
#if shot.getSNR(traceID)[0] < snrthreshold:
|
||||||
if shot.getSNR(traceID)[0] < shot.getSNRthreshold(traceID):
|
if shot.getSNR(traceID)[0] < shot.getSNRthreshold(traceID):
|
||||||
shot.removePick(traceID)
|
shot.removePick(traceID)
|
||||||
|
|
||||||
# set epp and lpp if SNR > 1 (else earllatepicker cant set values)
|
# set epp and lpp if SNR > 1 (else earllatepicker cant set values)
|
||||||
if shot.getSNR(traceID)[0] > 1:
|
if shot.getSNR(traceID)[0] > 1:
|
||||||
shot.setEarllatepick(traceID)
|
shot.setEarllatepick(traceID)
|
||||||
@ -314,10 +315,10 @@ class Survey(object):
|
|||||||
# shotnumbers.append(shot.getShotnumber())
|
# shotnumbers.append(shot.getShotnumber())
|
||||||
|
|
||||||
# shotnumbers = [shotnumbers for (shotnumbers, shotnames) in sorted(zip(shotnumbers, shotnames))]
|
# shotnumbers = [shotnumbers for (shotnumbers, shotnames) in sorted(zip(shotnumbers, shotnames))]
|
||||||
|
|
||||||
for shotnumber in self.getShotlist():
|
for shotnumber in self.getShotlist():
|
||||||
if index <= figPerSubplot:
|
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')
|
#+str(shot_dict[shotnumber].getShotnumber()), xlabel = 'X', ylabel = 'Y', zlabel = 'traveltime')
|
||||||
#shot_dict[shotnumber].plot3dttc(ax = ax, plotpicks = True)
|
#shot_dict[shotnumber].plot3dttc(ax = ax, plotpicks = True)
|
||||||
ax = fig.add_subplot(3, 4, index)
|
ax = fig.add_subplot(3, 4, index)
|
||||||
@ -374,7 +375,7 @@ class Survey(object):
|
|||||||
for shot in self.data.values():
|
for shot in self.data.values():
|
||||||
for traceID in shot.getTraceIDlist():
|
for traceID in shot.getTraceIDlist():
|
||||||
if plotRemoved == False:
|
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))
|
dist.append(shot.getDistance(traceID))
|
||||||
pick.append(shot.getPick(traceID))
|
pick.append(shot.getPick(traceID))
|
||||||
snrlog.append(math.log10(shot.getSNR(traceID)[0]))
|
snrlog.append(math.log10(shot.getSNR(traceID)[0]))
|
||||||
@ -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)
|
||||||
|
@ -151,7 +151,7 @@ class SeismicShot(object):
|
|||||||
|
|
||||||
def getSymmetricPickError(self, traceID):
|
def getSymmetricPickError(self, traceID):
|
||||||
pickerror = self.pick[traceID]['spe']
|
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)
|
print "SPE is NaN for shot %s, traceID %s"%(self.getShotnumber(), traceID)
|
||||||
return pickerror
|
return pickerror
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ class SeismicShot(object):
|
|||||||
|
|
||||||
:param: traceID
|
:param: traceID
|
||||||
:type: int
|
:type: int
|
||||||
|
|
||||||
:param: cutwindow (equals HOScf 'cut' variable)
|
:param: cutwindow (equals HOScf 'cut' variable)
|
||||||
:type: tuple
|
:type: tuple
|
||||||
|
|
||||||
@ -313,10 +313,10 @@ class SeismicShot(object):
|
|||||||
(self.pick[traceID]['epp'],
|
(self.pick[traceID]['epp'],
|
||||||
self.pick[traceID]['lpp'],
|
self.pick[traceID]['lpp'],
|
||||||
self.pick[traceID]['spe']) = earllatepicker(self.getSingleStream(traceID),
|
self.pick[traceID]['spe']) = earllatepicker(self.getSingleStream(traceID),
|
||||||
nfac, (tnoise, tgap, tsignal),
|
nfac, (tnoise, tgap, tsignal),
|
||||||
self.getPickIncludeRemoved(traceID),
|
self.getPickIncludeRemoved(traceID),
|
||||||
stealthMode = True)
|
stealthMode = True)
|
||||||
|
|
||||||
# TEST OF 1/2 PICKERROR
|
# TEST OF 1/2 PICKERROR
|
||||||
# self.pick[traceID]['spe'] *= 0.5
|
# self.pick[traceID]['spe'] *= 0.5
|
||||||
# TEST OF 1/2 PICKERROR
|
# TEST OF 1/2 PICKERROR
|
||||||
@ -630,7 +630,10 @@ class SeismicShot(object):
|
|||||||
def connectButton(event = None):
|
def connectButton(event = None):
|
||||||
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)
|
||||||
@ -664,7 +659,7 @@ class SeismicShot(object):
|
|||||||
stime = getGlobalTimes(stream)[0]
|
stime = getGlobalTimes(stream)[0]
|
||||||
timeaxis = prepTimeAxis(stime, stream[0])
|
timeaxis = prepTimeAxis(stime, stream[0])
|
||||||
timeaxis -= stime
|
timeaxis -= stime
|
||||||
|
|
||||||
if ax is None:
|
if ax is None:
|
||||||
ax = self.traces4plot[traceID]['ax1']
|
ax = self.traces4plot[traceID]['ax1']
|
||||||
|
|
||||||
@ -678,18 +673,18 @@ class SeismicShot(object):
|
|||||||
ax.set_title('Shot: %s, traceID: %s, pick: %s'
|
ax.set_title('Shot: %s, traceID: %s, pick: %s'
|
||||||
%(self.getShotnumber(), traceID, self.getPick(traceID)))
|
%(self.getShotnumber(), traceID, self.getPick(traceID)))
|
||||||
ax.plot(timeaxis, stream[0].data, 'k', label = 'trace')
|
ax.plot(timeaxis, stream[0].data, 'k', label = 'trace')
|
||||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'r', label = 'most likely')
|
'r', label = 'most likely')
|
||||||
if self.getEarliest(traceID) is not None:
|
if self.getEarliest(traceID) is not None:
|
||||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'g:', label = 'earliest')
|
'g:', label = 'earliest')
|
||||||
if self.getLatest(traceID) is not None:
|
if self.getLatest(traceID) is not None:
|
||||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'b:', label = 'latest')
|
'b:', label = 'latest')
|
||||||
|
|
||||||
@ -710,18 +705,18 @@ class SeismicShot(object):
|
|||||||
|
|
||||||
ax.plot(hoscf.getTimeArray(), hoscf.getCF(), 'b', label = 'HOS')
|
ax.plot(hoscf.getTimeArray(), hoscf.getCF(), 'b', label = 'HOS')
|
||||||
ax.plot(hoscf.getTimeArray(), aiccf.getCF(), 'g', label = 'AIC')
|
ax.plot(hoscf.getTimeArray(), aiccf.getCF(), 'g', label = 'AIC')
|
||||||
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
ax.plot([self.getPick(traceID), self.getPick(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'r', label = 'most likely')
|
'r', label = 'most likely')
|
||||||
if self.getEarliest(traceID) is not None:
|
if self.getEarliest(traceID) is not None:
|
||||||
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
ax.plot([self.getEarliest(traceID), self.getEarliest(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'g:', label = 'earliest')
|
'g:', label = 'earliest')
|
||||||
if self.getLatest(traceID) is not None:
|
if self.getLatest(traceID) is not None:
|
||||||
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
ax.plot([self.getLatest(traceID), self.getLatest(traceID)],
|
||||||
[ax.get_ylim()[0],
|
[ax.get_ylim()[0],
|
||||||
ax.get_ylim()[1]],
|
ax.get_ylim()[1]],
|
||||||
'b:', label = 'latest')
|
'b:', label = 'latest')
|
||||||
ax.plot([0, self.getPick(traceID)],
|
ax.plot([0, self.getPick(traceID)],
|
||||||
@ -784,7 +779,7 @@ class SeismicShot(object):
|
|||||||
plotmethod = {'2d': self.plot2dttc, '3d': self.plot3dttc}
|
plotmethod = {'2d': self.plot2dttc, '3d': self.plot3dttc}
|
||||||
|
|
||||||
plotmethod[method](*args)
|
plotmethod[method](*args)
|
||||||
|
|
||||||
def matshow(self, ax = None, step = 0.5, method = 'linear', plotRec = True, annotations = True, colorbar = True):
|
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
|
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)
|
shots_found[shot.getShotnumber()].append(traceID)
|
||||||
|
|
||||||
return shots_found
|
return shots_found
|
||||||
|
|
||||||
|
def cleanUp(survey):
|
||||||
|
|
||||||
|
for shot in survey.data.values():
|
||||||
|
shot.traces4plot = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user