# VMT_ComputeNormProf

## PURPOSE

Computes the normaized median profile from multiemsemble data.

## SYNOPSIS

function [znm,vm] = VMT_ComputeNormProf(zn,v,n)

## DESCRIPTION

     Computes the normaized median profile from multiemsemble data.

     Inputs:

     zn: matrix of normized, bed origin bin locations (#bins x #ens)
     v:  matrix of observed velocity magniitude (#bins x #ens)
     n:  number of cells to use in the profile binning

     P.R. Jackson, USGS, 8-31-12

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [znm,vm] = VMT_ComputeNormProf(zn,v,n)
    0002 % Computes the normaized median profile from multiemsemble data.
    0003 %
    0004 % Inputs:
    0005 %
    0006 % zn: matrix of normized, bed origin bin locations (#bins x #ens)
    0007 % v:  matrix of observed velocity magniitude (#bins x #ens)
    0008 % n:  number of cells to use in the profile binning
    0009 %
    0010 % P.R. Jackson, USGS, 8-31-12
    0011
    0012 % Reshape the matrices to create vectors
    0013 zn_vec = reshape(zn,size(zn,1)*size(zn,2),1);
    0014 v_vec  = reshape(v,size(v,1)*size(v,2),1);
    0015
    0016 % Bin the data and compute median values
    0017 cell_breaks = 0:1/n:1;  %Limits of each cell
    0018 dum = diff(cell_breaks);
    0019 znm = cumsum([(cell_breaks(2)/2) dum(2:end)]);
    0020
    0021 vm  = nan*ones(1,n);  %preallocate
    0022 obs = nan*ones(1,n);  %preallocate
    0023 for i = 1:n
    0024     indx = find(zn_vec >= cell_breaks(i) & zn_vec < cell_breaks(i+1));
    0025     vm(i) = nanmedian(v_vec(indx));
    0026     obs(i) = length(indx);
    0027 end
    0028
    0029 % Find any cells that have < 20% of the median number of data points all
    0030 % other bins
    0031 indx = find(obs < 0.2*nanmedian(obs));
    0032
    0033 % Plot the data
    0034
    0035 if 0  %for debugging
    0036     figure(1); clf
    0037     plot(v_vec,zn_vec,'k.'); hold on
    0038     plot(vm,znm,'bs-'); hold on
    0039     plot(vm(indx),znm(indx),'ro')
    0040     xlabel('velocity')
    0041     ylabel('normalized height above bottom')
    0042     xlim([0 max(v_vec)])
    0043     ylim([0 1])
    0044 end
    0045
    0046 %Remove lean cells
    0047 vm(indx) = nan;
    0048
    0049
    0050
    0051
    0052
    0053