3

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?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86

2 Answers2

5

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 
N1B4
  • 3,377
  • 1
  • 21
  • 24
1

Just to add to the answer above. If longitude is in "degrees east", i.e. it goes from 0 to 360 and not -180 to 180, you will need to modify the call.

So, the following will not crop the file from -30 to 40 degrees.

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

But this will:

ncks -d lon,40.,-30. file.nc -O cropped_file.nc
Robert Wilson
  • 3,192
  • 11
  • 19