Many methods in meteorology consider a threshold of grid points that satisfy a certain criterion. I want to select, from daily Era-Interim gridded data, those days in with areas of potential vorticity greater than 20 grid points.
Here is some Matlab coding that should be able to be modified for Grads pretty easily; that takes advantage of the power of matrices and indexing which are common to both Matlab and Grads
So if you take an array (e.g., velocity) and test for a variable (speed) criteria; e.g., speed greater than 33 knots; so then you just find an index (sel2) and then apply that index to the original dataset to subset the data you want. So, essentially only two lines vice a lot of ifs/endifs/elseifs, etc.
sel2 = find (speed > 33); %sel2 becomes your index variable
NEWvelocity = velocity (:,sel2);
So now you have a new matrix (NEWvelocity) with just wind speeds > 33 kts
Okay; whatever works for you; I like to avoid a lot of if/endif/else statements and use the power of the vector matrices, but again, if that works for you, great!