Hi,
I know that the error above indicates that I'm trying to assign something into an array that doesn't fit the array dimensions. However, in this case, the error arises the _second_ time through a loop but not the first. I've tried several things and found that it's not the input data that's the problem, or the reinitialization of the variables. The file read statement also works properly. Any idea what's wrong?
Thanks,
Laura
Notes: bad = -9999.0
The error message is
% Array subscript for PLOTSTATS must have same size as source expression.
% Execution halted at: $MAIN$ 54
where line 54 is plotstats[*,i] = stats[0:4] about half way down in the code below.
stats[6] eq bad will not occur until the second time through the loop, but the error occurs
before that happens. (I checked the values of the read variables.)
;----------------------------------------------------------- --
txt1 = ' ' ; Dummy read variables.
site = ' '
season = ' '
n = 0
;----------------------------------------------------------- --
; Bar and whiskers plots for all sites individually.
nsites = 7
sites = strarr(nsites)
stats = fltarr(7)
seasons = strarr(nsites)
plotstats = fltarr(5,nsites)
means = fltarr(nsites)
npoints = intarr(nsites)
infile = indir + 'site.whiskerplot.stats.3hourly.surfrad.match.snow.LWcorr.so rt.txt'
openr, 3, infile ; Read past header. Number of header lines hard wired.
for i = 0, 4 do begin
readf, 3, txt1
endfor
for j = 0, 1 do begin ; For snow and all conditions.
plotstats[*,*] = bad
means[*] = bad
npoints[*] = 0
for i = 0, nsites-1 do begin
readf, 3, format = '(A7, 7F12.2, I10, A15)', site, stats, n, season
sites[i] = site
seasons[i] = season
npoints[i] = n
means[i] = stats[5]
plotstats[*,i] = stats[0:4]
if (stats[6] eq bad) then begin
plotstats[0,i] = bad ; Make all stat values bad. (This would be 0 otherwise.)
plotstats[4,i] = bad
endif else begin
plotstats[0,i] = means[i] - stats[6] ; Substitute mean+/-std. dev. for max and min.
plotstats[4,i] = means[i] + stats[6]
endelse
endfor
locations = indgen(nsites)+1
; if (j eq 0) then npoints1 = max(npoints)
npoints1 = max(npoints)
xwidth = npoints * 0.3 / npoints1 ; Width proportional to the number of points.
xvals = [-1,nsites+2]
titletext = 'Surface-CERES differences, corrected LW, ' + strtrim(seasons[0],2) + ' samples'
dummy = boxplot(locations, plotstats, mean_values = means, ytitle = 'Irradiance differences [Wm$^{-2}$]',yrange = [-100,80], width=x
width, thick=3, xtickname = ['', strtrim(sites,2), ' '], xtext_orientation=90, xminor = 0, xthick = 2, ythick = 2, title = titletext)
graphic = plot(xvals,yvals,overplot = 1,xrange = [0,nsites+1])
endfor
|