Skip to content

Commit

Permalink
Merge branch 'postprocess_SWIFT'
Browse files Browse the repository at this point in the history
  • Loading branch information
jthomson-apluw committed Oct 11, 2024
2 parents 6340d26 + d4b2d03 commit 5bfba46
Show file tree
Hide file tree
Showing 40 changed files with 3,924 additions and 2,166 deletions.
Binary file modified .DS_Store
Binary file not shown.
266 changes: 175 additions & 91 deletions Aquadopp/catAQH.m
Original file line number Diff line number Diff line change
@@ -1,104 +1,188 @@
function aqh = catAQH(AQH)
function aqh = catAQH(AQH,varargin)
%Produces summary plot of burst-averaged signature data stored in 'SIG'
% also returns concatenated data
plotaqh = true;

aqh.time = [AQH.time];
aqh.hrz = AQH(round(end/2)).HRprofile.z;
aqh.hrw = NaN(length(aqh.hrz),length(aqh.time));
aqh.hrwvar = aqh.hrw;
aqh.hrcorr = aqh.hrw;
aqh.hramp = aqh.hrw;
aqh.eps_struct = aqh.hrw;
aqh.struct_slope = aqh.hrw;
aqh.pitchvar = NaN(1,length(aqh.time));
for it = 1:length(aqh.time)
%HR
aqh.hrw(:,it) = AQH(it).HRprofile.w;
aqh.hrwvar(:,it) = AQH(it).HRprofile.werr;
aqh.hrcorr(:,it) = AQH(it).QC.hrcorr;
aqh.hramp(:,it) = AQH(it).QC.hramp;
aqh.eps_struct(:,it) = AQH(it).HRprofile.eps_structHP;
aqh.struct_slope(:,it) = AQH(it).QC.slopeHP;
aqh.pitchvar(it) = AQH(it).QC.pitchvar;
end
plotaqh = false;
QCaqh = false;

% Plot
if plotaqh && length(aqh.time)>1
clear b
figure('color','w')
MP = get(0,'monitorposition');
set(gcf,'outerposition',MP(1,:).*[1 1 1 1]);
h = tight_subplot(6,1);
if nargin > 1
if any(strcmp(varargin,'plot'))
plotaqh = true;
end
if any(strcmp(varargin,'qc'))
QCaqh = true;
end
if ~(any(strcmp(varargin,'plot') | strcmp(varargin,'qc')))
error('Optional inputs must be ''plot'' or ''qc''')
end
end

%Pitch + Roll
axes(h(1))
b(1) = bar(aqh.time,sqrt(aqh.pitchvar));
b(1).FaceColor = 'r';
set(b,'EdgeColor',rgb('grey'))
ylabel('\sigma_{\phi} (^{\circ})');title('Pitch Variance')
c = colorbar;c.Visible = 'off';
xlim([min(aqh.time) max(aqh.time)])
ylim([0 mean(sqrt(aqh.pitchvar),'omitnan') + 2*std(sqrt(aqh.pitchvar),'omitnan')])
datetick('x','KeepLimits')
if isfield(AQH,'time')
aqh.time = [AQH.time];
nt = length(aqh.time);

aqh.hrz = AQH(round(end/2)).HRprofile.z;
nzhr = length(aqh.hrz);
aqh.hrcorr = NaN(nzhr,nt);
aqh.hramp = aqh.hrcorr;
aqh.hrw = aqh.hrcorr;
aqh.hrwvar = aqh.hrcorr;
aqh.epshp = aqh.hrcorr;
aqh.epseof = aqh.hrcorr;
aqh.epsnf = aqh.hrcorr;
aqh.epswv = aqh.hrcorr;
aqh.A = aqh.hrcorr;
aqh.B = aqh.hrcorr;
aqh.N = aqh.hrcorr;
aqh.mspe = aqh.hrcorr;
aqh.slope = aqh.hrcorr;
aqh.pspike = aqh.hrcorr;
aqh.pbadping = NaN(1,nt);
aqh.wpeofmag = aqh.hrcorr;
aqh.eofs = NaN(nzhr,nzhr,nt);
aqh.eofsvar = aqh.hrcorr;
aqh.pitch = NaN(1,nt);
aqh.roll = NaN(1,nt);
aqh.head = NaN(1,nt);
aqh.pitchvar = NaN(1,nt);
aqh.rollvar = NaN(1,nt);
aqh.headvar = NaN(1,nt);

