;+ ; Contains the read_att procedure ; ; :Author: ; Baptiste Cecconi ; ; :History: ; 2006/07/16: Created ; ; 2012/04/25: added j2000 quaternion support (qj20 file production) ;- ; ;+ ; reads an attitude text file path/fichier.att ; (created from the web team page) ; ; :Params: ; fichier: in, required, type=sometype ; must have full path and extension included. ; ma: out, required, type='fltarr(3,3)' ; 3x3 matrix (S/C to XSE coordinate systems) ; t97: out, required, type=sometype ; time 1997.0 ; datatype: out, required, type=sometype ; quaternion or matrix ;- pro READ_ATT, fichier, ma, t97, datatype ; checking end of file : openr,u,fichier,/get_lun fs = fstat(u) bbb = 0b point_lun,u,fs.size-45 & readu,u,bbb if string(bbb) eq '*' then begin bbb = bytarr(fs.size-48) point_lun,u,0 readu,u,bbb close,u & free_lun,u openw,u,fichier,/get_lun writeu,u,bbb close,u endif else close,u & free_lun,u ; reading openr,u,fichier,/get_lun comment = '' readf,u,comment datatype_txt = strcompress(comment) message,'data type = '+datatype_txt,/info readf,u,comment if strpos(datatype_txt,"Quaternion") ne -1 then begin message,' Reading Quaternion',/info n=0 ma = fltarr(4,10000) while not eof(u) do begin readf,u,format='(i4,1x,i3,2(1x,i2),1x,f6.3,1x,4f14.6)',a,j,h,m,s,q1,q2,q3,q4 buf=[q1,q2,q3,q4] sec=h*3600.d0+m*60.d0+s if n eq 0 then aj=[a*1000.d0+j+sec/86400.d0] $ else aj=[aj,a*1000.d0+j+sec/86400.d0] ma(*,n)=buf n=n+1 if (n mod 10000) eq 0 then begin mm=n_elements(ma(0,*)) buf=fltarr(4,mm+10000L) buf(*,0:mm-1)=ma ma=buf endif endwhile close,u & free_lun,u message,string(n)+' quaternion read',/info ma=reform(ma(*,0:n-1),4,n) datatype='quaternion' endif else begin message,' Reading Attitude Matrix',/info n=0 ma=fltarr(3,3,10000) while not eof(u) do begin readf,u,format='(i4,1x,i3,2(1x,i2),1x,f6.3,1x,3f16.6)', a,j,h,m,s,m11,m12,m13 readf,u,m21,m22,m23 readf,u,m31,m32,m33 readf,u,comment buf=[[m11,m12,m13],[m21,m22,m23],[m31,m32,m33]] sec=h*3600.d0+m*60.d0+s if n eq 0 then aj=[a*1000.d0+j+sec/86400.d0] $ else aj=[aj,a*1000.d0+j+sec/86400.d0] ma(*,*,n)=buf n=n+1 if (n mod 10000) eq 0 then begin mm=n_elements(ma(0,0,*)) buf=fltarr(3,3,mm+10000L) buf(*,*,0:mm-1)=ma ma=buf endif endwhile close,u & free_lun,u message,string(n)+' attitude matrix read',/info ma=reform(ma(*,*,0:n-1),3,3,n) datatype='matrix' endelse t97=aj_t97(aj) return end