2-d histogram and Routines of same name [message #70992] |
Mon, 17 May 2010 02:33 |
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?
|
|
|