VMT_CompMeanXS

PURPOSE ^

Computes the mean cross section data from individual transects

SYNOPSIS ^

function [A,V,log_text] = VMT_CompMeanXS(z,A,V)

DESCRIPTION ^

 Computes the mean cross section data from individual transects
 that have been previously mapped to a common grid.

 (adapted from code by J. Czuba)

 P.R. Jackson, USGS, 12-9-08

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [A,V,log_text] = VMT_CompMeanXS(z,A,V)
0002 % Computes the mean cross section data from individual transects
0003 % that have been previously mapped to a common grid.
0004 %
0005 % (adapted from code by J. Czuba)
0006 %
0007 % P.R. Jackson, USGS, 12-9-08
0008 
0009 
0010 
0011 %% Average mapped mean cross-sections from individual transects together
0012 
0013 % Averaging for backscatter is only computed for Rio Grande probes
0014 % Procedure for SonTek probes is different
0015 
0016 switch V.probeType
0017     % Assign mapped uniform grid vectors to the same array for averaging
0018     % Put all of the Sontek data in one place, then interpolate values at
0019     % the MCS grid
0020     case 'M9'
0021         
0022         x       = []; 
0023         y       = []; 
0024         East    = [];
0025         North   = [];
0026         Vert    = [];
0027         Error   = [];
0028         for zi = 1: z
0029             
0030             Dir(:,:,zi) = A(zi).Comp.mcsDir(:,:);
0031             Bed(:,:,zi) = A(zi).Comp.mcsBed(:,:);
0032             
0033             xx    = meshgrid(A(zi).Comp.dl,A(zi).Wat.binDepth(:,1));
0034             x     = [x; xx(:)];
0035             y     = [y; A(zi).Wat.binDepth(:)];
0036             East  = [East;  A(zi).Wat.vEast(:)];
0037             North = [North; A(zi).Wat.vNorth(:)];
0038             Vert  = [Vert;  A(zi).Wat.vVert(:)];
0039             Error = [Error; A(zi).Wat.vError(:)];
0040         end
0041 
0042         % FIXME: I call griddate 3 times. Need to rewrite to create 1
0043         % delauney tri, and replace the V data.
0044         V.mcsEast  = griddata(x,y,East,V.mcsDist,V.mcsDepth);
0045         V.mcsNorth = griddata(x,y,North,V.mcsDist,V.mcsDepth);
0046         V.mcsVert  = griddata(x,y,Vert,V.mcsDist,V.mcsDepth);
0047         V.mcsError = griddata(x,y,Error,V.mcsDist,V.mcsDepth);
0048         
0049     otherwise % Could be 'RG' or 'RR'
0050         for zi = 1 : z
0051             
0052             Back(:,:,zi)  = A(zi).Comp.mcsBack(:,:);
0053             Dir(:,:,zi)   = A(zi).Comp.mcsDir(:,:);
0054             Mag(:,:,zi)   = A(zi).Comp.mcsMag(:,:);
0055             East(:,:,zi)  = A(zi).Comp.mcsEast(:,:);
0056             North(:,:,zi) = A(zi).Comp.mcsNorth(:,:);
0057             Vert(:,:,zi)  = A(zi).Comp.mcsVert(:,:);
0058             Error(:,:,zi) = A(zi).Comp.mcsError(:,:);
0059             Bed(:,:,zi)   = A(zi).Comp.mcsBed(:,:);
0060             
0061         end
0062         
0063         numavg = nansum(~isnan(Mag),3);
0064         numavg(numavg==0) = NaN;
0065         enscnt = nanmean(numavg,1);
0066         [I,J] = ind2sub(size(enscnt),find(enscnt>=1));  %Changed to >= 1 PRJ 12-10-08  (uses data even if only one measurement)
0067         
0068         
0069         Backone= Back;
0070         Backone(~isnan(Back))=1;
0071         V.countBack = nansum(Backone,3);
0072         V.countBack(V.countBack==0)=NaN;
0073         V.mcsBack = nanmean(Back,3);
0074         
0075         
0076         Magone = Mag;
0077         Vertone = Vert;
0078         Bedone = Bed;
0079         
0080         
0081         Magone(~isnan(Mag))=1;
0082         Vertone(~isnan(Vert))=1;
0083         Bedone(~isnan(Bed))=1;
0084         
0085         
0086         V.countMag = nansum(Magone,3);
0087         V.countVert = nansum(Vertone,3);
0088         V.countBed = nansum(Bedone,3);
0089         
0090         V.countMag(V.countMag==0)=NaN;
0091         V.countVert(V.countVert==0)=NaN;
0092         V.countBed(V.countBed==0)=NaN;
0093         
0094         % Average mapped mean cross-sections from individual transects together
0095         
0096         %V.mcsDir = nanmean(Dir,3);  % Will not average correctly in all cases due to 0-360
0097         %wrapping (PRJ, 9-29-10)
0098         %V.mcsMag = nanmean(Mag,3);  %Mag recomputed from north, east, up components(PRJ, 3-21-11)
0099         V.mcsEast  = nanmean(East,3);
0100         V.mcsNorth = nanmean(North,3);
0101         V.mcsVert  = nanmean(Vert,3);
0102         V.mcsError = nanmean(Error,3);
0103     
0104     
0105 
0106 end % switch Probe type
0107 
0108         %Average Magnitude
0109         V.mcsMag = sqrt(V.mcsEast.^2 + V.mcsNorth.^2 + V.mcsVert.^2);
0110         
0111         %Average the flow direction
0112         V.mcsDir = ari2geodeg((atan2(V.mcsNorth, V.mcsEast))*180/pi);
0113         % V.mcsDir = 90 - (atan2(V.mcsNorth, V.mcsEast))*180/pi; %Compute the atan from the velocity componentes, convert to radians, and rotate to north axis
0114         % qindx = find(V.mcsDir < 0);
0115         %     if ~isempty(qindx)
0116         %         V.mcsDir(qindx) = V.mcsDir(qindx) + 360;  %Must add 360 deg to Quadrant 4 values as they are negative angles from the +y axis
0117         %     end
0118         
0119         V.mcsBed = nanmean(Bed,3);
0120         
0121         %Compute the Bed Elevation in meters (Takes the mean value of the entered
0122         %WSE timeseries if file loaded)
0123         %disp(['Assigned Water Surface Elevation (WSE; in meters) = ' num2str(mean(A(1).wse))])
0124         log_text = ['      WSE in meters) = ' num2str(mean(A(1).wse))];
0125         V.mcsBedElev = mean(A(1).wse) - V.mcsBed;
0126         
0127 
0128 
0129 return
0130 
0131 % Remove values (Omitted 11/23/10, PRJ)
0132 % Clean up
0133 % switch A(1).probeType
0134 %     case 'RG'
0135 %         V.mcsBack(:,1:J(1)-1)=NaN;
0136 %         V.mcsBack(:,J(end)+1:end)=NaN;
0137 %         V.countBack(:,1:J(1)-1)=NaN;
0138 %         V.countBack(:,J(end)+1:end)=NaN;
0139 % end
0140 %
0141 % V.mcsDir(:,1:J(1)-1)=NaN;
0142 % V.mcsDir(:,J(end)+1:end)=NaN;
0143 % V.mcsMag(:,1:J(1)-1)=NaN;
0144 % V.mcsMag(:,J(end)+1:end)=NaN;
0145 % V.mcsEast(:,1:J(1)-1)=NaN;
0146 % V.mcsEast(:,J(end)+1:end)=NaN;
0147 % V.mcsNorth(:,1:J(1)-1)=NaN;
0148 % V.mcsNorth(:,J(end)+1:end)=NaN;
0149 % V.mcsVert(:,1:J(1)-1)=NaN;
0150 % V.mcsVert(:,J(end)+1:end)=NaN;
0151 % V.mcsBed(:,1:J(1)-1)=NaN;
0152 % V.mcsBed(:,J(end)+1:end)=NaN;
0153 % V.countMag(:,1:J(1)-1)=NaN;
0154 % V.countVert(:,1:J(1)-1)=NaN;
0155 % V.countBed(:,1:J(1)-1)=NaN;
0156 % V.countMag(:,J(end)+1:end)=NaN;
0157 % V.countVert(:,J(end)+1:end)=NaN;
0158 % V.countBed(:,J(end)+1:end)=NaN;
0159 
0160

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005