I am attempting to apply an assortment of filters to a seismogram, after the seismogram is plotted. So, if I plot the original seismogram, and I click the button "Apply Bandpass Filter", it'll apply the bandpass filter automatically to the trace that is currently on the screen.
My code (below) is currently programmed so that I must delete a figure before being able to successfully click one of the other buttons that I created. Do you have any suggestions for how I could make the above edits to my code? I'll spare you the lines creating the GUI, as they won't affect what I'm trying to accomplish. The functions defined below will plot the seismogram, the seismogram with a high-pass filter, the seismogram w/ a bandpass filter, or the spectrogram. Thanks for your help.
#!/usr/bin/env python
from Tkinter import *
from obspy.core import read
import obspy.signal
import matplotlib.pyplot as plt
import numpy as np
import pylab
import math
class Plot_Seismogram:
def __init__(self, parent):
.....
# Widget design that I omitted
# Quit Function
def quit(self, event=None):
self.master.quit()
# Seismogram Function
def plot_seis(self, event=None):
event = read(self.List1.get(self.List1.curselection()[0]))
event.plot()
# BandPass Filter Function
def highpass_filter(self, event=None):
event_filter = read(self.List1.get(self.List1.curselection()[0]))
event_filter.filter('highpass', freq=1.0, corners=1, zerophase=True)
event_filter.plot()
def bandpass_filter(self, event=None):
event_filter = read(self.List1.get(self.List1.curselection()[0]))
event_filter.filter('bandpass', freqmin=2, freqmax=5, corners=4, zerophase=False)
event_filter.plot()
# Spectrogram Function
def plot_spectro(self, event=None):
event_spect = read(self.List1.get(self.List1.curselection()[0]))
event_spect.spectrogram(log=False, )
root = Tk()
Plot_Seismo = Plot_Seismogram(root)
root.mainloop()