| Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41423 is a reply to message #41419] |
Fri, 22 October 2004 08:32  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Gianguido wrote:
> Hi everyone,
>
> here's my problem:
> I have an 3 x N array. the 3 cols represent r,t and F(r,t). I don't
> know what the function F is I just have some noisy data to fill the
> matrix.
>
> I would like to compute a 2d image where the intensity of each pixel
> is proportional to the average value of F(r,t) and where the
> coordinates of the pixel in question is related to the value of r and
> t.
>
> I have two further points:
>
> 1) r and t are continuous so I would like to create bins along the
> axes
> 2) within a given bin (or a given r and t range) F(r,t) can have
> different values, so I need to compute the average of F over the bin.
>
Two functions will help you here (for IDL 5.5+) GRID_INPUT will handle
duplicates in a variety of ways (including average). If you are OK with
interpolating from there, use GRIDDATA to manufacture the 2D 'image'.
If you don't want to interpolate across 'empty' cells, but would rather
'sprinkle' your data onto the image - then you will need to translate your r and
t data pairs into 'image coordinates'. I think something like the following
(kind of thinking out loud here, I have not tried this in a long time)...
nX = imageXSize ;these are based on what resolution you
ny = imageYSize ;need in r and t space
data = MAKE_ARRAY(nx,ny, VALUE = !VALUES.F_NAN)
count = LonArr(nx,ny)
;normalize r and t - then scale up to image coordinates
rValues = (r - MIN(r))/(MAX(r)-MIN(r)) * (nX -1)
tValues = (t - MIN(t))/(MAX(t)-MIN(t)) * (nY -1)
;sprinkle the data onto the image
for i = 0L, n_elements(f)-1 Do Begin
data[rValues[i],tValues[i]] += f[i]
count[rValues[i],tValues[i]] += 1
EndFor
;find the mean of the data
;you could skip this part if you first filtered the data
;using GRID_INPUT with DUPLICATES = 'AVG'
;in which caase data already holds the mean values
data[rValues,tValues] /= count[rValues,tValues]
>
> PS: this group seems more active than the "plain" lang.idl. what is
> the difference between idl and idl-pvwave?
I think the .idl group works with "Interface Definition Language" while
idl-pvwave is for IDL and PVWAVE (and David Fanning's tennis game.) The .idl
groupies might be quieter? Perhaps they are Yankees fans? I don't follow pro
sports, but I noticed my rabid Red-Sox-fan co-workers high-fiving and hugging
each other lately - they certainly aren't quiet.
|
|
|
|