-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from jukent/taylordiagram
add taylordiagram example
- Loading branch information
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# `TaylorDiagram`\n", | ||
"\n", | ||
"This notebook is a simple example of the GeoCAT-viz class <a href=\"../user_api/generated/geocat.viz.TaylorDiagram.html\">`TaylorDiagram`</a> class." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import packages:\n", | ||
"\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"import geocat.viz as gv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create sample data:\n", | ||
"\n", | ||
"# Model A\n", | ||
"a_sdev = [1.230, 0.988, 1.092, 1.172, 1.064, 0.966, 1.079] # normalized standard deviation\n", | ||
"a_ccorr = [0.958, 0.973, 0.740, 0.743, 0.922, 0.982, 0.952] # correlation coefficient\n", | ||
"a_bias = [2.7, -1.5, 17.31, -20.11, 12.5, 8.341, -4.7] # bias (%)\n", | ||
"\n", | ||
"# Model B\n", | ||
"b_sdev = [1.129, 0.996, 1.016, 1.134, 1.023, 0.962, 1.048] # normalized standard deviation\n", | ||
"b_ccorr = [0.963, 0.975, 0.801, 0.814, 0.946, 0.984, 0.968] # correlation coefficient\n", | ||
"b_bias = [1.7, 2.5, -17.31, 20.11, 19.5, 7.341, 9.2]\n", | ||
"\n", | ||
"# Sample Variable List\n", | ||
"var_list = ['Surface Pressure', '2m Temp', 'Dew Point Temp', 'U Wind', 'V Wind', 'Precip', 'Cloud Cov']" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create figure and TaylorDiagram instance\n", | ||
"fig = plt.figure(figsize=(10, 10))\n", | ||
"taylor = gv.TaylorDiagram(fig=fig, label='REF')\n", | ||
"\n", | ||
"# Draw diagonal dashed lines from origin to correlation values\n", | ||
"# Also enforces proper X-Y ratio\n", | ||
"taylor.add_xgrid(np.array([0.6, 0.9]))\n", | ||
"\n", | ||
"# Add models to Taylor diagram\n", | ||
"taylor.add_model_set(a_sdev,\n", | ||
" a_ccorr,\n", | ||
" percent_bias_on=True, # indicate marker and size to be plotted based on bias_array\n", | ||
" bias_array=a_bias, # specify bias array\n", | ||
" color='red',\n", | ||
" label='Model A',\n", | ||
" fontsize=16)\n", | ||
"\n", | ||
"taylor.add_model_set(b_sdev,\n", | ||
" b_ccorr,\n", | ||
" percent_bias_on=True,\n", | ||
" bias_array=b_bias,\n", | ||
" color='blue',\n", | ||
" label='Model B',\n", | ||
" fontsize=16)\n", | ||
"\n", | ||
"# Add model name\n", | ||
"taylor.add_model_name(var_list, fontsize=16)\n", | ||
"\n", | ||
"# Add figure legend\n", | ||
"taylor.add_legend(fontsize=16)\n", | ||
"\n", | ||
"# Add bias legend\n", | ||
"taylor.add_bias_legend()\n", | ||
"\n", | ||
"# Add constant centered RMS difference contours.\n", | ||
"taylor.add_contours(levels=np.arange(0, 1.1, 0.25),\n", | ||
" colors='lightgrey',\n", | ||
" linewidths=0.5);" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "geocat_sandbox", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters