comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to represent the spatial distribution of a parameter
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to represent the spatial distribution of a parameter [message #64248 is a reply to message #64172] Thu, 11 December 2008 07:34 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Dec 10, 8:05 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> Hi,
>
> I did something similar a while ago... here is part of it:
>
> newX = Xdata / CellSizeX    ;Agregate the data
> newY = Ydata / CellSizeY
>
> nbCol = ceil((maxX+1.0) / cellSizeX)
> nbRow = ceil((maxY+1.0) / cellSizeY)
> nPoint = n_elements(newX)
>
> image = lonarr(nbCol, nbRow)
> nbPointsXY = lonarr(nbCol, nbRow)
>
> for i = 0L, nPoint-1 do begin
>      image[newX[i], newY[i]] += v[i]
>      nbPointsXY[newX[i], newY[i]] += 1
> endfor
>
> image /= nbPointsXY   ;do the average
>
> tvscl, image
>
> Jean

If there are on average lots of points per grid cell, it would be more
efficient to use the reverse indices in David's HIST_ND:

histimage = hist_nd(transpose([[X],[Y]], [binX,binY], $
min=[minX,minY], max=[maxX,maxY], reverse_indices=hiri)
meanimage = fltarr(size(histimage,/dimen))
for i=0l,n_elements(histimage)-1 do if histimage[i] gt 0 then $
meanimage[i] = mean(V[hiri[hiri[i]:hiri[i+1]-1]])

If performance is still a serious issue, you should go read
http://www.dfanning.com/code_tips/drizzling.html (it's effectively the
same thing - you just need to divide by histimage at the end). In
fact, go read it anyway - it's very illuminating. :-)=

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: % RESTORE: Procedure RUNFROMIDL can't be restored while active.
Next Topic: widget_tab

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 13:12:40 PDT 2025

Total time taken to generate the page: 2.08022 seconds