%  HowManyWaves.m
% Calculate how many cycles the piston traveled during the June 2012 deployment

clear 
clc

dpath = '134.89.12.189/data/';
dataDirs = dir([dpath 'R*']);

Cycles = 0;
for k = 1:length(dataDirs)
  if(dataDirs(k).isdir == 1)
     ppath = [dpath dataDirs(k).name '/'];
     
     matfiles = dir([ppath 'D*.mat']);

     K = length(matfiles);
     for k = 1:K
       load([ppath matfiles(k).name]);
       Cycles = Cycles + length(findpeaks(PistonDistance));
     end
  end
end