% naètení dat
clear;
close all;

% cesta
temp_dir = 'F:\Phoenix_AFL_data_ALL\data\';

% výbìr senzoru
selected_sensor = 'pd_oh_h_04';

% list of directories to read
dir_listing = dir([temp_dir,selected_sensor,'\']);
dir_number = length(dir_listing);

% naèítání dat
% vymezení mìøených dat
data_measured = cell(1,6);
% cyklus skrz všechny podadresáøe

initDay_index = 5;
for n = initDay_index:dir_number
    temp_name = [temp_dir, selected_sensor, '\',dir_listing(n).name, '\'];
    
    act_file_listing = dir(temp_name);
    file_number = length(act_file_listing);
    all_data_per_dir = [];
    
    % cyklus skrz všechny soubory v adresáøích
    for m=3:file_number
        act_file_name = [temp_name, act_file_listing(m).name];
        act_data = txt2mat(act_file_name);
        if m == 3
            number_of_columns = size(act_data,2);
        else
            if size(act_data,2) ~= number_of_columns
                disp('Inconsistent input data')
            end
        end
        % naètení dat do jedné matice
        all_data_per_dir = [all_data_per_dir; act_data];
       
    end
    % zpracování èasu
     data_time = all_data_per_dir(:,4)*3600 + all_data_per_dir(:,5)*60 + all_data_per_dir(:,6);
     data_time = data_time - data_time(1);
     
     % zpracování dat, naètení možných hodnot
     meanValue(n-initDay_index+1) = mean(all_data_per_dir(:,7));
     medianValue(n-initDay_index+1) = median(all_data_per_dir(:,7));
     stdValue(n-initDay_index+1) = std(all_data_per_dir(:,7));
     skewnessValue(n-initDay_index+1) = skewness(all_data_per_dir(:,7));
     kurtosisValue(n-initDay_index+1) = kurtosis(all_data_per_dir(:,7));
     maxValue(n-initDay_index+1) = max(all_data_per_dir(:,7));

    % vytvoøení promìnných
    
    data_name = [dir_listing(n).name];
    data_measured{n-initDay_index+1}.name = data_name;
    data_measured{n-initDay_index+1}.time = data_time;
    data_measured{n-initDay_index+1}.meanValue = meanValue(n-initDay_index+1);
    data_measured{n-initDay_index+1}.medianValue = medianValue(n-initDay_index+1);
    data_measured{n-initDay_index+1}.stdValue = stdValue(n-initDay_index+1);
    data_measured{n-initDay_index+1}.maxValue = maxValue(n-initDay_index+1);
end

% plot
figure
number_of_days =  length(meanValue);


plot(1:number_of_days,maxValue)
hold on

leg = legend(selected_sensor);
set(leg,'Interpreter', 'none');
xlabel('Èas [dny]')
ylabel('Maximální pomìrné prodloužení [\mum/m]')
grid on
title('Vykreslení dat vypovídající o charakteru letù')
