Project

General

Profile

Average a variable through a particular dimension

Added by Craig Wallace about 4 years ago

Hello CDO Community

I have a seasonal forecast netcdf file with temperature variable '2m_temperature' as [lon, lat, ensembles, time]

I am attempting to average through the ensemble dimension, which is named 'number' in the file.

CDO operator 'ensmean' will not work since the ensemble members are not in separate files.

Is there some operator I can use to point to my variable and declare the dimension(either name, or number [3 in this case]) I would like to average over?

Thank you

Craig


Replies (5)

RE: Average a variable through a particular dimension - Added by Craig Wallace about 4 years ago

ok I hacked this by using nco dimension rename from 'number' to 'depth' and then I issued [cdo vertmean infile.nc outfile.nc] and left cdo to use constant weights.

Don't judge me.

RE: Average a variable through a particular dimension - Added by Ralf Mueller about 4 years ago

hi Craig!

Neat solution. I guess splitting the file along the number into several files and use ensmean would have been my strategy. But the result should be identical.

cheers
ralf

RE: Average a variable through a particular dimension - Added by Craig Wallace about 4 years ago

Thanks Ralf - that is a good suggestion too.

RE: Average a variable through a particular dimension - Added by Ralf Mueller about 4 years ago

the workflow would be like

  1. add axis="Z" to your ensemble dimension
  2. call cdo splitlevel to create multiple ensemble files
  3. call ensmean or whatever is needed

RE: Average a variable through a particular dimension - Added by Adrian Tompkins 3 months ago

Actually, if you want to average over an arbitrary dimension rather than a standard "time", "lat", "lon" dimension as is this case, I think this is one use case where nco is currently more straightforward to revert to (sorry!)

ncwa -a number input_ensemble.nc output_mean.nc
    (1-5/5)