%Amplitude
axes(h(2))
pcolor(aqh.time,-aqh.hrz,aqh.hramp);shading flat
caxis([80 150])
ylabel('Depth (m)');cmocean('thermal');title('Amplitude')
c = colorbar;c.Label.String = 'A [counts]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
for it = 1:length(aqh.time)

%HR
nz = length(AQH(it).HRprofile.w);
aqh.hrcorr(1:nz,it) = AQH(it).HRprofile.QC.hrcorr;
aqh.hramp(1:nz,it) = AQH(it).HRprofile.QC.hramp;
aqh.pspike(1:nz,it) = AQH(it).HRprofile.QC.pspike;
aqh.pbadping(it) = AQH(it).HRprofile.QC.pbadping;
aqh.hrw(1:nz,it) = AQH(it).HRprofile.w;
aqh.hrwvar(1:nz,it) = AQH(it).HRprofile.wvar;
aqh.epshp(1:nz,it) = AQH(it).HRprofile.QC.epsHP;
aqh.epseof(1:nz,it) = AQH(it).HRprofile.QC.epsEOF;
aqh.epsnf(1:nz,it) = AQH(it).HRprofile.QC.epsNF;
aqh.epswv(1:nz,it) = AQH(it).HRprofile.QC.epsWV;
aqh.A(1:nz,it) = AQH(it).HRprofile.QC.qualEOF.A;
aqh.B(1:nz,it) = AQH(it).HRprofile.QC.qualEOF.B;
aqh.N(1:nz,it) = AQH(it).HRprofile.QC.qualEOF.N;
aqh.mspe(1:nz,it) = AQH(it).HRprofile.QC.qualEOF.mspe;
aqh.slope(1:nz,it) = AQH(it).HRprofile.QC.qualEOF.slope;

aqh.wpeofmag(1:nz,it) = AQH(it).HRprofile.QC.wpeofmag;
aqh.eofs(1:nz,1:nz,it) = AQH(it).HRprofile.QC.eofs;
aqh.eofsvar(1:nz,it) = AQH(it).HRprofile.QC.eofsvar;

%Correlation
axes(h(3))
pcolor(aqh.time,-aqh.hrz,aqh.hrcorr);shading flat
caxis([0 100])
ylabel('Depth (m)');cmocean('curl');title('Correlation')
c = colorbar;c.Label.String = 'C [%]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
% Motion
aqh.pitch(it) = AQH(it).motion.pitch;
aqh.roll(it) = AQH(it).motion.roll;
aqh.head(it) = AQH(it).motion.head;
aqh.pitchvar(it) = AQH(it).motion.pitchvar;
aqh.rollvar(it) = AQH(it).motion.rollvar;
aqh.headvar(it) = AQH(it).motion.headvar;
end

%Velocity
axes(h(4))
pcolor(aqh.time,-aqh.hrz,aqh.hrw);shading flat
caxis([-0.025 0.025])
ylabel('Depth (m)');cmocean('balance');title('W_{HR}')
c = colorbar;c.Label.String = 'ms^{-1}';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
%QC
badburst = [AQH.badburst];
if QCaqh && sum(badburst) < length(aqh.time)

aqh.hrcorr(:,badburst) = [];
aqh.hramp(:,badburst) = [];
aqh.hrw(:,badburst) = [];
aqh.hrwvar(:,badburst) = [];
aqh.epshp(:,badburst) = [];
aqh.epseof(:,badburst) = [];
aqh.epsnf(:,badburst) = [];
aqh.epswv(:,badburst) = [];
aqh.A(:,badburst) = [];
aqh.B(:,badburst) = [];
aqh.N(:,badburst) = [];
aqh.mspe(:,badburst) = [];
aqh.slope(:,badburst) = [];
aqh.pspike(:,badburst) = [];
aqh.pbadping(badburst) = [];
aqh.time(badburst) = [];
aqh.wpeofmag(:,badburst) = [];
aqh.eofs(:,:,badburst) = [];
aqh.eofsvar(:,badburst) = [];
aqh.pitch(badburst) = AQH(badburst).motion.pitch;
aqh.roll(badburst) = AQH(badburst).motion.roll;
aqh.head(badburst) = AQH(badburst).motion.head;
aqh.pitchvar(badburst) = AQH(badburst).motion.pitchvar;
aqh.rollvar(badburst) = AQH(badburst).motion.rollvar;
aqh.headvar(badburst) = AQH(badburst).motion.headvar;
else
aqh.badburst = badburst;
end

