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