Skip to content

Commit

Permalink
More text and color changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshkv committed Jun 15, 2024
1 parent f73fd90 commit e1c05b5
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 49 deletions.
30 changes: 23 additions & 7 deletions notebooks/ocn-carbonfluxes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@
"id": "9f3a04c6-f810-4fcb-bcb7-3786e06e1d80",
"metadata": {},
"source": [
"## Processing - global means in time and space"
"## Processing - means in time and space"
]
},
{
"cell_type": "markdown",
"id": "e6cb6cfa-758a-4eca-9249-ce550c2d732e",
"metadata": {},
"source": [
"Pull in the functions we defined in the nutrients notebook..."
"Pull in the function we defined in the nutrients notebook..."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f6b93b4b-3e8d-4f20-a560-26e6d2e8a576",
"id": "1bdf13bd-b1f9-42cc-aac1-ff4d0cc5248f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -274,17 +274,33 @@
" # Make a DataArray with the number of days in each month, size = len(time)\n",
" month_length = ds.time.dt.days_in_month\n",
"\n",
" # Calculate the weights by grouping by 'time.season'\n",
" # Calculate the weights by grouping by 'time.year'\n",
" weights = (\n",
" month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n",
" )\n",
"\n",
" # Test that the sum of the weights for each season is 1.0\n",
" # Test that the sum of the year for each season is 1.0\n",
" np.testing.assert_allclose(weights.groupby(\"time.year\").sum().values, np.ones((len(ds.groupby(\"time.year\")), )))\n",
"\n",
" # Calculate the weighted average\n",
" return (ds * weights).groupby(\"time.year\").sum(dim=\"time\")\n",
" \n",
" return (ds * weights).groupby(\"time.year\").sum(dim=\"time\")"
]
},
{
"cell_type": "markdown",
"id": "79d7db02-ed13-4f8e-b75f-349378c3bc3c",
"metadata": {},
"source": [
"We also define a new function to take global mean in space."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "90bb975d-36fc-43ab-b829-88a151161c62",
"metadata": {},
"outputs": [],
"source": [
"def global_mean(ds, ds_grid, compute_vars, normalize=True, include_ms=False):\n",
" \"\"\"\n",
" Compute the global mean on a POP dataset. \n",
Expand Down
16 changes: 8 additions & 8 deletions notebooks/ocn-iron.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"## Overview\n",
"Iron is one of the most important micronutrients in the ocean, limiting production in some areas. In this notebook, we make a map of iron concentration and compare to observational data.\n",
"\n",
"1. Gemeral setup\n",
"1. General setup\n",
"2. Subsetting\n",
"3. Processing data\n",
"3. Processing - long-term mean\n",
"4. Comparing to observational data\n",
" "
]
Expand Down Expand Up @@ -248,7 +248,7 @@
"id": "5e3e1e23-3443-419f-b724-2f0ef79a9087",
"metadata": {},
"source": [
"## Transforming from monthly to annual data"
"## Processing - long-term mean"
]
},
{
Expand All @@ -275,12 +275,12 @@
" # Make a DataArray with the number of days in each month, size = len(time)\n",
" month_length = ds.time.dt.days_in_month\n",
"\n",
" # Calculate the weights by grouping by 'time.season'\n",
" # Calculate the weights by grouping by 'time.year'\n",
" weights = (\n",
" month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n",
" )\n",
"\n",
" # Test that the sum of the weights for each season is 1.0\n",
" # Test that the sum of the year for each season is 1.0\n",
" np.testing.assert_allclose(weights.groupby(\"time.year\").sum().values, np.ones((len(ds.groupby(\"time.year\")), )))\n",
"\n",
" # Calculate the weighted average\n",
Expand Down Expand Up @@ -371,7 +371,7 @@
"### CESM\n",
"ax = fig.add_subplot(1,2,1, projection=ccrs.Robinson(central_longitude=305.0))\n",
"lon, lat, field = adjust_pop_grid(lons, lats, ds.Fe.isel(z_t=0))\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0.05,vmax=1.6,transform=ccrs.PlateCarree())\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='plasma',vmin=0.05,vmax=1.6,transform=ccrs.PlateCarree())\n",
"land = cartopy.feature.NaturalEarthFeature('physical', 'land', scale='110m', edgecolor='k', facecolor='white', linewidth=0.5)\n",
"ax.add_feature(land)\n",
"ax.set_title('CESM Fe at surface', fontsize=10)\n",
Expand All @@ -385,8 +385,8 @@
"\n",
"df_sub = df.loc[(df.depth <= 2.5)]\n",
"sc = ax.scatter(df_sub.lon, df_sub.lat, c=df_sub.dFe_obs.values,\n",
" cmap='jet',\n",
" vmin=0.05, vmax=0.6, \n",
" cmap='plasma',\n",
" vmin=0.05, vmax=1.6, \n",
" transform=ccrs.PlateCarree())\n",
"\n"
]
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ocn-macronuts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"\n",
"1. General setup\n",
"2. Subsetting\n",
"3. Transforming from monthly to annual data\n",
"3. Processing - means in time and space\n",
"4. Compare to World Ocean Atlas data\n",
"5. Make depth profiles\n"
]
Expand Down Expand Up @@ -300,12 +300,12 @@
" # Make a DataArray with the number of days in each month, size = len(time)\n",
" month_length = ds.time.dt.days_in_month\n",
"\n",
" # Calculate the weights by grouping by 'time.season'\n",
" # Calculate the weights by grouping by 'time.year'\n",
" weights = (\n",
" month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n",
" )\n",
"\n",
" # Test that the sum of the weights for each season is 1.0\n",
" # Test that the sum of the year for each season is 1.0\n",
" np.testing.assert_allclose(weights.groupby(\"time.year\").sum().values, np.ones((len(ds.groupby(\"time.year\")), )))\n",
"\n",
" # Calculate the weighted average\n",
Expand Down
10 changes: 5 additions & 5 deletions notebooks/ocn-phyto-biomass.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"1. General setup\n",
"2. Subsetting\n",
"3. Taking a quick look\n",
"4. Processing data\n",
"4. Processing - long-term mean\n",
"5. Mapping biomass at different depths\n",
"6. Mapping productivity\n",
"7. Compare NPP to satellite observations\n",
Expand Down Expand Up @@ -276,15 +276,15 @@
"id": "674bbf53-101d-4867-9858-f13740b36da6",
"metadata": {},
"source": [
"## Processing - global mean in time"
"## Processing - long-term mean"
]
},
{
"cell_type": "markdown",
"id": "b78f8deb-5853-4fd8-9d5f-b3e7b382f164",
"metadata": {},
"source": [
"Pull in the functions we defined in the nutrients notebook..."
"Pull in the function we defined in the nutrients notebook..."
]
},
{
Expand All @@ -303,12 +303,12 @@
" # Make a DataArray with the number of days in each month, size = len(time)\n",
" month_length = ds.time.dt.days_in_month\n",
"\n",
" # Calculate the weights by grouping by 'time.season'\n",
" # Calculate the weights by grouping by 'time.year'\n",
" weights = (\n",
" month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n",
" )\n",
"\n",
" # Test that the sum of the weights for each season is 1.0\n",
" # Test that the sum of the year for each season is 1.0\n",
" np.testing.assert_allclose(weights.groupby(\"time.year\").sum().values, np.ones((len(ds.groupby(\"time.year\")), )))\n",
"\n",
" # Calculate the weighted average\n",
Expand Down
20 changes: 6 additions & 14 deletions notebooks/ocn-phyto-lims.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"\n",
"1. General setup\n",
"2. Subsetting\n",
"4. Processing data\n",
"5. Mapping nutrient limitation at the surface\n",
"6. Mapping biomass-weighted nutrient limitation in the top 100m\n",
"7. Making monthly climatology maps\n",
"3. Processing - long-term mean\n",
"4. Mapping nutrient limitation at the surface\n",
"5. Mapping biomass-weighted nutrient limitation in the top 100m\n",
"6. Making monthly climatology maps\n",
" "
]
},
Expand Down Expand Up @@ -249,23 +249,15 @@
"id": "1ab5692f-1739-4093-ba41-fd13334bd07f",
"metadata": {},
"source": [
"## Processing"
]
},
{
"cell_type": "markdown",
"id": "d0839bf0-81e4-4ad4-84e4-dcbd7357ffb8",
"metadata": {},
"source": [
"### Global mean in time"
"## Processing - long-term mean"
]
},
{
"cell_type": "markdown",
"id": "0a6077af-aa1b-4a2a-b800-efd718206ab3",
"metadata": {},
"source": [
"Pull in the functions we defined in the nutrients notebook..."
"Pull in the function we defined in the nutrients notebook..."
]
},
{
Expand Down
23 changes: 11 additions & 12 deletions notebooks/ocn-zoo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"\n",
"1. General setup\n",
"2. Subsetting\n",
"4. Processing data\n",
"5. Mapping zooplankton biomass at the surface\n",
"6. Comparing mesozooplankton biomass to observations\n",
"7. Making monthly climatology maps to compare to observations\n",
"3. Processing - long-term mean\n",
"4. Mapping zooplankton biomass at the surface\n",
"5. Comparing mesozooplankton biomass to observations\n",
"6. Making monthly climatology maps to compare to observations\n",
" "
]
},
Expand Down Expand Up @@ -250,15 +250,15 @@
"id": "febdf9c0-a98c-49fa-b224-bbe085895384",
"metadata": {},
"source": [
"## Processing - global mean in time"
"## Processing - long-term mean"
]
},
{
"cell_type": "markdown",
"id": "65b8fc08-c579-4353-bacf-af1b4f11d33d",
"metadata": {},
"source": [
"Pull in the functions we defined in the nutrients notebook..."
"Pull in the function we defined in the nutrients notebook..."
]
},
{
Expand All @@ -270,19 +270,18 @@
"source": [
"def year_mean(ds):\n",
" \"\"\"\n",
" Add a docstring\n",
" Source: https://ncar.github.io/esds/posts/2021/yearly-averages-xarray/\n",
" \"\"\"\n",
" \n",
" # Make a DataArray with the number of days in each month, size = len(time)\n",
" month_length = ds.time.dt.days_in_month\n",
"\n",
" # Calculate the weights by grouping by 'time.season'\n",
" # Calculate the weights by grouping by 'time.year'\n",
" weights = (\n",
" month_length.groupby(\"time.year\") / month_length.groupby(\"time.year\").sum()\n",
" )\n",
"\n",
" # Test that the sum of the weights for each season is 1.0\n",
" # Test that the sum of the weights for each year is 1.0\n",
" np.testing.assert_allclose(weights.groupby(\"time.year\").sum().values, np.ones((len(ds.groupby(\"time.year\")), )))\n",
"\n",
" # Calculate the weighted average\n",
Expand All @@ -296,7 +295,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Take the long-term mean of our data set, processing years and months separately (improve this comment)\n",
"# Take the long-term mean of our data set, processing years and months separately\n",
"\n",
"ds_annual = year_mean(ds).mean(\"year\")"
]
Expand All @@ -321,7 +320,7 @@
"ax = fig.add_subplot(2,1,1, projection=ccrs.Robinson(central_longitude=305.0))\n",
"ax.set_title('microzooC at surface', fontsize=12)\n",
"lon, lat, field = adjust_pop_grid(lons, lats, ds_annual.microzooC.isel(z_t_150m=0))\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=2,transform=ccrs.PlateCarree())\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='Blues',vmin=0,vmax=2,transform=ccrs.PlateCarree())\n",
"cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='microzooC (mmol m$^{-3}$)')\n",
"land = cartopy.feature.NaturalEarthFeature('physical', 'land', scale='110m', edgecolor='k', facecolor='white', linewidth=0.5)\n",
"ax.add_feature(land)\n",
Expand All @@ -330,7 +329,7 @@
"ax = fig.add_subplot(2,1,2, projection=ccrs.Robinson(central_longitude=305.0))\n",
"ax.set_title('mesozooC at surface', fontsize=12)\n",
"lon, lat, field = adjust_pop_grid(lons, lats, ds_annual.mesozooC.isel(z_t_150m=0))\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=4,transform=ccrs.PlateCarree())\n",
"pc=ax.pcolormesh(lon, lat, field, cmap='Oranges',vmin=0,vmax=4,transform=ccrs.PlateCarree())\n",
"cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='mesozooC (mmol m$^{-3}$)')\n",
"land = cartopy.feature.NaturalEarthFeature('physical', 'land', scale='110m', edgecolor='k', facecolor='white', linewidth=0.5)\n",
"ax.add_feature(land)"
Expand Down

0 comments on commit e1c05b5

Please sign in to comment.