Skip to content

Commit

Permalink
v3.15.3 documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Aug 31, 2023
1 parent 912dc6f commit 9adfb1e
Show file tree
Hide file tree
Showing 3,814 changed files with 7,116 additions and 7,087 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion docs/2_to_3_changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@



<h1 class="logo"><a href="index.html">cf 3.15.2</a></h1>
<h1 class="logo"><a href="index.html">cf 3.15.3</a></h1>



Expand Down
447 changes: 228 additions & 219 deletions docs/Changelog.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_downloads/plot_12_recipe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"9. Now plot both the AOD from `high-quality` retrieval and all other retrievals \nusing [cfplot.con](http://ajheaps.github.io/cf-plot/con.html). Here:\n\n- [cfplot.gopen](http://ajheaps.github.io/cf-plot/gopen.html) is used to \n define the parts of the plot area, specifying that the figure should have \n 1 row and 2 columns, which is closed by \n [cfplot.gclose](http://ajheaps.github.io/cf-plot/gclose.html);\n- [plt.suptitle](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.suptitle.html)\n is used to add a title for the whole figure;\n- the subplots for plotting are selected using \n [cfplot.gpos](https://ajheaps.github.io/cf-plot/gpos.html) after which \n [cfplot.mapset](https://ajheaps.github.io/cf-plot/mapset.html) is used to \n set the map limits and resolution for the subplots; \n- and as cf-plot stores the plot in a plot object with the name \n ``cfp.plotvars.plot``, country borders are added using normal \n [Cartopy operations](https://scitools.org.uk/cartopy/docs/latest/reference/index.html) \n on the ``cfp.plotvars.mymap`` object:\n\n"
"9. Now plot both the AOD from `high-quality` retrieval and all other retrievals\nusing [cfplot.con](http://ajheaps.github.io/cf-plot/con.html). Here:\n\n- [cfplot.gopen](http://ajheaps.github.io/cf-plot/gopen.html) is used to\n define the parts of the plot area, specifying that the figure should have\n 1 row and 2 columns, which is closed by\n [cfplot.gclose](http://ajheaps.github.io/cf-plot/gclose.html);\n- [plt.suptitle](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.suptitle.html)\n is used to add a title for the whole figure;\n- the subplots for plotting are selected using\n [cfplot.gpos](https://ajheaps.github.io/cf-plot/gpos.html) after which\n [cfplot.mapset](https://ajheaps.github.io/cf-plot/mapset.html) is used to\n set the map limits and resolution for the subplots;\n- and as cf-plot stores the plot in a plot object with the name\n ``cfp.plotvars.plot``, country borders are added using normal\n [Cartopy operations](https://scitools.org.uk/cartopy/docs/latest/reference/index.html)\n on the ``cfp.plotvars.mymap`` object:\n\n"
]
},
{
Expand Down
22 changes: 11 additions & 11 deletions docs/_downloads/plot_12_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@
high = aod.where(mask, cf.masked)

# %%
# 9. Now plot both the AOD from `high-quality` retrieval and all other retrievals
# 9. Now plot both the AOD from `high-quality` retrieval and all other retrievals
# using `cfplot.con <http://ajheaps.github.io/cf-plot/con.html>`_. Here:
#
# - `cfplot.gopen <http://ajheaps.github.io/cf-plot/gopen.html>`_ is used to
# define the parts of the plot area, specifying that the figure should have
# 1 row and 2 columns, which is closed by
# - `cfplot.gopen <http://ajheaps.github.io/cf-plot/gopen.html>`_ is used to
# define the parts of the plot area, specifying that the figure should have
# 1 row and 2 columns, which is closed by
# `cfplot.gclose <http://ajheaps.github.io/cf-plot/gclose.html>`_;
# - `plt.suptitle <https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.suptitle.html>`_
# is used to add a title for the whole figure;
# - the subplots for plotting are selected using
# `cfplot.gpos <https://ajheaps.github.io/cf-plot/gpos.html>`_ after which
# `cfplot.mapset <https://ajheaps.github.io/cf-plot/mapset.html>`_ is used to
# set the map limits and resolution for the subplots;
# - and as cf-plot stores the plot in a plot object with the name
# ``cfp.plotvars.plot``, country borders are added using normal
# `Cartopy operations <https://scitools.org.uk/cartopy/docs/latest/reference/index.html>`_
# - the subplots for plotting are selected using
# `cfplot.gpos <https://ajheaps.github.io/cf-plot/gpos.html>`_ after which
# `cfplot.mapset <https://ajheaps.github.io/cf-plot/mapset.html>`_ is used to
# set the map limits and resolution for the subplots;
# - and as cf-plot stores the plot in a plot object with the name
# ``cfp.plotvars.plot``, country borders are added using normal
# `Cartopy operations <https://scitools.org.uk/cartopy/docs/latest/reference/index.html>`_
# on the ``cfp.plotvars.mymap`` object:
import cartopy.feature as cfeature

Expand Down
4 changes: 2 additions & 2 deletions docs/_downloads/plot_13_recipe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"8. The line for variable ``nino34_anomaly`` calculates the standardized\nanomaly for each time step in the ``nino34_index`` data. It subtracts the\n``climatology`` from the ``nino34_index`` and then divides by the ``std_dev``.\nThe resulting ``nino34_anomaly`` data represents how much the SST in the Ni\u00f1o \n3.4 region deviates from the 1961-1990 average, in units of standard \ndeviations. This is a common way to quantify climate anomalies like El Ni\u00f1o \nand La Ni\u00f1a events:\n\n"
"8. The line for variable ``nino34_anomaly`` calculates the standardized\nanomaly for each time step in the ``nino34_index`` data. It subtracts the\n``climatology`` from the ``nino34_index`` and then divides by the ``std_dev``.\nThe resulting ``nino34_anomaly`` data represents how much the SST in the Ni\u00f1o\n3.4 region deviates from the 1961-1990 average, in units of standard\ndeviations. This is a common way to quantify climate anomalies like El Ni\u00f1o\nand La Ni\u00f1a events:\n\n"
]
},
{
Expand Down Expand Up @@ -195,7 +195,7 @@
},
"outputs": [],
"source": [
"elnino = nino34_rolling >= 0.4\nlanina = nino34_rolling <= -0.4\n\ncfp.gset(xmin='1940-1-1', xmax='2022-12-31', ymin=-3, ymax=3)\n\ncfp.gopen(figsize=(10, 6))\ncfp.lineplot(\n nino34_rolling,\n color=\"black\",\n title=\"SST Anomaly in Ni\u00f1o 3.4 Region (5N-5S, 120-170W)\",\n ylabel=\"Temperature anomaly ($\\degree C$)\",\n xlabel=\"Year\",\n)\ncfp.plotvars.plot.axhline(\n 0.4, color=\"red\", linestyle=\"--\", label=\"El Ni\u00f1o Threshold\"\n)\ncfp.plotvars.plot.axhline(\n -0.4, color=\"blue\", linestyle=\"--\", label=\"La Ni\u00f1a Threshold\"\n)\ncfp.plotvars.plot.axhline(0, color=\"black\", linestyle=\"-\", linewidth=1)\ncfp.plotvars.plot.fill_between(\n nino34_rolling.coordinate(\"T\").array,\n 0.4,\n nino34_rolling.array.squeeze(),\n where=elnino.squeeze(),\n color=\"red\",\n alpha=0.3,\n)\ncfp.plotvars.plot.fill_between(\n nino34_rolling.coordinate(\"T\").array,\n -0.4,\n nino34_rolling.array.squeeze(),\n where=lanina.squeeze(),\n color=\"blue\",\n alpha=0.3,\n)\ncfp.plotvars.plot.legend(frameon=False, loc=\"lower center\", ncol=2)\ncfp.gclose()"
"elnino = nino34_rolling >= 0.4\nlanina = nino34_rolling <= -0.4\n\ncfp.gset(xmin=\"1940-1-1\", xmax=\"2022-12-31\", ymin=-3, ymax=3)\n\ncfp.gopen(figsize=(10, 6))\ncfp.lineplot(\n nino34_rolling,\n color=\"black\",\n title=\"SST Anomaly in Ni\u00f1o 3.4 Region (5N-5S, 120-170W)\",\n ylabel=\"Temperature anomaly ($\\degree C$)\",\n xlabel=\"Year\",\n)\ncfp.plotvars.plot.axhline(\n 0.4, color=\"red\", linestyle=\"--\", label=\"El Ni\u00f1o Threshold\"\n)\ncfp.plotvars.plot.axhline(\n -0.4, color=\"blue\", linestyle=\"--\", label=\"La Ni\u00f1a Threshold\"\n)\ncfp.plotvars.plot.axhline(0, color=\"black\", linestyle=\"-\", linewidth=1)\ncfp.plotvars.plot.fill_between(\n nino34_rolling.coordinate(\"T\").array,\n 0.4,\n nino34_rolling.array.squeeze(),\n where=elnino.squeeze(),\n color=\"red\",\n alpha=0.3,\n)\ncfp.plotvars.plot.fill_between(\n nino34_rolling.coordinate(\"T\").array,\n -0.4,\n nino34_rolling.array.squeeze(),\n where=lanina.squeeze(),\n color=\"blue\",\n alpha=0.3,\n)\ncfp.plotvars.plot.legend(frameon=False, loc=\"lower center\", ncol=2)\ncfp.gclose()"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions docs/_downloads/plot_13_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@
# 8. The line for variable ``nino34_anomaly`` calculates the standardized
# anomaly for each time step in the ``nino34_index`` data. It subtracts the
# ``climatology`` from the ``nino34_index`` and then divides by the ``std_dev``.
# The resulting ``nino34_anomaly`` data represents how much the SST in the Niño
# 3.4 region deviates from the 1961-1990 average, in units of standard
# deviations. This is a common way to quantify climate anomalies like El Niño
# The resulting ``nino34_anomaly`` data represents how much the SST in the Niño
# 3.4 region deviates from the 1961-1990 average, in units of standard
# deviations. This is a common way to quantify climate anomalies like El Niño
# and La Niña events:
nino34_anomaly = (nino34_index - climatology) / std_dev

Expand Down Expand Up @@ -228,7 +228,7 @@
elnino = nino34_rolling >= 0.4
lanina = nino34_rolling <= -0.4

cfp.gset(xmin='1940-1-1', xmax='2022-12-31', ymin=-3, ymax=3)
cfp.gset(xmin="1940-1-1", xmax="2022-12-31", ymin=-3, ymax=3)

cfp.gopen(figsize=(10, 6))
cfp.lineplot(
Expand Down
21 changes: 16 additions & 5 deletions docs/_downloads/plot_15_recipe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Resampling Land Use Flags to a Coarser Grid\n\nIn this recipe, we will compare the land use distribution in different countries\nusing a land use data file and visualize the data as a histogram. This will help\nto understand the proportion of different land use categories in each country.\n\nThe land use data is initially available at a high spatial resolution of \napproximately 100 m, with several flags defined with numbers representing the \ntype of land use. Regridding the data to a coarser resolution of approximately \n25 km would incorrectly represent the flags on the new grids.\n\nTo avoid this, we will resample the data to the coarser resolution by \naggregating the data within predefined spatial regions or bins. This approach \nwill give a dataset where each 25 km grid cell contains a histogram of land use \nflags, as determined by the original 100 m resolution data. It retains the \noriginal spatial extent of the data while reducing its spatial complexity. \nRegridding, on the other hand, involves interpolating the data onto a new grid, \nwhich can introduce artifacts and distortions in the data.\n"
"\n# Resampling Land Use Flags to a Coarser Grid\n\nIn this recipe, we will compare the land use distribution in different countries\nusing a land use data file and visualize the data as a histogram. This will help\nto understand the proportion of different land use categories in each country.\n\nThe land use data is initially available at a high spatial resolution of\napproximately 100 m, with several flags defined with numbers representing the\ntype of land use. Regridding the data to a coarser resolution of approximately\n25 km would incorrectly represent the flags on the new grids.\n\nTo avoid this, we will resample the data to the coarser resolution by\naggregating the data within predefined spatial regions or bins. This approach\nwill give a dataset where each 25 km grid cell contains a histogram of land use\nflags, as determined by the original 100 m resolution data. It retains the\noriginal spatial extent of the data while reducing its spatial complexity.\nRegridding, on the other hand, involves interpolating the data onto a new grid,\nwhich can introduce artifacts and distortions in the data.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import cartopy.io.shapereader as shpreader\nimport matplotlib.pyplot as plt\nimport numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Import the required libraries. We will use Cartopy's ``shapereader`` to \nwork with shapefiles that define country boundaries:\n\n"
"1. Import the required libraries. We will use Cartopy's ``shapereader`` to\nwork with shapefiles that define country boundaries:\n\n"
]
},
{
Expand All @@ -33,7 +44,7 @@
},
"outputs": [],
"source": [
"import cf\nimport cartopy.io.shapereader as shpreader\nimport matplotlib.pyplot as plt\nimport numpy as np"
"import cf"
]
},
{
Expand Down Expand Up @@ -76,7 +87,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"4. Define a function to plot a histogram of land use distribution for a\nspecific country:\n\n- The [digitize](https://ncas-cms.github.io/cf-python/method/cf.Field.digitize.html)\n function of the ``cf.Field`` object is called to convert the land use data \n into indices of bins. It takes an array of bins (defined by \n the [np.linspace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html) function)\n and the ``return_bins=True`` parameter, which returns the actual bin values \n along with the digitized data.\n- The [np.linspace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html)\n function is used to create an array of evenly spaced bin edges from 0 to 50,\n with 51 total values. This creates bins of width 1.\n- The ``digitized`` variable contains the bin indices for each data point, \n while the bins variable contains the actual bin values.\n- The [cf.histogram](https://ncas-cms.github.io/cf-python/function/cf.histogram.html) \n function is called on the digitized data to create a histogram. This \n function returns a field object with the histogram data.\n- The [squeeze](https://ncas-cms.github.io/cf-python/method/cf.Field.squeeze.html)\n function applied to the histogram ``array`` extracts the histogram data as a NumPy\n array and removes any single dimensions.\n- The ``total_valid_sub_cells`` variable calculates the total number of valid \n subcells (non-missing data points) by summing the histogram data.\n- The last element of the bin_counts array is removed with slicing \n (``bin_counts[:-1]``) to match the length of the ``bin_indices`` array.\n- The ``percentages`` variable calculates the percentage of each bin by \n dividing the ``bin_counts`` by the ``total_valid_sub_cells`` and multiplying\n by 100.\n- The ``bin_indices`` variable calculates the center of each bin by averaging \n the bin edges. This is done by adding the ``bins.array[:-1, 0]`` and \n ``bins.array[1:, 0]`` arrays and dividing by 2.\n- The ``ax.bar`` function is called to plot the histogram as a bar chart on \n the provided axis. The x-axis values are given by the ``bin_indices`` array,\n and the y-axis values are given by the ``percentages`` array.\n- The title, x-axis label, y-axis label, and axis limits are set based on the \n input parameters.\n\n"
"4. Define a function to plot a histogram of land use distribution for a\nspecific country:\n\n- The [digitize](https://ncas-cms.github.io/cf-python/method/cf.Field.digitize.html)\n function of the ``cf.Field`` object is called to convert the land use data\n into indices of bins. It takes an array of bins (defined by\n the [np.linspace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html) function)\n and the ``return_bins=True`` parameter, which returns the actual bin values\n along with the digitized data.\n- The [np.linspace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html)\n function is used to create an array of evenly spaced bin edges from 0 to 50,\n with 51 total values. This creates bins of width 1.\n- The ``digitized`` variable contains the bin indices for each data point,\n while the bins variable contains the actual bin values.\n- The [cf.histogram](https://ncas-cms.github.io/cf-python/function/cf.histogram.html)\n function is called on the digitized data to create a histogram. This\n function returns a field object with the histogram data.\n- The [squeeze](https://ncas-cms.github.io/cf-python/method/cf.Field.squeeze.html)\n function applied to the histogram ``array`` extracts the histogram data as a NumPy\n array and removes any single dimensions.\n- The ``total_valid_sub_cells`` variable calculates the total number of valid\n subcells (non-missing data points) by summing the histogram data.\n- The last element of the bin_counts array is removed with slicing\n (``bin_counts[:-1]``) to match the length of the ``bin_indices`` array.\n- The ``percentages`` variable calculates the percentage of each bin by\n dividing the ``bin_counts`` by the ``total_valid_sub_cells`` and multiplying\n by 100.\n- The ``bin_indices`` variable calculates the center of each bin by averaging\n the bin edges. This is done by adding the ``bins.array[:-1, 0]`` and\n ``bins.array[1:, 0]`` arrays and dividing by 2.\n- The ``ax.bar`` function is called to plot the histogram as a bar chart on\n the provided axis. The x-axis values are given by the ``bin_indices`` array,\n and the y-axis values are given by the ``percentages`` array.\n- The title, x-axis label, y-axis label, and axis limits are set based on the\n input parameters.\n\n"
]
},
{
Expand Down Expand Up @@ -112,7 +123,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"6. Set up the figure and axes for plotting the histograms:\n\n- The ``plt.subplots`` function is called to set up a figure with three \n subplots, with a figure size of 8 inches by 10 inches.\n- A loop iterates over each country in the countries list and for each \n country, the ``extract_data`` function is called to extract its land use \n data.\n- The ``plot_histogram`` function is then called to plot the histogram of land\n use distribution on the corresponding subplot.\n- The ``plt.tight_layout`` function is called to ensure that the subplots are \n properly spaced within the figure and finally, the ``plt.show`` function\n displays the figure with the histograms.\n\n"
"6. Set up the figure and axes for plotting the histograms:\n\n- The ``plt.subplots`` function is called to set up a figure with three\n subplots, with a figure size of 8 inches by 10 inches.\n- A loop iterates over each country in the countries list and for each\n country, the ``extract_data`` function is called to extract its land use\n data.\n- The ``plot_histogram`` function is then called to plot the histogram of land\n use distribution on the corresponding subplot.\n- The ``plt.tight_layout`` function is called to ensure that the subplots are\n properly spaced within the figure and finally, the ``plt.show`` function\n displays the figure with the histograms.\n\n"
]
},
{
Expand Down
Loading

0 comments on commit 9adfb1e

Please sign in to comment.