def taylor_diagram(*args, **kwargs): ''' Plot a Taylor diagram from statistics of different series. taylor_diagram(STDs,RMSs,CORs,keyword=value) The first 3 arguments must be the inputs as described below followed by keywords in the format OPTION = value. An example call to the function would be: taylor_diagram(STDs,RMSs,CORs,markerdisplayed='marker') INPUTS: STDs: Standard deviations RMSs: Centered Root Mean Square Difference CORs: Correlation Each of these inputs are one-dimensional with the same length. First index corresponds to the reference series for the diagram. For example STDs[1] is the standard deviation of the reference series and STDs[2:N] are the standard deviations of the other series. Note that only the latter are plotted. Note that by definition the following relation must be true for all series i: RMSs(i) = sqrt(STDs(i).^2 + STDs(1)^2 - 2*STDs(i)*STDs(1).*CORs(i)) This relation is checked if the checkStats option is used, and if not verified an error message is sent. This relation is not checked by default. Please see Taylor's JGR article for more informations about this relation. OUTPUTS: None. LIST OF OPTIONS: For an exhaustive list of options to customize your diagram, call the function without arguments at a Python command line: % python >>> import skill_metrics as sm >>> sm.taylor_diagram() Reference: Taylor, K. E. (2001), Summarizing multiple aspects of model performance in a single diagram, J. Geophys. Res., 106(D7), 7183-7192, doi:10.1029/2000JD900719. Author: Peter A. Rochford Symplectic, LLC www.thesymplectic.com [email protected] Created on Dec 3, 2016 ''' # Check for number of arguments nargin = len(args) STDs, RMSs, CORs = _get_taylor_diagram_arguments(*args, **kwargs) if nargin == 0: return # Get options option = get_taylor_diagram_options(CORs, **kwargs) # Check the input statistics if requested. if option['checkstats'] == 'on': check_taylor_stats(STDs[1:], RMSs[1:], CORs[1:], 0.01) # Express statistics in polar coordinates. rho = STDs theta = np.arccos(CORs) # Get axis values for plot axes, cax = get_taylor_diagram_axes(rho, option) # Plot axes for target diagram if option['overlay'] == 'off': # Draw circles about origin overlay_taylor_diagram_circles(axes, cax, option) # Draw lines emanating from origin overlay_taylor_diagram_lines(axes, cax, option) # Plot axes for Taylor diagram ax = plot_taylor_axes(axes, cax, option) # Plot marker on axis indicating observation STD plot_taylor_obs(ax, STDs[0], axes, option) # Plot data points. Note that only rho[1:N] and theta[1:N] are # plotted. X = np.multiply(rho[1:], np.cos(theta[1:])) Y = np.multiply(rho[1:], np.sin(theta[1:])) lowcase = option['markerdisplayed'].lower() if lowcase == 'marker': plot_pattern_diagram_markers(X, Y, option) elif lowcase == 'colorbar': plot_pattern_diagram_colorbar(X, Y, RMSs[1:], option) else: raise ValueError('Unrecognized option: ' + option['markerdisplayed'])
def target_diagram(*args, **kwargs): ''' Plot a target diagram from statistics of different series. target_diagram(Bs,RMSDs,RMSDz,keyword=value) The first 3 arguments must be the inputs as described below followed by keywords in the format OPTION = value. An example call to the function would be: target_diagram(Bs,RMSDs,RMSDz,markerdisplayed='marker') INPUTS: Bs : Bias (B) or Normalized Bias (B*). Plotted along y-axis as "Bias". RMSDs : unbiased Root-Mean-Square Difference (RMSD') or normalized unbiased Root-Mean-Square Difference (RMSD*'). Plotted along x-axis as "uRMSD". RMSDz : total Root-Mean-Square Difference (RMSD). Labeled on plot as "RMSD". OUTPUTS: None. LIST OF OPTIONS: For an exhaustive list of options to customize your diagram, call the function without arguments at a Python command line: % python >>> import skill_metrics as sm >>> sm.target_diagram() Reference: Jolliff, J. K., J. C. Kindle, I. Shulman, B. Penta, M. Friedrichs, R. Helber, and R. Arnone (2009), Skill assessment for coupled biological/physical models of marine systems, J. Mar. Sys., 76(1-2), 64-82, doi:10.1016/j.jmarsys.2008.05.014 Author: Peter A. Rochford Symplectic, LLC www.thesymplectic.com [email protected] Created on Nov 25, 2016 ''' # Check for number of arguments nargin = len(args) Bs, RMSDs, RMSDz = _get_target_diagram_arguments(*args) if nargin == 0: return # Get options option = get_target_diagram_options(**kwargs) # Get axis values for plot axes = get_target_diagram_axes(RMSDs,Bs,option) # Plot data points lowcase = option['markerdisplayed'].lower() if lowcase == 'marker': plot_pattern_diagram_markers(RMSDs,Bs,option) elif lowcase == 'colorbar': plot_pattern_diagram_colorbar(RMSDs,Bs,RMSDz,option) else: raise ValueError('Unrecognized option: ' + option['markerdisplayed']) # Modify axes for target diagram (no overlay) if option['overlay'] == 'off': plot_target_axes(axes) # Overlay circles overlay_target_diagram_circles(option)