- 积分
- 1323
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-8-5
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位高手好,小弟想用IDL批量处理MODIS气溶胶产品MOD04_L2.目前已经能够实现程序的目的,但是我有一个疑惑,不知道为什么当读取的数据超过了一定数量时,程序就会自动停止。报错图所示。求各位大神帮忙看看程序哪里错了~数据是没有问题的。我试过了,当数据量在20个左右的时候程序是可以正常运行的,但是数据多了就不行了……坐等高手回复!
说明,这里批处理用到的文件名都是用windows的批处理实现的,只是用IDL都取了文本。相见附件!
由于数据量较少时程序运行正常,所以就不方便上传大量数据了!各位可以利用一下自己现有的数据资源~谢谢!
;+
; :Author: Qing
;-
PRO readMOD ;read mod04_l2
PRINT,'___________________________________________________________________________________________________________________'
;打开批处理路径文件in.txt
FILENAMEIN=DIALOG_PICKFILE(PATH='I:\TDDOWNLOAD\20100320sandstrom\MOD04-L2\20100320',TITLE='打开批处理文件in.txt',FILTER='*txt')
;打开批处理名称文件out.txt
FILENAMEOUT=DIALOG_PICKFILE(PATH='I:\TDDOWNLOAD\20100320sandstrom\MOD04-L2\20100320',TITLE='打开批处理文件out.txt',FILTER='*txt')
;合成一天的数据day.txt
;FILEDAY='I:\TDDOWNLOAD\20100320sandstrom\MOD04-L2\20100320\20100320.txt'
;open the file in.txt
OPENR,1,FILENAMEIN
OPENR,2,FILENAMEOUT
;OPENW,3,FILENAMEDAY
;define a string variable
IN=''
OUT=''
YEAR=''
NUMBER=''
MONTH=''
TIME=''
NAME=''
;;
;READF,2,FILEOUT
;;
;loop until eof is found
WHILE ~EOF(1) DO BEGIN
;read a line of text
READF,1,IN
READF,2,OUT
;分别将文件路径和文件名赋值给FILEIN AND FILEOUT
FILEIN=IN
;;;判断是否为同一天的数据
;JUG=STRCMP(DATE,OUT,15,/FOLD_CASE)
;PRINT,JUG
;;;
FILEOUT=OUT
;;;DATE Result = STRMID('abcdefttt',2,4) 从第2+1个字符开始提取4个字符
YEAR=STRMID(OUT,8,4)
NUMBER=STRMID(OUT,12,3)
;;;判断是否为闰年
IF ((YEAR MOD 4) EQ 0 AND (YEAR MOD 100) NE 0) OR ((YEAR MOD 400) EQ 0) THEN BEGIN
;'RUNNAIN'
;;
IF (NUMBER LE 31) THEN MONTH='01'+STRMID(STRING(NUMBER),6,2)
IF (NUMBER GT 31 AND NUMBER LE 60) THEN MONTH='02'+STRMID(STRING(NUMBER-31),6,2)
IF (NUMBER GT 60 AND NUMBER LE 91) THEN MONTH='03'+STRMID(STRING(NUMBER-60),6,2)
IF (NUMBER GT 91 AND NUMBER LE 121) THEN MONTH='04'+STRMID(STRING(NUMBER-91),6,2)
IF (NUMBER GT 121 AND NUMBER LE 152) THEN MONTH='05'+STRMID(STRING(NUMBER-121),6,2)
IF (NUMBER GT 152 AND NUMBER LE 182) THEN MONTH='06'+STRMID(STRING(NUMBER-152),6,2)
IF (NUMBER GT 182 AND NUMBER LE 213) THEN MONTH='07'+STRMID(STRING(NUMBER-182),6,2)
IF (NUMBER GT 213 AND NUMBER LE 244) THEN MONTH='08'+STRMID(STRING(NUMBER-213),6,2)
IF (NUMBER GT 244 AND NUMBER LE 274) THEN MONTH='09'+STRMID(STRING(NUMBER-244),6,2)
IF (NUMBER GT 274 AND NUMBER LE 305) THEN MONTH='10'+STRMID(STRING(NUMBER-274),6,2)
IF (NUMBER GT 305 AND NUMBER LE 335) THEN MONTH='11'+STRMID(STRING(NUMBER-305),6,2)
IF (NUMBER GT 335 AND NUMBER LE 366) THEN MONTH='12'+STRMID(STRING(NUMBER-335),6,2)
ENDIF ELSE BEGIN
;'PINGNIAN'
;;
IF (NUMBER LE 31) THEN MONTH='01'+STRMID(STRING(NUMBER),6,2)
IF (NUMBER GT 31 AND NUMBER LE 59) THEN MONTH='02'+STRMID(STRING(NUMBER-31),6,2)
IF (NUMBER GT 59 AND NUMBER LE 90) THEN MONTH='03'+STRMID(STRING(NUMBER-59),6,2)
IF (NUMBER GT 90 AND NUMBER LE 120) THEN MONTH='04'+STRMID(STRING(NUMBER-90),6,2)
IF (NUMBER GT 120 AND NUMBER LE 151) THEN MONTH='05'+STRMID(STRING(NUMBER-120),6,2)
IF (NUMBER GT 151 AND NUMBER LE 181) THEN MONTH='06'+STRMID(STRING(NUMBER-151),6,2)
IF (NUMBER GT 181 AND NUMBER LE 212) THEN MONTH='07'+STRMID(STRING(NUMBER-181),6,2)
IF (NUMBER GT 212 AND NUMBER LE 243) THEN MONTH='08'+STRMID(STRING(NUMBER-212),6,2)
IF (NUMBER GT 243 AND NUMBER LE 273) THEN MONTH='09'+STRMID(STRING(NUMBER-243),6,2)
IF (NUMBER GT 273 AND NUMBER LE 304) THEN MONTH='10'+STRMID(STRING(NUMBER-273),6,2)
IF (NUMBER GT 304 AND NUMBER LE 334) THEN MONTH='11'+STRMID(STRING(NUMBER-304),6,2)
IF (NUMBER GT 334 AND NUMBER LE 365) THEN MONTH='12'+STRMID(STRING(NUMBER-334),6,2)
ENDELSE
TIME=STRMID(OUT,16,4)
;文件重命名
NAME='MOD04_L2_'+YEAR+'_'+MONTH+'_'+TIME+'.TXT'
PRINT,NAME
;print filein
PRINT,FILEIN,' read in process'
;FILEOUT=FILEPATH(FILEOUT,ROOT_DIR=PATH,SUBDIRECTORY=['MOD04_L2']) ;系统默认路径I:\ENVI4.8\IDL\IDL80
;;;;;;;;主程序;;;;;;;
AOD_NAME='Optical_Depth_Land_And_Ocean'
LAT_NAME='Latitude'
LON_NAME='Longitude'
AOD_SCALE_FACTOR=0.001
SD_ID=HDF_SD_START(FILEIN,/READ)
SDS_INDEX_AOD=HDF_SD_NAMETOINDEX(SD_ID,AOD_NAME)
SDS_INDEX_LAT=HDF_SD_NAMETOINDEX(SD_ID,LAT_NAME)
SDS_INDEX_LON=HDF_SD_NAMETOINDEX(SD_ID,LON_NAME)
SDS_ID_AOD=HDF_SD_SELECT(SD_ID, SDS_INDEX_AOD)
SDS_ID_LAT=HDF_SD_SELECT(SD_ID, SDS_INDEX_LAT)
SDS_ID_LON=HDF_SD_SELECT(SD_ID, SDS_INDEX_LON)
;读取HDF文件信息
HDF_SD_GETINFO, SDS_ID_AOD,LABEL=L,DIMS=D,FILL=F;数据集名称,数组大小
HDF_SD_GETINFO, SDS_ID_LON,LABEL=M
HDF_SD_GETINFO, SDS_ID_LAT,LABEL=N
HDF_SD_GETDATA, SDS_ID_AOD, DATA_AOD
HDF_SD_GETDATA, SDS_ID_LAT, DATA_LAT
HDF_SD_GETDATA, SDS_ID_LON, DATA_LON
HDF_SD_ENDACCESS, SDS_ID_AOD
HDF_SD_ENDACCESS, SDS_ID_LAT
HDF_SD_ENDACCESS, SDS_ID_LON
HDF_SD_END, SD_ID
AODMAX=MAX(DATA_AOD)
LON=MAX(DATA_LON,MIN=LONMI)
LAT=MAX(DATA_LAT,MIN=LATMI)
PRINT,'INFORMATION'
PRINT,'NAME ',L
PRINT,' ',M
PRINT,' ',N
PRINT,'FILL ',F
PRINT,'DIMS',D(0),'列',D(1),'行'
PRINT,'LON ',LONMI,LON
PRINT,'LAT ',LATMI,LAT
IF AODMAX GE 0 THEN PRINT,'MAXI ',AODMAX*AOD_SCALE_FACTOR
IF AODMAX LE 0 THEN PRINT,'MAXI ',0
;ELSE PRINT,0
;ENDIF
;PRINT,DI
;写入数据
;FILEOUT=FILEPATH(FILEOUT,ROOT_DIR=PATH,SUBDIRECTORY=['MOD04_L2']) ;系统默认路径I:\ENVI4.8\IDL\IDL80
FILEOUT=FILEPATH(NAME,ROOT_DIR=PATH,SUBDIRECTORY=['MOD04_L2']) ;系统默认路径I:\ENVI4.8\IDL\IDL80
OPENW,LUN,FILEOUT,/GET_LUN
;OPENW,LUN,'I:\project\IDLreadMOD04\MOD04_L2.A2008001.0115.005.2008003025658.DAT',/GET_LUN
FOR I=0,D(1)-1 DO BEGIN
FOR J=0,D(0)-1 DO BEGIN
IF (DATA_AOD(J,I) GE 0) AND (DATA_LON(J,I) GE 70 AND DATA_LON(J,I) LE 140) AND (DATA_LAT(J,I) GE 15 AND DATA_LAT(J,I) LE 60) $
THEN PRINTF,LUN,DATA_LON(J,I),DATA_LAT(J,I),DATA_AOD(J,I)*AOD_SCALE_FACTOR
;
ENDFOR
ENDFOR
CLOSE,LUN
;提示文件读取完成
PRINT,FILEOUT,' write completed!'
PRINT,'___________________________________________________________________________________________________________________'
ENDWHILE
CLOSE,1
CLOSE,2
;;;;;;;;;;;;;;;;
PRINT,' !!!!!!!!PROGRAM END!!!!!!!!!'
END
|
-
-
-
-
获取文件路径.bat
22 Bytes, 下载次数: 13, 下载积分: 金钱 -5
-
-
改变文件名.bat
101 Bytes, 下载次数: 6, 下载积分: 金钱 -5
-
-
readmod.pro
11.11 KB, 下载次数: 17, 下载积分: 金钱 -5
-
-
out.txt
2.41 KB, 下载次数: 6, 下载积分: 金钱 -5
-
-
in.txt
8.91 KB, 下载次数: 8, 下载积分: 金钱 -5
|