idl programming language - IDL for loop overwrites data -
i have problem for-loops in idl.
for sl=0,2 begin ; number of hours t=90,90 begin ; timesteps each hour rad_num = 0, 3 begin ; number of radars ibin = 0, 333 begin ; distance radar iray = 0, 359 begin ; angle if finite(input(ibin,iray,rad_num)) eq 1 begin bin = bin_index(ibin,iray,rad_num) ray = ray_index(ibin,iray,rad_num) ; necessary because of different grids array(sl,t,ray,bin)=array(sl,t,ray,bin)+ input(ibin,iray,rad_num) array_n(sl,t,ray,bin) = array_n(sl,t,ray,bin) + 1. endif endfor endfor endfor endfor endfor array = array / array_n
when stopped program after first sl-loop-step, following:
print, array[0,90,315,49] 44.0.673
but when don't stop program, this:
print, array[0,90,315,49] -nan
it seems, program overwrites data of previous loop-step. when make scatter-plot, have points of last loop-step only...
do see mistake? lot! kiki
you don't assign dwd
in code show (and code won't compile as-is because of enddo's -- assume had rewrite code instead of copy-and-past reason?).
Comments
Post a Comment