Skip to content

Commit

Permalink
auto formatting for notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
nmizukami committed Nov 14, 2024
1 parent f436dd2 commit 4aabd48
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
63 changes: 31 additions & 32 deletions examples/nblibrary/rof/global_discharge_gauge_compare_obs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@
"tags": []
},
"source": [
"## NB1. ROF global monthly, annual, seasonal flows analysis <a id='top'></a>\n",
"## ROF global monthly, annual, seasonal flows analysis <a id='top'></a>\n",
"\n",
"Use \n",
"Use the following datasets\n",
"\n",
"1. reach-D19 gauge link ascii\n",
"2. D19 flow site geopackage\n",
"3. D19 discharge netCDF\n",
"4. monthly and yearly flow netCD (history file)\n",
"4. history netCD including river discharge\n",
"\n",
"[1. Setupt](#setup)\n",
"\n",
"[2. Loading data](#load_data)\n",
"\n",
"- monthly history files (directory from CESM or postprocessed) from archive. \n",
"\n",
"- Reference data is monthly discharge estimates at 922 big river mouths from Dai et al. 2019 data (D19)\n",
"- Read monthly history files from archive. \n",
"- Reference data: monthly discharge estimates at 922 big river mouths from Dai et al. 2019 data (D19)\n",
"\n",
"[3. Large 24 river analysis](#24_large_rivers)\n",
"\n",
"- Plotting time seriese (annual, seasonal cycle) and scatter plots at Large 24 selected rivers with D19 referece data\n",
"- Plotting time seriese (annual, seasonal cycle).\n",
"- if D19 referece data is available, scatter plots at Large 24 selected rivers against D19 referece data\n",
"\n",
"[4. Large 50 rivers analysis](#50_large_rivers)\n",
"\n",
"- Annual flow summary table at large 50 selected rivers. \n",
"- Annual flow summary table at large 50 selected rivers.\n",
"- if D19 referece data is available, Scatter plot of annual flow against D19 reference data.\n",
"\n",
"[5. 922 rivers analysis](#922_rivers)\n",
"\n",
"- summary statistics (%bias, rmse, correlation) at all 922 river sites - map and boxplots.\n",
"\n",
"[6. basin area vs annual flow](#flow_diagnoisis)\n",
"\n",
"Moved this to another notebook"
"- run only if reference flow is available\n",
"- error statistics (%bias, rmse, correlation) at all 922 river sites.\n",
"- plot error statistic on the global map\n",
"- plot boxplots including case(s) for each error metric\n"
]
},
{
Expand Down Expand Up @@ -73,6 +73,7 @@
"from dask.distributed import Client, LocalCluster\n",
"\n",
"import scripts.colors as colors\n",
"import scripts.metrics as metric\n",
"from scripts.utility import load_yaml\n",
"from scripts.utility import no_time_variable\n",
"\n",
Expand Down Expand Up @@ -194,7 +195,7 @@
"source": [
"# Spin up cluster (if running in parallel)\n",
"client = None\n",
"if serial:\n",
"if not serial:\n",
" cluster = LocalCluster(**lc_kwargs)\n",
" client = Client(cluster)\n",
"\n",
Expand All @@ -213,9 +214,9 @@
"metadata": {},
"source": [
"### 2.1. Monthly/annual flow netCDFs\n",
"- month_data (xr dataset)\n",
"- year_data (xr dataset)\n",
"- seas_data (xr dataset)"
"- month_data (xr dataset) - read from archive\n",
"- year_data (xr dataset) - computed from monthly\n",
"- seas_data (xr dataset) - computed from monthly"
]
},
{
Expand Down Expand Up @@ -386,13 +387,6 @@
"dr_q_obs_seasonal = ds_q_obs_mon.groupby(\"time.month\").mean(\"time\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -971,14 +965,14 @@
"metadata": {},
"source": [
"------\n",
"## 3. Anaysis for all 922 sites <a id='922_rivers'></a>"
"## 5. Anaysis for all 922 sites <a id='922_rivers'></a>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 3.1 Compute metris at all the sites (no plots nor tables)"
"### 5.1 Compute metris at all the sites (no plots nor tables)"
]
},
{
Expand Down Expand Up @@ -1042,9 +1036,9 @@
" )\n",
"\n",
" # compute %bias, correlation, RMSE\n",
" bias[ix] = np.nanmean(q_sim - q_obs) / np.nanmean(q_obs) * 100.0\n",
" bias[ix] = metric.pbias(q_sim, q_obs)\n",
" corr[ix] = np.corrcoef(q_sim, q_obs)[0, 1]\n",
" rmse[ix] = np.sqrt(np.mean((q_sim - q_obs) ** 2))\n",
" rmse[ix] = metric.rmse(qsim, qobs)\n",
"\n",
" mon_pbias[case] = bias\n",
" mon_corr[case] = corr\n",
Expand All @@ -1059,7 +1053,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 4.2. Spatial metric map "
"### 5.2. Spatial metric map "
]
},
{
Expand Down Expand Up @@ -1093,8 +1087,13 @@
" }\n",
"\n",
" meta = {\n",
" \"bias\": {\"name\": \"%bias\", \"vmin\": -100, \"vmax\": 100, \"cm\": colors.cmap11},\n",
" \"corr\": {\"name\": \"correlation\", \"vmin\": 0.2, \"vmax\": 1, \"cm\": colors.cmap12},\n",
" \"bias\": {\n",
" \"name\": \"%bias\",\n",
" \"vmin\": -100,\n",
" \"vmax\": 100,\n",
" \"cm\": colors.cmap_RedGrayBlue,\n",
" },\n",
" \"corr\": {\"name\": \"correlation\", \"vmin\": 0.2, \"vmax\": 1, \"cm\": colors.cmap_corr},\n",
" \"rmse\": {\"name\": \"RMSE\", \"vmin\": 0, \"vmax\": 1000, \"cm\": mpl.cm.turbo},\n",
" }\n",
"\n",
Expand Down Expand Up @@ -1133,7 +1132,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### 4.3 Boxplots of Error metrics (RMSE, %bias, and correlation coefficient)\n",
"### 5.4 Boxplots of Error metrics (RMSE, %bias, and correlation coefficient)\n",
"Boxplot distribution is based on metrics sampled at 922 sites.\n",
"\n",
"The box extends from the Q1 to Q3 quartile values of the data, with a line at the median (Q2). \n",
Expand Down
22 changes: 11 additions & 11 deletions examples/nblibrary/rof/global_discharge_ocean_compare_obs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"tags": []
},
"source": [
"## NB2. ROF monthly, annual, seasonal discharge at ocean outlets <a id='top'></a>\n",
"## ROF monthly, annual, seasonal discharge at ocean outlets <a id='top'></a>\n",
"\n",
"Use \n",
"Use the following datasets\n",
"\n",
"1. reach-D19 gauge link ascii\n",
"2. D19 flow site geopackage\n",
Expand All @@ -21,20 +21,20 @@
"\n",
"[1. Setupt](#setup)\n",
"\n",
"[2. Loading data](#load_data)\n",
"\n",
"- monthly history files (directory from CESM or postprocessed) from archive. \n",
"[2. Loading discharge data](#load_discharge_data)\n",
"\n",
"- Reference data is monthly discharge estimates at 922 big river mouths from Dai et al. 2019 data (D19)\n",
"- Read monthly history files from archive. \n",
"- Reference data: monthly discharge estimates at 922 big river mouths from Dai et al. 2019 data (D19)\n",
"\n",
"[3. Read river, catchment, gauge information](#read_meta)\n",
"[3. Read river, catchment, gauge information](#read_ancillary)\n",
"\n",
"- catchment polygon (geopackage)\n",
"- gauge point (geopackage)\n",
"- gauge-catchment link (csv)\n",
"- outlet reach information (netCDF) including discharging ocean names\n",
"\n",
"[4. Ocean discharge line plots](#922_rivers)\n",
"[4. Ocean discharge line plots](#24_large_rivers)\n",
"\n",
"- total seasonal flow for oceans. \n"
]
Expand Down Expand Up @@ -197,7 +197,7 @@
"source": [
"# Spin up cluster (if running in parallel)\n",
"client = None\n",
"if serial:\n",
"if not serial:\n",
" cluster = LocalCluster(**lc_kwargs)\n",
" client = Client(cluster)\n",
"\n",
Expand All @@ -208,7 +208,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Loading data <a id='load_data'></a>"
"## 2. Loading discharge data <a id='load_discharge_data'></a>"
]
},
{
Expand Down Expand Up @@ -331,7 +331,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Reading river, catchment, gauge infomation <a id='read_meta'></a>\n",
"## 3. Reading river, catchment, gauge infomation <a id='read_ancillary'></a>\n",
"\n",
"- catchment polygon (geopackage)\n",
"- gauge point (geopackage)\n",
Expand Down Expand Up @@ -484,7 +484,7 @@
},
"source": [
"------\n",
"## 4. plot annual cycle for global oceans <a id='24_large_rivers'></a>\n",
"## 3. plot annual cycle for global oceans <a id='24_large_rivers'></a>\n",
"\n",
"TODO: Referece flow plot should be independent from cases (network). Currently the last case plotted looks better matched with reference flow. "
]
Expand Down

0 comments on commit 4aabd48

Please sign in to comment.