diff --git a/docs/recipes/index.html b/docs/recipes/index.html index 3e051434a4..af5e9d496a 100644 --- a/docs/recipes/index.html +++ b/docs/recipes/index.html @@ -28,6 +28,21 @@ + + + + + + + + + + + + + + + diff --git a/docs/recipes/plot_01_recipe.html b/docs/recipes/plot_01_recipe.html index be6356336c..db70fc0f18 100644 --- a/docs/recipes/plot_01_recipe.html +++ b/docs/recipes/plot_01_recipe.html @@ -148,8 +148,8 @@
Read the field constructs:
f = cf.read("~/recipes/cru_ts4.06.1901.2021.tmp.dat.nc")
-print(f)
+
[<CF Field: ncvar%stn(long_name=time(1452), long_name=latitude(360), long_name=longitude(720))>,
@@ -159,8 +159,8 @@ Related Topics
Select near surface temperature by index and look at its contents:
-temp = f[1]
-print(temp)
+
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -174,14 +174,14 @@ Related Topics
Select latitude and longitude dimensions by identities, with two different techniques:
-lon = temp.coordinate("long_name=longitude")
-lat = temp.coordinate("Y")
+lon = temp.coordinate("long_name=longitude")
+lat = temp.coordinate("Y")
Print the description of near surface temperature using the dump method to show properties of all constructs:
-temp.dump()
+
-----------------------------------------------------
@@ -229,9 +229,9 @@ Related Topics
Latitude and longitude dimension coordinate cell bounds are absent, which are created and set:
-a = lat.create_bounds()
-lat.set_bounds(a)
-lat.dump()
+a = lat.create_bounds()
+lat.set_bounds(a)
+lat.dump()
Dimension coordinate: long_name=latitude
@@ -242,9 +242,9 @@ Related Topics
Bounds:Data(360, 2) = [[-90.0, ..., 90.0]] degrees_north
-b = lon.create_bounds()
-lon.set_bounds(b)
-lon.dump()
+b = lon.create_bounds()
+lon.set_bounds(b)
+lon.dump()
Dimension coordinate: long_name=longitude
@@ -255,7 +255,7 @@ Related Topics
Bounds:Data(720, 2) = [[-180.0, ..., 180.0]] degrees_east
-print(b.array)
+print(b.array)
[[-180. -179.5]
@@ -270,10 +270,10 @@ Related Topics
Time dimension coordinate cell bounds are similarly created and set for cell sizes of one calendar month:
-time = temp.coordinate("long_name=time")
-c = time.create_bounds(cellsize=cf.M())
-time.set_bounds(c)
-time.dump()
+time = temp.coordinate("long_name=time")
+c = time.create_bounds(cellsize=cf.M())
+time.set_bounds(c)
+time.dump()
Dimension coordinate: long_name=time
@@ -289,16 +289,16 @@ Related Topics
Calculate and plot the area weighted mean surface temperature for each time:
-global_avg = temp.collapse("area: mean", weights=True)
-cfp.lineplot(global_avg, color="red", title="Global mean surface temperature")
+global_avg = temp.collapse("area: mean", weights=True)
+cfp.lineplot(global_avg, color="red", title="Global mean surface temperature")
Calculate and plot the annual global mean surface temperature:
-annual_global_avg = global_avg.collapse("T: mean", group=cf.Y())
-cfp.lineplot(
- annual_global_avg,
+annual_global_avg = global_avg.collapse("T: mean", group=cf.Y())
+cfp.lineplot(
+ annual_global_avg,
color="red",
title="Annual global mean surface temperature",
)
diff --git a/docs/recipes/plot_02_recipe.html b/docs/recipes/plot_02_recipe.html
index 9751eac31e..b7a0437707 100644
--- a/docs/recipes/plot_02_recipe.html
+++ b/docs/recipes/plot_02_recipe.html
@@ -148,8 +148,8 @@ Related Topics
Read the field constructs:
-f = cf.read("~/recipes/cru_ts4.06.1901.2021.tmp.dat.nc")
-print(f)
+
[<CF Field: ncvar%stn(long_name=time(1452), long_name=latitude(360), long_name=longitude(720))>,
@@ -159,8 +159,8 @@ Related Topics
Select near surface temperature by index and look at its contents:
-temp = f[1]
-print(temp)
+
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -174,14 +174,14 @@ Related Topics
Select latitude and longitude dimensions by identities, with two different techniques:
-lon = temp.coordinate("long_name=longitude")
-lat = temp.coordinate("Y")
+lon = temp.coordinate("long_name=longitude")
+lat = temp.coordinate("Y")
Print the description of near surface temperature to show properties of all constructs:
-temp.dump()
+
-----------------------------------------------------
@@ -229,9 +229,9 @@ Related Topics
Latitude and longitude dimension coordinate cell bounds are absent, which are created and set:
-a = lat.create_bounds()
-lat.set_bounds(a)
-lat.dump()
+a = lat.create_bounds()
+lat.set_bounds(a)
+lat.dump()
Dimension coordinate: long_name=latitude
@@ -242,9 +242,9 @@ Related Topics
Bounds:Data(360, 2) = [[-90.0, ..., 90.0]] degrees_north
-b = lon.create_bounds()
-lon.set_bounds(b)
-lon.dump()
+b = lon.create_bounds()
+lon.set_bounds(b)
+lon.dump()
Dimension coordinate: long_name=longitude
@@ -255,7 +255,7 @@ Related Topics
Bounds:Data(720, 2) = [[-180.0, ..., 180.0]] degrees_east
-print(b.array)
+print(b.array)
[[-180. -179.5]
@@ -270,10 +270,10 @@ Related Topics
Time dimension coordinate cell bounds are similarly created and set for cell sizes of one calendar month:
-time = temp.coordinate("long_name=time")
-c = time.create_bounds(cellsize=cf.M())
-time.set_bounds(c)
-time.dump()
+time = temp.coordinate("long_name=time")
+c = time.create_bounds(cellsize=cf.M())
+time.set_bounds(c)
+time.dump()
Dimension coordinate: long_name=time
@@ -289,22 +289,22 @@ Related Topics
Calculate the area weighted mean surface temperature for each time using the collapse method:
-global_avg = temp.collapse("area: mean", weights=True)
+global_avg = temp.collapse("area: mean", weights=True)
Calculate the annual global mean surface temperature:
-annual_global_avg = global_avg.collapse("T: mean", group=cf.Y())
+annual_global_avg = global_avg.collapse("T: mean", group=cf.Y())
The temperature values are averaged for the climatological period of 1961-1990 by defining a subspace within these years using cf.wi query instance over subspace and doing a statistical collapse with the collapse method:
-annual_global_avg_61_90 = annual_global_avg.subspace(
- T=cf.year(cf.wi(1961, 1990))
+annual_global_avg_61_90 = annual_global_avg.subspace(
+ T=cf.year(cf.wi(1961, 1990))
)
-print(annual_global_avg_61_90)
+print(annual_global_avg_61_90)
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -316,8 +316,8 @@ Related Topics
: long_name=longitude(1) = [0.0] degrees_east
-temp_clim = annual_global_avg_61_90.collapse("T: mean")
-print(temp_clim)
+temp_clim = annual_global_avg_61_90.collapse("T: mean")
+print(temp_clim)
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -332,9 +332,9 @@ Related Topics
The temperature anomaly is then calculated by subtracting these climatological temperature values from the annual global average temperatures and plotted:
-temp_anomaly = annual_global_avg - temp_clim
-cfp.lineplot(
- temp_anomaly,
+temp_anomaly = annual_global_avg - temp_clim
+cfp.lineplot(
+ temp_anomaly,
color="red",
title="Global Average Temperature Anomaly (1901-2021)",
ylabel="1961-1990 climatology difference ",
diff --git a/docs/recipes/plot_03_recipe.html b/docs/recipes/plot_03_recipe.html
index 222121715a..3163f5a4e8 100644
--- a/docs/recipes/plot_03_recipe.html
+++ b/docs/recipes/plot_03_recipe.html
@@ -148,8 +148,8 @@ Related Topics
Read the field constructs:
-f = cf.read("~/recipes/cru_ts4.06.1901.2021.tmp.dat.nc")
-print(f)
+
[<CF Field: ncvar%stn(long_name=time(1452), long_name=latitude(360), long_name=longitude(720))>,
@@ -159,8 +159,8 @@ Related Topics
Select near surface temperature by index and look at its contents:
-temp = f[1]
-print(temp)
+
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -174,13 +174,13 @@ Related Topics
Average the monthly mean surface temperature values by the time axis using the collapse method:
-global_avg = temp.collapse("mean", axes="long_name=time")
+global_avg = temp.collapse("mean", axes="long_name=time")
Plot the global mean surface temperatures:
-cfp.con(global_avg, lines=False, title="Global mean surface temperature")
+cfp.con(global_avg, lines=False, title="Global mean surface temperature")
Total running time of the script: ( 0 minutes 8.465 seconds)
diff --git a/docs/recipes/plot_04_recipe.html b/docs/recipes/plot_04_recipe.html
index b251ea5b7b..f5c4b36e99 100644
--- a/docs/recipes/plot_04_recipe.html
+++ b/docs/recipes/plot_04_recipe.html
@@ -146,18 +146,18 @@ Related Topics
Read the field constructs:
-obs = cf.read("~/recipes/cru_ts4.06.1901.2021.tmp.dat.nc", chunks=None)
-print(obs)
+
[<CF Field: ncvar%stn(long_name=time(1452), long_name=latitude(360), long_name=longitude(720))>,
<CF Field: long_name=near-surface temperature(long_name=time(1452), long_name=latitude(360), long_name=longitude(720)) degrees Celsius>]
-model = cf.read(
+
[<CF Field: air_temperature(time(1980), latitude(144), longitude(192)) K>]
@@ -166,8 +166,8 @@ Related Topics
Select observation and model temperature fields by identity and index respectively, and look at their contents:
-obs_temp = obs.select_field("long_name=near-surface temperature")
-print(obs_temp)
+obs_temp = obs.select_field("long_name=near-surface temperature")
+print(obs_temp)
Field: long_name=near-surface temperature (ncvar%tmp)
@@ -178,8 +178,8 @@ Related Topics
: long_name=longitude(720) = [-179.75, ..., 179.75] degrees_east
-model_temp = model[0]
-print(model_temp)
+model_temp = model[0]
+print(model_temp)
Field: air_temperature (ncvar%tas)
@@ -196,8 +196,8 @@ Related Topics
Regrid observational data to that of the model data and create a new low resolution observational data using bilinear interpolation:
-obs_temp_regrid = obs_temp.regrids(model_temp, method="linear")
-print(obs_temp_regrid)
+obs_temp_regrid = obs_temp.regrids(model_temp, method="linear")
+print(obs_temp_regrid)
Field: long_name=near-surface temperature (ncvar%tmp)
diff --git a/docs/recipes/plot_05_recipe.html b/docs/recipes/plot_05_recipe.html
index cf6c8d447e..2504418710 100644
--- a/docs/recipes/plot_05_recipe.html
+++ b/docs/recipes/plot_05_recipe.html
@@ -148,22 +148,22 @@ Related Topics
Read the field constructs:
-f1 = cf.read("~/recipes/northward.nc")
-print(f1)
+
[<CF Field: northward_wind(time(1980), latitude(144), longitude(192)) m s-1>]
-f2 = cf.read("~/recipes/eastward.nc")
-print(f2)
+
[<CF Field: eastward_wind(time(1980), latitude(144), longitude(192)) m s-1>]
-f3 = cf.read("~/recipes/monthly_precipitation.nc")
-print(f3)
+
[<CF Field: long_name=precipitation(long_name=time(1452), latitude(144), longitude(192)) mm/month>]
@@ -172,8 +172,8 @@ Related Topics
Select wind vectors and precipitation data by index and look at their contents:
-v = f1[0]
-print(v)
+
Field: northward_wind (ncvar%vas)
@@ -186,8 +186,8 @@ Related Topics
: height(1) = [10.0] m
-u = f2[0]
-print(u)
+
Field: eastward_wind (ncvar%uas)
@@ -200,8 +200,8 @@ Related Topics
: height(1) = [10.0] m
-pre = f3[0]
-print(pre)
+
Field: long_name=precipitation (ncvar%pre)
@@ -215,23 +215,23 @@ Related Topics
Plot the wind vectors on top of precipitation data for June 1995 by creating a subspace with a date-time object and using cfplot.con. Here cfplot.gopen is used to define the parts of the plot area, which is closed by cfplot.gclose; cfplot.cscale is used to choose one of the colour maps amongst many available; cfplot.levs is used to set the contour levels for precipitation data; and cfplot.vect is used to plot the wind vectors for June 1995:
-june_95 = cf.year(1995) & cf.month(6)
-cfp.gopen()
-cfp.cscale("precip4_11lev")
-cfp.levs(step=100)
-cfp.con(
- pre.subspace(T=june_95),
+june_95 = cf.year(1995) & cf.month(6)
+cfp.gopen()
+cfp.cscale("precip4_11lev")
+cfp.levs(step=100)
+cfp.con(
+ pre.subspace(T=june_95),
lines=False,
title="June 1995 monthly global precipitation",
)
-cfp.vect(
- u=u.subspace(T=june_95),
- v=v.subspace(T=june_95),
+cfp.vect(
+ u=u.subspace(T=june_95),
+ v=v.subspace(T=june_95),
key_length=10,
scale=35,
stride=5,
)
-cfp.gclose()
+cfp.gclose()
Total running time of the script: ( 0 minutes 6.138 seconds)
diff --git a/docs/recipes/plot_06_recipe.html b/docs/recipes/plot_06_recipe.html
index f40a3fbc55..d3827a91b2 100644
--- a/docs/recipes/plot_06_recipe.html
+++ b/docs/recipes/plot_06_recipe.html
@@ -148,8 +148,8 @@ Related Topics
Read the field constructs using read function:
-f = cf.read("~/recipes/au952a.pd20510414.pp")
-print(f)
+
[<CF Field: id%UM_m01s03i463_vn1006(time(8), grid_latitude(432), grid_longitude(444))>]
@@ -158,8 +158,8 @@ Related Topics
Select the field by index and print its description to show properties of all constructs:
-gust = f[0]
-gust.dump()
+
-----------------------------------------------------------
@@ -246,7 +246,7 @@ Related Topics
Access the time coordinate of the gust field and retrieve the datetime values of the time coordinate:
-print(gust.coordinate("time").datetime_array)
+print(gust.coordinate("time").datetime_array)
[cftime.Datetime360Day(2051, 4, 14, 1, 30, 0, 0, has_year_zero=True)
@@ -262,8 +262,8 @@ Related Topics
Create a new instance of the cf.dt class with a specified year, month, day, hour, minute, second and microsecond. Then store the result in the variable test
:
-test = cf.dt(2051, 4, 14, 1, 30, 0, 0)
-print(test)
+
2051-04-14 01:30:00
@@ -272,15 +272,15 @@ Related Topics
Plot the wind gust by creating a subspace for the specified variable test
using cfplot.con. Here cfplot.mapset is used to set the mapping parameters like setting the map resolution to 50m:
-cfp.mapset(resolution="50m")
-cfp.con(gust.subspace(T=test), lines=False)
+cfp.mapset(resolution="50m")
+cfp.con(gust.subspace(T=test), lines=False)
To see the rotated pole data on the native grid, the above steps are repeated and projection is set to rotated in cfplot.mapset:
-cfp.mapset(resolution="50m", proj="rotated")
-cfp.con(gust.subspace(T=test), lines=False)
+cfp.mapset(resolution="50m", proj="rotated")
+cfp.con(gust.subspace(T=test), lines=False)
8. Create dimension coordinates for the destination grid with the latitude and
@@ -291,9 +291,9 @@
Related Topics
The method also takes an argument 'linear'
which specifies the type of
regridding method to use. The description of the regridded_data
is finally
printed to show properties of all its constructs:
-target_domain = cf.Domain.create_regular((-25, 45, 10), (32, 72, 10))
-regridded_data = gust.regrids(target_domain, "linear")
-regridded_data.dump()
+target_domain = cf.Domain.create_regular((-25, 45, 10), (32, 72, 10))
+regridded_data = gust.regrids(target_domain, "linear")
+regridded_data.dump()
-----------------------------------------------------------
@@ -355,8 +355,8 @@ Related Topics
Step 6 is similarly repeated for the regridded_data
to plot the wind gust on a regular latitude-longitude domain:
-cfp.mapset(resolution="50m")
-cfp.con(regridded_data.subspace(T=test), lines=False)
+cfp.mapset(resolution="50m")
+cfp.con(regridded_data.subspace(T=test), lines=False)
Total running time of the script: ( 0 minutes 27.364 seconds)
diff --git a/docs/recipes/plot_07_recipe.html b/docs/recipes/plot_07_recipe.html
index 5ee9d2e41c..8a4619b92e 100644
--- a/docs/recipes/plot_07_recipe.html
+++ b/docs/recipes/plot_07_recipe.html
@@ -148,8 +148,8 @@ Related Topics
Read the field constructs using read function and store it in the variable f
. The * in the filename is a wildcard character which means the function reads all files in the directory that match the specified pattern. [0:5] selects the first five elements of the resulting list:
-f = cf.read("~/recipes/realization/PRMSL.1941_mem*.nc")[0:5]
-print(f)
+
[<CF Field: long_name=Pressure reduced to MSL(time(2920), latitude(256), longitude(512)) Pa>,
@@ -162,7 +162,7 @@ Related Topics
The description of one of the fields from the list shows 'realization'
as a property by which the members of the model ensemble are labelled:
-f[1].dump()
+f[1].dump()
------------------------------------------------------
@@ -222,10 +222,10 @@ Related Topics
An ensemble of the members is then created by aggregating the data in f
along a new 'realization'
axis using the cf.aggregate function, and storing the result in the variable ensemble
. 'relaxed_identities=True'
allows for missing coordinate identities to be inferred. [0] selects the first element of the resulting list. id%realization
now shows as an auxiliary coordinate for the ensemble:
-ensemble = cf.aggregate(
- f, dimension=("realization",), relaxed_identities=True
+ensemble = cf.aggregate(
+ f, dimension=("realization",), relaxed_identities=True
)[0]
-print(ensemble)
+print(ensemble)
Field: long_name=Pressure reduced to MSL (ncvar%PRMSL)
@@ -240,7 +240,7 @@ Related Topics
To see the constructs for the ensemble, print the constructs attribute:
-print(ensemble.constructs)
+print(ensemble.constructs)
Constructs:
@@ -256,19 +256,19 @@ Related Topics
6. Loop over the realizations in the ensemble using the range function and the domain_axis to determine the size of the realization dimension. For each realization, extract a subspace of the ensemble using the subspace method and the 'id%realization'
keyword argument along a specific latitude and longitude and plot the realizations from the 4D field using cfplot.lineplot.
A moving average of the ensemble along the time axis, with a window size of 90 (i.e. an approximately 3-month moving average) is calculated using the moving_window method. The mode='nearest'
parameter is used to specify how to pad the data outside of the time range. The squeeze method removes any dimensions of size 1 from the field to produce a 2D field:
-cfp.gopen()
+cfp.gopen()
-for realization in range(1, ensemble.domain_axis("id%realization").size + 1):
- cfp.lineplot(
- ensemble.subspace(
- **{"id%realization": realization}, latitude=[0], longitude=[0]
+for realization in range(1, ensemble.domain_axis("id%realization").size + 1):
+ cfp.lineplot(
+ ensemble.subspace(
+ **{"id%realization": realization}, latitude=[0], longitude=[0]
).squeeze(),
- label=f"Member {realization}",
+ label=f"Member {realization}",
linewidth=1.0,
)
-cfp.lineplot(
- ensemble.moving_window(
+cfp.lineplot(
+ ensemble.moving_window(
method="mean", window_size=90, axis="T", mode="nearest"
)[0, :, 0, 0].squeeze(),
label="Ensemble mean",
@@ -277,7 +277,7 @@ Related Topics
title="Model Ensemble Pressure",
)
-cfp.gclose()
+cfp.gclose()
Total running time of the script: ( 1 minutes 4.205 seconds)
diff --git a/docs/recipes/plot_08_recipe.html b/docs/recipes/plot_08_recipe.html
index d94ba24d48..c3ae90167f 100644
--- a/docs/recipes/plot_08_recipe.html
+++ b/docs/recipes/plot_08_recipe.html
@@ -153,8 +153,8 @@ Related Topics
linear_trend(data, time_axis)
: This function calculates the linear regression slope and p-value for the input data along the time axis. It takes two arguments: 'data'
, which represents the temperature anomalies or any other data you want to analyse, and 'time_axis'
, which represents the corresponding time points for the data. The function uses the stats.linregress method from the scipy.stats library to calculate the slope and p-value of the linear regression. It returns these two values as a tuple:
-def linear_trend(data, time_axis):
- slope, _, _, p_value, _ = stats.linregress(time_axis, data)
+def linear_trend(data, time_axis):
+ slope, _, _, p_value, _ = stats.linregress(time_axis, data)
return slope, p_value
@@ -170,20 +170,20 @@ Related Topics
process_subsets(subset_mask)
: This function processes the subsets of data by applying the linear_trend
function along a specified axis. It takes one argument, 'subset_mask'
, which is a boolean mask representing the time points to be considered in the analysis. The function first extracts the masked subset of data and then applies the linear_trend
function along the time axis (axis 0) using the numpy.ma.apply_along_axis function. The result is an array containing the slope and p-value for each grid point in the dataset:
-def process_subsets(subset_mask):
- subset_data = masked_data[subset_mask, :, :]
- return np.ma.apply_along_axis(
- linear_trend, 0, subset_data, time_axis[subset_mask]
+def process_subsets(subset_mask):
+ subset_data = masked_data[subset_mask, :, :]
+ return np.ma.apply_along_axis(
+ linear_trend, 0, subset_data, time_axis[subset_mask]
)
Read the field constructs:
-temperature_data = cf.read(
+temperature_data = cf.read(
"~/recipes/HadCRUT.5.0.1.0.analysis.anomalies.ensemble_mean.nc"
)[0]
-print(temperature_data)
+print(temperature_data)
Field: long_name=blended air_temperature_anomaly over land with sea_water_temperature_anomaly (ncvar%tas_mean)
@@ -199,34 +199,34 @@ Related Topics
Calculate the annual mean temperature anomalies. The