7
votes

I have a netCDF file with 8 variables and 4 dimensions: latitude (dim: 26), longitude (dim:17), time (dim: a lot) and level (dim:1, pressure level). In order to use it in a specific program I need to have only 3 dimensions: latitude, longitude and time.

Is there an easy way to delete the level dimension in each variable?

I've found ncwa -a old_dim ifile.nc ofile.nc but sometimes it converts the type from short to float. When it keeps the short type the attributes "scale factor" and "add.offset" are deleted. The problem is that I want to keep the short type with scale factor and add offset.

1

1 Answers

5
votes

Your method is correct, however, your input data are "packed". Repack the output file with ncpdq after averaging-out the level dimension with ncwa:

ncpdq ofile.nc ofile2.nc

and you are done. See docs here.