In [1]:
# Import the libraries that we'll be using
import numpy as np
import pandas as pd
import hydropy as hp
# Set the notebook to plot graphs in the output cells.
%matplotlib inline
In [2]:
# Create a Pandas dataframe using the USGS daily discharge for Herring Run.
start = '2011-01-01'
end = '2016-01-01'
herring = hp.get_usgs('01585200', 'dv', start, end)
stony = hp.get_usgs('01589464', 'dv', start, end)
In [3]:
bfc = hp.get_baseflow_chapman(herring, 0.00001)
bfc.head()
Out[3]:
In [4]:
type(bfc)
Out[4]:
In [5]:
bfb = hp.get_baseflow_boughton(herring, .5, 15.0)
bfb.head()
Out[5]:
In [6]:
bfi = hp.get_baseflow_ihacres(herring, 0.1, 15, .5)
bfi.head()
Out[6]:
In [7]:
stony.head()
Out[7]:
In [8]:
multi = pd.merge(herring, stony, left_index=True, right_index=True, suffixes=('_herring', '_stony'))
multi.head()
Out[8]:
In [9]:
# Analyze the data using the HydroAnalysis class.
my_analysis = hp.HydroAnalysis(multi)
# Plot discharge on a logarithmic scale for the Y axis.
my_analysis.plot(figsize=(16,6), logy=True)
Out[9]:
In [10]:
# We'll need to import pyplot to access the sub-plotfeature
import matplotlib.pyplot as plt
# Create a single figure with a single x-axis.
fig, ax = plt.subplots(figsize=(13, 6))
# Plot our data like normal, but use the special x-axis 'ax'.
my_analysis.plot(ax=ax)
# Plot a new column of data that only includes peaks that are in the 90th percentile;
# Plot the new column using filled circles, and use the axis 'ax' that we created.
my_analysis.get_highpeaks(150, above_percentile=0.9).plot(style='o', ax=ax)
Out[10]:
In [11]:
my_analysis.data.groupby('season').mean()
Out[11]:
In [12]:
my_analysis.summary()
Out[12]:
In [ ]: