forked from dailyerosion/dep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple snow diagnostic for dailyerosion#115
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |