Hi Bridget,
On Fri, Jun 25, 2010 at 2:09 PM, Bridget Thrasher
<bthrasher@climatecentral.org> wrote:
> Say I've got a 2-D array (lat/lon) that has a blob of data in the middle
> surrounded by missing values. Is there an NCL function that will
> automatically crop or trim that array to the edges of the data, thereby
> getting rid of the surrounding cells of missing data? Just curious since I
> don't see anything in the function list that appears to do this.
Although it won't eliminate every missing value, this simple function
should crop the array to the smallest rectangular region that includes
all of the non-missing data:
undef("crop2D")
function crop2D(x:numeric)
local i
begin
i = ind_resolve(ind(.not.ismissing(ndtooned(x))),dimsizes(x))
x_crop = x( min(i(:,0)):max(i(:,0)), min(i(:,1)):max(i(:,1)) )
return(x_crop)
end
The function should retain the metadata associated with the input
array. Untested equivalents for 1-D, 3-D, and 4-D arrays are
attached.
~Rob
-- Robert Nicholas Department of Atmospheric Sciences University of Washington, Box 351640 Seattle, WA 98195-1640
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.1.8 : Fri Jul 02 2010 - 07:45:13 MDT