Project

General

Profile

Extract highest value and its latitude

Added by Shane Brian over 1 year ago

Hi, is there a cdo function that I can use with cdo -outputtab,date,name,value,lat to select the highest values per year and its latitude from a NetCDF consisting of multiple years (2020-2099)?


Replies (4)

RE: Extract highest value and its latitude - Added by Ralf Mueller over 1 year ago

Hi Shane!

you might try the yearmax operators. See here or check

cdo -h yearmax

RE: Extract highest value and its latitude - Added by Shane Brian over 1 year ago

Thanks Ralf for suggestion,

I went through the operators as per your suggestion and I found the operator below
but I am struggling to run it on the command line, or perhaps do you know how to run it?

Yearly maximum
For every adjacent sequence t_1,...,t_n of timesteps of the same year it is:
o(t,x) = max{i(t′,x),t1 < t′≤ tn}

RE: Extract highest value and its latitude - Added by Ralf Mueller over 1 year ago

Frist of all, you can prepend it to any of your calls like

 cdo  -outputtab,date,name,value,lat -yearmax <ifile>

BUT: yearmax only gives a single timestep. hence it cannot provide multiple date/time values for possible different dates for different grid points. With this technique you can only get the max values and their location, bot not the datetimes.

is your input horizontally distributed or only a single point?

RE: Extract highest value and its latitude - Added by Karin Meier-Fleischer over 1 year ago

To write the date, value and lat (only?) for the maximum value of your lonlat data for each timestep to an output file you can do the following.

Example 'infile.nc' with variable 'tas'

cdo -s -outputtab,date,name,value,lat \
       -selname,tas_max \
       -expr,'tas_max=(tas==fldmax(tas))? tas : tas/0' \
       -yearmax \
       -selyear,2020/2099 infile.nc | grep -v 1e+20 > outputtab_date_name_value_lat.txt
    (1-4/4)