0001 function [Plots]=do_ph_change_points_plot(plotOPTS,FVCOM,startIdx)
0002
0003
0004 m_mappath;
0005
0006 plotOPTS.figure=1;
0007 plotOPTS.var_plot='ph';
0008 plotOPTS.do_mesh=1;
0009 startIdx=1;
0010
0011 plotOPTS.threshold_change=-0.2;
0012
0013 plotOPTS.nz_plot=1;
0014
0015 [nx,nz,ttot]=size(FVCOM.(plotOPTS.var_plot));
0016
0017
0018 if ~isfield(FVCOM,plotOPTS.var_plot)
0019 error('Need %s input to calculate change in %s.',plotOPTS.var_plot,plotOPTS.var_plot)
0020 end
0021
0022
0023 if isfield(plotOPTS,'save_intervals') && isempty(plotOPTS.save_intervals)
0024 plotOPTS.save_intervals=1:length(plotOPTS.Time_record);
0025 dontSave=1;
0026 else
0027 dontSave=0;
0028 end
0029
0030
0031 dt=round((plotOPTS.Time_record(2)-plotOPTS.Time_record(1))*24*60*60);
0032
0033
0034 sigThickness=roundn(abs(diff(FVCOM.siglev,1,2)),-5);
0035
0036 totalDepth=repmat(FVCOM.h,1,size(FVCOM.zeta,2))+FVCOM.zeta;
0037
0038 cellVolume=nan(nx,nz,ttot);
0039 for ii=1:nz
0040 for jj=1:ttot
0041
0042
0043
0044
0045
0046
0047 cellVolume(:,ii,jj)=totalDepth(:,jj).*sigThickness(:,ii).*FVCOM.art1;
0048 end
0049 end
0050
0051
0052
0053
0054
0055 if isfield(plotOPTS,'depth_average') && plotOPTS.depth_average
0056 bgPH=squeeze(mean(FVCOM.(plotOPTS.var_plot)(:,:,startIdx),2));
0057 else
0058 bgPH=squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,startIdx));
0059 end
0060
0061 if isfield(plotOPTS,'depth_average') && plotOPTS.depth_average
0062
0063
0064 phMean=squeeze(mean(FVCOM.(plotOPTS.var_plot),2));
0065 phDiff=phMean-repmat(bgPH,1,size(phMean,2));
0066 else
0067 phDiff=squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,:))-repmat(bgPH,1,size(FVCOM.(plotOPTS.var_plot),3));
0068 end
0069
0070
0071 phDiffCumulative=zeros(nx,ttot,'single');
0072 for tt=1:ttot
0073 if tt>1 && tt<ttot
0074 currpH=FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,tt);
0075 nextpH=FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,tt+1);
0076 phDiffCumulative(:,tt)=phDiffCumulative(:,tt)+(currpH-nextpH);
0077 elseif tt==1
0078 currpH=FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,tt);
0079 nextpH=FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,tt+1);
0080 phDiffCumulative(:,tt)=currpH-nextpH;
0081 end
0082 end
0083
0084 [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0085
0086 foundXY=cell(1,length(plotOPTS.nz_plot));
0087 countSites=zeros(nx,1);
0088
0089 for tt=1:ttot
0090
0091 idx=find(phDiff(:,tt)<plotOPTS.threshold_change);
0092 if ~isempty(idx)
0093 countSites(idx)=countSites(idx)+1;
0094 foundXY{tt}.xy=[X(idx),Y(idx)];
0095 end
0096 end
0097
0098
0099
0100
0101 totalVolume=squeeze(cellVolume(:,plotOPTS.nz_plot,1)).*countSites;
0102
0103
0104 Plots(1).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0105 'Cdata',countSites,...
0106 'edgecolor','interp','facecolor','interp');
0107 if plotOPTS.do_mesh
0108
0109 [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0110 patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0111 'EdgeColor',[0.6 0.6 0.6],'FaceColor','none'); hold on
0112 end
0113 colorbar
0114
0115 figure;
0116 patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0117 'Cdata',totalVolume/1e9,...
0118 'edgecolor','interp','facecolor','interp');
0119 if plotOPTS.do_mesh
0120
0121 [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0122 patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0123 'EdgeColor',[0.6 0.6 0.6],'FaceColor','none'); hold on
0124 end
0125 colorbar
0126
0127 figure;
0128 patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0129 'Cdata',squeeze(FVCOM.ph(:,1,2)),...
0130 'edgecolor','interp','facecolor','interp');
0131 colorbar
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141