pro read_dst,filename,time=time,value=value,max_days=max_days ;+ ;read the hourly DST index from the standard text data file provided ;by NOAA/NGDC ; ;History ; 2004/12/09 Jie Zhang created ;- if not keyword_set(max_days) then max_days= 366 ; holding maximum one year's data (366) date_str = STRARR(max_days) ; date in DSTYYMM*DD dst_ind = INTARR(24,max_days) ; DST index, one-hour averaged, 24 per day line='' i=0 ; Read in the index file OPENR,lu,filename,/get_lun WHILE (not eof(lu)) DO BEGIN READF,lu,line IF (strmid(line,0,1) ne '#') THEN BEGIN date_str[i]=strmid(line,0,10) READS,strmid(line,16,104),tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7,tmp8,tmp9,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16,tmp17,tmp18,tmp19,tmp20,tmp21,tmp22,tmp23,tmp24,tmp25,tmp26,FORMAT='(26i4)' dst_ind[0,i]=tmp2 dst_ind[1,i]=tmp3 dst_ind[2,i]=tmp4 dst_ind[3,i]=tmp5 dst_ind[4,i]=tmp6 dst_ind[5,i]=tmp7 dst_ind[6,i]=tmp8 dst_ind[7,i]=tmp9 dst_ind[8,i]=tmp10 dst_ind[9,i]=tmp11 dst_ind[10,i]=tmp12 dst_ind[11,i]=tmp13 dst_ind[12,i]=tmp14 dst_ind[13,i]=tmp15 dst_ind[14,i]=tmp16 dst_ind[15,i]=tmp17 dst_ind[16,i]=tmp18 dst_ind[17,i]=tmp19 dst_ind[18,i]=tmp20 dst_ind[19,i]=tmp21 dst_ind[20,i]=tmp22 dst_ind[21,i]=tmp23 dst_ind[22,i]=tmp24 dst_ind[23,i]=tmp25 i=i+1 ENDIF if i ge max_days then break ENDWHILE FREE_LUN,lu day_num=i ;print,'valid day=',day_num if day_num gt 0 then begin ; Truncate the array to include only valid points date_str = date_str(0:day_num-1); print the date of Dst dst_ind = dst_ind(*,0:day_num-1); print the value of Dst interger value=fltarr(24*day_num) ; print value of Dst in float ;convert the data into a single array, the time into a single UTC array time_str=STRARR(24*day_num) for i=0,day_num-1 do begin for j=0,23 do begin ; if (strmid(date_str[i],3,2) gt 10) then yy='19' else yy='20' ;year 2000 problem yy='20' tmp_str=yy+strmid(date_str[i],3,2)+'/'+strtrim(strmid(date_str[i],5,2),2)+'/'+strtrim(strmid(date_str[i],8,2),2)+' '+strtrim(string(j+1),2)+':00' time_str(i*24+j)=tmp_str value(i*24+j)=dst_ind(j,i) endfor endfor ;stop time=str2utc(time_str) endif RETURN END