Skip to content

Commit 9e2d650

Browse files
Update recipe canonical files for spelling fixes & import order
1 parent eee3c6a commit 9e2d650

11 files changed

+30
-24
lines changed

docs/source/recipes/plot_08_recipe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
# 1. Import cf-python, cf-plot, numpy and scipy.stats:
1010

1111
import cfplot as cfp
12+
import cf
13+
1214
import numpy as np
1315
import scipy.stats as stats
1416

15-
import cf
1617

1718
# %%
1819
# 2. Three functions are defined:

docs/source/recipes/plot_09_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
histogram_data = joint_histogram.array
5353

5454
# %%
55-
# 8. Calculate bin centers for PM2.5 and temperature bins:
55+
# 8. Calculate bin centres for PM2.5 and temperature bins:
5656
pm25_bin_centers = [(a + b) / 2 for a, b in pm25_bins]
5757
temp_bin_centers = [(a + b) / 2 for a, b in temp_bins]
5858

docs/source/recipes/plot_10_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# <https://ncas-cms.github.io/cf-python/function/cf.curl_xy.html>`_ and
4343
# plotted using `cfplot.con <https://ncas-cms.github.io/cf-plot/build/con.html>`_.
4444
# The ``with cf.relaxed_identities(True)`` context manager statement prevents
45-
# the curl opereration broadcasting across the two ``expver`` dimensions because
45+
# the curl operation broadcasting across the two ``expver`` dimensions because
4646
# it can't be certain that they are the same as they lack the standardised
4747
# metadata. Setting
4848
# ``cf.relaxed_identities(True)`` allows the ``long_name`` to be treated

docs/source/recipes/plot_11_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
global_avg_temp = global_temperature.array.squeeze()
4848

4949
# %%
50-
# 7. Create a normalization function that maps the interval from the minimum to
50+
# 7. Create a normalisation function that maps the interval from the minimum to
5151
# the maximum temperature to the interval [0, 1] for colouring:
5252
norm_global = plt.Normalize(global_avg_temp.min(), global_avg_temp.max())
5353

docs/source/recipes/plot_12_recipe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# %%
1414
# 1. Import cf-python, cf-plot and matplotlib.pyplot:
1515

16-
import cfplot as cfp
1716
import matplotlib.pyplot as plt
17+
import cfplot as cfp
1818

1919
import cf
2020

@@ -44,7 +44,7 @@
4444
# %%
4545
# 6. Plot the AOD for all the retrievals using
4646
# `cfplot.con <https://ncas-cms.github.io/cf-plot/build/con.html>`_. Here the argument
47-
# ``'ptype'`` specifies the type of plot to use (latituide-longitude here) and
47+
# ``'ptype'`` specifies the type of plot to use (latitude-longitude here) and
4848
# the argument ``'lines=False'`` does not draw contour lines:
4949
cfp.con(f=aod.array, x=lon.array, y=lat.array, ptype=1, lines=False)
5050

