在绘制地震图后,我试图将各种滤波器应用于地震图。因此,如果我绘制原始地震图,并单击“应用带通滤波器”按钮,它将自动将带通滤波器应用于当前屏幕上的轨迹。
我的代码(下面)目前正在编程,因此我必须删除一个数字才能成功点击我创建的其他按钮之一。您对我如何对我的代码进行上述编辑有任何建议吗?我会为你省去创建GUI的线路,因为它们不会影响我想要完成的任务。下面定义的功能将绘制地震图,具有高通滤波器的地震图,带有带通滤波器的地震图或频谱图。谢谢你的帮助。
#!/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()