Skip to content

Commit

Permalink
add simple snow diagnostic for dailyerosion#115
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Feb 1, 2022
1 parent 52e72a5 commit b8713e2
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/plots/plot_wb_snow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""Diagnose some Water Balance stuff"""
import sys
import glob
import datetime

from tqdm import tqdm
import pandas as pd
from scipy import stats
import seaborn as sns
from pyiem.plot import figure_axes
from pyiem.dep import read_wb
from pyiem.util import get_dbconnstr


def main(argv):
"""Do things"""
obs = pd.read_sql(
"SELECT day, snowd from alldata_mn where station = 'MN2142' "
"and year >= 2007 and year < 2022 ORDER by day ASC",
get_dbconnstr("coop"),
index_col="day",
)
df = read_wb(argv[1])
# just care about OFE 1 for now
df = df[df["ofe"] == 1].set_index("date")

df["obs"] = obs["snowd"] * 25.4
df["delta"] = df["snodpy"] - df["obs"]

g = sns.lmplot(x="snodpy", y="obs", data=df)
g.ax.set_title("Detroit Lakes 2007-2021 vs 090201030701 FP:32")
g.ax.set_ylabel("Snow Depth Obs (mm)")
g.ax.set_xlabel("Snow Depth WEPP (mm)")
df = df[pd.notnull(df["obs"])]
b = df["snodpy"].mean() - df["obs"].mean()
g.ax.text(0.05, 0.8, "bias:{:.3f}mm".format(b), transform=g.ax.transAxes)
g.fig.subplots_adjust(top=0.95)
g.fig.savefig("test.png")


if __name__ == "__main__":
main(sys.argv)

0 comments on commit b8713e2

Please sign in to comment.