Loop breaks IDL

This is a discussion on Loop breaks IDL within the Idl-pvwave forums in Programming Languages category; I beginning to feel like I'm inundating this board Is this the best way to do this, I 'm beginning to think not since IDL (in windows) starts to use up all my cpu cycles for more than 10 minutes. ----------------------------------------------------------------------------------------- ind_e= where (array[1,*] eq 2,count) if count eq 0 then tl_small=0 else ext=array[*,ind_e] while count gt 0 do begin ext_ = where(ext[2,*] lt 2*x1) ; select faults such that L < 2x ext_small = ext[*,ext_] ; place in matrice with identifer lc_small= ext_small[2,*] ; select only lengths to sum for small faults tl_small = total(lc_small^3) ; sum lengths according ...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-22-2008, 11:23 PM
mbweller@gmail.com
Guest
 
Default Loop breaks IDL

I beginning to feel like I'm inundating this board

Is this the best way to do this, I 'm beginning to think not since IDL
(in windows) starts to use up all my cpu cycles for more than 10
minutes.

-----------------------------------------------------------------------------------------
ind_e= where (array[1,*] eq 2,count)
if count eq 0 then tl_small=0 else ext=array[*,ind_e]
while count gt 0 do begin
ext_ = where(ext[2,*] lt 2*x1) ; select faults such that L < 2x
ext_small = ext[*,ext_] ; place in matrice with identifer
lc_small= ext_small[2,*] ; select only lengths to sum for
small faults
tl_small = total(lc_small^3) ; sum lengths according to
kostrov summation, small faults
endwhile
-------------------------------------------------------------------------------------------------------------------------------------------

Essentially there are 2 divisions, column 2 (with values of 1 or 2)
and fault size (large or small) of the data.
In case it's not obvious, the first two lines are saying that if there
is no data then tl_small = 0. If however, there is data do everything
below it to get some non 0 value of tl_small.
It seems like IDL just hangs up on the loop. Maybe this has something
to do with the embedded where statements?

As always thanks in advance and any help would be appreciated

~Matt.
Reply With Quote
  #2  
Old 08-22-2008, 11:42 PM
Jeremy Bailin
Guest
 
Default Re: Loop breaks IDL

On Aug 22, 11:23*pm, mbwel...@gmail.com wrote:
> I beginning to feel like I'm inundating this board
>
> Is this the best way to do this, I 'm beginning to think not since IDL
> (in windows) starts to use up all my cpu cycles for more than 10
> minutes.
>
> -----------------------------------------------------------------------------------------
> ind_e= where (array[1,*] eq 2,count)
> if count eq 0 then tl_small=0 else ext=array[*,ind_e]
> while count gt 0 do begin
> ext_ = where(ext[2,*] lt 2*x1) * *; select faults such that L < 2x
> ext_small = ext[*,ext_] * * * ; place in matrice with identifer
> lc_small= ext_small[2,*] * * * * *; select only lengths to sum for
> small faults
> tl_small = total(lc_small^3) * * * * ; sum lengths according to
> kostrov summation, small faults
> endwhile
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> Essentially there are 2 divisions, column 2 (with values of 1 or 2)
> and fault size (large or small) of the data.
> In case it's not obvious, the first two lines are saying that if there
> is no data then tl_small = 0. If however, there is data do everything
> below it to get some non 0 value of tl_small.
> It seems like IDL just hangs up on the loop. Maybe this has something
> to do with the embedded where statements?
>
> As always thanks in advance and any help would be appreciated
>
> ~Matt.


The probelm is that it keeps going through the loop over and over
again waiting for count to no longer be greater than zero... but count
never changes within the loop, so "count gt 0" is always true.

-Jeremy.
Reply With Quote
  #3  
Old 08-22-2008, 11:47 PM
David Fanning
Guest
 
Default Re: Loop breaks IDL

mbweller@gmail.com writes:

> I beginning to feel like I'm inundating this board
>
> Is this the best way to do this, I 'm beginning to think not since IDL
> (in windows) starts to use up all my cpu cycles for more than 10
> minutes.
>
> -----------------------------------------------------------------------------------------
> ind_e= where (array[1,*] eq 2,count)
> if count eq 0 then tl_small=0 else ext=array[*,ind_e]
> while count gt 0 do begin
> ext_ = where(ext[2,*] lt 2*x1) ; select faults such that L < 2x
> ext_small = ext[*,ext_] ; place in matrice with identifer
> lc_small= ext_small[2,*] ; select only lengths to sum for
> small faults
> tl_small = total(lc_small^3) ; sum lengths according to
> kostrov summation, small faults
> endwhile
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> Essentially there are 2 divisions, column 2 (with values of 1 or 2)
> and fault size (large or small) of the data.
> In case it's not obvious, the first two lines are saying that if there
> is no data then tl_small = 0. If however, there is data do everything
> below it to get some non 0 value of tl_small.
> It seems like IDL just hangs up on the loop. Maybe this has something
> to do with the embedded where statements?
>
> As always thanks in advance and any help would be appreciated


I would try transposing your array so you can access the
data in memory order. That should help a LOT.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #4  
Old 08-22-2008, 11:48 PM
David Fanning
Guest
 
Default Re: Loop breaks IDL

Jeremy Bailin writes:

> The probelm is that it keeps going through the loop over and over
> again waiting for count to no longer be greater than zero... but count
> never changes within the loop, so "count gt 0" is always true.


Well, that, too. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Reply With Quote
  #5  
Old 08-23-2008, 01:42 AM
mbweller@gmail.com
Guest
 
Default Re: Loop breaks IDL

On Aug 22, 8:48*pm, David Fanning <n...@dfanning.com> wrote:
> Jeremy Bailin writes:
> > The probelm is that it keeps going through the loop over and over
> > again waiting for count to no longer be greater than zero... but count
> > never changes within the loop, so "count gt 0" is always true.

>
> Well, that, too. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


It sound as if the while statement is not the correct approach, or at
least not count gt 0. What might work instead then?

~Matt
Reply With Quote
  #6  
Old 08-23-2008, 02:47 AM
Chris
Guest
 
Default Re: Loop breaks IDL

try this

ind_e=where(array[1,*] eq 2, count)
if count eq 0 then tl_small=0 else begin
ext=array[*,ind_e]
ext_test=where(ext[2,*] lt 2*x1, ct)
if ct eq 0 then tl_small=0 else tl_small=total(ext[2,ext_test]^3)
endelse

or, more compactly,

tl_small=total(array[2,*]^3*((array[1,*] eq 2) and (array[2,*] lt
2*x1)))


chris




Reply With Quote
  #7  
Old 08-23-2008, 03:51 PM
mbweller@gmail.com
Guest
 
Default Re: Loop breaks IDL

Well, that's what I get for staring at the computer screen for too
long while doing monotonous tasks, my brain stops working. I figured
out how to fix it with an if then begin statement, but it is always
nice to see other approaches, gives someone ideas.

Thanks for all the help.

~Matt

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 11:24 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.