Availability: ncbo, ncea, ncecat,
ncflint, ncks, ncpdq, ncra,
ncrcat, ncwa Short options: ‘-d dim,[min][,[max][,[stride]]]’ Long options: ‘--dimension dim,[min][,[max][,[stride]]]’, ‘--dmn dim,[min][,[max][,[stride]]]’ |
The stride is specified as the optional fourth argument to the
‘-d’ hyperslab specification:
-d
dim,[
min][,[
max][,[
stride]]]
.
Specify stride as an integer (i.e., no decimal point) following
the third comma in the ‘-d’ argument.
There is no default value for stride.
Thus using ‘-d time,,,2’ is valid but ‘-d time,,,2.0’ and
‘-d time,,,’ are not.
When stride is specified but min is not, there is an
ambiguity as to whether the extracted hyperslab should begin with (using
C-style, 0-based indexes) element 0 or element ‘stride-1’.
NCO must resolve this ambiguity and it chooses element 0
as the first element of the hyperslab when min is not specified.
Thus ‘-d time,,,stride’ is syntactically equivalent to
‘-d time,0,,stride’.
This means, for example, that specifying the operation
‘-d time,,,2’ on the array ‘1,2,3,4,5’ selects the hyperslab
‘1,3,5’.
To obtain the hyperslab ‘2,4’ instead, simply explicitly specify
the starting index as 1, i.e., ‘-d time,1,,2’.
For example, consider a file 8501_8912.nc which contains 60 consecutive months of data. Say you wish to obtain just the March data from this file. Using 0-based subscripts (see C and Fortran Index Conventions) these data are stored in records 2, 14, ... 50 so the desired stride is 12. Without the stride option, the procedure is very awkward. One could use ncks five times and then use ncrcat to concatenate the resulting files together:
for idx in 02 14 26 38 50; do # Bourne Shell ncks -d time,${idx} 8501_8912.nc foo.${idx} done foreach idx (02 14 26 38 50) # C Shell ncks -d time,${idx} 8501_8912.nc foo.${idx} end ncrcat foo.?? 8589_03.nc rm foo.??
With the stride option, ncks performs this hyperslab extraction in one operation:
ncks -d time,2,,12 8501_8912.nc 8589_03.nc
See ncks netCDF Kitchen Sink, for more information on ncks.
Applying the stride option to the record dimension in ncra and ncrcat makes it possible, for instance, to average or concatenate regular intervals across multi-file input data sets.
ncra -F -d time,3,,12 85.nc 86.nc 87.nc 88.nc 89.nc 8589_03.nc ncrcat -F -d time,3,,12 85.nc 86.nc 87.nc 88.nc 89.nc 8503_8903.nc