Skip to content

Commit

Permalink
Merge pull request #55 from UofU-Cryosphere/revision_1
Browse files Browse the repository at this point in the history
Paper Revision 1
  • Loading branch information
jomey authored Mar 7, 2024
2 parents 85cd282 + 38d621a commit f1c3e42
Show file tree
Hide file tree
Showing 9 changed files with 1,503 additions and 37 deletions.
195 changes: 192 additions & 3 deletions comparison/ASO/ASO-diff.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"source": [
"from mpl_toolkits.axes_grid1 import make_axes_locatable\n",
"from mpl_toolkits.axes_grid1 import ImageGrid\n",
"from palettable.colorbrewer.diverging import RdBu_5 as RedBlueCmap\n",
"from palettable.colorbrewer.diverging import RdBu_9 as RedBlueCmap\n",
"\n",
"RED_BLUE_CMAP = RedBlueCmap.mpl_colormap"
]
Expand All @@ -290,12 +290,12 @@
"metadata": {},
"outputs": [],
"source": [
"def plot_area(data, axes, title='', ylabel=''):\n",
"def plot_area(data, axes, title='', ylabel='', cmap=RED_BLUE_CMAP):\n",
" plt_data = axes.imshow(\n",
" data,\n",
" vmin=-1,\n",
" vmax=1,\n",
" cmap=RED_BLUE_CMAP,\n",
" cmap=cmap,\n",
" )\n",
" plt.setp(axes, xticks=[], yticks=[])\n",
" axes.set_facecolor('lightgrey')\n",
Expand Down Expand Up @@ -357,6 +357,195 @@
");"
]
},
{
"cell_type": "markdown",
"id": "e372766f-d891-4e9a-b051-a704c2875b12",
"metadata": {},
"source": [
"## Differences between configurations "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "69956f8e-b1a4-4591-b7ad-d242721f54d4",
"metadata": {},
"outputs": [],
"source": [
"april = data[HRRR_MODIS][DATES[0]].data - data[TIME_DECAY][DATES[0]].data\n",
"may = data[HRRR_MODIS][DATES[1]].data - data[TIME_DECAY][DATES[1]].data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29badb8b-6579-4709-a223-44f45c761315",
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure(dpi=300, figsize=(12, 6))\n",
"\n",
"grid = ImageGrid(\n",
" fig, 121,\n",
" nrows_ncols=(1, 2),\n",
" axes_pad=(0.1, 0.1),\n",
" cbar_location=\"bottom\",\n",
" cbar_mode=\"single\",\n",
" cbar_pad=\"0%\",\n",
" cbar_size='3%'\n",
")\n",
"\n",
"plot_area(april, grid[0], '21 April')\n",
"\n",
"cax = grid.cbar_axes[0]\n",
"cbar = cax.colorbar(\n",
" plot_area(may, grid[1], '18 May'),\n",
" ticks=np.arange(-1, 1.5, 0.5),\n",
" extend='both'\n",
")\n",
"cbar.set_label(\n",
" label=r'$\\Delta$ Snow Depth (m)',\n",
")\n",
"y_pos = 0.45\n",
"cax.annotate(\"Preserved\",\n",
" xy=(0.88, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
")\n",
"cax.annotate(\"Melted\",\n",
" xy=(0.12, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
")\n",
"cax.annotate(\"Model changes\",\n",
" xy=(0.5, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
");"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "57a6705d-0266-48e8-bfb1-9ed047a929f8",
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure(dpi=300, figsize=(8, 8))\n",
"\n",
"grid = ImageGrid(\n",
" fig, 111,\n",
" nrows_ncols=(2, 3),\n",
" axes_pad=(0.1, 0.1),\n",
" cbar_location=\"bottom\",\n",
" cbar_mode=\"single\",\n",
" cbar_pad=\"0%\",\n",
" cbar_size='3%'\n",
")\n",
"\n",
"plot_area(data[TIME_DECAY][DATES[0]], grid[0], title=LABELS[0], ylabel='21 Apr')\n",
"plot_area(data[HRRR_MODIS][DATES[0]], grid[1], title=LABELS[1])\n",
"plot_area(april, grid[2], title='Relative\\n Difference')\n",
"plot_area(data[TIME_DECAY][DATES[1]], grid[3], ylabel='18 May')\n",
"plot_area(may, grid[5])\n",
"\n",
"cax = grid.cbar_axes[0]\n",
"cbar = cax.colorbar(\n",
" plot_area(data[HRRR_MODIS][DATES[1]], grid[4]),\n",
" ticks=np.arange(-1, 1.5, 0.5),\n",
" extend='both'\n",
")\n",
"cbar.set_label(\n",
" label=r'$\\Delta$ Snow Depth (m)',\n",
")\n",
"\n",
"y_pos = 0.45\n",
"cax.annotate(\"Over\",\n",
" xy=(0.88, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
")\n",
"cax.annotate(\"Under\",\n",
" xy=(0.12, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
")\n",
"cax.annotate(\"Model simulation\",\n",
" xy=(0.5, y_pos),\n",
" xycoords='axes fraction',\n",
" va=\"center\", ha=\"center\",\n",
");"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "82a61f7c-b236-4170-9a88-c2d521ee1cd7",
"metadata": {},
"outputs": [],
"source": [
"print(\"April\")\n",
"single_stat(april)\n",
"print(\"May\")\n",
"single_stat(may)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c86bb87-2311-426a-9156-971fba5b296e",
"metadata": {},
"outputs": [],
"source": [
"fig, (ax1) = plt.subplots(\n",
" nrows=1, figsize=(2.75, 4), dpi=300\n",
")\n",
"\n",
"plot_violin(\n",
" ax1, \n",
" [\n",
" [val for val in april.flatten() if not np.isnan(val)], \n",
" [val for val in may.flatten() if not np.isnan(val)]\n",
" ],\n",
" 'indigo'\n",
")\n",
"\n",
"ax1.set_xticks(\n",
" [0.4, 0.725],\n",
" labels=LABELS\n",
")\n",
"ax1.tick_params(top=True, labeltop=True, bottom=False, labelbottom=False)\n",
"ax1.set_xlabel('')\n",
"\n",
"ax1.legend(\n",
" handles=[\n",
" mpatches.Patch(\n",
" facecolor='indigo', ec='grey', alpha=0.5,\n",
" label=datetime.strptime(DATES[0], '%Y%m%d').strftime('%d %b')\n",
" ),\n",
" mpatches.Patch(\n",
" facecolor='teal', ec='grey', alpha=0.5,\n",
" label=datetime.strptime(DATES[1], '%Y%m%d').strftime('%d %b')\n",
" ),\n",
" Line2D([0], [0], color='black', linestyle=':', label='Median'),\n",
" Line2D([0], [0], color='black', label='Quantiles (95%, 5%)')\n",
" ],\n",
" loc='lower right',\n",
" fontsize=8,\n",
" frameon=False,\n",
" bbox_to_anchor=(1.1, -0.18),\n",
" ncol=2\n",
")\n",
"\n",
"ax1.set_yscale('symlog', linthresh=1)\n",
"ax1.set_ylabel(r'$\\Delta$ Snow Depth (m)')\n",
"ax1.set_ylim(top=1, bottom=-1)\n",
"ax1.set_yticks([1, 0.5, 0, -0.5, -1,])\n",
"ax1.set_yticks(np.arange(-1, 1, 0.1), minor=True)\n",
"ax1.yaxis.set_major_formatter(\"{x:.1f}\")\n",
"ax1.tick_params(axis='y', direction='inout', length=6)"
]
},
{
"cell_type": "markdown",
"id": "c548b8d3-7029-4ef9-9f7c-803d72851500",
Expand Down
Loading

0 comments on commit f1c3e42

Please sign in to comment.