Project

General

Profile

Calculating percentile over whole dataset

Added by Anne Moree over 2 years ago

Hello,

I have a lon*lat*time dataset and want to calculate the 10th percentile over the whole dataset. Fldpctl,10 would work perfect for me, were it not for the time dimension.
Fldpctl namely returns a value for each timestep, while I want a percentile over the whole dataset. How would I go about this in CDO?

Thank you so much in advance for thinking along,
Anne


Replies (6)

RE: Calculating percentile over whole dataset - Added by Anne Moree over 2 years ago

Hi Karin,

Thanks for your quick reply! Timpctl would give a value for each gridcell over all timesteps, but I need only one value over all times and all gridcells. With Python I can do this, using numpy.nanpercentile as it flattens the 3D array and then takes the 10th percentile, but it would be great to do this with CDO directly for my purposes.

Cheers,
Anne

RE: Calculating percentile over whole dataset - Added by Ralf Mueller over 2 years ago

hi Anne!

CDO does not have an operator, which performs a pct computation along all dimensions at the same time. You can perform them in a sequence of operators, but I cannot tell, if this will give the correct answer.

you can try it with

cdo -timpctl,10 -fldpctl,10 .... 

cheers
ralf

RE: Calculating percentile over whole dataset - Added by Ralf Mueller over 2 years ago

in python you could combine cdo and numpy through the python-bindings of CDO - just an idea

RE: Calculating percentile over whole dataset - Added by Anne Moree over 2 years ago

Dear Ralf,

Thanks for thinking along! The 10th percentile over the horizontal layers of the 10th percentile over time is not the same as the 10th percentile over all data. Thanks for thinking along though! It may be a nice addition to CDO for a future release.
I will have a look at the python-CDO bindings you suggested.

Cheers, have a nice day,
Anne

RE: Calculating percentile over whole dataset - Added by Ralf Mueller over 2 years ago

Anne Moree wrote in RE: Calculating percentile over whole dataset:

Cheers, have a nice day,
Anne

you, too

here is like to start with https://github.com/Try2Code/cdo-bindings

    (1-6/6)