Averaging applied auxiliary coordinates - why mean of bounds?

27 views
Skip to first unread message

Goodwin Gibbins

unread,
Jul 8, 2020, 5:42:02 AM7/8/20
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
I've noticed that when a cube is averaged by, for example, cube.collapsed('time', iris.analysis.MEAN) or cube.aggregated_by('year', , iris.analysis.MEAN), the averaging which is applied to the auxiliary coordinates is mean(min(aux_coord), max(aux_coord)), which seems odd to me. Is this a bug or a feature? Why? I couldn't find mention of it in the documentation, but may have missed it.

A very minimal working example:

import iris
import numpy as np

# Load an example cube.
filename = iris.sample_data_path('ostia_monthly.nc')
cube = iris.load_cube(filename)

# Add a simple auxiliary coordinate.
addx = iris.coords.AuxCoord(1.0 + 0* cube.coord('time').points, long_name = 'x')
cube.add_aux_coord(addx, 0)
cube.coord('x').points[2] = 1000

col_cube = cube.collapsed('time', iris.analysis.MEAN)
print(col_cube.coord('x').points) # = 500.5

print(np.mean(cube.coord('x').points)) # = 19.5

RuthC

unread,
Jul 14, 2020, 5:30:32 AM7/14/20
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
I think it was just done that way for simplicity.  There is an open pull request to change this for the collapsed method, but I'm not sure of the status as it hasn't been updated in a while:

Ruth

Klaus Zimmermann

unread,
Jul 14, 2020, 5:32:30 AM7/14/20
to scitoo...@googlegroups.com
Hello,

to me, this seems reasonable.

What don't you like about it? What behavior would you prefer?

Cheers
Klaus
> --
> You received this message because you are subscribed to the Google
> Groups "SciTools (iris, cartopy, cf_units, etc.) -
> https://github.com/scitools" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scitools-iri...@googlegroups.com
> <mailto:scitools-iri...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/scitools-iris/2f1cc368-4a45-4e4a-8bbb-1515ef64e20ao%40googlegroups.com
> <https://groups.google.com/d/msgid/scitools-iris/2f1cc368-4a45-4e4a-8bbb-1515ef64e20ao%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages