'advanced examples' section for documentation
Closed this issue · 1 comments
stijnvanhoey commented
Whereas pywaterinfo is task is to query data from waterinfo.be, some examples of plots could be collected in a more extended tutorials secton for reuse. e.g. while checking the latest water level data during the 2021-07 heavy rain in Flanders, this example shows the data with 'alarm' level:
import matplotlib.pyplot as plt
from pywaterinfo import Waterinfo
vmm = Waterinfo("vmm")
data = vmm.get_timeseries_values(5794042, period="P10D")
alarm = vmm.get_timeseries_values(93763042, period="P10D")
waak = vmm.get_timeseries_values(93761042, period="P10D")
fig, ax = plt.subplots(figsize=(15, 6))
data[["Timestamp", "Value"]].set_index("Timestamp").rename(columns={"Value": "Water level"}).plot(ax=ax, legend=None)
alarm[["Timestamp", "Value"]].set_index("Timestamp").rename(columns={"Value": "Alarm"}).plot(color="red", ax=ax, legend=None)
start_value = alarm.loc[0, ["Timestamp", "Value"]]
ax.annotate('Alarm peil',
xy=(start_value.Timestamp, start_value.Value), xycoords='data',
xytext=(0, -5), textcoords='offset pixels',
horizontalalignment='left', fontsize=12,
verticalalignment='top', color="red")
waak[["Timestamp", "Value"]].set_index("Timestamp").rename(columns={"Value": "Alarm"}).plot(color="orange", ax=ax, legend=None)
start_value = waak.loc[0, ["Timestamp", "Value"]]
ax.annotate('Waak peil',
xy=(start_value.Timestamp, start_value.Value), xycoords='data',
xytext=(0, -5), textcoords='offset pixels',
horizontalalignment='left', fontsize=12,
verticalalignment='top', color="orange")
ax.set_ylabel("H (mTAW)")
ax.grid()
stijnvanhoey commented
Closing this issue to keep the focus of pywaterinfo on the data requests