Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a dimension in a NetCDF file

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.

like image 284
Douie Avatar asked Nov 26 '13 11:11

Douie


1 Answers

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.

like image 169
Charlie Zender Avatar answered Oct 06 '22 00:10

Charlie Zender