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 #64256 is a reply to message #64172] Wed, 10 December 2008 13:20 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Hi Du,

ok, so you have a set of X and Y coordinates

You want to plot them in a regular grid, so to know in which cell to
plot the corresponding data, you divide the coords by the cell size
ex: X = [1,2,2.5]
cellSizeX = 0.5

NewX = X/cellSizeX
==> 2.00000 4.00000 5.00000
==> on the grid, your point will be in cell 2,4 and 5
grid: 0-0.5-1-1.5-2-2.5-3-3.5-4-4.5-5 etc

Now, you want to know the size of your grid, so you do
nbCol = ceil((maxX+1.0) / cellSizeX)

this assume that the 1st cell of the grid is coord 0;0, do maxX-minX if not.
So basically, you take the highest X value and divide by the cell size.
Up-round this, so that you are sure that the new coord is within your grid.

Create a grid (an array) with the number of columns and rows. Create a
"count" layer, that you will use for doing the average.

For each point that you have, using the new X and Y coordinate, you
1)add the value V to the image,
2) add 1 to the count layer

then, simply divide the image by the count, and you get the average
value in each pixel.

Jean


> Excuse me!
> I do not understand your routine.
> Could you show me an example? or give me some detailed explanations?
>
> Du
>
>
> On Dec 10, 9:05 pm, "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
>
[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: Sat Oct 11 21:33:29 PDT 2025

Total time taken to generate the page: 0.55831 seconds