diff --git a/ncl/ncl_entries/climatology_functions.ipynb b/ncl/ncl_entries/climatology_functions.ipynb index 77c14225..317cbf59 100644 --- a/ncl/ncl_entries/climatology_functions.ipynb +++ b/ncl/ncl_entries/climatology_functions.ipynb @@ -16,10 +16,15 @@ "\n", "- [calcDayAnomTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/calcDayAnomTLL.shtml)\n", "- [calcMonAnomTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/calcMonAnomTLL.shtml)\n", + "- [clmDayHourTll](https://www.ncl.ucar.edu/Document/Functions/Contributed/clmDayHourTLL.shtml)\n", "- [clmDayTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/clmDayTLL.shtml)\n", + "- [clmMon2clmDay](https://www.ncl.ucar.edu/Document/Functions/Contributed/clmMon2clmDay.shtml)\n", "- [clmMonTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/clmMonTLL.shtml)\n", "- [month_to_season](https://www.ncl.ucar.edu/Document/Functions/Contributed/month_to_season.shtml)\n", + "- [month_to_season12](https://www.ncl.ucar.edu/Document/Functions/Contributed/month_to_season12.shtml)\n", + "- [month_to_seasonN](https://www.ncl.ucar.edu/Document/Functions/Contributed/month_to_seasonN.shtml)\n", "- [rmMonAnnCycTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/rmMonAnnCycTLL.shtml)\n", + "- [smthClmDayTll](https://www.ncl.ucar.edu/Document/Functions/Contributed/smthClmDayTLL.shtml)\n", "- [stdMonTLL](https://www.ncl.ucar.edu/Document/Functions/Contributed/stdMonTLL.shtml)\n" ] }, @@ -28,7 +33,7 @@ "metadata": {}, "source": [ "## calcDayAnomTLL\n", - "`calcDayAnomTLL` calculates daily anomalies from a daily data climatology" + "`calcDayAnomTLL` calculates daily anomalies from a daily data climatology." ] }, { @@ -64,7 +69,7 @@ "metadata": {}, "source": [ "## calcMonAnomTLL\n", - "`calcMonAnomTLL` calculates monthly anomalies by subtracting the long-term mean from each point" + "`calcMonAnomTLL` calculates monthly anomalies by subtracting the long-term mean from each point." ] }, { @@ -96,12 +101,34 @@ "calcMonAnomTLL[0, :, :].plot();" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## clmDayHourTll\n", + "`clmDayHourTll` calculates climatological day-hour means at user specified hours for each day of the year." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Grab and Go" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, "source": [ "## clmDayTLL\n", - "`clmDayTLL` calculates long-term daily means (daily climatology) from daily data" + "`clmDayTLL` calculates long-term daily means (daily climatology) from daily data." ] }, { @@ -131,12 +158,34 @@ "plt.ylabel(\"sea ice area\");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## clmMon2clmDay\n", + "`clmMon2clmDay` creates a daily climatology from a monthly climatology.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Grab and Go" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, "source": [ "## clmMonTLL\n", - "`clmMonTLL` calculates long-term monthly means (monthly climatology) from monthly data" + "`clmMonTLL` calculates long-term monthly means (monthly climatology) from monthly data." ] }, { @@ -173,7 +222,7 @@ "metadata": {}, "source": [ "## month_to_season\n", - "`month_to_season` computes a user-specified three-month seasonal mean (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ)\n", + "`month_to_season` computes a user-specified three-month seasonal mean (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ).\n", "\n", "```{note}\n", "You can do something similar with directly with Xarray as shown in [this example in the Xarray documentation](https://docs.xarray.dev/en/stable/examples/monthly-means.html#Calculating-Seasonal-Averages-from-Time-Series-of-Monthly-Means). However, it requires substantially more code and doesn't have as much flexibility with respect to how the seasons are defined.\n", @@ -210,12 +259,92 @@ "plt.title(\"2010 seasonal mean\");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## month_to_season12\n", + "\n", + "`month_to_season12` computes three-month seasonal means (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Grab and Go" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import geocat.datafiles as gdf\n", + "from geocat.comp import month_to_season\n", + "\n", + "ds = xr.open_dataset(\n", + " gdf.get(\"applications_files/inputs/CMIP6_sea_ice_monthly_subset.nc\")\n", + ")\n", + "aice = ds.aice\n", + "\n", + "month_to_season12 = {}\n", + "for month in [\"DJF\", \"JFM\", \"FMA\", \"MAM\", \"AMJ\", \"MJJ\", \"JJA\", \"JAS\", \"ASO\", \"SON\", \"OND\", \"NDJ\"]:\n", + " mon_to_season = month_to_season(aice, month)\n", + " mon_to_season = mon_to_season.assign_attrs(long_name=\"sea ice area\")\n", + " month_to_season12[month] = mon_to_season\n", + "\n", + "month_to_season12" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## month_to_seasonN\n", + "\n", + "`month_to_seasonN` computes a user-specified list of three-month seasonal means (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ). " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Grab and Go" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import geocat.datafiles as gdf\n", + "from geocat.comp import month_to_season\n", + "\n", + "ds = xr.open_dataset(\n", + " gdf.get(\"applications_files/inputs/CMIP6_sea_ice_monthly_subset.nc\")\n", + ")\n", + "aice = ds.aice\n", + "\n", + "month_to_season12 = {}\n", + "for month in [\"DJF\", \"MAM\", \"JJA\", \"SON\"]:\n", + " mon_to_season = month_to_season(aice, month)\n", + " mon_to_season = mon_to_season.assign_attrs(long_name=\"sea ice area\")\n", + " month_to_season12[month] = mon_to_season\n", + "\n", + "month_to_season12" + ] + }, { "cell_type": "markdown", "metadata": {}, "source": [ "## rmMonAnnCycTLL\n", - "`rmMonAnnCycTLL` removes the annual cycle from monthly data" + "`rmMonAnnCycTLL` removes the annual cycle from monthly data." ] }, { @@ -247,12 +376,35 @@ "plt.ylabel(\"sea ice area\");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## smthClmDayTll\n", + "\n", + "`smthClmDayTll` calculates a smooth mean daily annual cycle for an array.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Grab and Go" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, "source": [ "## stdMonTLL\n", - "`stdMonTLL` calculates standard deviations of monthly means" + "`stdMonTLL` calculates standard deviations of monthly means." ] }, { @@ -299,16 +451,11 @@ "- Project Pythia Foundations [Computations and Masks with Xarray tutorial](https://foundations.projectpythia.org/core/xarray/computation-masking.html)\n", "- Xarray User Guide [section on time series data](https://docs.xarray.dev/en/stable/user-guide/time-series.html)" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "geocat-applications", "language": "python", "name": "python3" }, @@ -322,7 +469,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/ncl/ncl_index/ncl-index-table.csv b/ncl/ncl_index/ncl-index-table.csv index 16887ba6..054e0279 100644 --- a/ncl/ncl_index/ncl-index-table.csv +++ b/ncl/ncl_index/ncl-index-table.csv @@ -16,6 +16,8 @@ NCL Function,Description,Python Equivalent,Notes `clmDayTLL `__,"Calculates long-term daily means (daily climatology) from daily data","``xarray.DataArray.groupby()``",`example notebook <../ncl_entries/climatology_functions.ipynb#clmdaytll>`__ `clmMonTLL `__,"Calculates long-term monthly means (monthly climatology) from monthly data","``xarray.DataArray.groupby()``",`example notebook <../ncl_entries/climatology_functions.ipynb#clmmontll>`__ `month_to_season `__,"Computes a user-specified three-month seasonal mean","``geocat.comp.month_to_season()``",`example notebook <../ncl_entries/climatology_functions.ipynb#month-to-season>`__ +`month_to_season12 `__,"Computes three-month seasonal means (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ).","``geocat.comp.month_to_season()``",`example notebook <../ncl_entries/climatology_functions.ipynb#month-to-season>`__ +`month_to_seasonN `__,"Computes a user-specified list of three-month seasonal means (DJF, JFM, FMA, MAM, AMJ, MJJ, JJA, JAS, ASO, SON, OND, NDJ).","``geocat.comp.month_to_season()``",`example notebook <../ncl_entries/climatology_functions.ipynb#month-to-season>`__ `rmMonAnnCycTLL `__,"Removes the annual cycle from monthly data","``xarray.DataArray.groupby()``",`example notebook <../ncl_entries/climatology_functions.ipynb#rmmonanncyctll>`__ `stdMonTLL `__,"Calculates standard deviations of monthly means","``xarray.DataArray.groupby()``",`example notebook <../ncl_entries/climatology_functions.ipynb#stdmontll>`__ `abs `__,"Returns the absolute value of numeric data","``abs()`` or ``numpy.abs()``",`example notebook <../ncl_entries/general_applied_math.ipynb#abs-fabs>`__