close all
clear all


hourly_data_file = '../HourlyResults/HourlyAverages.mat'

load(hourly_data_file);

idx =  1210:6690;

DateNum = HourlyData.baseFileDateNum(idx);
Power = HourlyData.PC_Power(idx);


figure
subplot(2,1,1)
plot(DateNum,Power)
datetick('x');
ylabel('Hourly Average Power (W)');
grid on;
title(['Hourly Average Power Capture from   ' datestr(DateNum(1)) '   to   ' datestr(DateNum(end))]);

WindowSize = 1:24*21;

for i = 1:length(WindowSize)
    MinAvgPower(i) = 1e6;
 for j = 1:length(Power)-WindowSize(i) 
  jdx = j:j+WindowSize(i);
  AvgPower = mean(Power(jdx));

  if(AvgPower < MinAvgPower(i))
      MinAvgPower(i) = AvgPower;
  end

 end
end


subplot(2,1,2)
plot(WindowSize/24,MinAvgPower);
grid on
xlabel('Time Span (Days)');
ylabel('Minimum Average Power (W)');
title(['Minimum average power over varying length timespans for data collected   ' datestr(DateNum(1)) '   to   ' datestr(DateNum(end))]);

