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

Home » Public Forums » archive » Speed problem
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
Speed problem [message #42813] Wed, 23 February 2005 10:22 Go to next message
lloyd is currently offline  lloyd
Messages: 16
Registered: February 2003
Junior Member
Hi

Can anyone help me speed up this piece of code. I've hear that using
histograms might be good, any ideas?

This piece of code takes a point centered at [pixel_z,pixel_y] and
looks for all detections within a 'radius'. The position of these
detections are defined by two arrays, z and y, giving their
coordinates. After this other things are done but this isn't a problem.
The really slow part is the pt1 where section. This identifies from the
arrays of 200,000 points, the points which lie in a box +-radius in y
and z. Then the coners are removed using then next where condition.

for pixel_y=uint(min(y)),roundup(max(y))-1 do begin
for pixel_z=uint(min(z)),roundup(max(z))-1 do begin
pt1 = where(y ge pixel_y-radius and y le pixel_y+radius and z ge
pixel_z-radius and z le pixel_z+radius)
if pt1[0] ne -1 then begin
b = where((y[pt1]-pixel_y)^2+(z[pt1]-pixel_z)^2 le radius^2)
if b[0] ne -1 then begin
a = pt1[b]
w = weight(SQRT((y[a]-pixel_y)^2+(z[a]-pixel_z)^2),FWHM/3.0)
m[(pixel_y-uint(min(y))),(pixel_z-uint(min(z)))] = total(w*s[a])
endif
endif
endfor
endfor


Any help would be greatly appriciated

Lloyd
Re: Speed problem [message #42899 is a reply to message #42813] Wed, 02 March 2005 10:41 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
Sorry, let me clarify: the "where" statement only takes about 20 ms.
Re: Speed problem [message #42900 is a reply to message #42813] Wed, 02 March 2005 10:19 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
Why do you even do the first where? Why not just do:

b = where( (y-pixel_y)^2+(z-pixel_z)^2 le radius^2 ) ?

Anyway, Your code only takes me about 20 ms?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL + Linux (Ubuntu) ??
Next Topic: make_dll and call_external....

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

Current Time: Wed Oct 08 15:47:09 PDT 2025

Total time taken to generate the page: 0.00615 seconds