Prado EFO PVA
figures_fcst.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 Created on Tue May 4 11:07:21 2021
4 
5 @author: cd
6 """
7 
8 import matplotlib.pyplot as plt
9 import matplotlib.dates as mdates
10 import warnings
11 warnings.filterwarnings('error', category=RuntimeWarning)
12 
13 def plot_fcst_hydrograph(*, ax, tFcst, fcstResults, parameter, units,
14  fontSz=9, timeInterval=24, yMin=0, yMax=None, lineWidth=0.75,
15  showXTicks=True, showTitle=True, colorOvrd=None, lineStyle='-'):
16  if colorOvrd:
17  ax.plot(tFcst, fcstResults, linewidth=lineWidth, linestyle=lineStyle, color=colorOvrd)
18  else:
19  ax.plot(tFcst, fcstResults, linewidth=lineWidth, linestyle=lineStyle)
20  ax.relim()
21  ax.autoscale()
22  ax.set_xlim(tFcst[0], tFcst[-1])
23  ax.set_ylim(bottom=yMin)
24  if yMax is not None:
25  ax.set_ylim(top=yMax)
26  ax.get_yaxis().get_major_formatter().set_scientific(False)
27  # Set the date tick interval
28  # ax1.xaxis.set_minor_locator(mdates.HourLocator(interval=1))
29  ax.xaxis.set_major_locator(mdates.HourLocator(interval=timeInterval))
30  if showXTicks:
31  ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d-%Hz'))
32  ax.xaxis.set_tick_params(rotation = 45)
33  for label in ax.xaxis.get_majorticklabels():
34  label.set_horizontalalignment('right')
35  else:
36  ax.set_xticklabels([])
37  ax.xaxis.grid(True, which='major', linestyle=':')
38  ax.yaxis.grid(True, which='major', linestyle=':')
39  plt.setp(ax.get_yticklabels(), fontsize=fontSz)
40  ax.set_ylabel(parameter+' ('+units+')', fontsize=fontSz)
41  if showTitle: ax.set_title(parameter, fontsize=fontSz)
42 
43 
44 def plot_fcst_risk(*, ax, tFcst, riskTol, riskFcst,
45  nameThreshold='Storage Threshold', fontSz=9, timeInterval=24, yMin=0, yMax=None,
46  showXTicks=True, showTitle=True):
47  ax.plot(tFcst, riskTol*100, 'b--', linewidth=1, label='Risk Tolerance')
48  ax.plot(tFcst, riskFcst*100, 'r-', linewidth=1.5, label='Forecasted Risk')
49  ax.set_xlim(tFcst[0], tFcst[-1])
50  ax.set_ylim(bottom=0, top=yMax)
51  # Set the date tick interval
52  # ax2.xaxis.set_minor_locator(mdates.HourLocator(interval=1))
53  ax.xaxis.set_major_locator(mdates.HourLocator(interval=timeInterval))
54  if showXTicks:
55  ax.xaxis.set_major_formatter(mdates.DateFormatter('%m-%d-%Hz'))
56  ax.xaxis.set_tick_params(rotation = 45)
57  for label in ax.xaxis.get_majorticklabels():
58  label.set_horizontalalignment('right')
59  else:
60  ax.set_xticklabels([])
61  ax.xaxis.grid(True, which='major', linestyle=':')
62  ax.yaxis.grid(True, which='major', linestyle=':')
63  plt.setp(ax.get_xticklabels(), fontsize=fontSz)
64  plt.setp(ax.get_yticklabels(), fontsize=fontSz)
65  ax.set_ylabel('Risk (%)', fontsize=fontSz)
66  ax.set_xlabel('Date', fontsize=fontSz)
67  ax.legend(prop=dict(size=fontSz), loc='upper left')
68  if showTitle: ax.set_title('% of Ensemble Members > '+nameThreshold, fontsize=fontSz)
def plot_fcst_risk(*ax, tFcst, riskTol, riskFcst, nameThreshold='Storage Threshold', fontSz=9, timeInterval=24, yMin=0, yMax=None, showXTicks=True, showTitle=True)
Definition: figures_fcst.py:46
def plot_fcst_hydrograph(*ax, tFcst, fcstResults, parameter, units, fontSz=9, timeInterval=24, yMin=0, yMax=None, lineWidth=0.75, showXTicks=True, showTitle=True, colorOvrd=None, lineStyle='-')
Definition: figures_fcst.py:15