newdir = '../../DecodedResults/';

cd(newdir);

%% START 
clear;
pbfiles = dir('*.mat');
date_to_plot_from = datenum('30-Nov-2018');

timeDT = [];
mtimeDT = [];

pctime = [];
pcpres = [];

%Now go through all of them. 
for i = 1:length(pbfiles) 
    if strfind(pbfiles(i).name,'_raw.mat') >0
    else continue;
    end
    
    % Make sure its recent
    if pbfiles(i).datenum < date_to_plot_from
        continue;
    end
    
    
    disp(['Loading ' pbfiles(i).name]);
    
    load(pbfiles(i).name);
    
    pctime = [pctime; PC_Time];
    pcpres = [pcpres; PC_DiffPress];
    
end

%% adjust to PDT
timeDT = timeDT - datenum(0,0,0,8,0,0);

%% moving avg
mpctime = movmean(pctime,3001);
mpcpres = movmean(pcpres,3001);

%% plotting

plot(datetime(pctime,'ConvertFrom','datenum'), pcpres ,'.',...
    datetime(mpctime,'ConvertFrom','datenum'), mpcpres,'-');
ylabel('Pressure (PSIG)');
xlabel('Time (PST)');
title(['Comp Pressure since ' datestr(date_to_plot_from)]);

legend('Raw','30K Point Mean','Location','SouthEast')
grid on;


