Skip to content
Snippets Groups Projects
Commit 787f8ba0 authored by pierre.rousselot_ird.fr's avatar pierre.rousselot_ird.fr
Browse files

New calibration protocol

parent 0ab0bca4
No related branches found
No related tags found
No related merge requests found
...@@ -7,3 +7,4 @@ IDMX*/ ...@@ -7,3 +7,4 @@ IDMX*/
old_data/ old_data/
doc/*.pdf doc/*.pdf
*.jnl *.jnl
ADCP_*
No preview for this file type
...@@ -5,14 +5,15 @@ ...@@ -5,14 +5,15 @@
clear all; close all; clear all; close all;
%% Variables %% Variables
FileToMerge1 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/FR28/ADCP_0N0W_2016_2018_1d.nc'; %.nc file to merge with FileToMerge1 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX2/ADCP_0N130E_2010_2010_1d.nc'; %.nc file to merge with
FileToMerge2 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/FR30/ADCP_0N0W_2018_2020_1d.nc'; %.nc file to merge FileToMerge2 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2016_1d.nc'; %.nc file to merge
FileToMerge3 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX2/ADCP_0N130E_2010_2012_1d.nc'; %.nc file to merge
% FileToMerge1 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2013_1d.nc'; %.nc file to merge with % FileToMerge1 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2013_1d.nc'; %.nc file to merge with
% FileToMerge2 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2016_1d.nc'; %.nc file to merge % FileToMerge2 = '/home/proussel/Documents/OUTILS/ADCP/ADCP_mooring_data_processing/IDMX/ADCP_0N130E_2013_2016_1d.nc'; %.nc file to merge
step_subsampling = 1; % 1=daily step_subsampling = 1; % 1=daily
plot_data = 0; plot_data = 1;
mooring.name = '0N0E'; mooring.name = '0N130E';
freq = '150'; freq = '75';
% mooring.name = '0N130E'; % mooring.name = '0N130E';
% freq = '75'; % freq = '75';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -27,13 +28,19 @@ ncfile2.time = ncread(FileToMerge2,'time'); ...@@ -27,13 +28,19 @@ ncfile2.time = ncread(FileToMerge2,'time');
ncfile2.depth = ncread(FileToMerge2,'depth'); ncfile2.depth = ncread(FileToMerge2,'depth');
ncfile2.u = ncread(FileToMerge2,'u'); ncfile2.u = ncread(FileToMerge2,'u');
ncfile2.v = ncread(FileToMerge2,'v'); ncfile2.v = ncread(FileToMerge2,'v');
%% Read third .nc file
ncfile3.time = ncread(FileToMerge3,'time');
ncfile3.depth = ncread(FileToMerge3,'depth');
ncfile3.u = ncread(FileToMerge3,'u');
ncfile3.v = ncread(FileToMerge3,'v');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Create depth matrix %% Create depth matrix
depth = max(vertcat(ncfile1.depth,ncfile2.depth)):ncfile1.depth(2)-ncfile1.depth(1):min(vertcat(ncfile1.depth,ncfile2.depth)); depth = max(vertcat(ncfile1.depth,ncfile2.depth)):ncfile1.depth(2)-ncfile1.depth(1):min(vertcat(ncfile1.depth,ncfile2.depth));
depth = fliplr(depth); depth = fliplr(depth);
%% Create time matrix %% Create time matrix
time = vertcat(ncfile1.time,ncfile2.time); time = vertcat(ncfile1.time,ncfile3.time,ncfile2.time);
time = time*ones(1,length(depth)); time = time*ones(1,length(depth));
%% Create u/v matrix %% Create u/v matrix
...@@ -45,8 +52,12 @@ for ii = 1:length(ncfile2.time) ...@@ -45,8 +52,12 @@ for ii = 1:length(ncfile2.time)
u2(ii,:) = interp1(ncfile2.depth,ncfile2.u(ii,:),depth); u2(ii,:) = interp1(ncfile2.depth,ncfile2.u(ii,:),depth);
v2(ii,:) = interp1(ncfile2.depth,ncfile2.v(ii,:),depth); v2(ii,:) = interp1(ncfile2.depth,ncfile2.v(ii,:),depth);
end end
u = vertcat(u1,u2); for ii = 1:length(ncfile3.time)
v = vertcat(v1,v2); u3(ii,:) = interp1(ncfile3.depth,ncfile3.u(ii,:),depth);
v3(ii,:) = interp1(ncfile3.depth,ncfile3.v(ii,:),depth);
end
u = vertcat(u1,u3,u2);
v = vertcat(v1,v3,v2);
%% Plot data %% Plot data
if plot_data if plot_data
...@@ -106,7 +117,7 @@ yr_end = datestr(time(end)+datenum(1950,01,01), 'yyyy'); ...@@ -106,7 +117,7 @@ yr_end = datestr(time(end)+datenum(1950,01,01), 'yyyy');
ncid = netcdf.create(['ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'.nc'],'NC_CLOBBER'); ncid = netcdf.create(['ADCP_',mooring.name,'_',num2str(yr_start),'_',num2str(yr_end),'.nc'],'NC_CLOBBER');
%create dimension %create dimension
dimidz = netcdf.defDim(ncid, 'DEPTH', length(depth)); dimidz = netcdf.defDim(ncid, 'DEPTH', size(depth,2));
dimidt = netcdf.defDim(ncid, 'TIME', netcdf.getConstant('NC_UNLIMITED')); dimidt = netcdf.defDim(ncid, 'TIME', netcdf.getConstant('NC_UNLIMITED'));
%Define IDs for the dimension variables (pressure,time,latitude,...) %Define IDs for the dimension variables (pressure,time,latitude,...)
time_ID = netcdf.defVar(ncid,'TIME','double',dimidt); time_ID = netcdf.defVar(ncid,'TIME','double',dimidt);
...@@ -128,7 +139,7 @@ netcdf.putAtt(ncid, v_ID, 'long_name', 'Meridional velocities'); ...@@ -128,7 +139,7 @@ netcdf.putAtt(ncid, v_ID, 'long_name', 'Meridional velocities');
%We are done defining the NetCdf %We are done defining the NetCdf
netcdf.endDef(ncid); netcdf.endDef(ncid);
%Then store the dimension variables in %Then store the dimension variables in
netcdf.putVar(ncid, depth_ID, depth); netcdf.putVar(ncid, depth_ID, depth(1,:));
netcdf.putVar(ncid, time_ID, 0, length(time), time); netcdf.putVar(ncid, time_ID, 0, length(time), time);
%Then store my main variable %Then store my main variable
netcdf.putVar(ncid, u_ID, u'); netcdf.putVar(ncid, u_ID, u');
......
...@@ -4,3 +4,29 @@ function [ru,rv]=uvrot(u,v,ang) ...@@ -4,3 +4,29 @@ function [ru,rv]=uvrot(u,v,ang)
ang=ang*pi/180; ang=ang*pi/180;
ru=u.*cos(ang)-v.*sin(ang); ru=u.*cos(ang)-v.*sin(ang);
rv=u.*sin(ang)+v.*cos(ang); rv=u.*sin(ang)+v.*cos(ang);
...@@ -16,21 +16,21 @@ addpath('/home/proussel/Documents/OUTILS/TOOLS/nansuite'); % NaNSuitePath ...@@ -16,21 +16,21 @@ addpath('/home/proussel/Documents/OUTILS/TOOLS/nansuite'); % NaNSuitePath
%% META information: %% META information:
% Location rawfile % Location rawfile
rawfile = '/home/proussel/Bureau/piratafr30/MOUILLAGE_ADCP/FR28_000.000'; % binary file with .000 extension rawfile = 'IDMX2/_RDI_000.000'; % binary file with .000 extension
fpath_output = './FR30/'; % Output directory fpath_output = './IDMX2/'; % Output directory
% Cruise/mooring info % Cruise/mooring info
cruise.name = 'PIRATA-FR30'; % cruise name cruise.name = 'INDOMIX'; % cruise name
mooring.name = '0N0W'; % '0N10W' mooring.name = '0N130E'; % '0N10W'
mooring.lat = '00°00.287'; % latitude [°'] mooring.lat = '00°04.066'; % latitude [°']
mooring.lon = '000°04.07'; % longitude [°'] mooring.lon = '129°12.41'; % longitude [°']
clock_drift = 276; % [seconds] clock_drift = 0; % [seconds]
% ADCP info % ADCP info
adcp.sn = 8237; % ADCP serial number adcp.sn = 13952; % ADCP serial number
adcp.type = '150 khz Quartermaster'; % Type : Quartermaster, longranger adcp.type = '75 khz Quartermaster'; % Type : Quartermaster, longranger
adcp.direction = 'up'; % upward-looking 'up', downward-looking 'dn' adcp.direction = 'up'; % upward-looking 'up', downward-looking 'dn'
adcp.instr_depth = 300; % nominal instrument depth adcp.instr_depth = 632; % nominal instrument depth
instr = 1; % this is just for name convention and sorting of all mooring instruments instr = 1; % this is just for name convention and sorting of all mooring instruments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -121,9 +121,9 @@ EA0 = round(mean(ea(nbin,:))); ...@@ -121,9 +121,9 @@ EA0 = round(mean(ea(nbin,:)));
%% Calculate Magnetic deviation values %% Calculate Magnetic deviation values
[a,~] = gregorian(raw.juliandate(1)); [a,~] = gregorian(raw.juliandate(1));
magnetic_deviation_ini = magdev(mooring.lat,mooring.lon,0,a+(raw.juliandate(1)-julian(a,1,1,0,0,0))/365.25); magnetic_deviation_ini = -magdev(mooring.lat,mooring.lon,0,a+(raw.juliandate(1)-julian(a,1,1,0,0,0))/365.25);
[a,~] = gregorian(raw.juliandate(end)); [a,~] = gregorian(raw.juliandate(end));
magnetic_deviation_end = magdev(mooring.lat,mooring.lon,0,a+(raw.juliandate(end)-julian(a,1,1,0,0,0))/365.25); magnetic_deviation_end = -magdev(mooring.lat,mooring.lon,0,a+(raw.juliandate(end)-julian(a,1,1,0,0,0))/365.25);
rot = (magnetic_deviation_ini+magnetic_deviation_end)/2; rot = (magnetic_deviation_ini+magnetic_deviation_end)/2;
mag_dev = linspace(magnetic_deviation_ini, magnetic_deviation_end, length(time0)); mag_dev = linspace(magnetic_deviation_ini, magnetic_deviation_end, length(time0));
mag_dev = mag_dev(first:last); mag_dev = mag_dev(first:last);
...@@ -131,10 +131,24 @@ mag_dev = mag_dev(first:last); ...@@ -131,10 +131,24 @@ mag_dev = mag_dev(first:last);
%% Correction of magnetic deviation %% Correction of magnetic deviation
disp('****') disp('****')
disp('Correct magnetic deviation') disp('Correct magnetic deviation')
% for ii = 1 : length(mag_dev)
% [u(:,ii),v(:,ii)] = uvrot(u2(:,ii), v2(:,ii), -mag_dev(ii));
% end
mag_dev = -mag_dev * pi/180;
for ii = 1 : length(mag_dev) for ii = 1 : length(mag_dev)
[u(:,ii),v(:,ii)] = uvrot(u2(:,ii), v2(:,ii), -mag_dev(ii)); M(1,1) = cos(mag_dev(ii));
M(1,2) = -sin(mag_dev(ii));
M(2,1) = sin(mag_dev(ii));
M(2,2) = cos(mag_dev(ii));
vvel(1,:) = u2(:,ii);
vvel(2,:) = v2(:,ii);
vvvel = M * vvel;
u(:,ii) = vvvel(1,:);
v(:,ii) = vvvel(2,:);
end end
%% Correct percent good: Exclude data with percent good below prct_good %% Correct percent good: Exclude data with percent good below prct_good
figure; figure;
colormap jet; colormap jet;
...@@ -279,6 +293,21 @@ else ...@@ -279,6 +293,21 @@ else
offset = 0; offset = 0;
end end
binmat = repmat((1:nbin)',1,length(dpt1));
if strcmp(adcp.direction,'up')
z(1,:) = dpt1(1,:)-(tlen+blen+lag)*0.5-blnk;
for ii = 2:length(binmat(:,1))
z(ii,:) = z(1,:)-(binmat(ii,:)-1.5)*blen;
end
elseif strcmp(adcp.direction,'dn')
z(1,:) = dpt1(1,:)+(tlen+blen+lag)*0.5+blnk;
for ii = 2:length(binmat(:,1))
z(ii,:) = z(1,:)+(binmat(ii,:)-1.5)*blen;
end
else
error('Bin depth calculation: unknown direction!');
end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment