import warnings

import matplotlib.pyplot as plt
import pandas
import seaborn

import pycvc

warnings.simplefilter("ignore")

palette = seaborn.color_palette('deep', n_colors=6)
seaborn.set(style='ticks', context='paper', rc={'text.usetex': False})
%matplotlib inline

"""
Explanation: Storm Depth Histograms
Setup the basic working environment
End of explanation
"""


hydro = pandas.read_csv('output/tidy/hydro_simple.csv')

"""
Explanation: Load Tidy Hydrologic Data
End of explanation
"""


fg = pycvc.viz.hydro_histogram(hydro, hue='site', row='has_outflow', save=False)
pycvc.viz.savefig(fg.fig, 'Hist_Site_Outflow', extra='HydroHistogram')

"""
Explanation: Split by site name (color) and presence of outflow (row)
End of explanation
"""


fg = pycvc.viz.hydro_histogram(hydro, row='site', col='has_outflow', hue='season',
                          hue_order=['winter', 'spring', 'summer', 'autumn'],
                          margin_titles=True, palette='BrBG_r', save=False)
pycvc.viz.savefig(fg.fig, 'Hist_Site_Outflow_Season', extra='HydroHistogram')

"""
Explanation: Split by site (row), presence of outflow (column), and season (hue)
Also use a blue-green to brown color palette.
End of explanation
"""


fg = pycvc.viz.hydro_histogram(hydro, col='site', hue='year', col_wrap=2, save=False)
pycvc.viz.savefig(fg.fig, 'Hist_Site_Year', extra='HydroHistogram')

"""
Explanation: Split by years (hue) and outflow (columns, wrapped at 2 wide)
End of explanation
"""


fg = pycvc.viz.hydro_histogram(hydro.query("site == 'ED-1'"), palette='Blues', save=False)
pycvc.viz.savefig(fg.fig, 'Hist_ED1only', extra='HydroHistogram')

"""
Explanation: Just look at ED-1
End of explanation
"""


