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

Home » Public Forums » archive » Re: Help: Plotting 3d data as 2d intensity map or histogram
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41397] Mon, 25 October 2004 10:20
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Thu, 21 Oct 2004 20:07:14 -0700, 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.
>
> I thought hist_2d could do it but that is not what I need... any help
> or suggestions? I have no idea about how to go about coding...
>
> Many thanks for any help you can give!

Using HIST_ND (http://www.dfanning.com/programs/hist_nd.pro) with
reverse indices should do the trick. You bin the data in 2D (choose an
appropriate number of bins in each direction), and then compute the
total (or average) F value in each bin by visiting the reverse indices
one at a time (they will be indices to the row of the 3xn array you
mention).

All together it would look like, calling your array "a":

im=hist_nd(a[0:1,*],NBINS=[20,20],REVERSE_INDICES=ri)
F_im=make_array(/FLOAT,size(im,/DIMENSIONS))
for j=0,n_elements(im)-1 do if ri[j+1] gt ri[j] then $
F_im[j]=total(a[2,ri[ri[j]:ri[j+1]-1]])

JD
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41408 is a reply to message #41397] Mon, 25 October 2004 06:07 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Gianguido wrote:
> Thanks a lot everyone!
> I'll try the code you suggested....
>
> Initially i was wondering why nobody had answered my call for help.
> Then, all of a sudden I got your suggestions and I think I know how
> all this works:
>
> You guys have "actual" jobs during the day and by night, you put your
> IDL capes/superhero costumes on and get on this list to help poor
> newbies like my self... it's a very noble cause :-D
>
> Grazie tanto,
> Gianguido

I think you're only partially right. Most of us have jobs (I hope!), but
I sent you my reply at midday, from work. I consider reading
comp.lang.idl-pvwave to be a work-related activity.

A lot of the people on this newsgroup are based in the US. Judging from
your "Grazie tanto", I suspect that working hours for us correspond to
after-work hours for you, and that may be the real reason for the delay
you mentioned.
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41414 is a reply to message #41408] Sat, 23 October 2004 12:47 Go to previous message
gianguido is currently offline  gianguido
Messages: 2
Registered: October 2004
Junior Member
Thanks a lot everyone!
I'll try the code you suggested....

Initially i was wondering why nobody had answered my call for help.
Then, all of a sudden I got your suggestions and I think I know how
all this works:

You guys have "actual" jobs during the day and by night, you put your
IDL capes/superhero costumes on and get on this list to help poor
newbies like my self... it's a very noble cause :-D

Grazie tanto,
Gianguido
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41416 is a reply to message #41414] Fri, 22 October 2004 14:33 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
James Kuyper writes:

> Which 1/2 of you are they within?

This happens when you are learning a new language.
You can't decide if it is "miles" or "kilometers"
and while you are thinking, your brain just freezes
up on you. It must happen a dozen times a day to me,
at least. :-)

The good news is, I'll speak German when I get home.
The bad news is, I won't remember any English. Sigh...

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41418 is a reply to message #41416] Fri, 22 October 2004 11:48 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
David Fanning wrote:
...
> Alas, 17 clay courts within 1/2 of me and I haven't played
> tennis once. :-(

Which 1/2 of you are they within?
:-)
Re: Help: Plotting 3d data as 2d intensity map or histogram [message #41419 is a reply to message #41418] Fri, 22 October 2004 10:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ben Tupper writes:

> I think the .idl group works with "Interface Definition Language" while
> idl-pvwave is for IDL and PVWAVE (and David Fanning's tennis game.)

Alas, 17 clay courts within 1/2 of me and I haven't played
tennis once. :-(

I did buy some tennis balls, though. I paid 13 Euro for
four balls. "Nine, nine,", I said, not the gold-plated ones!
But, yes, this is what even the ordinary balls cost. Guess
I'm going to give up tennis and learn UNIX administration.
Will have to if I'm going to pay for those balls.

Cheers,

David

P.S. I'm trying to think of something IDL-related to
mention, but nothing occurs to me. :-(

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
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 Go to previous message
btt is currently offline  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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: CW_FORM: Can't seem to get SET_VALUE to work
Next Topic: Re: 2D histogram color plot

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

Current Time: Fri Oct 10 14:03:13 PDT 2025

Total time taken to generate the page: 0.64120 seconds