fukuno.jig.jp
www.wbgt.env.go.jp
import datetime
import pandas as pd
import matplotlib.pyplot as plt
point = 73076
df_tmp = pd.read_csv(f"https://www.wbgt.env.go.jp/prev15WG/dl/yohou_{point}.csv").T
dt_now = datetime.datetime.strptime(df_tmp.iat[1, 0], "%Y/%m/%d %H:%M")
df = df_tmp.iloc[2:].copy()
df.rename(columns={0: "WBGT"}, inplace=True)
df.index = df.index.astype(str).map(
lambda s: pd.to_datetime(s[:8]) + pd.Timedelta(hours=int(s[8:]))
)
df["WBGT"] = df["WBGT"] / 10
df["状況"] = pd.cut(
df["WBGT"], [0, 21, 25, 28, 31, 50], labels=["ほぼ安全", "注意", "警戒", "厳重警戒", "危険"]
)
df
ax = df.plot(grid=True, figsize=(10, 5))
ax.set_ylim(10, 40)
ax.axhline(y=31, linestyle="--", color="red", linewidth=1, label="危険")
ax.axhline(y=28, linestyle="--", color="orange", linewidth=1, label="厳重警戒")
ax.axhline(y=25, linestyle="--", color="yellow", linewidth=1, label="警戒")
ax.axhline(y=21, linestyle="--", color="cyan", linewidth=1, label="注意")
plt.savefig("wbgt.png", dpi=200, bbox_inches="tight")
plt.show()