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

Home » Public Forums » archive » Improving a piece of code with arrays and for-loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Improving a piece of code with arrays and for-loops [message #52584 is a reply to message #52472] Fri, 09 February 2007 04:55 Go to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
How about this:

; indsetmin (s never goes there)
indsetmin=where((tke lt rebin(tkelvl,ni,nj,ns)) or (tke_diff lt eps))

; Set windspeeds to the minimum value (you can also take 0,
; if these speeds never go below zero, which seems logical ;-))
wspmin=min(wsp)
wsp[indsetmin]=wspmin

; Maximum wsp
fgtmp[*,*,2]=max(wsp, DIMENSION=3)

; Maximum wsp where (int_diff ge 0)
wsptmp=wsp
wsptmp[where(int_diff lt 0)]=wspmin
fgtmp[*,*,0]=max(wsptmp, DIMENSION=3)

; Maximum wsp where (int_diffver ge 0)
wsp[where(int_diffver lt 0)]=wspmin
fgtmp[*,*,2]=max(wsp, DIMENSION=3)



On 8 Feb 2007 05:23:53 -0800, "Halfdan" <halfdana@gmail.com> wrote:

> for i=1,ni-2 do begin
> for j=1, nj-2 do begin
> s = ns-1
> REPEAT BEGIN
> if int_diff(i,j,s) GE 0. AND wsp(i,j,s) GT fgtmp(i,j,
> 0) then $
> fgtmp(i,j,0) = wsp(i,j,s)
> if wsp(i,j,s) GT fgtmp(i,j,1) then $
> fgtmp(i,j,1) = wsp(i,j,s)
> if int_diffver(i,j,s) GE 0. AND wsp(i,j,s) GT
> fgtmp(i,j,2) then $
> fgtmp(i,j,2) = wsp(i,j,s)
> s=s-1
> ENDREP UNTIL tke(i,j,s) LT tkelvl(i,j) OR
> tke_diff(i,j,s) LT eps
> endfor
> endfor
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: fit through zero
Next Topic: Re: TRIANGULATE. Finding contiguous cells efficiently?

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

Current Time: Fri Oct 10 08:56:45 PDT 2025

Total time taken to generate the page: 0.00630 seconds