Skip to content

Commit

Permalink
add e3sm notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Jan 9, 2025
1 parent bda455c commit 40c49b1
Showing 1 changed file with 211 additions and 5 deletions.
216 changes: 211 additions & 5 deletions notebooks/04-recipes/e3sm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,225 @@
"id": "480d31e75354650d",
"metadata": {},
"source": [
"# E3SM Radiative Feedback Analysis\n",
"---"
"<img src=\"https://raw.githubusercontent.com/UXARRAY/uxarray/main/docs/_static/images/logos/uxarray_logo_h_dark.svg\"\n",
" width=\"30%\"\n",
" alt=\"UXarray logo\"\n",
" align=\"right\"\n",
"/>\n",
"\n",
"# E3SM Atmosphere \n",
"\n",
"This recipe demonstrates how to analyze unstructured grid output from the Energy Exascale Earth System Model (E3SM) using UXarray. Unlike traditional approaches that require regridding, UXarray enables direct analysis of the native model output, preserving the full fidelity of the simulation data.\n",
"\n",
"## Objectives\n",
"\n",
"This recipe guides you through calculating and visualizing key atmospheric radiation metrics:\n",
"\n",
"1. Shortwave Cloud Radiative Effect (SWCRE)\n",
"2. Longwave Cloud Radiative Effect (LWCRE)\n",
"3. Net Cloud Radiative Effect (NetCRE)\n",
"\n",
"The workflow includes techniques for:\n",
"\n",
"- Computing radiation components directly on the native unstructured grid\n",
"- Visualizing spatial patterns at the beginning and end of the simulation\n",
"- Analyzing temporal evolution through difference plots\n",
"\n",
"\n",
"-----"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b831f927ed134d7e",
"metadata": {},
"source": [
"import cartopy.crs as ccrs\n",
"import holoviews as hv\n",
"import uxarray as ux\n",
"\n",
"hv.extension(\"bokeh\")"
],
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"# todo"
]
"## Data\n",
"\n",
"The example uses output from an E3SMv2 atmosphere-only (AMIP) simulation with the following specifications:\n",
"\n",
"- Simulation Period: 6 years\n",
"- Configuration: Present-day control forcing (F2010)\n",
"- Resolution: 1-degree horizontal (ne30pg2)\n",
"- Boundary Conditions: Default E3SMv2 settings for sea surface temperatures and sea ice, cycling annually"
],
"id": "d87d469db62575a3"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"grid_path = \"../../meshfiles/ne30pg2.grid.nc\"\n",
"data_path = \"../../meshfiles/ne30pg2.data.nc\"\n",
"\n",
"uxds = ux.open_dataset(grid_path, data_path)"
],
"id": "7382203e13e8533b",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"## Calculating Shortwave Cloud Radiative Effect (SWCRE)\n",
"\n",
"Shortwave cloud radiative effect can be approximated as the difference beteween all-sky net shortwave flux (FSNT) at the top of the model and the clear-sky net shortwave flux (FSNTC).\n",
"\n",
"$$SWCRE = FSNT - FSNTC$$\n",
"\n"
],
"id": "68f9976f957933ae"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"uxds[\"SWCRE\"] = uxds[\"FSNT\"] - uxds[\"FSNTC\"]\n",
"uxds[\"SWCRE\"]"
],
"id": "f91d13dd7567cdda",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"## Calculating Longwave Cloud Radiative Effect (LWCRE)\n",
"\n",
"Longwave cloud radiative effect is similar to that for SWCRE, but the all-sky and clear-sky longwave fluxes are applied instead.\n",
"\n",
"$$LWCRE = FLUT - FLUTC$$"
],
"id": "15147661043ff38"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"uxds[\"LWCRE\"] = uxds[\"FLUT\"] - uxds[\"FLUTC\"]\n",
"uxds[\"LWCRE\"]"
],
"id": "b1f7a5c84d773935",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"\n",
"## Calculating Net Cloud Radiative Effect (NetCRE)\n",
"\n",
"Net cloud radiative effect is thus the difference beteween shortwave and longwave cloud radiative effect.\n",
"\n",
"$$netCRE = SWCRE - LWCRE$$"
],
"id": "99782d8595d79ce5"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"uxds[\"netCRE\"] = uxds[\"SWCRE\"] - uxds[\"LWCRE\"]\n",
"uxds[\"netCRE\"]"
],
"id": "da1da3f5be008cd9",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"## Plotting\n",
"\n",
"Having computed the Net Cloud Radiative Effect (NetCRE), we can now create visualizations to examine the spatial patterns and temporal evolution of cloud-radiation interactions. Our visualization approach focuses on three key aspects:\n",
"\n",
"1. Initial conditions represented by the first timestep\n",
"2. Final conditions from the last timestep \n",
"3. The difference between these states to reveal temporal changes\n",
"\n",
"The following sections demonstrate how to create these visualizations while maintaining the native unstructured grid structure, ensuring we preserve the full resolution of our simulation data. Below we declare our desired projection.\n"
],
"id": "3d9a1bef36af59e4"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"projection = ccrs.Robinson()"
],
"id": "cdfacf0d558f0b0",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"### Visualizing Initial and Final States\n",
"\n",
"The following visualization displays the Net Cloud Radiative Effect at two critical points in our model output: the initial state (first timestep) and final state (last timestep). This comparison allows us to examine both the baseline conditions and the evolved state of cloud-radiation interactions.\n"
],
"id": "7b22d758f9d5c36e"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"(\n",
" uxds[\"netCRE\"]\n",
" .isel(time=0)\n",
" .plot(\n",
" projection=projection, pixel_ratio=4.0, coastline=True, title=\"First Time Step\"\n",
" )\n",
" + uxds[\"netCRE\"]\n",
" .isel(time=-1)\n",
" .plot(\n",
" projection=projection, pixel_ratio=4.0, coastline=True, title=\"Final Time Step\"\n",
" )\n",
").cols(1)"
],
"id": "ed56690664c99508",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"### Difference Analysis\n",
"\n",
"To quantify and visualize how the Net Cloud Radiative Effect evolved over the simulation period, we compute the difference between the final and initial states. This differential analysis highlights regions where cloud-radiation interactions have strengthened or weakened during the simulation.\n"
],
"id": "85742fa517eb8bdd"
},
{
"metadata": {},
"cell_type": "code",
"source": [
"(uxds[\"netCRE\"].isel(time=-1) - uxds[\"netCRE\"].isel(time=-0)).plot(\n",
" projection=projection, coastline=True, pixel_ratio=4.0, title=\"Change in NetCRE\"\n",
")"
],
"id": "d15916950f596215",
"outputs": [],
"execution_count": null
}
],
"metadata": {
Expand Down

0 comments on commit 40c49b1

Please sign in to comment.