Skip to content

Commit

Permalink
prevent error on hourly precip plot
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed May 17, 2016
1 parent b99c8ee commit b82dfdd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion htdocs/plotting/auto/scripts/p20.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def plotter(fdict):
agg2 a LEFT JOIN myyear m
on (m.month = a.month) ORDER by a.month ASC
""", pgconn, params=(station, year), index_col=None)

if len(df.index) == 0:
return "No Precipitation Data Found for Site"
(fig, ax) = plt.subplots(1, 1)
monthly = df['avg'].values.tolist()
bars = ax.bar(df['month'] - 0.4, monthly, fc='red', ec='red',
Expand Down Expand Up @@ -100,3 +101,6 @@ def plotter(fdict):
) % (nt.sts[station]['name'], station))

return fig, df

if __name__ == '__main__':
plotter(dict(zstation='CGS', network='MD_ASOS', year=2016))

0 comments on commit b82dfdd

Please sign in to comment.