Monday, March 21, 2005

Changed NetCDF fixed dimension to record dimension

Sometimes it is neccissary to change a fixed length dimension to a record dimension (an UNLIMITED) dimension. There is no straightforward way to do this, unfortunately, but I have found this relatively simple hack to be useful:

First make a new NetCDF file that contains only one record dimension, the same name as the dimension you wish to change, say time. I do this in MATLAB like this

f = nc('rec_dim.nc','noclobber');
f('time') = 0;
close(f);


Now, simply append the information in the NetCDF file using ncks (part of the nco package), like this

ncks -A orig.nc rec_dim.nc


You can now delete orig.nc. (You could also overwrite the origional directly).

No comments:

Post a Comment