Skip to content
Snippets Groups Projects
Commit 6c112ee1 authored by Pierre Rousselot's avatar Pierre Rousselot
Browse files

Version reviewed

parent f50a844a
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
% - U and V fields interpolated on a regulard grid, filtered and subsampled % - U and V fields interpolated on a regulard grid, filtered and subsampled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; clear all;close all;
close all;
% path % path
addpath('.\moored_adcp_proc'); addpath('.\moored_adcp_proc');
...@@ -122,4 +121,30 @@ print(hf,graph_name,'-dpdf','-r300'); ...@@ -122,4 +121,30 @@ print(hf,graph_name,'-dpdf','-r300');
% rmpath % rmpath
rmpath('.\moored_adcp_proc'); rmpath('.\moored_adcp_proc');
clear all; close all;
%% Write netcdf file
[yr_start , ~, ~] = gregorian(down_time(1));
[yr_end, ~, ~] = gregorian(down_time(length(down_time)));
ncid=netcdf.create([fpath_output,'ADCP_',mooring.name, '_',num2str(yr_start),'_',num2str(yr_end),'_1d.nc'],'NC_WRITE');
%create dimension
dimidt = netcdf.defDim(ncid,'time',length(down_time));
dimidz = netcdf.defDim(ncid,'depth',length(z_final));
%Define IDs for the dimension variables (pressure,time,latitude,...)
time_ID=netcdf.defVar(ncid,'time','double',dimidt);
depth_ID=netcdf.defVar(ncid,'depth','double',dimidz);
%Define the main variable ()
u_ID = netcdf.defVar(ncid,'u','double',[dimidt dimidz]);
v_ID = netcdf.defVar(ncid,'v','double',[dimidt dimidz]);
%We are done defining the NetCdf
netcdf.endDef(ncid);
%Then store the dimension variables in
netcdf.putVar(ncid,time_ID,down_time);
netcdf.putVar(ncid,depth_ID,z_final);
%Then store my main variable
netcdf.putVar(ncid,u_ID,u_final);
netcdf.putVar(ncid,v_ID,v_final);
%We're done, close the netcdf
netcdf.close(ncid);
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
% OUTPUTS: % OUTPUTS:
% - U and V fields interpolated on a regulard grid, filtered and subsampled % - U and V fields interpolated on a regulard grid, filtered and subsampled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% First part --------------------------------------------------------------------------------------------------------------------
close all close all
clear all clear all
% path
addpath('.\moored_adcp_proc');
%% META information: %% META information:
% Path
addpath('.\moored_adcp_proc'); % ou par exemple ('C:\Users\IRD_US_IMAGO\TRAITEMENTS\ADCP_MOUILLAGE\01_DATA_PROCESSING\moored_adcp_proc');
addpath('.\backscatter'); % (Optionnel) / ou par exemple ('C:\Users\IRD_US_IMAGO\TRAITEMENTS\ADCP_MOUILLAGE\01_DATA_PROCESSING\backscatter');
% Location rawfile % Location rawfile
fpath = ''; fpath = '';
rawfile='.\data_example\FR24_000.000'; % binary file with .000 extension rawfile='.\data_example\FR24_000.000'; % binary file with .000 extension
...@@ -23,47 +26,57 @@ rawfile='.\data_example\FR24_000.000'; % binary file with .000 extension ...@@ -23,47 +26,57 @@ rawfile='.\data_example\FR24_000.000'; % binary file with .000 extension
% Directory for outputs % Directory for outputs
fpath_output = '.\data_example\'; fpath_output = '.\data_example\';
cruise.name = ''; % Cruise/mooring info
mooring.name='10W0N'; cruise.name = 'Cruise Name';
mooring.lat=00+00/60; %latitude mooring.name='Lat Lon'; % 0N10W par exemple
mooring.lon=-10+00/60; %longitude mooring.lat=00+00/60; %latitude en degrs dcimaux
mooring.lon=-10+00/60; %longitude en degrs dcimaux
% ADCP info
adcp.sn=15258; adcp.sn=15258;
adcp.type='150 khz Quartermaster'; adcp.type='150 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=178; % nominal instrument depth adcp.instr_depth=280; % 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
% If ADCP was not set up to correct for magnetic deviation internally % If ADCP was not set up to correct for magnetic deviation internally
% ("EA0" code in configuration file), use http://www.ngdc.noaa.gov/geomag-web/#declination % ("EA0" code in configuration file), use http://www.ngdc.noaa.gov/geomag-web/#declination
% Magnetic deviation: Mean of deviations at time of deployment and time of recovery % Magnetic deviation: Mean of deviations at time of deployment and time of recovery
% magnetic deviation values % Magnetic deviation values
magnetic_deviation_ini = 15.11; magnetic_deviation_ini = 9.29;
magnetic_deviation_end = 15.01; magnetic_deviation_end = 9.05;
rot=-(magnetic_deviation_ini+magnetic_deviation_end)/2; rot=-(magnetic_deviation_ini+magnetic_deviation_end)/2;
% determine first and last indiced when instrument was at depth (you can do this by plotting 'raw.pressure' for example % Read rawfile
first = 8; fprintf('Read %s\n', rawfile);
last = 7963; raw=read_os3(rawfile,'all');
figure;plot(raw.pressure);set(gca,'ydir','reverse');
title('pressure sensor');ylabel('Depth(m)');xlabel('Time index');grid on;
saveas(gcf,[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Pressure_sensor'],'fig')
% Second part --------------------------------------------------------------------------------------------------------------------
% Determine first and last indiced when instrument was at depth (you can do this by plotting 'raw.pressure' for example
first = 12;
last = 17620;
% amplitude of the bins / Correction ADCP's depth
ea = squeeze(mean(raw.amp(:,:,first:last),2));
figure; imagesc(ea);title('Amplitude of the bins'); colorbar;
ylabel('Bins');xlabel('Time index');
saveas(gcf,[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Amplitude_bins'],'fig')
% Third part --------------------------------------------------------------------------------------------------------------------
% If upward looking: range of surface bins used for instrument depth correction below! % If upward looking: range of surface bins used for instrument depth correction below!
sbins= 17:28; % here a range of bins is given which cover the surface reflection sbins= 31:38; % here a range of bins is given which cover the surface reflection
% Exclude data with percent good below prct_good % Exclude data with percent good below prct_good
prct_good = 20; prct_good = 20;
% Read rawfile
fprintf('Read %s\n', rawfile);
raw=read_os3(rawfile,'all');
figure;plot(raw.pressure);set(gca,'ydir','reverse');
freq = raw.config.sysconfig.frequency;
%% Read data %% Read data
ea = squeeze(mean(raw.amp(:,:,first:last),2)); % amplitude of the bins freq = raw.config.sysconfig.frequency;
figure; imagesc(ea);title('Amplitude of the bins'); colorbar;
u2 = squeeze(raw.vel(:,1,first:last)); u2 = squeeze(raw.vel(:,1,first:last));
v2 = squeeze(raw.vel(:,2,first:last)); v2 = squeeze(raw.vel(:,2,first:last));
...@@ -101,12 +114,16 @@ binmat = repmat((1:nbin)',1,length(dpt1)); ...@@ -101,12 +114,16 @@ binmat = repmat((1:nbin)',1,length(dpt1));
% surface reflection, which is done in adcp_surface_fit % surface reflection, which is done in adcp_surface_fit
if strcmp(adcp.direction,'up') if strcmp(adcp.direction,'up')
[z,dpt1,offset,xnull]=adcp_surface_fit(dpt,ea,sbins,blen,blnk,nbin); [z,dpt1,offset,xnull]=adcp_surface_fit(dpt,ea,sbins,blen,blnk,nbin);
elseif strcmp(direction,'dn') elseif strcmp(adcp.direction,'dn')
z = dpt1+(binmat-0.5)*blen+blnk; z = dpt1+(binmat-0.5)*blen+blnk;
else else
error('Bin depth calculation: unknown direction!'); error('Bin depth calculation: unknown direction!');
end end
saveas(figure(1),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Hist_diff_orig-depth_recon-depth'],'fig')
saveas(figure(2),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Offset_depth'],'fig')
saveas(figure(3),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Amplitude_bins_2'],'fig')
%% Remove bad data if ADCP is looking upward %% Remove bad data if ADCP is looking upward
u1=u; v1=v; w1=w; vel_err1=vel_err; ea1=ea; u1=u; v1=v; w1=w; vel_err1=vel_err; ea1=ea;
...@@ -115,7 +132,7 @@ if strcmp(adcp.direction,'up') ...@@ -115,7 +132,7 @@ if strcmp(adcp.direction,'up')
sz_dpt(i)=adcp_shadowzone(dpt(i),raw.config.sysconfig.angle); % depending on the instrument depth and the beam angle the shadow zone, i.e. the depth below the surface which is contaminated by the surface reflection is determined sz_dpt(i)=adcp_shadowzone(dpt(i),raw.config.sysconfig.angle); % depending on the instrument depth and the beam angle the shadow zone, i.e. the depth below the surface which is contaminated by the surface reflection is determined
iz(i)=find(z(:,i)>sz_dpt(i),1,'last'); iz(i)=find(z(:,i)>sz_dpt(i),1,'last');
sbin(i)=bin(iz(i))-1; sbin(i)=bin(iz(i));
% here a manual criterion should be hard-coded if % here a manual criterion should be hard-coded if
% adcp_check_surface (below) shows bad velocities close to the % adcp_check_surface (below) shows bad velocities close to the
...@@ -138,6 +155,7 @@ if strcmp(adcp.direction,'up') ...@@ -138,6 +155,7 @@ if strcmp(adcp.direction,'up')
% here the closest bins below the surface are plotted that are supposed to have good velocities, if there are still bad velocities a manual criterion needs to be found % here the closest bins below the surface are plotted that are supposed to have good velocities, if there are still bad velocities a manual criterion needs to be found
end end
end end
saveas(figure(4),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','Meridional_zonal_velocity'],'fig')
%% SAVE DATA %% SAVE DATA
% More meta information % More meta information
...@@ -180,11 +198,14 @@ end ...@@ -180,11 +198,14 @@ end
%% Horizontal interpolation, filtering and subsampling %% Horizontal interpolation, filtering and subsampling
[uintfilt,vintfilt,inttim] = adcp_filt_sub(data,u_interp',v_interp',1:length(Z),40); [uintfilt,vintfilt,inttim] = adcp_filt_sub(data,u_interp',v_interp',1:length(Z),40);
saveas(figure(5),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','data_raw_filt_subsampled_1'],'fig')
saveas(figure(6),[fpath_output,mooring.name,'_',num2str(adcp.sn),'_instr_',num2str(instr),'_','data_raw_filt_subsampled_2'],'fig')
% Save interpolated data % Save interpolated data
data.uintfilt=uintfilt(1:length(Z),:); bin_start = 1; % bin indice where good interpolated data for the whole dataset start
data.vintfilt=vintfilt(1:length(Z),:); data.uintfilt=uintfilt(bin_start:length(Z),:);
data.Z = Z(1:length(Z)); data.vintfilt=vintfilt(bin_start:length(Z),:);
data.Z = Z(bin_start:length(Z));
data.inttim = inttim; data.inttim = inttim;
save([fpath_output, mooring.name '_' num2str(adcp.sn) '_instr_' sprintf('%02d',instr) '_int_filt_sub.mat'],'adcp','mooring','data','raw'); save([fpath_output, mooring.name '_' num2str(adcp.sn) '_instr_' sprintf('%02d',instr) '_int_filt_sub.mat'],'adcp','mooring','data','raw');
...@@ -195,7 +216,7 @@ niv_v = (-0.5:0.1:0.5); ...@@ -195,7 +216,7 @@ niv_v = (-0.5:0.1:0.5);
hf=figure('position', [0, 0, 1400, 1000]); hf=figure('position', [0, 0, 1400, 1000]);
%u %u
subplot(2,1,1); subplot(2,1,1);
[C,h] = contourf(inttim,Z(1:length(Z)),uintfilt(1:length(Z),:),niv_u); [C,h] = contourf(inttim,Z(bin_start:length(Z)),uintfilt(bin_start:length(Z),:),niv_u);
set(h,'LineColor','none'); set(h,'LineColor','none');
caxis(niv_u([1 end])); caxis(niv_u([1 end]));
h=colorbar; h=colorbar;
...@@ -209,7 +230,7 @@ title({[mooring.name, ' - MERIDIONAL VELOCITY - RDI ',num2str(freq),' kHz']}); ...@@ -209,7 +230,7 @@ title({[mooring.name, ' - MERIDIONAL VELOCITY - RDI ',num2str(freq),' kHz']});
%v %v
subplot(2,1,2); subplot(2,1,2);
[C,h] = contourf(inttim,Z(1:length(Z)),vintfilt(1:length(Z),:),niv_v); [C,h] = contourf(inttim,Z(bin_start:length(Z)),vintfilt(bin_start:length(Z),:),niv_v);
set(h,'LineColor','none'); set(h,'LineColor','none');
caxis(niv_v([1 end])); caxis(niv_v([1 end]));
h=colorbar; h=colorbar;
...@@ -254,5 +275,7 @@ netcdf.putVar(ncid,v_ID,vintfilt); ...@@ -254,5 +275,7 @@ netcdf.putVar(ncid,v_ID,vintfilt);
netcdf.close(ncid); netcdf.close(ncid);
% rmpath % rmpath
rmpath('..\moored_adcp_proc'); % rmpath('..\moored_adcp_proc');
clear all; close all; clear all; close all;
\ No newline at end of file
% -------------------------------------------------------------------------------------------
\ No newline at end of file
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