Aggregation and percentiles

148 views
Skip to first unread message

FColledge

unread,
Feb 21, 2014, 3:41:55 AM2/21/14
to scitoo...@googlegroups.com
Hello

I have a cube with daily data for ten years over a number of grid points, I wanting to aggregate it so that it calculates the 5th, 25th, med, 75th, 95th percentiles for each day over the ten year period.

daily precipitation analysis interpolated onto 0.25deg grids [mm/day] / (mm/day) (time: 3650; latitude: 132; longitude: 136)
     Dimension coordinates:
          time                                                                                                           x               -               -
          latitude                                                                                                       -               x               -
          longitude                                                                                                     -               -               x
     Auxiliary coordinates:
          day_of_month                                                                                             x               -               -
          month_number                                                                                            x               -               -


Would I use this?

iris.analysis.Aggregator(cell_method, call_func, units_func=None, **kwargs)

I am unsure by what is meant by cell_method, I am guessing it would look something like this:

calc = iris.analysis.Aggregator(cell_method, call_func  = iris.analysis.PERCENTILE, units_func = None, percent=95)

cube.aggregated_by(['day_of_month', 'month_number'], calc) ??





Richard Hattersley

unread,
Feb 21, 2014, 3:54:25 AM2/21/14
to scitoo...@googlegroups.com
Hi,

If I've understood "for each day over the ten year period" correctly then you want something like:

iris.coord_categorisation.add_day_of_year(cube)
p5
= cube.aggregated_by('day_of_year', iris.analysis.PERCENTILE, percent=5)
p25 = cube.aggregated_by('day_of_year', iris.analysis.PERCENTILE, percent=25)
etc.

Each of your result cubes will then have the shape: (day_of_year: 365; latitude: 132; longitude: 136).

NB. Each day's percentile values are being estimated from just ten values - is that what you're after?

Regards,
Richard

FColledge

unread,
Feb 21, 2014, 4:08:12 AM2/21/14
to scitoo...@googlegroups.com

Hi Richard

That works but the resultant cube has day_of_year: 365.

Is there a way to stop add_day_of_year having 366 days?

Thanks

Francis

FColledge

unread,
Feb 21, 2014, 4:38:19 AM2/21/14
to scitoo...@googlegroups.com
Apologies I meant the resultant cube has day_of_year: 366

Carwyn Pelley

unread,
Feb 21, 2014, 10:59:50 AM2/21/14
to scitoo...@googlegroups.com
If this is on a standard gregorian calendar, then this will include leap days and so I might expect 366 days resulting.
If you don't want to include these leap days, it sounds like you want to perform your analysis with respect to some form of categorisation that does not involve a calendar (this is inferred by the result you expect).

Example: consider comparing data on one calendar with another calendar.  Comparing times becomes impossible (apples and oranges).  We must infer a way of comparing between these data sets that does not involve calendars.  One way of categorising these two data sets might be on season for example and doing away with the times.

If you mean to convert your coordinate to a different calendar, (i.e. still infer specific times with calendars), then do so at your own risk and you will have to calculate this yourself for your own purposes.

chris.kent

unread,
Feb 24, 2014, 4:11:27 AM2/24/14
to scitoo...@googlegroups.com
Is there a way to combine this percentile processing with a rolling window?

I.e. for a given timeseries return the 10th percentile for each day of year centered in a 30-day window (should include wrap around day numbers; such as 360 +- 15 days )?

Andrew Dawson

unread,
Feb 24, 2014, 4:20:33 AM2/24/14
to scitoo...@googlegroups.com
You can use any aggregator you like with the rolling_window method of a cube. However, the rolling_window method does not support circular coordinates at the present time so you would have to manually construct a cube with cyclic data before use.
Reply all
Reply to author
Forward
0 new messages