# Re: finding the top and bottom

From: Debasish Pai Mazumder <debasish_at_nyahnyahspammersnyahnyah>
Date: Tue, 21 Apr 2009 15:02:35 -0800

Dear Cory,

You can try to reduce the loop using ndtooned and onedtond function like..

data2d = new((/x*y,z/),float)

do k=z,0,-1
data2d (:,k)= ndtooned(data(:,:,k))
end do

printVarSummary(data2d)

data1d = new((/x*y/),float)

do i=0,x*y-1
if(data2d(i,:).gt.0.0) then
data1d(i)=k
end do

data_final = onedtond(data1d, (/x,y/))

Thanks

Debasish

-----Original Message-----
From: ncl-talk-bounces_at_ucar.edu [mailto:ncl-talk-bounces_at_ucar.edu] On Behalf
Of Cory Wolff
Sent: Tuesday, April 21, 2009 2:11 PM
To: ncl-talk_at_ucar.edu
Subject: finding the top and bottom

I have data in a 3-d array (x,y,z) and would like to create a 2-d array
(x,y) that holds the level at which the values go above a certain
threshold in the z coordinate, starting from the top. I would also use
this to find the same starting from the bottom in a separate array. I
know that I can do this with loops:
do i=0,x
do j=0,y
do k=z,0,-1
if(data(i,j,k).gt.0.0) then
top(i,j) = k
...

That will be really slow, of course, so I'm wondering if I can do it
without resorting to loops. Any help would be appreciated. Thanks.

Cory

_______________________________________________
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 Tue Apr 21 2009 - 17:02:35 MDT

This archive was generated by hypermail 2.2.0 : Fri Apr 24 2009 - 14:12:40 MDT