I may be starting to obsess a bit, but give the attached python script a
try. You may have to install additional modules, e.g. geopy and sqlite3.
1. On line 9, specify your location
2. On line 14, specify the range of hours you want to examine, around the
event.
3. On line 25, you may need to adjust the query if your pressure data is
not in the barometer column of the archive table
3. Move to the directory containing your weewx.sdb database, or on line 22,
specify its full path.
4. Run the script
The script calculates the distance from the eruption to your location, the
travel time to your location at the speed of sound, and then queries and
plots, and saves the barometer data for a time range around the estimated
arrival time. It also remove any linear trend and plots the difference from
that linear trend.
Follow up with any improvements!
Mine looks like this:
[image: hunga_tonga.png]
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/a387d05e-39d0-4586-b979-2ee027c9b951n%40googlegroups.com.
import time
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import sqlite3
from geopy import distance
# change as needed
home = (44.80321621050904, -63.62038361172844)
hunga_tonga = (-20.5452074472518, -175.38715105641674)
speed_of_sound = 0.32 # km/s
eruption_time = 1642220085 # 2022-01-15 04:14:45 UTC
hour_span = 6
distance = distance.distance(hunga_tonga, home).km
travel_time = distance / speed_of_sound
arrival_time = eruption_time + travel_time
print("distance to eruption %0.1f km arrival at %.0f (%s)" % (distance, arrival_time, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(arrival_time))))
connection = sqlite3.connect('weewx.sdb')
cursor = connection.cursor()
query = "select datetime, barometer from archive where datetime > %.0f and datetime < %.0f order by dateTime;" % (arrival_time - hour_span*3600, arrival_time + hour_span*3600)
cursor.execute(query).fetchall
result = cursor.fetchall()
connection.close()
xdata = []
ydata = []
tdata = []
for row in result:
xdata.append(row[0])
tdata.append(mdates.datestr2num(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(row[0]))))
ydata.append(row[1])
# remove any linear trend
coeff = np.polyfit(xdata, ydata, 1)
trend = np.polyval(coeff, xdata)
fig, ax = plt.subplots()
date_formatter = mdates.DateFormatter('%m-%d %H:%M')
ax.tick_params(axis="x", rotation=90)
ax.xaxis.set_major_formatter(date_formatter)
fig.subplots_adjust(bottom=0.2)
ax.plot(tdata, ydata, color="paleturquoise", linewidth=3)
ax2=ax.twinx()
ax2.plot(tdata, ydata - trend, marker="+", linewidth=1)
plt.show()
# save the plot as a file
fig.savefig('./hunga_tonga.png', format='png', dpi=100, bbox_inches='tight')
plt.show()