Fab
Fab

Reputation: 1215

CDO/NCO - Replicate dataset over a dimension

I have several variables defined as follows:

dimensions:
        t = UNLIMITED ; // (1 currently)
        y = 3963 ;
        x = 5762 ;
        myz = 1 ;
        z = 98 ;
variables:
        float e1u(t, y, x, myz) ;
        float e1v(t, y, x, myz) ;
        float e2v(t, y, x, myz) ;
        float e2u(t, y, x, myz) ;
        float nav_lev(z) ;

I'd like to define the e1u variable over the z dimension, by replicating the (x,y) grid for all the 98 levels. Is there a cdo/nco command to accomplish that?

Thanks!

Upvotes: 3

Views: 420

Answers (1)

Charlie Zender
Charlie Zender

Reputation: 6352

ncap2 -s 'e1uz[t,y,x,myz,z]=e1u' in.nc out.nc # This replicates over z
ncks -O -x -v e1u out.nc out.nc # Delete original e1u variable
ncrename -v e1uz,e1u out.nc # Rename to original name

Upvotes: 2

Related Questions