@@ -23,9 +23,9 @@ Collapsing Entire Data Dimensions
23
23
24
24
In the :doc: `subsetting_a_cube ` section we saw how to extract a subset of a
25
25
cube in order to reduce either its dimensionality or its resolution.
26
- Instead of simply extracting a sub-region of the data,
27
- we can produce statistical functions of the data values
28
- across a particular dimension,
26
+ Instead of simply extracting a sub-region of the data,
27
+ we can produce statistical functions of the data values
28
+ across a particular dimension,
29
29
such as a 'mean over time' or 'minimum over latitude'.
30
30
31
31
.. _cube-statistics_forecast_printout :
@@ -57,9 +57,9 @@ For instance, suppose we have a cube:
57
57
um_version: 7.3
58
58
59
59
60
- In this case we have a 4 dimensional cube;
61
- to mean the vertical (z) dimension down to a single valued extent
62
- we can pass the coordinate name and the aggregation definition to the
60
+ In this case we have a 4 dimensional cube;
61
+ to mean the vertical (z) dimension down to a single valued extent
62
+ we can pass the coordinate name and the aggregation definition to the
63
63
:meth: `Cube.collapsed() <iris.cube.Cube.collapsed> ` method:
64
64
65
65
>>> import iris.analysis
@@ -88,8 +88,8 @@ we can pass the coordinate name and the aggregation definition to the
88
88
mean: model_level_number
89
89
90
90
91
- Similarly other analysis operators such as ``MAX ``, ``MIN `` and ``STD_DEV ``
92
- can be used instead of ``MEAN ``, see :mod: `iris.analysis ` for a full list
91
+ Similarly other analysis operators such as ``MAX ``, ``MIN `` and ``STD_DEV ``
92
+ can be used instead of ``MEAN ``, see :mod: `iris.analysis ` for a full list
93
93
of currently supported operators.
94
94
95
95
For an example of using this functionality, the
@@ -103,14 +103,14 @@ in the gallery takes a zonal mean of an ``XYT`` cube by using the
103
103
Area Averaging
104
104
^^^^^^^^^^^^^^
105
105
106
- Some operators support additional keywords to the ``cube.collapsed `` method.
107
- For example, :func: `iris.analysis.MEAN <iris.analysis.MEAN> ` supports
108
- a weights keyword which can be combined with
106
+ Some operators support additional keywords to the ``cube.collapsed `` method.
107
+ For example, :func: `iris.analysis.MEAN <iris.analysis.MEAN> ` supports
108
+ a weights keyword which can be combined with
109
109
:func: `iris.analysis.cartography.area_weights ` to calculate an area average.
110
110
111
- Let's use the same data as was loaded in the previous example.
112
- Since ``grid_latitude `` and ``grid_longitude `` were both point coordinates
113
- we must guess bound positions for them
111
+ Let's use the same data as was loaded in the previous example.
112
+ Since ``grid_latitude `` and ``grid_longitude `` were both point coordinates
113
+ we must guess bound positions for them
114
114
in order to calculate the area of the grid boxes::
115
115
116
116
import iris.analysis.cartography
@@ -155,24 +155,24 @@ including an example on taking a :ref:`global area-weighted mean
155
155
Partially Reducing Data Dimensions
156
156
----------------------------------
157
157
158
- Instead of completely collapsing a dimension, other methods can be applied
159
- to reduce or filter the number of data points of a particular dimension.
158
+ Instead of completely collapsing a dimension, other methods can be applied
159
+ to reduce or filter the number of data points of a particular dimension.
160
160
161
161
162
162
Aggregation of Grouped Data
163
163
^^^^^^^^^^^^^^^^^^^^^^^^^^^
164
164
165
- The :meth: `Cube.aggregated_by <iris.cube.Cube.aggregated_by> ` operation
166
- combines data for all points with the same value of a given coordinate.
167
- To do this, you need a coordinate whose points take on only a limited set
168
- of different values -- the *number * of these then determines the size of the
165
+ The :meth: `Cube.aggregated_by <iris.cube.Cube.aggregated_by> ` operation
166
+ combines data for all points with the same value of a given coordinate.
167
+ To do this, you need a coordinate whose points take on only a limited set
168
+ of different values -- the *number * of these then determines the size of the
169
169
reduced dimension.
170
- The :mod: `iris.coord_categorisation ` module can be used to make such
171
- 'categorical' coordinates out of ordinary ones: The most common use is
172
- to aggregate data over regular *time intervals *,
170
+ The :mod: `iris.coord_categorisation ` module can be used to make such
171
+ 'categorical' coordinates out of ordinary ones: The most common use is
172
+ to aggregate data over regular *time intervals *,
173
173
such as by calendar month or day of the week.
174
174
175
- For example, let's create two new coordinates on the cube
175
+ For example, let's create two new coordinates on the cube
176
176
to represent the climatological seasons and the season year respectively::
177
177
178
178
import iris
@@ -188,8 +188,8 @@ to represent the climatological seasons and the season year respectively::
188
188
189
189
.. note ::
190
190
191
- The 'season year' is not the same as year number, because (e.g.) the months
192
- Dec11, Jan12 + Feb12 all belong to 'DJF-12'.
191
+ The 'season year' is not the same as year number, because (e.g.) the months
192
+ Dec11, Jan12 + Feb12 all belong to 'DJF-12'.
193
193
See :meth: `iris.coord_categorisation.add_season_year `.
194
194
195
195
@@ -206,10 +206,10 @@ to represent the climatological seasons and the season year respectively::
206
206
iris.coord_categorisation.add_season_year(cube, 'time', name='season_year')
207
207
208
208
annual_seasonal_mean = cube.aggregated_by(
209
- ['clim_season', 'season_year'],
209
+ ['clim_season', 'season_year'],
210
210
iris.analysis.MEAN)
211
211
212
-
212
+
213
213
Printing this cube now shows that two extra coordinates exist on the cube:
214
214
215
215
.. doctest :: aggregation
@@ -238,20 +238,20 @@ These two coordinates can now be used to aggregate by season and climate-year:
238
238
.. doctest :: aggregation
239
239
240
240
>>> annual_seasonal_mean = cube.aggregated_by(
241
- ... [' clim_season' , ' season_year' ],
241
+ ... [' clim_season' , ' season_year' ],
242
242
... iris.analysis.MEAN )
243
243
>>> print (repr (annual_seasonal_mean))
244
244
<iris 'Cube' of surface_temperature / (K) (time: 19; latitude: 18; longitude: 432)>
245
-
246
- The primary change in the cube is that the cube's data has been
247
- reduced in the 'time' dimension by aggregation (taking means, in this case).
248
- This has collected together all data points with the same values of season and
245
+
246
+ The primary change in the cube is that the cube's data has been
247
+ reduced in the 'time' dimension by aggregation (taking means, in this case).
248
+ This has collected together all data points with the same values of season and
249
249
season-year.
250
250
The results are now indexed by the 19 different possible values of season and
251
251
season-year in a new, reduced 'time' dimension.
252
252
253
- We can see this by printing the first 10 values of season+year
254
- from the original cube: These points are individual months,
253
+ We can see this by printing the first 10 values of season+year
254
+ from the original cube: These points are individual months,
255
255
so adjacent ones are often in the same season:
256
256
257
257
.. doctest :: aggregation
@@ -271,7 +271,7 @@ so adjacent ones are often in the same season:
271
271
djf 2007
272
272
djf 2007
273
273
274
- Compare this with the first 10 values of the new cube's coordinates:
274
+ Compare this with the first 10 values of the new cube's coordinates:
275
275
All the points now have distinct season+year values:
276
276
277
277
.. doctest :: aggregation
@@ -294,7 +294,7 @@ All the points now have distinct season+year values:
294
294
295
295
Because the original data started in April 2006 we have some incomplete seasons
296
296
(e.g. there were only two months worth of data for 'mam-2006').
297
- In this case we can fix this by removing all of the resultant 'times' which
297
+ In this case we can fix this by removing all of the resultant 'times' which
298
298
do not cover a three month period (note: judged here as > 3*28 days):
299
299
300
300
.. doctest :: aggregation
@@ -306,7 +306,7 @@ do not cover a three month period (note: judged here as > 3*28 days):
306
306
>>> full_season_means
307
307
<iris 'Cube' of surface_temperature / (K) (time: 17; latitude: 18; longitude: 432)>
308
308
309
- The final result now represents the seasonal mean temperature for 17 seasons
309
+ The final result now represents the seasonal mean temperature for 17 seasons
310
310
from jja-2006 to jja-2010:
311
311
312
312
.. doctest :: aggregation
0 commit comments