close all
clear all

Jun = load('June2012DeploymentSummaryData');
Nov = load('November2012DeploymentSummaryData.mat');


yi_Controller = ceil(Nov.yi_Controller);


idx_resistive = find(yi_Controller == 1);
idx_scheduled = find(yi_Controller == 2);
idx_latching = find(yi_Controller == 3);

idx_scheduled = idx_scheduled(1:end-83);


%Compute Mean Lines


Nov_Mean = mean(Nov.yi_meas(1:830/2));
Jun_Mean = mean(Jun.yi_meas);



figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
set(gca,'FontSize',20);
%plot(Jun.yi_Hs,100*Jun.yi_meas./Jun.yi_max,'x',Nov.yi_Hs(idx_scheduled),100*Nov.yi_meas(idx_scheduled)./Nov.yi_max(idx_scheduled),'ro',Nov.yi_Hs(idx_resistive),100*Nov.yi_meas(idx_resistive)./Nov.yi_max(idx_resistive),'ro');
plotyy(Jun.yi_Hs,100*Jun.yi_meas./Jun.yi_max,'x',Jun.yi_Hs,100*Jun.yi_meas./Jun.yi_max,'x',

Nov.yi_Hs(idx_scheduled),100*Nov.yi_meas(idx_scheduled)./Nov.yi_max(idx_scheduled),'ro',Nov.yi_Hs(idx_resistive),100*Nov.yi_meas(idx_resistive)./Nov.yi_max(idx_resistive),'ro');
%title('June 26, 2012 through July 10, 2012');
legend('June Deployment','November Deployment','Location','NorthWest');
xlabel('Rectified Power (Watts)');
ylabel('Percentage of Theoretical Maximum');
print('PercentageOfMaxAndRectifiedPowerVsWaveHeight','-dpdf');
print('PercentageOfMaxAndRectifiedPowerVsWaveHeight','-dpng');



figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
set(gca,'FontSize',20);
plot(Jun.yi_meas,100*Jun.yi_meas./Jun.yi_max,'x',Nov.yi_meas(idx_scheduled),100*Nov.yi_meas(idx_scheduled)./Nov.yi_max(idx_scheduled),'ro',Nov.yi_meas(idx_resistive),100*Nov.yi_meas(idx_resistive)./Nov.yi_max(idx_resistive),'ro');
%title('June 26, 2012 through July 10, 2012');
legend('June Deployment','November Deployment','Location','NorthWest');
xlabel('Rectified Power (Watts)');
ylabel('Percentage of Theoretical Maximum');
print('PercentageOfMaxVsRectifiedPower','-dpdf');
print('PercentageOfMaxVsRectifiedPower','-dpng');

figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
set(gca,'FontSize',20);
plot(Jun.yi_Hs,100*Jun.yi_meas./Jun.yi_max,'x',Nov.yi_Hs(idx_scheduled),100*Nov.yi_meas(idx_scheduled)./Nov.yi_max(idx_scheduled),'ro',Nov.yi_Hs(idx_resistive),100*Nov.yi_meas(idx_resistive)./Nov.yi_max(idx_resistive),'ro');
%title('June 26, 2012 through July 10, 2012');
legend('June Deployment','November Deployment','Location','NorthWest');
xlabel('Significant Wave Height (m)');
ylabel('Percentage of Theoretical Maximum');
print('PercentageOfMaxVsWaveHeight','-dpdf');
print('PercentageOfMaxVsWaveHeight','-dpng');


figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
set(gca,'FontSize',20);
plot(Jun.yi_Hs,Jun.yi_meas,'x',Nov.yi_Hs(idx_scheduled),Nov.yi_meas(idx_scheduled),'ro');
legend(['June Deployment: Mean = ' num2str(Jun_Mean,3) ' Watts'],['November Deployment: Mean = ' num2str(Nov_Mean,3) ' Watts'],'Location','NorthWest');
xlabel('Significant Wave Height (m)');
ylabel('Rectified Power (W)');
print('RectifiedPowerVsWaveHeight','-dpdf');
print('RectifiedPowerVsWaveHeight','-dpng');


idx_Jun = find(Jun.yi_Hs < 2);
idx_Nov = find(Nov.yi_Hs < 2);

A = [Jun.yi_Hs(idx_Jun)'  ones(length(idx_Jun),1)];
B = 100*Jun.yi_meas(idx_Jun)'./Jun.yi_max(idx_Jun)';
x_Jun = A\B;

A = [Nov.yi_Hs(idx_Nov)'  ones(length(idx_Nov),1)];
B = 100*Nov.yi_meas(idx_Nov)'./Nov.yi_max(idx_Nov)';
x_Nov = A\B;

figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
set(gca,'FontSize',20);
plot(Jun.yi_Hs(idx_Jun),100*Jun.yi_meas(idx_Jun)./Jun.yi_max(idx_Jun),'x',Nov.yi_Hs(idx_Nov),100*Nov.yi_meas(idx_Nov)./Nov.yi_max(idx_Nov),'ro',Jun.yi_Hs(idx_Jun),x_Jun(1)*Jun.yi_Hs(idx_Jun)+x_Jun(2),'-b',Nov.yi_Hs(idx_Nov),x_Nov(1)*Nov.yi_Hs(idx_Nov)+x_Nov(2),'-r');
%title('June 26, 2012 through July 10, 2012');
legend('June Deployment','November Deployment','Location','NorthWest');
xlabel('Significant Wave Height (m)');
ylabel('Percentage of Theoretical Maximum');
print('PercentageOfMaxVsWaveHeightLessThan2m','-dpdf');
print('PercentageOfMaxVsWaveHeightLessThan2m','-dpng');


Hs = .5:.05:2.0;


figure('Position',[19 45 1538 1093],'PaperPositionMode','manual','PaperType','usletter','PaperPosition',[0 0 11 8.5],'PaperOrientation','landscape');
plot(Hs,(x_Nov(1)*Hs+x_Nov(2))./(x_Jun(1)*Hs+x_Jun(2)),'LineWidth',2);
set(gca,'FontSize',20);
xlabel('Significant Wave Height (m)');
title('Increase in Average Efficiency from June to November');
print('EfficiencyIncreaseBelow2m','-dpdf');
print('EfficiencyIncreaseBelow2m','-dpng');
