disp('read_hed')
fclose('all');
%ICEALOT 2008 Running at 10Hz
%
clear
read_parameters_rhb; %Reading parameter files flux conf from D:/data/lb/flux_eval_rhb_06
st1=[];
jds = input('Input start yearday to evaluate.... ','S');
bjd = str2num(jds);
    ict = 0;

for d = bjd:91
    if d<10,
            jds=['00' num2str(d)];
    elseif (d >= 10 & d <100)
            jds=['0' num2str(d)];
    else
            jds=num2str(jam);
        end;                            %end if jam

for jam=0:23     %6:6,						%cycle thru 24 hourly files
if jam<10,
            hr=['0' num2str(jam)];
        else
            hr=num2str(jam);
        end;                            %end if jam

        e=[way_raw_data, 'day', jds,'\hed008' jds hr '_raw.txt'];
    %03/24/2008 00:00 Heading Crescent VS100 (SN: 9)
    %0000003 $GPHDT,181.63,T*08
    %0000112 $GPHDT,181.73,T*09
    flist=fopen(e,'r');
    if flist>0,					    %if the file exists,
    disp(['Reading heading file  ',e])
    dmp=fgets(flist);			%read 1st header line
    YY = str2num(dmp(7:10));
    MM = str2num(dmp(1:2));
    DD = str2num(dmp(4:5));
    hh = str2num(dmp(12:13));
    %while feof(flist)==0,
    for p = 1:100
        dtmp=fgetl(flist);
        if 1  %length(dtmp) > 30
            ict = ict + 1;
            tim = dtmp(1:8);
            mm = str2num(tim(:,1:2));
            ss = str2num(tim(:,3:8))/1000;
            %calculate year day
            yd=datenum(YY,MM,DD,hh,0,0)-datenum(YY-1,12,31);
            jdn(ict,1) = yd + (((mm+(ss/60))/60))/24;
            st1(1,ict) = jdn(ict,1);
            data1 = dtmp(16:length(dtmp));
            C = textscan(data1,'%f','CollectOutput',1);
            tmp = C{:};
            st1(2,ict) = tmp(1,1);  %  heading
        end %test for good data
    end  %while
    fclose(flist);
    end  % flist
end;         %end of hour loop jam
end %day loop
        ss = size(st1);
        %% DEW 5/18/2007
        plot(jdn,st1(2,:),'k')
        title('GPS Heading')
        xlabel('Year Day (UTC)');
        ylabel('Degrees)');


