Search code examples
pythonnetcdfnco

Extending dimensions of netCDF file using NCO


Is there a NCO or netCDF4 command that can be used to extend the lat-lon dimensions of netCDF file.

E.g. I have a netCDF file with foll. dimensons:

dimensions(sizes): time(10), var(1), latitude(1674), longitude(4320)

I want to extend the latitude dimension to cover the entire globe i.e. instead of 1674 it should be 2160. Is there a way to do that? The new cells should be assigned a user-specified value say 0.0


Solution

  • You could generate a new grid of the size you want and then remap your original data to that grid with ncremap. It's a fairly sophisticated feature but then so is what you want to do :). Or you could open your file in ncap2, define new dimensions of the sizes above, and then use hyperslab subscripting to copy your original data into a corner of your new array, then use ncks to extract only the new fields/dimensions from that file.