disp('read_gyro_sjohnson_05')

%Heading=zeros(1,17000).*NaN;
Heading=zeros(1,432120).*NaN;  %lets it work without full day
HEADING=[];

for hhh=0:23;
    if hhh<10,
        dfx2=['0',num2str(hhh)];
    else,
        dfx2=num2str(hhh);
    end;
    if ddd<10,
        dfx1=['00',num2str(ddd)];
    elseif ddd<100,
        dfx1=['0',num2str(ddd)];
    else,
        dfx1=num2str(ddd);
    end;
    dfx=[dfx1 dfx2];
    dfl=['d:\data\day',dfx1,'\P3_',dfx];
    flist=fopen(dfl,'r');
    if flist>0
        disp(dfl);
        dmp1=fgetl(flist);
        iii=0;
        while feof(flist)==0,
            headline=fgetl(flist);
            if length(headline)>26,
                if ~isempty(str2num(headline(23:27)));
                    iii=iii+1;
                    Heading(iii)=str2num(headline(23:27));
                end;
            end;
        end;      %end while not end of file
        for iii=1:length(Heading),
            if ~isfinite(Heading(iii)),
                Heading=Heading(1:iii-1);
                break
            end;
        end;
        HEADING=[HEADING Heading];
    end %if flist
end;

sHEADING=sin(HEADING./180.*pi);
cHEADING=cos(HEADING./180.*pi);

clear Heading
jjj=0;

for iii=1:300:length(HEADING)-299,
    jjj=jjj+1;
    sHeading(jjj)=median(sHEADING(iii:iii+299));
    cHeading(jjj)=median(cHEADING(iii:iii+299));
    if jjj==1440,break;end;
end;
Heading=mod(atan2(sHeading,cHeading)*180./pi+360,360);			%laser ring gyro
