hist_nd to place just one point on a grid [message #53703] |
Tue, 24 April 2007 15:10 |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
IDL Wizards,
I use hist_nd a great deal. One of the important things I do with it
is match gridded maps to point data sets and vice versa. Like this:
IDL> histogram = hist_nd(transpose([[point_x],[point_y]]),
[dx_grid,dy_grid],min=[minx_grid,miny_grid],max=[maxx_grid,m axy_grid],reverse_indices=ri)
followed by:
IDL> matched_pts = point_x * 0.0; initialize array to hold sampled
output
IDL> for i=0l,n_elements(histogram)-1 do if(histogram[i] gt 0) then
matched_points[ri[ri[i]:(ri[i+1]-1)]] = gridded_data[i]
or:
IDL> grid_totals = gridded_data * 0.0; initialize array to hold
gridded output
IDL> for i=0l,n_elements(histogram)-1 do if(histogram[i] gt 0) then
grid_totals[i] = total(point_data[ri[ri[i]:(ri[i+1]-1)]])
My problem is that hist_nd is unhappy when the inputs [point_x] and
[point_y] contain only one point. I could code an exception for this
case, but surely there is a more elegant solution?
|
|
|