Re: random extraction of data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 1 Mar 2007 21:24:30 -0700 (MST)

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 Thu Mar 01 2007 - 21:24:30 MST

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