Aggregator of 2 cubes?

94 views
Skip to first unread message

RuthC

unread,
Jan 22, 2015, 5:37:54 AM1/22/15
to scitoo...@googlegroups.com
I'm wondering if it's possible to create an Aggregator-like object that will work to combine 2 cubes.  An obvious example is correlation.  You often have 2 cubes of the same shape and want to correlate them along the time dimension, leaving all other dimensions as they are.  I currently have an application, with 2 cubes the same shape, where I want to split up a dimension and apply a correlation along each piece of that dimension.  If I had a correlation Aggregator, I could use it with cube.aggregated_by and save myself a lot of hassle.

Has anyone tried to do anything similar (successfully or otherwise)?

Thanks,

Ruth

Andrew Dawson

unread,
Jan 22, 2015, 5:51:28 AM1/22/15
to scitoo...@googlegroups.com
There isn't a generic mechanism is place for this at the moment, although it is something I have worked towards in the past. However, there is a function for correlation that already exists! Check out iris.analysis.stats.pearsonr. For temporal correlation you'd call it something like this:

from iris.analysis.stats import pearsonr

r
= pearsonr(cube_a, cube_b, corr_coords=['time'])

RuthC

unread,
Jan 22, 2015, 8:22:20 AM1/22/15
to scitoo...@googlegroups.com
Thanks Andrew,

I might want Spearman's correlation, but Pearson's is certainly a start (and the code will be a good starting point if I want to write others).

As an aside, I don't think the pearsonr function will always work correctly for masked arrays, so I've just raised my second issue: https://github.com/SciTools/iris/issues/1534

Ruth
Reply all
Reply to author
Forward
0 new messages