Project

General

Profile

Attempting to obtain time indices corresponding to values returned by yearmax

Added by Matt Bonnyman about 5 years ago

I am currently analysing climate data and attempting to find yearly maximum values as well as the days on which they occur. I am working with large netCDF that consists of 3-hour or daily tiem resolution.

I am able to use CDO for most of this, but am having issues finding a way to obtain the time indices corresponding to the maximum values obtained using CDO.

For example, if I am working with 30 years of 3-hourly temperature data I may do something like this...

1. Convert to daily time resolution by getting daily maximums
cdo daymax temp_30yr_3hr.nc temp_30yr_daymax.nc
2. Obtain grids of the maximums for every year
cdo yearmax temp_30yr_daymax.nc temp_30yr_yearmax.nc

At this point I should have a netCDF file with 30 time steps(one for each year) and each of these steps should be made up of the maximum temperatures that were observed over the whole year at each point.
I need help creating a netCDF that has the same dimesions as temp_30yr_yearmax.nc and indicates the days of the year at which the maximum temperatures were observed on. Ideally this would be done using integer values that count the days since the start of the year (as opposed to actual dates).

Any advice is appreciated.


Replies (3)

RE: Attempting to obtain time indices corresponding to values returned by yearmax - Added by Uwe Schulzweida about 5 years ago

Hi Matt,

I have implemented the CDO functions yearmaxidx/yearminidx and selyearidx in CDO release 1.9.4. The status is experimental and there is no documentation, but it work perfectly:)
Use yearmaxidx to generate the indices of the yearly maximum. selyearidx uses these indices to select the data.
Here is an example:

cdo yearmaxidx infile  yearlyindices
cdo selyearidx yearlyindices infile outfile
The datatype of the indices is currently the same as the datatype of the input data. I will change it to integer in the next release, the result is the same.

Cheers,
Uwe

RE: Attempting to obtain time indices corresponding to values returned by yearmax - Added by Joel Zeder over 3 years ago

Dear Uwe,
A follow-up question; what would be the easiest way to apply selyearidx (obtained from applying yearmaxidx to a 1D time series) to 2D spatial fields (I'm trying to obtain pressure fields during temperature maxima at a specific location).
If I try to do so, I get an error saying "cdo selyearidx (Abort): Grid size of the input parameters do not match!".
Thank you very much for the support!
Best regards,
Joel

RE: Attempting to obtain time indices corresponding to values returned by yearmax - Added by Uwe Schulzweida over 3 years ago

You have to apply the operator enlarge to the 1D time series:

cdo selyearidx -enlarge,infile yearlyindices infile outfile

    (1-3/3)