Project

General

Profile

Does eof3d with CDO_WEIGHT_MODE=on also weight by *level thickness*, if a level-bounds variable is present in the file?

Added by Luke Davis almost 6 years ago

When I use cdo eof3d on my file with pressure-level bounds, will CDO also weight by pressure-level thickness, like it weights horizontal coordinate by grid cell area? And if so, is this behavior part of the CDO_WEIGHT_MODE option?

I suppose if not, I will have to hammer out a hacky solution with ncap2 to multiply the data by their pressure-level thickness.

Here is the output of cdo zaxisdes file.nc, if you're curious:

#                                                                                    
# zaxisID 1
#
zaxistype = pressure
size      = 40
name      = plev
longname  = "pressure level" 
units     = "mb" 
levels    = 12.66562 37.99687 63.32812 88.65938 113.9906 139.3219 164.6531 189.9844
            215.3156 240.6469 265.9781 291.3094 316.6406 341.9719 367.3031 392.6344
            417.9656 443.2969 468.6281 493.9594 519.2906 544.6218 569.9531 595.2844
            620.6156 645.9469 671.2781 696.6094 721.9407 747.2719 772.6031 797.9343
            823.2656 848.5969 873.9281 899.2594 924.5906 949.9219 975.2532 1000.584
lbounds   = 0 25.33125 50.6625 75.99375 101.325 126.6562 151.9875 177.3188 202.65
            227.9812 253.3125 278.6437 303.975 329.3062 354.6375 379.9688 405.3 430.6313
            455.9625 481.2938 506.625 531.9562 557.2875 582.6188 607.95 633.2812
            658.6125 683.9437 709.275 734.6063 759.9375 785.2687 810.6 835.9313 861.2625
            886.5938 911.925 937.2562 962.5875 987.9188
ubounds   = 25.33125 50.6625 75.99375 101.325 126.6562 151.9875 177.3188 202.65 227.9812
            253.3125 278.6437 303.975 329.3062 354.6375 379.9688 405.3 430.6313 455.9625
            481.2938 506.625 531.9562 557.2875 582.6188 607.95 633.2812 658.6125
            683.9437 709.275 734.6063 759.9375 785.2687 810.6 835.9313 861.2625 886.5938
            911.925 937.2562 962.5875 987.9188 1013.25

Replies (4)

RE: Does eof3d with CDO_WEIGHT_MODE=on also weight by *level thickness*, if a level-bounds variable is present in the file? - Added by Luke Davis almost 6 years ago

My bad, the zaxisdes output above was from the wrong file; this is the one I want weighted by pressure level (because, obviously, the level spacing is uneven):

#
# zaxisID 1
#
zaxistype = pressure
size      = 37
name      = plev
longname  = "pressure" 
units     = "mb" 
levels    = 1 2 3 5 7 10 20 30 50 70 100 125 150 175 200 225 250 300 350 400 450
            500 550 600 650 700 750 775 800 825 850 875 900 925 950 975 1000
lbounds   = 0 1.5 2.5 4 6 8.5 15 25 40 60 85 112.5 137.5 162.5 187.5 212.5 237.5
            275 325 375 425 475 525 575 625 675 725 762.5 787.5 812.5 837.5 862.5
            887.5 912.5 937.5 962.5 987.5
ubounds   = 1.5 2.5 4 6 8.5 15 25 40 60 85 112.5 137.5 162.5 187.5 212.5 237.5 275
            325 375 425 475 525 575 625 675 725 762.5 787.5 812.5 837.5 862.5 887.5
            912.5 937.5 962.5 987.5 1013.25

RE: Does eof3d with CDO_WEIGHT_MODE=on also weight by *level thickness*, if a level-bounds variable is present in the file? - Added by Uwe Schulzweida almost 6 years ago

The CDO operator eof3d doesn't consider the level thickness for the weights. Only the grid cell area is used for weighting.

RE: Does eof3d with CDO_WEIGHT_MODE=on also weight by *level thickness*, if a level-bounds variable is present in the file? - Added by Luke Davis almost 6 years ago

Thanks, that would have been my guess.

In any case here's my ncap2 workaround for future readers (this is using the bash shell):

neof=10 # number of EOFs
param=foo # parameter in file "unweighted.nc" 
ncap2 -O -v -s '*dp[$plev]=plev_bnds(:,1)-plev_bnds(:,0); '"new${param}=${param}*dp" unweighted.nc weighted.nc
CDO_WEIGHT_MODE=on cdo eof3d,$neof -setname,eof -detrend weighted.nc evecs.nc evals.nc

The asterisk before "dp" indicates this is a "RAM variable" (see ncap2 documentation), and the "-v" flag indicates we only want to keep variables defined explicitly in the script string -- i.e. our newly weighted parameter. Before multiplication, ncap2 automatically broadcasts the single-dimension variable "dp" onto the multi-dimensional variable "foo", since they both share the level dimension "plev".

Also note "$text" is expanded to the (possibly empty) variable named "text" if enclosed by double-quotes; single quotes are necessary where we assign to dp[$plev].

RE: Does eof3d with CDO_WEIGHT_MODE=on also weight by *level thickness*, if a level-bounds variable is present in the file? - Added by Ralf Mueller almost 6 years ago

hi Luke!

thx for sharing ncap2 recipe. I always wonder, what can be done with it. Do you know some more examples than on the docs at http://nco.sourceforge.net/nco.html#ncap2? It reminds me of a stripped down C-slang of NCL...

cheers
ralf

    (1-4/4)