Re: random extraction of data

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon, 05 Mar 2007 12:40:28 -0700

Hi Debasish,

At the bottom of the script Dennis sent you he uses ind_resolve to
return the indices of the input array that were randomly chosen using
the unique_index function he created for you..

You can use output of ind_resolve to do what you want as is shown in
Example 3 of the ind_resolve webpage:
http://www.ncl.ucar.edu/Document/Functions/Built-in/ind_resolve.shtml

You will want to use gsn_add_polymarker to draw the locations of these
random points...

continuing on from Dennis's script:

iT = unique_index (product(dimsizes(T)), nUnq, 0)
ir = ind_resolve(iT, dimsizes(T) ) ; 2D [500,2]
printVarSummary(ir)

; will assume T has coordinate variables lon and lat
lat = T&lat
lon = T&lon

wks = gsn_open_wks("x11","test")
res = True
res_at_gsnDraw = False
res_at_gsnFrame = False

plot = gsn_csm_map_ce(wks,res)

xres = True
xres_at_gsMarkerIndex = 1
xres_at_gsMarkerColor = "black"
xres_at_gsMarkerThicknessF = 3.0
pmarker = gsn_add_polymarker(wks,plot,lon(ir(:,1)),lat(ir(:,0)),posRes)
draw(plot)
frame(wks)

Good luck,
Adam

Debasish Pai Mazumder wrote:
> Dear Dennis,
>
> Thanks again for your solution. unique_index function is working perfectly.
> I have already get 500 unique grid points using your solution. Now I am
> trying to mark this grid points on contour map. I think I need to use
> polymarker examples. But I do not figure it out how will I convert those
> grid points to x and y for using polymarker examples or any other way to
> mark those grid points in a contour map?
>
> Any help will be appreciated
>
> Thanks in advance
>
> Debasish
>
> -----Original Message-----
> From: Dennis Shea [mailto:shea_at_cgd.ucar.edu]
> Sent: Friday, March 02, 2007 8:53 AM
> To: debasish_at_gi.alaska.edu
> Cc: ncl-talk_at_ucar.edu
> Subject: RE: [ncl-talk] random extraction of data
>
>> 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)
>>
>> -----Original Message-----
>
> I took another look. Attached is a simple function.
> This works fine for small grids. Otherwise, it may be
> a bit slow.
>
> Please note: Just because the grid locations are randomly
> sampled does not mean that the sampled values
> are random (independent).
>
> ie: if (say) the 37th random subscript
> corresponds to T(15,38) and the (say)
> 437th random subscript corresponds
> to T(15,39), clearly T(15,38)
> and T(15,39) are not independent.
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Mar 05 2007 - 12:40:28 MST

This archive was generated by hypermail 2.2.0 : Mon Mar 12 2007 - 11:26:34 MDT