% go_gps_gps.m
% get 1 minute gps records from etl server
% 2011/4/11 skipping plot
set_up
if exist('gps.mat','file')
    load gps.mat
else
    gps=[];
end
nnewf=get_etl_gps_files(etldir);
if nnewf > 0
    infiles=dir('data/gps/new/*.txt');
    if ~isempty(infiles)
        for iiff=1:length(infiles)
            infile=['data/gps/new/' infiles(iiff).name ];
            [newgps] = get_etl_gps(infile);
            if isstruct(newgps)
                if isstruct(gps)
                    gps=structsadd(gps,newgps);
                else
                    gps=newgps;
                end
            else
                disp(['error in ' infile]);
            end
            [j,idx,j]=unique(gps.mday);
            gps = structsort(gps, idx);
            save gps.mat gps
            try
                movefile( infile ,'data/gps/read');
            catch
                disp(['can  not move ' infile]);
            end
        end
    end
    if isstruct(gps)
        [j,idx,j]=unique(gps.mday);
        gps = structsort(gps, idx);
        save gps.mat gps
        gps=get_gps_avg(gps);
        save gps1h.mat gps
        % now plot 
        % normally this would be called by go.m
        % gps_map
    end
end
        % now plot 
        % normally this would be called by go.m
        % gps_map
