Hello Everyone.
I processed time series MOD13q1 16 days for 2000-2010, 250 images,on my layer stack, but need monthly ploting... I have found this script but no found runs but does not write the correct information...........
threshold=0
name="MOD13Q1.B0."
cutoffdays=[1,32,60,91,121,152,182,213,244,274,305,335]
months=['01','02','03','04','05','06','07','08','09','10','11','12']
ofolder='/home/david/xx/'
; *********************************************************************
; Select ENVI file
ENVI_SELECT, fid=fid, dims=dims, pos=pos, title='Pick the image to subset'
if (fid[0] eq -1) then return
ENVI_FILE_QUERY, fid, fname=fname, bnames=bnames, ns=ns, nl=nl, nb=nb
map_info = ENVI_GET_MAP_INFO(fid=fid)
; Select input folder that contains all files
PRINT, FORMAT=F120S
PRINT, 'Opening file: ', fname
PRINT, FORMAT=F80
; Actual processing
sumdata=INTARR(nl,ns)
ndata=INTARR(nl,ns)
for i = 0L, nb-1 do begin
year=STRMID(bnames[i],STRPOS(bnames[i],name)+11,4)
day=STRMID(bnames[i],STRPOS(bnames[i],name)+15,3)
result=WHERE(cutoffdays EQ UINT(day))
if (result[0] NE -1) then begin
; Calculate output
ndata[ WHERE(ndata eq 0)]++
data=float(sumdata)/float(ndata)
; Write data to file
out_name=ofolder+name+year+months[result]
PRINT, FORMAT=F80
PRINT, 'Writing file: ', out_name
ENVI_WRITE_ENVI_FILE, data, out_name=out_name, data_type=4, map_info=map_info, nb=1, ns=ns, nl=nl
PRINT, '----> DONE'
; Reset data
PRINT, FORMAT=F80
sumdata=INTARR(nl,ns)
ndata=INTARR(nl,ns)
endif
PRINT, year + ' - ' + day
temp = ENVI_GET_DATA(fid=fid, dims=dims, pos=i)
sumdata[WHERE( temp ge threshold)] += temp[WHERE( temp ge threshold)]
ndata[WHERE( temp ge threshold)]++
endfor
; Write data to file
out_name=ofolder+name+year+'12'
PRINT, FORMAT=F80
PRINT, 'Writing file: ', out_name
ENVI_WRITE_ENVI_FILE, data, out_name=out_name, data_type=4, map_info=map_info, nb=1, ns=ns, nl=nl
PRINT, '----> DONE'
END
|