%% aquadop data processing
% palmyra 2012
% test at 

close all, clear all;clc

% 2MHz
filename = 'PS914b01_2Mhz_test';
depth  = 3*0.3048; %depth in m

z = 0.7+0.5*[0:1:15];

E_vel = dlmread(strcat(filename,'.v1'));
N_vel = dlmread(strcat(filename,'.v2'));
z_vel = dlmread(strcat(filename,'.v3'));
sen =  dlmread(strcat(filename,'.sen'));
Press = sen(:,14);
Temp = sen(:,15);
bins_keep = find(z<depth, 1, 'last' );
E_avg = mean(E_vel(:,1:bins_keep),2);
N_avg = mean(N_vel(:,1:bins_keep),2);
Vel_mag = sqrt(E_vel.^2+N_vel.^2);
Vel_mag_avg = mean(Vel_mag(:,1:bins_keep));
datenumber = datenum(sen(:,3),sen(:,1),sen(:,2),sen(:,4),sen(:,5),sen(:,6));
save(strcat(filename))