% Velocity Variance
% pcolor(aqh.time,-aqh.hrz,aqh.hrwvar);shading flat
% caxis([0 0.03]);
% ylabel('Depth (m)');title('\sigma_W_{HR}')
% c = colorbar;c.Label.String = 'ms^{-1}';
% xlim([min(aqh.time) max(aqh.time)])
% datetick('x','KeepLimits')
% Plot
if plotaqh && length(aqh.time)>1

%Dissipation Rate
axes(h(5))
pcolor(aqh.time,-aqh.hrz,log10(aqh.eps_struct));shading flat
caxis([-7.5 -4.5]);
ylabel('Depth (m)');title('SF \epsilon')
c = colorbar;c.Label.String = 'log_{10}(m^3s^{-2})';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
figure('color','w')
MP = get(0,'monitorposition');
set(gcf,'outerposition',MP(1,:).*[1 1 1 1]);
clear b

% SF Slope
axes(h(6))
pcolor(aqh.time,-aqh.hrz,aqh.struct_slope);shading flat
caxis([0 2*2/3]);
ylabel('Depth (m)');title('SF Slope')
c = colorbar;c.Label.String = 'D \propto r^n';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
cmocean('curl')
% HR
h(1) = subplot(4,2,1);% HR Correlation
pcolor(aqh.time,-aqh.hrz,aqh.hrcorr);shading flat
caxis([50 100]);
ylabel('Depth (m)');cmocean('thermal');title('HR Correlation')
c = colorbar;c.Label.String = '[%]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(3) = subplot(4,2,3);% Vertical Velocity
pcolor(aqh.time,-aqh.hrz,aqh.hrw);shading flat
caxis([-0.05 0.05]);
ylabel('Depth (m)');cmocean('balance');title('W')
c = colorbar;c.Label.String = 'ms^{-1}';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(5) = subplot(4,2,5);% Velocity Variance
pcolor(aqh.time,-aqh.hrz,sqrt(aqh.hrwvar));shading flat
caxis([0 0.5]);
ylabel('Depth (m)');title('\sigma_W')
c = colorbar;c.Label.String = 'ms^{-1}';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(7) = subplot(4,2,7);% Percent Spikes
pcolor(aqh.time,-aqh.hrz,100*aqh.pspike);shading flat
caxis([0 25]);colormap(gca,lansey(25))
ylabel('Depth (m)');title('Spike Percent')
c = colorbar;c.Label.String = 'P [%]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(2) = subplot(4,2,2);% HR Amplitude
pcolor(aqh.time,-aqh.hrz,aqh.hramp);shading flat
caxis([60 160]);
ylabel('Depth (m)');cmocean('haline');title('HR Amplitude')
c = colorbar;c.Label.String = '[counts]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(8) = subplot(4,2,4);% Dissipation Rate
pcolor(aqh.time,-aqh.hrz,log10(aqh.epseof));shading flat
caxis([-6 -3]);colormap(gca,'jet')
ylabel('Depth (m)');title('Dissipation Rate')
c = colorbar;c.Label.String = 'log_{10}(m^3s^{-2})';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(6) = subplot(4,2,6);% MSPE of SF r^(2/3) fit
pcolor(aqh.time,-aqh.hrz,100*sqrt(aqh.mspe));shading flat
caxis([0 25]);colormap(gca,lansey(25))
ylabel('Depth (m)');title('MSPE')
c = colorbar;c.Label.String = '[%]';
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
h(8) = subplot(4,2,8);% Best-fit slope to SF
pcolor(aqh.time,-aqh.hrz,aqh.slope);shading flat
caxis([0 2*2/3]);
ylabel('Depth (m)');title('SF Slope')
c = colorbar;c.Label.String = 'D \propto r^n';cmocean('curl')
xlim([min(aqh.time) max(aqh.time)])
datetick('x','KeepLimits')
drawnow
end

h = findobj('Type','axes');
h = flipud(h);
set(h(1:end-1),'XTickLabel',[])
else
aqh = [];
warning('AQH empty...')
end

end
Loading

0 comments on commit 5bfba46

Please sign in to comment.