a little tip for reading modis data [message #94658] |
Mon, 07 August 2017 22:55 |
bjy512
Messages: 2 Registered: August 2017
|
Junior Member |
|
|
Hi, my name is Juyeon and i am newbie using idl.
i am working on my thesis paper which is related to dealing with the MODIS/TERRA sensor to retrieve AOD data.
i was strugling for whole day some error occured in my code.
for i=0l,terra-1l do begin
33 openw,lun,'/data/AOT_thesis_data/AOD_MODIS/MOD04/correct_m'+ name(i)+'.txt',/get_lun,/append
34 print,i
35 sds_name='Optical_Depth_Land_And_Ocean'
36 sd_id=hdf_sd_start(filelist1(i),/read)
37 sds_index=hdf_sd_nametoindex(sd_id,sds_name)
38 sds_id=hdf_sd_select(sd_id,sds_index)
...
(there was code to retrieve latitude and longitude in here!)
...
82 for o=0l,cnt-1l do begin
83 for p=0, n-1 do begin
84 if ((abs(slon(p)-lon(o)) le 0.1) and (abs(slat(p)-lat(o)) le 0.1)) then begin
85 printf,lun,day_terra(i),hour_terra(i),min_terra(i),aod(o),lo n(o),lat(o),stn(p),f='(i4,2x,i2,2x,i2,2x,d14.10,2x,d9.5,2x,d 9.5,2x,i7)'
86 endif
87 endfor
88 endfor
89
90 endif
91 hdf_sd_endaccess,sds_id
92 hdf_sd_endaccess,lon_id
93 hdf_sd_endaccess,lat_id
94 hdf_sd_end,sd_id
95 free_lun,lun
96 endfor
basically i wanted to shirink the data due to its too big size to use.
so i had to write data in other place.
but the error kept coming up looking just like below
HDF_SD_START error : invalid hdf file
I had searched all over in google but i could not find the answer.
but luckly i found the solution!!
if you are writing the information in other text file or such file, than you should write 'free_lun,lun' in exact place it has to be.
In my case i first i wrote free_lun,lun after the 96 row after the endfor, and error didn't stop.
so if you have a problem similar to mine, then look carefully your code again.
You will definitely find your solution!
cheers~!
|
|
|