Re: IDLy approach to splatting points on a grid? [message #51467 is a reply to message #51462] |
Fri, 24 November 2006 10:52   |
MarioIncandenza
Messages: 231 Registered: February 2005
|
Senior Member |
|
|
Jonathan,
This problem sounds worth some attention. I'm missing a few details, so
I hope I don't obfuscate the thread. I am going to assume that 1) your
problem actually is 2-D, and 2) you really want square windows (not
radii? really?), and 3) each particle has BOTH a radius of influence
AND a value it contributes. These assumptions are probably wrong,
but...
I generally brainstorm these with the following thought experiment:
"If memory was no limitation, how would I solve the problem?"
In this case, like this:
particle_x; particle x-coords
particle_y; particle y-coords
particle_r; particle size of window (R=2 => 5x5)
particle_v; particle values
n_particles=n_elements(particle_r); number of particles
nx_grid; x-dim of grid
ny_grid; y-dim of grid
;make HUGE arrays
big_x = rebin(lindgen(nx_grid),nx_grid,ny_grid,n_particles)
offset_x = temporary(big_x) - $
rebin(particle_x,nx_grid,ny_grid,n_particles)
big_y = rebin(transpose(lindgen(ny_grid)),nx_grid,ny_grid,n_particle s)
offset_y = temporary(big_y) - $
rebin(transpose(particle_y),nx_grid,ny_grid,n_particles)
big_r=rebin(reform(particle_r,[1,1,n_particles]),nx_grid,ny_ grid,n_particles)
big_v=rebin(reform(particle_v,[1,1,n_particles]),nx_grid,ny_ grid,n_particles)
; Make a binary array of "influenced' cells;
yesno = (offset_x le big_r) * (offset_y le big_r)
; That's easy to modify to use radii instead
answer= yesno * big_v
Obviously, memory limitations present a problem. But if you looped the
problem over values of R or V, you need only 3 giant arrays, and if you
chunked the problem according to what you could fit in memory, I expect
you could get something acceptably fast.
I'd like to see how this gets resolved. We all need more practice with
REBIN/REFORM magic.
Good luck,
Edward H.
|
|
|