function [Test] = QualityCK(y1,y2,y3,y4)
%y is data of wind data

%%Exclude winds above 150[m/s]

for i=1:numel(y1)
    if abs(y1(i)) > 150
        y1(i)=NaN;
    end
    if abs(y2(i)) > 150
        y2(i)=NaN;
    end
    if abs(y3(i)) > 150
        y3(i)=NaN;
    end
    if abs(y4(i)) > 150
        y4(i)=NaN;
    end
end
    
%%segments covering at least half of the hourly means and spanning at least
%16 different hours

%4 days segments that have data gaps>3h occuring at the same hours in each
%day are excludeed

Test = 1;
BlankDataCounter = 0;
DataGap1 = 0;

for i=1:numel(y1)
    if isnan(y1(i)) && isnan(y2(i)) && isnan(y3(i)) && isnan(y4(i))
        BlankDataCounter = BlankDataCounter+1;
        DataGap1 = DataGap1+1;
        if BlankDataCounter==9 || DataGap1==4
            Test = 0;
            disp('not 16, gap over 3h');
            return
        end
    else
        DataGap1 = 0;
    end
end

if sum(isnan([y1 y2 y3 y4]))>48
    Test = 0;
    disp('less than half')
    return
end


%4days segments with data gaps>12h that covers the same hours in both
%halves of the segment are rejected

TwoDay1 = [y1 y2];
TwoDay2 = [y3 y4];
DataGap2 = 0;

for i = 1:numel(TwoDay1)
    if isnan(TwoDay1(i)) && isnan(TwoDay2(i))
        DataGap2 = DataGap2 + 1;
        if DataGap2==12
            Test = 0;
            disp('datagap2 more than 12h');
            return
        end
    else 
        DataGap2=0;
    end
end

