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

Home » Public Forums » archive » 'loop limit expression too large for loop variable type' error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
'loop limit expression too large for loop variable type' error [message #72325] Mon, 30 August 2010 08:36
Snow53 is currently offline  Snow53
Messages: 32
Registered: July 2010
Member
Hi,

My code runs great on small data sets, but I'm trying to use it for
larger sets and I've started getting an
''loop limit expression too large for loop variable type' error when I
reach the "for j=0, num_ids-1 do begin". Why is this happening and
how can I fix it?

THANKS!


pro fractional_water_extraction_linux

;created by J. Watts (August 2010) .

; input: 1)file with fine spatial resolution data (300 m in this
example)
; 2)grid file of coarse resolution (25 km in this example).
create using lingen().
; 3)grid file with fine resolution (create by resampling the
coarse resolution grid to the resolution of
; the input fine with fine resolution data; generates pixels
with id values with that of the coarse res. grid).
; This grid was cliped to the same spatial extent of the fine
resolution input data.

; output: a coarse resolution (25 km) file with fractional coverage
information for each pixel.

; program objective: Determine fractional coverage of a certain DN
value for all fine resolution pixels within each
; coarse resolution pixel. Output fractional value for each coarse
pixel in envi binary file.





; Open index grids and store in arrays

coarse_grid = lonarr(368,390)
fine_grid = lonarr(30595,32478)


OPENR, lun1, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/
25km_EASE_grid_subset_PanArctic_unq_ID', /get_lun
READU, lun1, coarse_grid
close, lun1
free_lun, lun1

OPENR, lun2, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/
25km_EASE_grid_subset_PanArctic_unq_ID_300m_subGlob', /get_lun
readu, lun2, fine_grid
close, lun2
free_lun, lun2

; Initialize input grid that will hold high resolution VI data

in_data_grid = bytarr(30594,32477, 1)
openr, lun3, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/
Globcover_NEASE', /get_lun
readu, lun3, in_data_grid
close, lun3
free_lun, lun3

;determine input grid data layer

VI=in_data_grid[*,*,0]

;determine output grid
out_grid = fltarr(368,390,1)


;determine the unique id values from the grid and sort these values
by order

coarse_ids = fine_grid[UNIQ(fine_grid, SORT(fine_grid))]
;print, coarse_ids

; determine the number of returned unique coarse_ids

num_ids = n_elements(coarse_ids)
;print, num_ids

; loop through each coarse_id number

for j=0, num_ids-1 do begin ; this is where I get that
error message

id = coarse_ids[j]

;count how many fine pixels occur at coarse_ids[j]
id_index = where(fine_grid EQ id, count)
count=count
fcount=float(count)
print, count



if count EQ 0 then begin
Fclass = -9999 ; gives this value to the output pixel

endif else begin

; determine how many fine pixels of a certain class are within the
coarse pixel, and have a value equal to 210.

class=210

indexed_pixels=VI(id_index)
count_class = where(indexed_pixels EQ class,count)
count2=count
fcount2=float(count2)

; print, count2

if count EQ 0 then begin
Fclass = 0
endif else begin

;compute the fraction of pixels with VI equal to 210 out of total
count.



Fclass = (fcount2 /fcount)
;print, Fclass

endelse
endelse

; place the fractional values in an out-grid
out_grid[id] = Fclass


endfor

; write the grid containing the fractional values to a file
openw, out_lun, '/measures/MODIS_MERIS_Water_Cover_panArctic/GlobCover/
GlobCover_Fractional_Water_Maps/GlobCover_FW_C210' , /get_lun
writeu, out_lun, out_grid
close, out_lun
free_lun, out_lun


end
[Message index]
 
Read Message
Previous Topic: Workspace Path Variable?
Next Topic: Re: Workspace Path Variable?

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

Current Time: Wed Oct 08 19:56:17 PDT 2025

Total time taken to generate the page: 0.00370 seconds