if(1 == 0)
    t0 = 1621;
    for i= 0:18
        i
        fileName = [num2str(t0 + i), 'Dec29-09.csv'];
        subData = csvread(fileName);
        if i == 0
	       HPUData = subData;
        else
            HPUData = vertcat(HPUData, subData);
        end
    end
end

% HPU data header: time(msec), trajectory amplitude, actual ram position, analog output voltage
%HPUData = csvread('16XXDec29-09.csv');
%HPUData = csvread('0856Dec30-09.csv');
HPUData = csvread('1519Jan05-10.csv');
ramZ = 0.0254 * HPUData(:,3);
trajZ = 0.0254 * HPUData(:,2);
ramTime = HPUData(:,1) / 1000;
Zerror = trajZ - ramZ;

RamNumSamples = length(ramZ);
ramDT = ramTime(2:RamNumSamples) - ramTime(1:RamNumSamples-1); 
ramVelocity =(ramZ(2:RamNumSamples) - ramZ(1:RamNumSamples-1)) ./ ramDT; 

% iGo data header: uSecsSinceReset, SecsElapsed, DesiredDepth, ActualDepth, m_P, m_D, m_I, m_V, m_U, m_TotalTension
%iGoData=dlmread('profiler_20091230_073917Mod.dat', '\t', 1, 0);
iGoData=dlmread('profiler_20100105_151411Mod.dat', '\t', 1, 0);
desDepth = iGoData(:,3);
actDepth = iGoData(:,4);
tension = iGoData(:,10);
espTime = iGoData(:,1) / 1000000;

espNumSamples = length(iGoTime);
espDT = espTime(2:espNumSamples) - espTime(1:espNumSamples-1); 
espVelocity =(actDepth(2:espNumSamples) - actDepth(1:espNumSamples-1)) ./ espDT; 

figure
plot(espTime,actDepth)
title('ESP Depth vs Time');
figure
plot(ramTime,ramZ+5.5)
title('Ram Position vs Time');
figure
plot((espTime-2600),actDepth,(ramTime-84428),ramZ+6.3)
ylim([5 7.5])
xlim([150 1550])
ylabel('Depth (m)   Ram Position (m)')
xlabel('Time (seconds)')
title('ESP Depth (blue) Ram Position(green) vs Time (seconds)')
