%bellows position summary bellows.m
clear;
fp = '2018Aug07';
sn = 'BOG2'
path = sprintf( '../%s/%s/parsed/CPF%s_ENG.mat',sn,fp,fp);
load(path,'BP','P','DATETIMENUM','BATTI','SEDTRAP','NUMSBDIX',...
    'BATTV','STATE','PID_UCPS','PIDU');
t=1;
format longg, DATETIMENUM;
format longg, t;
numprofiles = size(P,1);
%figure;hold on;
%figure; hold on;
j=1;
k=1;
l=1;
m=1;
n=1;
o=1;
sampleno=1;

prof = 10;

   
    for i = 1:1:size(BP,2)
       if(~isnan(BP(prof,i)))
           bp(j) = BP(prof,i);
           bpt(j) = DATETIMENUM(prof,i);
           j=j+1;
       end
       if(~isnan(P(prof,i)))
           p(k) = P(prof,i);
           pt(k) = DATETIMENUM(prof,i);
           k=k+1;
       end   
       if(~isnan(BATTI(prof,i)))
           batti(l) = BATTI(prof,i);
           battit(l) = DATETIMENUM(prof,i);
           l=l+1;
       end 
       if(~isnan(BATTV(prof,i)))
           battv(n) = BATTV(prof,i);
           battvt(n) = DATETIMENUM(prof,i);
           %fprintf('BATTV(%d,%d)=%f; DT(%d,%d) = %d battvt(%d)=%f\n',prof,i,...
           %    BATTV(prof,i),prof,i,DATETIMENUM(prof,i),n,battvt(n));
           n=n+1;
       end
       if(~isnan(PID_UCPS(prof,i)))
           ucps(m) = PID_UCPS(prof,i);
           ucpst(m) = DATETIMENUM(prof,i);
           %fprintf('BATTV(%d,%d)=%f; DT(%d,%d) = %d battvt(%d)=%f\n',prof,i,...
           %    BATTV(prof,i),prof,i,DATETIMENUM(prof,i),n,battvt(n));
           m=m+1;
       end   
       if(~isnan(PIDU(prof,i)))
           pidu(o) = PIDU(prof,i);
           pidut(o) = DATETIMENUM(prof,i);
           %fprintf('BATTV(%d,%d)=%f; DT(%d,%d) = %d battvt(%d)=%f\n',prof,i,...
           %    BATTV(prof,i),prof,i,DATETIMENUM(prof,i),n,battvt(n));
           o=o+1;
       end 
    end
    
plot(pt,p)
yyaxis right
plot(ucpst,ucps)    

figure;
plot(pt,p)
yyaxis right
plot(pidut,pidu);

figure;
plot(pt,p)
yyaxis right
plot(bpt,bp);
%integrate total rotations
cnts = 0;
for i=250:260
    t = ( ucpst(i+1) - ucpst(i) ) * 24 * 3600; %seconds
    cnts = cnts + (t * ucps(i));
end
































