NCO cropping a netcdf file using dimension values

2019-04-13 23:31发布

问题:

CDO can crop a netcdf file in terms of latitude and longitude as long as they are defined in a standard way, and I know that NCO can cut out a subset of a netcdf file along any dimension if you know the range of indices that you want, as stated in the answers to this related question:

Is there a way to crop a NETCDF file?

However, I was wondering if the ncks hyperslabber can work directly on the values of the dimension, rather than the index values?

回答1:

Yes, using a decimal indicates the range of actual values (eg, latitudes) to extract over, while using integers indicates the range of indices corresponding to the values.

For instance, to extract across latitudes 30.0 - 40.0 degrees N:

ncks -d lat,30.,40. file.nc -O cropped_file.nc