;+ ; NAME : HR_READ.pro (procedure) ; PURPOSE : ; Read Huairou Solar Observation Station data file ; CATEGORY : ; idl/flare ; CALLING SEQUENCE : ; hr_read,filename,data,info,swap=swap,dir=dir ; INPUTS : ; filename: name of data file to be read ; OPTIONAL INPUT PARAMETERS : ; none ; OUTPUTS : ; data: raw data ; info: 12-element string array containing the observing information ; 0 spectral line ; 1 date ; 2 time ; 3 seeing ; 4 sun disc coordinate x ; 5 sun disc coordinate y ; 6 orthogonal coordinate x ; 7 orthogonal coordinate y ; 8 carrington coordinate x ; 9 carrington coordinate y ; 10 frame ; 11 huirou number ; KEYWORD PARAMETERS : ; swap=swap: option for high-low 8-bits conversion ; dir = dir: directory where the file to be read is located ; COMMON BLOCKS : none ; SIDE EFFECTS : ; RESTRICTIONS : ; PROCEDURE : ; ; MODIFICATION HISTORY : ; by X.Z. Hu ; last change date May 11, 1995 ; Sep. 28, 1997, for different Device Environment ; By Deng Y. Y. ; Option: Swap---- Judge if the data need swap ; Default: swap=0 ; Hui LI, 2000/10/24 add /dir and reorganize the procedure ;------------------------------------------------------------------------ ;- pro hr_read,filename,data,info,swap=swap,dir=dir if (n_elements(swap) eq 0) then begin swap=0 endif else begin if (swap ne 0) then swap=1 endelse if keyword_set(dir) then begin if !version.os_family eq 'Windows' then begin if strmid(dir,strlen(dir)-1,1) eq '\' then dir=dir else dir=dir+'\' endif else begin if strmid(dir,strlen(dir)-1,1) eq '/' then dir=dir else dir=dir+'/' endelse endif else begin dir='' endelse filename=dir+strlowcase(filename) length=strlen(filename) ff=findfile(filename) !error=0 if ff(0) eq '' then begin !error=1 if keyword_set(dir) then $ print,'File '+filename+' not found ! Procedure stopped.' else $ print,'File '+filename+' in current directory not found ! Procedure stopped.' return endif if length lt 1 then begin print,'Haven"t selected a file' data=0 info=0 goto,end_lab end first_char=strmid(filename,length-12,1) case first_char of "s":data=bytarr(512,512) "t":data=bytarr(512,512) "d":data=bytarr(512,512) "l":data=intarr(512,512) "q":data=intarr(512,512) "u":data=intarr(512,512) "v":data=intarr(512,512) "h":data=bytarr(512,512) "c":data=bytarr(512,512) else:message,'not a HSOS format data file!' endcase tail=bytarr(65) xy=intarr(7) info=strarr(12) openr,unit,filename,/get_lun readu,unit,data,tail,xy free_lun,unit if (swap eq 1) then xy=swap_endian(xy) xy=xy/10. xy=string(format='(f7.1)',xy) xy(6)=string(format='(i4)',xy(6)) if (first_char ne 's') and (first_char ne 't') and $ (first_char ne 'h') and (first_char ne 'c') and $ (swap eq 1) then data=swap_endian(data) line=strmid(filename,length-11,1) case line of '5':info(0)='5324A' '4':info(0)='4861A' 'a':info(0)='6563A' endcase if (first_char eq 'c') then info(0)='3933A' info(1)=string(tail(2:12)) info(2)=string(tail(15:22)) info(3)=string(tail(62)) info(4:10)=xy(0:6) info(11)=strmid(filename,length-8,3) end_lab: data=rotate(data,7) end