The problem is that 'Tdata' has multiple entries that equal
individual 'Temp' values.
eg: Tdata = (/ 9, 45, 9, -5, 9, 33/)
There is one -5 BUT there are three values of 9.
---
Here is a version that will work. In cases of multiple
entries of the same value, this will return the 1st index.
If you need something different, you will have to
write your own function.
Good luck
=====================
undef("get1Dindex")
function get1Dindex (cv[*], cvWant[*])
local nWant, indWant, n
begin
nWant = dimsizes (cvWant)
indWant = new (nWant, "integer")
do n=0,nWant-1
iii = ind( cv.eq.cvWant(n) )
if (.not.ismissing(iii(0))) then
indWant(n) = iii(0)
end if
delete(iii)
end do
return (indWant)
end
nyrs = 32
ntim = 368
ts_rev = toint( random_uniform( -22.0, 5.0, (/nyrs,ntim/)) ) ;
make int
Temp = ispan(-20,4,1) ; need index for
;print(Temp)
do ii =0,nyrs-1 ; no of years =32
Tdata = ts_rev(ii,:) ; given temp value for all
; timestep at each year
i = get1Dindex(Tdata,Temp)
delete(i)
end do
On 10/31/13 8:09 PM, Bithi De wrote:
> Tdata = new((/368/),"integer")
> Temp = ispan(-20,4,1) ; need index for
> ; print(Temp)
>
> do ii =0,31 ; no of years =32
> Tdata(:) = ts_rev(ii,:) ; given temp value for all
> timestep at each year
> printVarSummary(Tdata)
>
>
> i = get1Dindex(Tdata,Temp)
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Oct 31 21:15:19 2013
This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT