-
Notifications
You must be signed in to change notification settings - Fork 92
Examples: Target Diagrams
Several example scripts are given below to illustrate how to produce target diagrams in a variety of formats using the Skill Metrics package.
A first example of how to create a simple target diagram given one set of reference observations and multiple model predictions for the quantity. The Python code is kept to a minimum.
This example shows how to calculate the required statistics and produce the target diagram.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target1.py -noshow
All functions in the Skill Metrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
A second example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the first example (target1) where now the data points are labeled and axes properties are specified.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target2.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
A third example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the second example (target2) where now the maximum scale for the bias and unnormalized RMSD (uRMSD) axis is increased, color properties are modified for the data points, and color & style properties are modified for the axes.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target3.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
How to create a target diagram with a legend plus changed marker colors and circles.
A fourth example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the third example (target3) where now a legend is added, the marker colors are changed, and the radii of circles to draw are specified. Note that symbols are used for the points when requesting a legend.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target4.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
How to create a target diagram with a color bar.
A fifth example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the third example (target3) where now the markers are displayed in a color spectrum corresponding to their RMSD. A color bar is automatically displayed showing the correspondence with the RMSD values. The x-axis label for uRMSD = 30 is also suppressed so the markers appear more clearly.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target5.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
How to create a target diagram with overlaid markers.
A sixth example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the third example (target3) where now a fourth data point having a negative bias is overlaid on an existing target diagram that already has 3 data points with positive bias. It is chosen to have the first 3 data points appear in red while the fourth data point is displayed in blue.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target6.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection. The fourth prediction was created by taking the negative of the values of the third prediction for illustration purposes.
How to create a target diagram with a legend plus changed marker colors and circles that show co-located points.
A seventh example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the fourth example (target4) where now a legend is added, the marker colors are changed, the radii of circles to draw are specified, and two points are co-located (i.e. overly each other). Symbols with transparent faces are used so the co-located points can be seen. The list of points are checked for those that agree within 1% of each other and reported to the screen.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target7.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
How to create a Target diagram with multiple sets of data overlaid
An eighth example of how to create a target diagram given one set of reference observations and two sets of model predictions for the quantity.
This example shows how to display multiple data sets on the same target diagram where a different color marker is used for each data set to identify its source. This is accomplished by overlaying the points from the second data set onto the target diagram created using the first data set. Three data sets are used in this example where one is the reference and the other two are model predictions. This example also shows how to specify the legend using a dictionary instead of a list.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target8.py -noshow
The data sets are yearly time series for years 2001-2014, each stored as a list in a dictionary having a key of the form 'spi_2001', 'spi_2002', etc. There is a separate dictionary for each of the observation data set and the two model predictions. Each dictionary is written to its own pickle file. A different file suffix is used depending upon whether the file is created using Python 2 (.pkl) or Python 3 (.pkl3) because the pickle package is not cross version compatible for pickle files containing dictionaries.
The data in these files are statistics calculated from yearly time series of Standard Precipitation Index value over the Mekong basin, a trans-boundary river in Southeast Asia that originates in the Tibetan Plateau and runs through China's Yunnan Province, Myanmar, Laos, Thailand, Cambodia, and Vietnam. The data sources are the ERA5 climate reanalysis dataset from the European Centre for Medium-Range Weather Forecasts (ECMWF) and the Tropical Rainfall Measuring Mission (TRMM 3B42 v7) satellite data, whilst the observation data is the Asian Precipitation - Highly-Resolved Observational Data Integration Towards Evaluation (APHRODITE V1801R1) rain-gauge data. All the statistics for the yearly time series are calculated using the observations for 2001 as the reference.
This data was provide courtesy of Iacopo Ferrario, Resources Scientist, HR Wallingford, Flood and Water Resources group, Wallingford Oxfordshire, United Kingdom
How to create a figure with multiple target diagrams using subplots.
A ninth example of how to create a target diagram given five sets of data, each set composed by the statistics of the observation of five different models, and each set referring to a different forecasting time. This example shows the high level of customization possible using the capability to directly pass in subplot axes to create high quality figures for journal publications. Note this level of customization requires the user have a high level of proficiency with Python.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
-output_file : Defines the output file name
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target9.py -noshow
Mock data is used in the example.
This example was based on the Taylor 14 example that was provided courtesy of Andre D. L. Zanchetta.
How to create a target diagram with a color bar for a specified color map.
A tenth example of how to create a target diagram given one set of reference observations and multiple model predictions for the quantity.
This example is a variation on the fifth example (target5) where a different color map (viridis) and markers (triangles) are specified. As in the fifth example a color bar is automatically displayed showing the correspondence with the RMSD values. The x-axis label for uRMSD = 30 is also suppressed so the markers appear more clearly. Also, a different CSV file format is used for reading the data where the physical units of the physical quantities are specified in the first row.
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
python target10.py -noshow
All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:
data_files = ['pred1_units.csv', 'pred2_units.csv', 'pred3_units.csv', \
'ref_units.csv']
This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.
The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig
function.
The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.
How to create a target diagram with a large number of symbols of different color along with a legend.
An eleventh example of how to create a target diagram with individual control of the marker symbols, color, type, size, etc. This allows the use to have custom control over the appearance of the markers and the legend. However, it requires the user to specify all the details for each marker in a dictionary where the key is the marker label provided as a string. For example, for river gauge "14197":
MARKERS = {
"14197": { # marker label
"labelColor": "k", # label color of black
"symbol": "+", # plus marker symbol
"size": 9, # marker size of 9 pt
"faceColor": "r", # marker face color of red
"edgeColor": "r", # marker edge color of red
}
It supports the following arguments as options.
-noshow : No figure is shown if this flag is present
-nosave : No figure is saved if this flag is present
They can be invoked from a command line as, for example, to not show the plot to allow batch execution:
$ python target11.py -noshow
The target diagram created is for a model of water temperatures in the Farmington River basin of Connecticut. Note that the bias values were created for representative purposes and do not represent the true bias of the model water temperatures.
The data are stored in arrays named: bias, sdev, crmsd, rmsd, ccoef, and gageID. Each of these contain 1 reference value (first position) and 22 prediction values, for a total of 23 values. These arrays are stored in a container which is then written to a pickle file for Python 3 (.pkl3). The source data is an observation set at each location as well as a simulation set.
This data was provide courtesy of John Yearsley, Affiliate Professor, UW-Hydro|Computational Hydrology, University of Washington.