读取由NetCDF转存成的tiff文件(365or366个波段),求每个像素365个波段的Max,并重写成新的tiff文件
pro runnian
path='F:c2'
fname=file_search(path,'*.tif',count=fnums)
for n=0,fnums-1 do begin
print,fname[n]
d=read_tiff(fname[n])
name=strmid(fname[n],11,4)
print,name
if (name mod 400 eq 0) or (name mod 4 eq 0 and name mod 4 ne 100) then begin
print, name + "是闰年"
data=dblarr(240,121,366)
for i=0,365 do begin
for j=0,239 do begin
for k=0,120 do begin
data[j,k,i]=d[i,j,k]
endfor
endfor
endfor
help,data
a=dblarr(366)
newarr=dblarr(240,121)
for j=0,239 do begin
for k=0,120 do begin
for i=0,365 do begin
a[i]=data[j,k,i]
newarr[j,k]=max(a)
endfor
endfor
endfor
write_tiff,'F:a1max'+name+'.tiff',newarr,/double
endif else begin
data=dblarr(240,121,365)
for i=0,364 do begin
for j=0,239 do begin
for k=0,120 do begin
data[j,k,i]=d[i,j,k]
endfor
endfor
endfor
help,data
a=dblarr(365)
newarr=dblarr(240,121)
for j=0,239 do begin
for k=0,120 do begin
for i=0,364 do begin
a[i]=data[j,k,i]
newarr[j,k]=max(a)
endfor
endfor
endfor
write_tiff,'F:a1max'+name+'.tiff',newarr,/double
endelse
endfor
print, 'success'
end