Blockdit Logo
Blockdit Logo (Mobile)
สำรวจ
ลงทุน
คำถาม
เข้าสู่ระบบ
มีบัญชีอยู่แล้ว?
เข้าสู่ระบบ
หรือ
ลงทะเบียน
ก
ไก่ตอน (Kpython)
•
ติดตาม
29 มี.ค. เวลา 08:45 • วิทยาศาสตร์ & เทคโนโลยี
Download คลื่นไหวสะเทือน 2025-03-28 7.7 Mw Myanmar
https://ds.iris.edu/wilber3/find_stations/11952284
แสดงสถานีวัดแผ่นดินไหว ที่บันทึกเหตุการณ์นี้ได้
1.
สามารถเลือกสถานีที่ต้องการข้อมูลโดย click ที่ station ด้านซ้ายมือ ในรูปนี้คือเอาข้อมูลที่อยู่ในรัศมี 30 องศา (~30*111 km) แล้วกด Request Data
2.
กรอกลายละเอียด เมื่อข้อมูลเสร็จ จะมีอีเมลส่ง link ให้ download ข้อมูล
3.
ลอง plot โดยใช้ code Python นี้
4.
ต้องลง package เพิ่ม; >> pip3 install tkinter, ObsPy, matplotlib หรืออื่น ๆ
import tkinter as tk
from tkinter import filedialog, messagebox
from obspy import read
from obspy.core.stream import Stream
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
class SeismogramPlotter(
tk.Tk
):
def __init__(self):
super().__init__()
self.title("Seismogram Plotter")
self.geometry("1000x700")
self.streams = {} # Dictionary to hold Stream objects for each station
self.open_button = tk.Button(self, text="Load SAC Files", command=self.load_files)
self.open_button.pack(pady=10)
self.save_button = tk.Button(self, text="Save Current Plot", command=self.save_plot)
self.save_button.pack(pady=10)
self.station_listbox = tk.Listbox(self)
self.station_listbox.pack(fill=tk.BOTH, expand=True)
self.station_listbox.bind('<>', self.plot_selected_station)
self.current_figure = None
self.current_station = None
def load_files(self):
files = filedialog.askopenfilenames(title="Select SAC files", filetypes=[("SAC files", "*.sac")])
streams_by_station = {}
for file in files:
stream = read(file)
trace = stream[0]
station = trace.stats.station
if station not in streams_by_station:
streams_by_station[station] = Stream()
streams_by_station[station] += stream
self.streams = streams_by_station
self.update_station_list()
def update_station_list(self):
self.station_listbox.delete(0, tk.END)
for station in self.streams.keys():
self.station_listbox.insert(tk.END, station)
def plot_selected_station(self, event):
selection = self.station_listbox.curselection()
if not selection:
return
station = self.station_listbox.get(selection[0])
stream = self.streams[station]
self.current_station = station
self.current_figure, ax = plt.subplots(3, 1, figsize=(12, 8))
self.current_figure.suptitle(f'Station: {station}')
for i, trace in enumerate(stream):
ax[i].plot(trace.times(), trace.data)
ax[i].set_title(trace.stats.channel)
ax[i].set_xlabel('Time (s)')
ax[i].set_ylabel('Amplitude')
plt.tight_layout()
plt.show()
def save_plot(self):
if self.current_figure is None or self.current_station is None:
messagebox.showwarning("No Plot", "No plot to save. Please select a station and plot it first.")
return
file_path = filedialog.asksaveasfilename(defaultextension=".png", filetypes=[("PNG Image", "*.png"), ("All Files", "*.*")])
if file_path:
self.current_figure.savefig(file_path)
messagebox.showinfo("Success", "Plot saved successfully.")
if __name__ == "__main__":
app = SeismogramPlotter()
app.mainloop()
code นี้สร้างจากการใช้ chatGPT ในการช่วย
ตัวอย่างหน้าตาโปรแกรมหลัง run code นี้
เลือกสถานี CHTO
เทคโนโลยี
แผ่นดินไหว
บันทึก
2
2
โฆษณา
ดาวน์โหลดแอปพลิเคชัน
© 2025 Blockdit
เกี่ยวกับ
ช่วยเหลือ
คำถามที่พบบ่อย
นโยบายการโฆษณาและบูสต์โพสต์
นโยบายความเป็นส่วนตัว
แนวทางการใช้แบรนด์ Blockdit
Blockdit เพื่อธุรกิจ
ไทย