RE: [ncl-talk] random extraction of data

From: Debasish Pai Mazumder <debasish_at_nyahnyahspammersnyahnyah>
Date: Thu, 1 Mar 2007 23:33:29 -0900

Dear Dennis

Thanks for your solution. It is working.
But iu takes the maximum value 3200 whereas I have 10500 grid points.
I did not figure it out how will I increase the value of iu (it will be good
if iu takes the value nearer to 9000) so that random 500 grids will be more
disperse over the region (i.e. 10500 grid points)

Thanks

Debasish

-----Original Message-----
From: Dennis Shea [mailto:shea_at_ucar.edu]
Sent: Thursday, March 01, 2007 7:25 PM
To: Debasish Pai Mazumder
Cc: ncl-talk_at_ucar.edu
Subject: Re: random extraction of data

Oops!!!

   IR = round( random_uniform(0,(NR-1), NR) , 3)

Actually, I think something like the following
will return *unique* points

   NR = 500
   NRMX= 9*NR
   IR = round(random_uniform(0,(NR-1),NRMX), 3)

   LU = new( NRMX, "logical")
   LU = True
   do n=0,NRMX-1
      i = ind(IR.eq.IR(n) .and. LU(n))
      ni = dimsizes(i)
      if (ni.gt.1) then
         LU(i(1:)) = False
      end if
      delete(i)
   end do
 
   iu = ind(LU)
   print(IR(iu))

so ......
  
    T(70,150)
  
    T1D = ndtooned(T)
    NR = 500

    TR = T1D(iu)

good luck

    

On Thu, 1 Mar 2007, Dennis Shea wrote:

> On Thu, 1 Mar 2007, Debasish Pai Mazumder wrote:
>
> > Hi All,
> > I have a temperature data which has dimension of latitude and longitude
> > like,
> >
> > T(latitude=70, longitude=150)
> >
> > So I have 70X150=10500 girded temperature. I just want to extract the
> > temperature for 500 grid points from total 10500 grids randomly.
> >
> > Is there any easy way to do that in NCL?
>
> If you are talking about 500 grid points with replicates ... yes
>
> T(70,150)
>
> T1D = ndtooned(T)
> NR = 500

> TR = T1D(IR)
>
> If you are talking about 500 unique grid points ... no easy way
>
> Generate a very large number of IR
>
> IR = round( random_uniform(0,1, 10*NR) , 3)
>
> Use a loop to get unique numbers [ IRU ] ... then use the 1st NR
>
> TR = T1D(IRU)
>
> If you find an efficient way to do this ... let me know! :-)
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 02 2007 - 01:33:29 MST

This archive was generated by hypermail 2.2.0 : Fri Mar 02 2007 - 17:25:16 MST