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

Home » Public Forums » archive » Speeding up a call to the where function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Speeding up a call to the where function [message #59027] Tue, 04 March 2008 13:08
nathan12343 is currently offline  nathan12343
Messages: 14
Registered: August 2007
Junior Member
Hi all-

Let's first try and explain what this bit of code does. I have an
array, centerdist, a 512 X 512 array which represents the distance
form any particular pixel to some point of interest in the 512 X 512
window. I also have an array of radii, rads, and I want to find the
indices which have a centerdist value between two particular radii
values in rads. I also have a 512 X 512 mask array which tells me
which pixels to ignore. I find the pixels that aren't masked out and
are the correct distance from the point of interest, and I save their
indices in heap variables referenced by an array of pointers, annpix.
The code looks like this:

centerdist=sqrt((xdist-xc)^2 + (ydist-yc)^2)
rads=(dindgen(nrads+1))*info[j].radius^2/10
rads=sqrt(rads)
FOR anNum=0,nrads-2 DO BEGIN
startwh=systime(1)
whpix=where(centerdist LE rads[annum+1] AND centerdist GT
rads[annum] AND $
mask eq 1)
IF (whpix NE [-1]) THEN BEGIN
*annpix[annum]=[*annpix[annum],whpix]
ENDIF
ENDFOR

The problem is, that where function call takes a prohibitive amount of
time and since I need to do this thousands of times, my code is really
slow.

Since the only pixels I'm interested in are in a little window (~ 30 X
30 pixels instead of 512 X 512 pixels), I don't really need to search
through all of centerdist. I would have to convert the indices the
where function returns using a smaller window to the indices I get now
and I have no idea how to do this.

Does anyone know how one might go about speeding my code up?

Thanks for your help, I'll try and answer any questions you might
have.

-Nathan
[Message index]
 
Read Message
Previous Topic: Convenient IGRF in IDL
Next Topic: Re: Convenient IGRF in IDL

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

Current Time: Sat Oct 11 22:25:41 PDT 2025

Total time taken to generate the page: 1.39438 seconds