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

Home » Public Forums » archive » 2-d histogram and Routines of same name
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
2-d histogram and Routines of same name [message #70992] Mon, 17 May 2010 02:33
Mrunmayee is currently offline  Mrunmayee
Messages: 24
Registered: May 2009
Junior Member
Jeez, my original problem something completely different... Still. I
have a dataset with x,y values (about 700 each). These values range
from about [200,800] and [200,1200]. I place a grid of size 2 (in data
units) on this x,y plot. Now I paint the square as 1 if it contains a
point, 0 if it doesn't. In IDL way this is what I do.

dl = 2 ; gridsize
grid = fltarr(300,500) ; with above gridsize, this would be size of
grid.
ix = FIX( (x-(min(x))/dl ) & jy = FIX( (y-min(y)).dl) ; This converts
x,y to integers and literally gives indices where grid will become 1.
grid[ix,jy] = 1

Now my aim is to count points in each grid cell. That is I want to see
typically how many points are there in a cell. A brute force solution
would be something like this:
counter = intarr(300,500) ; Size of grid
for i = 0,299 do begin
for j = 0, 499 do begin
index = where(x ge i*dl and x lt (i+1)*dl AND y ge j*dl and y lt
(j+1)*dl, nindex)
counter[i,j] = nindex
endfor
endfor

So my first problem is how to do this IDL way?

Then I felt this is a histogram problem. So went to IDL's hist_2d
which does what I want, but doesn't return reverse indices. But I did
find hist_nd written byt David. This routine uses PRODUCT(.., /
Preserve_Type). Unfortunately, idlastrolib ALSO contains the routine
of the same name which DOESN'T use the keywords in IDL's routine. So I
keep getting KEYWORD NOT ALLOWED error. My guess is that (becaue of
various issues, I have to set my IDL_PATH such that) this other
routine always get compiled first. When I have such a problem, of
having two routines of same name doing things differently, I usually
compile with full path. E.g

.com /path/to/routine/I/want/routinename

But I don't think there is any product.pro in IDL's libs. So my second
problem is how do I tell IDL to use inbuilt function instead of user
written when there is no .pro file associated with it?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Viewing Shapefiles in IDL
Next Topic: Keyword TNAME not allowed in call to: DATATYPE

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

Current Time: Wed Oct 08 11:44:07 PDT 2025

Total time taken to generate the page: 0.00482 seconds