{
"metadata": {
"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.8.10"
},
"orig_nbformat": 4,
"kernelspec": {
"name": "python3",
"display_name": "Python 3.8.10 64-bit ('base': conda)"
},
"interpreter": {
"hash": "fa576ebcd40e010bdc0ae86b06ce09151f3424f9e9aed6893ff04f39a9299d89"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"source": [
"# Diagnostic output skill\n",
"\n",
"Measurement diagnostics (type 1) support different type of skill assessments by comparison between the model result and the measurements stored in the file:\n",
"\n",
"* skill() - table with skill statistics\n",
"* scatter() - scatter plot\n",
"\n",
"The same skill assessment methods and properties are available for their main data properties .result, .forecast, .forecast_at_update, and .analysis (if the file contains no updates only .result and .forecast will be available and they will be identical)."
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import fmdap"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"fn = '../tests/testdata/Diagnostics_F16_EnKF.dfs0'\n",
"diag = fmdap.read_diagnostic(fn, name=\"F16\")"
]
},
{
"source": [
"## skill()"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" n bias rmse urmse mae cc \\\n",
"observation \n",
"F16 analysis 58 0.207470 0.419241 0.364307 0.311775 0.970885 \n",
"F16 forecast 67 0.169513 0.393557 0.355179 0.281344 0.973028 \n",
"F16 forecast@update 58 0.204999 0.418657 0.365033 0.307975 0.970494 \n",
"F16 result 67 0.171653 0.394095 0.354748 0.284634 0.973410 \n",
"\n",
" si r2 \n",
"observation \n",
"F16 analysis 0.087019 0.920583 \n",
"F16 forecast 0.088905 0.930080 \n",
"F16 forecast@update 0.087193 0.920804 \n",
"F16 result 0.088797 0.929889 "
],
"text/html": "
\n\n
\n \n \n | \n n | \n bias | \n rmse | \n urmse | \n mae | \n cc | \n si | \n r2 | \n
\n \n | observation | \n | \n | \n | \n | \n | \n | \n | \n | \n
\n \n \n \n | F16 analysis | \n 58 | \n 0.207470 | \n 0.419241 | \n 0.364307 | \n 0.311775 | \n 0.970885 | \n 0.087019 | \n 0.920583 | \n
\n \n | F16 forecast | \n 67 | \n 0.169513 | \n 0.393557 | \n 0.355179 | \n 0.281344 | \n 0.973028 | \n 0.088905 | \n 0.930080 | \n
\n \n | F16 forecast@update | \n 58 | \n 0.204999 | \n 0.418657 | \n 0.365033 | \n 0.307975 | \n 0.970494 | \n 0.087193 | \n 0.920804 | \n
\n \n | F16 result | \n 67 | \n 0.171653 | \n 0.394095 | \n 0.354748 | \n 0.284634 | \n 0.973410 | \n 0.088797 | \n 0.929889 | \n
\n \n
\n
"
},
"metadata": {},
"execution_count": 3
}
],
"source": [
"diag.skill()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" n bias rmse urmse mae cc si r2\n",
"observation \n",
"F16 forecast@update 58 0.205 0.419 0.365 0.308 0.97 0.087 0.921"
],
"text/html": "\n\n
\n \n \n | \n n | \n bias | \n rmse | \n urmse | \n mae | \n cc | \n si | \n r2 | \n
\n \n | observation | \n | \n | \n | \n | \n | \n | \n | \n | \n
\n \n \n \n | F16 forecast@update | \n 58 | \n 0.205 | \n 0.419 | \n 0.365 | \n 0.308 | \n 0.97 | \n 0.087 | \n 0.921 | \n
\n \n
\n
"
},
"metadata": {},
"execution_count": 4
}
],
"source": [
"diag.forecast_at_update.skill().round(3)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" n mape mef nse r2 lin_slope\n",
"observation \n",
"F16 analysis 58 7.902526 0.28181 0.923925 0.920583 0.991982"
],
"text/html": "\n\n
\n \n \n | \n n | \n mape | \n mef | \n nse | \n r2 | \n lin_slope | \n
\n \n | observation | \n | \n | \n | \n | \n | \n | \n
\n \n \n \n | F16 analysis | \n 58 | \n 7.902526 | \n 0.28181 | \n 0.923925 | \n 0.920583 | \n 0.991982 | \n
\n \n
\n
"
},
"metadata": {},
"execution_count": 5
}
],
"source": [
"diag.analysis.skill(metrics=[\"mape\",\"mef\",\"nse\",\"r2\",\"lin_slope\"])"
]
},
{
"source": [
"## scatter()\n",
"diag.scatter() = diag.result.scatter()"
],
"cell_type": "markdown",
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "",
"image/svg+xml": "\r\n\r\n\r\n