Project

General

Profile

cdo percentile numpy options

Added by Adrian Tompkins about 2 years ago

cdo numpy percentile options

I see from the documentation that one can switch cdo percentile calculations to using numpy.percentile using the --percentile option, but the numpy percentile routine itself has further calculation method options. Is there any way of selecting a "suboption" to tell CDO, I want numpy with method "x" please, or does the numpy option only allow to use the numpy default method?

If the latter is true, could the possibility of using specifying the numpy suboptions be added as a feature request?

thanks, Adrian


Replies (9)

RE: cdo percentile numpy options - Added by Adrian Tompkins about 2 years ago

ps: Apologies for cross posting, I wanted to delete this from the discussion list as there was no follow up, but see now that there is no "delete posting" option.

RE: cdo percentile numpy options - Added by Uwe Schulzweida about 2 years ago

Hi Adrian,

Thanks for the hint, I hadn't noticed that new methods have been added in NumPy.
We will implement all missing NumPy methods to calculate the percentile in the next CDO version 2.2.

Cheers,
Uwe

RE: cdo percentile numpy options - Added by Adrian Tompkins about 2 years ago

That's great Uwe, and apologies again for cross-posting. Was just wondering if this were possible, since I wanted to make a percentiles video for CU, and if this were possible to add, I thought better to wait to make sure the video is up to date. Best wishes, Adrian

RE: cdo percentile numpy options - Added by Adrian Tompkins about 2 years ago

ps: How do you plan to implement the additional "switch"? - I note you already have the lower/upper/nearest options available after the underscore (e.g. "numpy_lower"), will this be implemented with numpy_lower_option ? (just so I can preempt the video material prep) :-)

RE: cdo percentile numpy options - Added by Uwe Schulzweida about 2 years ago

I'm not quite sure about that yet. Either all methods get the prefix numpy_, or I leave out the numpy_. Then the names of the methods would be simple:

inverted_cdf|averaged_inverted_cdf|closest_observation|...
These methods were already documented in 1996 (R. J. Hyndman and Y. Fan, "Sample quantiles in statistical packages"). And in R these methods are also available for a longer time. So it might be more general to leave out the numpy_. What do you think?

RE: cdo percentile numpy options - Added by Adrian Tompkins about 2 years ago

I think that leaving out the numpy_ is better as it prevents the argument getting too long, and there is not a clash between the CDO option names and the numpy options, it brings things on the "same level" across all method options - The only thing to perhaps add is that one might also leave in the option "numpy", which essentially becomes an (eventually depreciated) alias for "linear", so that existing scripts written pre-2.2 are not broken after the the version upgrade.

RE: cdo percentile numpy options - Added by Uwe Schulzweida about 2 years ago

Hi Adrian,

The new CDO bug fix release 2.1.1 already contains the new methods for testing.
Here is the complete list of all available percentile methods in CDO:
  • nrank
  • nist
  • rtype8
  • linear
  • lower
  • higher
  • nearest
  • midpoint
  • inverted_cdf
  • averaged_inverted_cdf
  • closest_observation
  • interpolated_inverted_cdf
  • hazen
  • weibull
  • median_unbiased
  • normal_unbiased

The old numPy methods "numpy numpy_lower numpy_higher numpy_nearest" remain and are an alias to the new names.
The methods rtype8 and median_unbiased do basically the same. rtype8 will then probably also be an alias to median_unbiased.

Cheers,
Uwe

RE: cdo percentile numpy options - Added by Adrian Tompkins about 2 years ago

that's great Uwe,
thanks so much... So to confirm the lower/midpoint/higher etc options are for the linear method yes?
best wishes, Adrian

RE: cdo percentile numpy options - Added by Uwe Schulzweida about 2 years ago

Yes, these are the discontinuous variations of the linear method!

    (1-9/9)