docs/source/recipes/plot_13_recipe.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@
1414
"""
1515

1616
# %%
17-
# 1. Import cf-python and cf-plot:
17+
# 1. Import cf-python and cf-plot, as well as some other libraries for use
18+
# in next steps.
19+
20+
import cartopy.crs as ccrs
21+
import matplotlib.patches as mpatches
1822

1923
import cfplot as cfp
2024

2125
import cf
2226

27+
2328
# %%
2429
# 2. Read and select the SST by index and look at its contents:
2530
sst = cf.read("~/recipes/ERA5_monthly_averaged_SST.nc")[0]
@@ -55,8 +60,6 @@
5560
# and
5661
# `Text <https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.html>`_
5762
# function with cf-plot plot object (``cfp.plotvars.plot``):
58-
import cartopy.crs as ccrs
59-
import matplotlib.patches as mpatches
6063

6164
cfp.gopen()
6265
cfp.mapset(proj="cyl", lonmin=0, lonmax=360, latmin=-90, latmax=90)
@@ -160,7 +163,7 @@
160163
cfp.gclose()
161164

162165
# %%
163-
# 6. Calculate the Niño 3.4 index and standardize it to create an anomaly index.
166+
# 6. Calculate the Niño 3.4 index and standardise it to create an anomaly index.
164167
# The `collapse <https://ncas-cms.github.io/cf-python/method/cf.Field.collapse.html>`_
165168
# method is used to calculate the mean over the longitude (X) and latitude (Y)
166169
# dimensions:
@@ -179,7 +182,7 @@
179182
std_dev = base_period.collapse("T: sd")
180183

181184
# %%
182-
# 8. The line for variable ``nino34_anomaly`` calculates the standardized
185+
# 8. The line for variable ``nino34_anomaly`` calculates the standardised
183186
# anomaly for each time step in the ``nino34_index`` data. It subtracts the
184187
# ``climatology`` from the ``nino34_index`` and then divides by the ``std_dev``.
185188
# The resulting ``nino34_anomaly`` data represents how much the SST in the Niño

docs/source/recipes/plot_14_recipe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import cf
1717

1818
# %%
19-
# 2. Read and select the 200 hpa geopotential by index and look at its contents:
19+
# 2. Read and select the 200 hPa geopotential by index and look at its contents:
2020
gp = cf.read("~/recipes/ERA5_monthly_averaged_z200.nc")[0]
2121
print(gp)
2222

@@ -42,7 +42,7 @@
4242
# set various attributes of the plot, like setting the thickness of the lines
4343
# that represent continents;
4444
# - `cfplot.con <https://ncas-cms.github.io/cf-plot/build/con.html>`_ plots the contour
45-
# lines representing the 200 hpa geopotential height values without filling
45+
# lines representing the 200 hPa geopotential height values without filling
4646
# between the contour lines (``fill=False``) and no colour bar
4747
# (``colorbar=False``);
4848
# - `cfplot.levs <https://ncas-cms.github.io/cf-plot/build/levs.html>`_ is used to
@@ -136,7 +136,7 @@
136136
# of temperature anomalies without contour lines (``lines=False``);
137137
# - `cfplot.levs() <https://ncas-cms.github.io/cf-plot/build/levs.html>`_ is used to
138138
# reset contour levels to default after which the steps to plot the contour
139-
# lines representing the 200 hpa geopotential height values, the approximate
139+
# lines representing the 200 hPa geopotential height values, the approximate
140140
# polar-front jet and subtropical jet from Step 5 are repeated:
141141
cfp.gopen()
142142
cfp.mapset(proj="robin")

docs/source/recipes/plot_15_recipe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
flags, as determined by the original 100 m resolution data. It retains the
1818
original spatial extent of the data while reducing its spatial complexity.
1919
Regridding, on the other hand, involves interpolating the data onto a new grid,
20-
which can introduce artifacts and distortions in the data.
20+
which can introduce artefacts and distortions in the data.
2121
2222
"""
2323

@@ -31,7 +31,8 @@
3131
import cf
3232

3333
# %%
34-
# 2. Read and select land use data by index and see properties of all construcs:
34+
# 2. Read and select land use data by index and see properties of
35+
# all constructs:
3536
f = cf.read("~/recipes/output.tif.nc")[0]
3637
f.dump()
3738

@@ -102,7 +103,7 @@ def extract_data(country_name):
102103
# - The ``percentages`` variable calculates the percentage of each bin by
103104
# dividing the ``bin_counts`` by the ``total_valid_sub_cells`` and multiplying
104105
# by 100.
105-
# - The ``bin_indices`` variable calculates the center of each bin by averaging
106+
# - The ``bin_indices`` variable calculates the centre of each bin by averaging
106107
# the bin edges. This is done by adding the ``bins.array[:-1, 0]`` and
107108
# ``bins.array[1:, 0]`` arrays and dividing by 2.
108109
# - The ``ax.bar`` function is called to plot the histogram as a bar chart on

docs/source/recipes/plot_17_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# %%
1212
# 1. Import cf-python and cf-plot:
1313

14-
import cfplot as cfp
1514
import matplotlib.pyplot as plt
15+
import cfplot as cfp
1616

1717
import cf
1818

docs/source/recipes/plot_18_recipe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
55
In this recipe, we will take two datasets, one for an independent variable
66
(in this example elevation) and one for a dependent variable (snow
7-
cover over a particuar day), regrid them to the same resolution then
7+
cover over a particular day), regrid them to the same resolution then
88
calculate the correlation coefficient, to get a measure of the relationship
99
between them.
1010
1111
"""
1212

1313
# %%
1414
# 1. Import cf-python, cf-plot and other required packages:
15-
import cfplot as cfp
1615
import matplotlib.pyplot as plt
1716
import scipy.stats.mstats as mstats
17+
import cfplot as cfp
1818

1919
import cf
2020

21+
2122
# %%
2223
# 2. Read the data in and unpack the Fields from FieldLists using indexing.
2324
# In our example We are investigating the influence of the land height on
@@ -89,7 +90,7 @@
8990

9091
# %%
9192
# 9. Make a final plot showing the two arrays side-by-side and quoting the
92-
# determined Pearson correlation coefficient to illustrate the relatoinship
93+
# determined Pearson correlation coefficient to illustrate the relationship
9394
# and its strength visually. We use 'gpos' to position the plots in two
9495
# columns and apply some specific axes ticks and labels for clarity.
9596
cfp.gopen(

0 commit comments

Comments
 (0)