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

Home » Public Forums » archive » Avoiding 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
Avoiding FOR loops ? [message #40673] Wed, 25 August 2004 03:31
sdj is currently offline  sdj
Messages: 20
Registered: November 2003
Junior Member
Dear All,

Is there a away to avoid the FOR loops in the following code:

;no. of months & no. of lat, lon points
n_months = 256
lon = 1304
lat = 1028

;3-D array with SST observations for all
;months and all pixels - Populated
data_all = fltarr(n_months, lon, lat)

;Array of all valid observations across all months
;for all pixels - To be populated
data_obs = intarr(lon, lat)

;Array of mean values across all months
;for all pixels - To be populated
data_mean = fltarr(lon, lat)

;Array of median values across all months
;for all pixels - To be populated
data_median = fltarr(lon, lat)

;The values of LAND to be avoided
;Bad value obs is defined as 0
def_val = -9999.9

FOR ilon = 0, lon - 1 DO BEGIN
FOR ilat = 0, lat - 1 DO BEGIN
valid = where(data_all(*, ilon, ilat) NE def_val AND $
data_all(*, ilon, ilat) NE 0, count = valid_obs)
data_obs(ilon, ilat) = valid_obs
data_mean(ilon, ilat) = mean(data_all(*, ilon, ilat))
data_median(ilon, ilat) = median(data_all(*, ilon, ilat))
ENDFOR
ENDFOR

It seems to me that I am not exactly speeding things up by using this method...

Thanks in advance for your help.

Regards,
Pepe


*************************************************
Pepe S. D. Juevara

- No debe cambiarse de caballo al cruzar el r�o -
*************************************************
[Message index]
 
Read Message
Previous Topic: Re: Max X-window width under OS X/X11
Next Topic: AVHRR Level 1B reader?

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

Current Time: Wed Oct 08 20:02:56 PDT 2025

Total time taken to generate the page: 0.76191 seconds