% 2-7-2017

clear all;
addpath('C:\windPRESSURE');
addpath('C:\windPRESSURE\jp1tap708wind360blue'); % locate data
% addpath('C:\windPRESSURE\jp1tap1715wind270GPD')
filename = '_jp1tap708wind360.csv';
% sheet = 'Sheet1';
xlRange = 'A1:A49792'; 
% xlRange = 'A1:A8299'
% xlRange = 'A8300:A16597'
% xlRange = 'A16598:A24896'
% xlRange = 'A24897:A33195'
% xlRange = 'A33196:A41493'
% xlRange = 'A41494:A49792'

cp = xlsread(filename,xlRange);  % read data
plot(cp)
t = length(cp)  % Size of data
% csvwrite(['cp6.csv'],cp);

% check time series is the correct one
[M,I] = max(cp)   % max and its index
[m,i] = min(cp)   % min and its index
% P = 0.5704 % mean of Gumbel distribution
% cp = -cp;   % reverse sign of time series if desired
% P = 0.78 % percent exceedance
% N = [15 24]; % vector of partitions

Blueresults = zeros(5,13);  % preset size of results
for n = 13:17  % select 5 sets of epochs from 13 to 17
%     n = N(:,i)  % number of data blocks
[p1_max, p2_max, p1_rmax, p2_rmax, u_max, b_max, cp_max, p1_min, p2_min, p1_rmin, p2_rmin, u_min, b_min, cp_min] = blue4pressure(cp, n, 0, 0, 0)
Blueresults(n-12,:) = [n;p1_max;p2_max;p1_rmax;p2_rmax;u_max;b_max; p1_min;p2_min;p1_rmin;p2_rmin;u_min;b_min];
% row 1 of results correspond to n = 13.  If I use n instead of n-12, I
% would end up with 17 rows, not 5
end
csvwrite(['_Blue4PressureResults_test.csv'],Blueresults);  % write results


