disp('rd_scs')
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:95
    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,'\scs008' jds hr '_raw.txt'];
%04/03/2008 00:00 Ship Computer System (SN: 1234)
%0002054 Thu Apr  3 00:59:59 BST 2008 $HEHDT,056.3,T*2F
%0002081 Thu Apr  3 01:00:02 BST 2008 #Gyro      	00:00:02	056.3
%0002123 Thu Apr  3 01:00:02 BST 2008 $GPVTG,065.3,T,,M,11.24,N,20.81,K*6D,$GPZDA,235959.00,2,4,2008,+0,+0*6B,$GPGGA,000000.00,6503.08439,N,00531.49002,W,2,6,2.1,26.24,M,53.17,M,10,0208*7F
%0003066 Thu Apr  3 01:00:02 BST 2008 #IMET_SWR  	00:00:03	0.1
%0003091 Thu Apr  3 01:00:03 BST 2008 #IMET_PRC  	00:00:03	0.01    0.00  41.65
%0003127 Thu Apr  3 01:00:03 BST 2008 #IMET_BPR  	00:00:02	1025.52
%0003157 Thu Apr  3 01:00:03 BST 2008 #TWind     	00:00:03	2.2423 7.6
%0007107 Thu Apr  3 01:00:03 BST 2008 $PKEL99,235956,3904.,+005.00,00.00,+005.00,1500,65 03.078156N,005 31.517379W
%0007155 Thu Apr  3 01:00:07 BST 2008 #IMET_HRH  	00:00:03	85.280    1.813
%0007191 Thu Apr  3 01:00:07 BST 2008 #Air_Temp  	00:00:03	1.813
%0007221 Thu Apr  3 01:00:07 BST 2008 #HRH       	00:00:03	85.280
%0007285 Thu Apr  3 01:00:07 BST 2008 #WXT5_Ta   	00:00:03	2.3
%0007315 Thu Apr  3 01:00:07 BST 2008 #WXT5_Pa   	00:00:03	1024.7
%0007363 Thu Apr  3 01:00:07 BST 2008 #WXT5_Ua   	00:00:03	90.4
%0007429 Thu Apr  3 01:00:07 BST 2008 $HEHDT,055.8,T*27
%0007456 Thu Apr  3 01:00:07 BST 2008 #Gyro      	00:00:07	055.8
%0007498 Thu Apr  3 01:00:07 BST 2008 $GPVTG,062.1,T,,M,12.92,N,23.93,K*66,$GPZDA,000006.00,3,4,2008,+0,+0*6D,$GPGGA,000007.00,6503.09638,N,00531.44198,W,2,6,2.1,27.34,M,53.17,M,10,0208*75
%0007706 Thu Apr  3 01:00:07 BST 2008 #TWD_5     	00:00:08	332.1
%0007737 Thu Apr  3 01:00:08 BST 2008 #TWS_5     	00:00:08	4.2679
%0009019 Thu Apr  3 01:00:08 BST 2008 #IMET_SWR  	00:00:09	0.1
%0009044 Thu Apr  3 01:00:09 BST 2008 #IMET_PRC  	00:00:09	0.01    0.00  41.65
%0009080 Thu Apr  3 01:00:09 BST 2008 #IMET_BPR  	00:00:09	1025.52
%0009109 Thu Apr  3 01:00:09 BST 2008 #TWind     	00:00:09	1.6192 346.9
%0012123 Thu Apr  3 01:00:09 BST 2008 $PKEL99,000003,3904.,+005.00,00.00,+005.00,1500,65 03.090054N,005 31.469639W
%0012173 Thu Apr  3 01:00:12 BST 2008 #Fluorometer	00:00:09	+00095.80
%0012194 Thu Apr  3 01:00:12 BST 2008 $HEHDT,055.9,T*26
%0012269 Thu Apr  3 01:00:12 BST 2008 #Gyro      	00:00:12	055.9
    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 length(dtmp) > 46 & dtmp(39:46) == 'IMET_PRC'  %find IMET precip data
            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(57:length(dtmp));
            C = textscan(data1,'%f%f%f','CollectOutput',1);
            tmp = C{:};
            st1(2,ict) = tmp(1,1);  %  heading
            st1(3,ict) = tmp(1,2);  %  heading
            st1(4,ict) = tmp(1,3);  %  heading            
            
        end %test for good data
    end  %while
    fclose(flist);
    end  % flist
end;         %end of hour loop jam
if 1
        s = 'c:\data\icealot\data\scs\'

        ss = size(st1);
        %% DEW 5/18/2007
        plot(jdn,st1(4,:),'k')
        title('Knorr SCS ')
        xlabel('Year Day (UTC)');
        ylabel('IMET rain total (mm)');
        ylim([ 0 12]);
        print_buffer = [s 'ICEALOT_scs_IMET_rain_' jds '.png'];
        print('-dpng ', print_buffer);
end
pause(1)
end %day loop
if 0
        s = 'c:\data\icealot\data\scs\'

        ss = size(st1);
        %% DEW 5/18/2007
        plot(jdn,st1(4,:),'k')
        title('Knorr SCS ')
        xlabel('Year Day (UTC)');
        ylabel('rain total (mm)');
        print_buffer = [s 'ICEALOT_scs_IMET_rain_' jds '.png'];
        print('-dpng ', print_buffer);
end

