Project

General

Profile

Calculate and export the mean value of a variable

Added by Diego Araujo over 1 year ago

Hello!

I want to calculate the average value of a variable (evapotranspiration, 'E'), from a GLEAM nc file. The file has dimensions lon x lat x time. Time has 365 days (1 year). I need the spatial average of variable E for all days of the year, thus being the average for the area. Is this the correct command?

cdo fldmean ifile ofile

Also, can I export the average area values as a text file containing two columns (time; mean var. value)?

Thank you in advance. :)


Replies (1)

RE: Calculate and export the mean value of a variable - Added by Karin Meier-Fleischer over 1 year ago

Hi Diego,

if your input data file has the dimension order (lon, lat, time) you have to reorder it to (time, lat, lon) first. Therefore, you can use NCO's ncpdq:

ncpdq -O -a time,lat,lon infile infile_reordered_dims

Then you can use the fldmean operator of CDO to compute the field mean

cdo -fldmean infile_reordered_dims outfile

To write the field mean data with time to an ASCII file use the

cdo -outputtab,date,time,value outfile > outfile.txt

See outputtab operator https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.14.6

    (1-1/1)