# VMT_ProcessTransects

## PURPOSE

Driver program to process multiple transects at a single cross-section

## SYNOPSIS

function [A,V,log_text] = VMT_ProcessTransects(z,A,setends,unitQcorrection)

## DESCRIPTION

     Driver program to process multiple transects at a single cross-section
     for velocity mapping.

     Among other things, it:

       Determines the best fit mean cross-section line from multiple transects
       Map ensembles to mean c-s line
       Determine uniform mean c-s grid for vector interpolating
       Determine location of mapped ensemble points for interpolating
       Interpolate individual transects onto uniform mean c-s grid
       Average mapped mean cross-sections from individual transects together
       Rotate velocities into u, v, and w components

     (adapted from code by J. Czuba)

     P.R. Jackson, USGS, 12-9-08
     Last modified: F.L. Engel, USGS, 5/20/2013

## CROSS-REFERENCE INFORMATION

This function calls:

- VMT_CompMeanXS Computes the mean cross section data from individual transects
- VMT_CompMeanXS_PriSec Computes the mean cross section velocity components (Primary
- VMT_CompMeanXS_UVW Computes the mean cross section velocity components (U,V,W)
- VMT_GridData2MeanXS This routine generates a uniformly spaced grid for the mean cross section and
- VMT_MapEns2MeanXS Fits multiple transects at a single location with a single
- VMT_Rozovskii Computes the frame of reference transpositon as described in Kenworthy

This function is called by:

- VMT --- THE VELOCITY MAPPING TOOLBOX ---

## SOURCE CODE

    0001 function [A,V,log_text] = VMT_ProcessTransects(z,A,setends,unitQcorrection)
    0002 % Driver program to process multiple transects at a single cross-section
    0003 % for velocity mapping.
    0004 %
    0005 % Among other things, it:
    0006 %
    0007 %   Determines the best fit mean cross-section line from multiple transects
    0008 %   Map ensembles to mean c-s line
    0009 %   Determine uniform mean c-s grid for vector interpolating
    0010 %   Determine location of mapped ensemble points for interpolating
    0011 %   Interpolate individual transects onto uniform mean c-s grid
    0012 %   Average mapped mean cross-sections from individual transects together
    0013 %   Rotate velocities into u, v, and w components
    0014 %
    0015 % (adapted from code by J. Czuba)
    0016 %
    0017 % P.R. Jackson, USGS, 12-9-08
    0018 % Last modified: F.L. Engel, USGS, 5/20/2013
    0019
    0020
    0021
    0022 log_text = {'   Processing Data...Please Be Patient.'};
    0023
    0024 try
    0025     %disp('Processing Data...')
    0026     warning off
    0027
    0028     %% Map ensembles to mean cross-section
    0029     [A,V,map_xs_log_text] = VMT_MapEns2MeanXS(z,A,setends);
    0030     %msgbox('Processing Data...Please Be Patient','VMT Status','help','replace');
    0031     log_text = vertcat(log_text, map_xs_log_text);
    0032
    0033     %% Set the probe type
    0034     %V.probeType = A(1).probeType;
    0035     V.probeType = 'RG';
    0036
    0037     %% Grid the measured data along the mean cross-section
    0038     %[A,V] = VMT_GridData2MeanXS(z,A,V);
    0039     [A,V] = VMT_GridData2MeanXS(z,A,V,unitQcorrection);
    0040     if unitQcorrection
    0041         log_text = vertcat(log_text,...
    0042             {'      Streamwise unit discharge continuity enforced'});
    0043     end
    0044     %msgbox('Processing Data...Please Be Patient','VMT Status','help','replace');
    0045     %log_text = {log_text; grid_data_log_text};
    0046
    0047     %% Computes the mean data for the mean cross-section
    0048     %[A,V] = VMT_CompMeanXS(z,A,V);
    0049     [A,V,comp_xs_log_text] = VMT_CompMeanXS(z,A,V);
    0050     %msgbox('Processing Data...Please Be Patient','VMT Status','help','replace');
    0051     log_text = vertcat(log_text, comp_xs_log_text);
    0052
    0053     %% Decompose the velocities into u, v, and w components
    0054     [A,V] = VMT_CompMeanXS_UVW(z,A,V);
    0055     %msgbox('Processing Data...Please Be Patient','VMT Status','help','replace');
    0056
    0057     %% Decompose the velocities into primary and secondary components
    0058     [A,V,comp_prisec_log_text] = VMT_CompMeanXS_PriSec(z,A,V);
    0059     %msgbox('Processing Data...Please Be Patient','VMT Status','help','replace');
    0060     log_text = vertcat(log_text, comp_prisec_log_text);
    0061
    0062     %% Perform the Rozovskii computations
    0063     [V,roz_log_text] = VMT_Rozovskii(V,A);
    0064     log_text = vertcat(log_text, roz_log_text);
    0065
    0066     %figure(4); clf
    0067     %plot3(V.mcsX,V.mcsY,V.mcsDepth(1))
    0068     %disp('Processing Completed')
    0069     log_text = vertcat(log_text, '   Processing Completed.');
    0070 catch err
    0071     if isdeployed
    0072         errLogFileName = fullfile(pwd,...
    0073             ['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
    0074         msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
    0075             ['Error details are being written to the following file: '];...
    0076             errLogFileName},...
    0077             'VMT Status: Unexpected Error',...
    0078             'error');
    0079         fid = fopen(errLogFileName,'W');
    0080         fwrite(fid,err.getReport('extended','hyperlinks','off'));
    0081         fclose(fid);
    0082         rethrow(err)
    0083     else
    0084         msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
    0085             'VMT Status: Unexpected Error',...
    0086             'error');
    0087         rethrow(err);
    0088     end
    0089 end
    0090
    0091
    0092 %% Notes:
    0093
    0094 %1. I removed scripts at the end of the original code that computes
    0095 %standard deviations (12-9-08)