Hi Ryan,
We don't have a built-in function for this, but I think you could easily use the "ind" function for something like this, depending on how you want your values grouped.
For example, if your 2D array is called "x", and your levels are called "levels", then (untested):
;---Working with 1D arrays is easier
index_vals_1d = new(dimsizes(product(x)),integer) ; Start with 1D array
x1d = ndtooned(x)
;---Loop across rest of dimensions and assign index values for middle contour levels
nlevels = dimsizes(levels)
do i=0,nlevels-1
if(i.eq.0) then
ii = ind(x1d.lt.levels(i))
else
if(i.eq.(nlevels-1)) then
ii = ind(x1d.ge.levels(i))
else
ii = ind(levels(i-1).ge.x1d.and.x1d.lt.levels(i))
end if
end if
if(.not.any(ismissing(ii))) then
indes_vals_1d(ii) = i+2 ; or whatever color index you want
end if
delete(ii)
end do
delete(x1d) ; Don't need this any more.
index_vals_2d = onedtond(index_vals_1d,dimsizes(x)) ; Convert to 2D
delete(index_vals_1d)
--Mary
On Aug 17, 2011, at 6:46 AM, Ryan Pavlick wrote:
> Hi,
>
> I was wondering if anyone on this list has written a function that
> takes a 2d data array and a colormap and produces a 2d array
> containing the corresponding colormap index values?
>
> Thanks,
> Ryan
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Aug 22 07:40:33 2011
This archive was generated by hypermail 2.1.8 : Mon Aug 22 2011 - 08:13:37 MDT