Project

General

Profile

Working out 20% threshold of yearmax for each year

Added by Nathanael Harwood over 2 years ago

Is the following compound problem possible in CDO please?

I want to find out the date that each gridcell crosses over the 20% threshold of the annual maximum value for that cell. I'd like to do that for each year of the dataset, which is a daily .nc file of 35 years' worth of data (1982-2016).

I guess the code would start with the yearmax operator. If this is possible but only for 1 year of data at a time (i.e. not possible to iterate these commands over 35 years in steps of 365 days), then I'd still like to know! Many thanks in advance,

Nathanael Harwood.


Replies (1)

RE: Working out 20% threshold of yearmax for each year - Added by Ralf Mueller over 2 years ago

hi Nathanael!
the problem is, that 'data' is not a CF-compliant data type. Hence you cannot store it as data, but only as a coordinate.

But you could compute the 'day-of-the-year' as an integer. It depends a bit on your input data.

here is my approach to your problem

1. compute the 20% yearmax value with something like

cdo -mulc,0.8 -yearmax <ifile> 20p-ymax.nc 

2. use these values for creating a 0-1-mask, where 1 means below and 0 means 'above'
 cdo -le <ifile> 10p-ymax.nc masked.nc 

3. No you can add up the 1s per grid point to calculate the 'day-of-the-year' where the threshold is exceeded
 cdo -yearsum masked.nc .... 

Problem: what about crossing this threshold multiple times? Can you exclude this? This solution only works for think that grow over the year. A possible solution could be to select only the first half of the year for computing the 'sum-of-1

    (1-1/1)