# VMT_PlotDAVvectors

## PURPOSE

Plots a plan view vector field using the given velocity

## SYNOPSIS

function VMT_PlotDAVvectors(Easting,Northing,DAVeast,DAVnorth,ascale,QuiverSpacing,plot_metric)

## DESCRIPTION

     Plots a plan view vector field using the given velocity
     components.  Input DAV are assumend to be in meters per second.
     Used by ASCII2GIS tool

     P.R. Jackson, USGS, 5-11-11

     Last modified: 05-29-2013
     Frank L. Engel, USGS (fengel@usgs.gov)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SUBFUNCTIONS

- function mypostcallback_zoom(obj,evd)
- function mypostcallback_pan(obj,evd)

## SOURCE CODE

    0001 function VMT_PlotDAVvectors(Easting,Northing,DAVeast,DAVnorth,ascale,QuiverSpacing,plot_metric)
    0002 % Plots a plan view vector field using the given velocity
    0003 % components.  Input DAV are assumend to be in meters per second.
    0004 % Used by ASCII2GIS tool
    0005 %
    0006 % P.R. Jackson, USGS, 5-11-11
    0007 %
    0008 % Last modified: 05-29-2013
    0009 % Frank L. Engel, USGS (fengel@usgs.gov)
    0010
    0011 warning off
    0012 disp('Plotting Plan View with Depth-Averaged Velocity Vectors...')
    0013
    0014 %% User Input
    0015
    0016 if exist('plot_metric')==0
    0017     plot_metric  = 1;
    0018     disp('No units specified, plotting in metric units by default')
    0019 end
    0020
    0021 %%
    0022
    0023 % See if PLOT 1 exists already, if so clear the figure
    0024 fig_planview_handle = findobj(0,'name','Plan View Map');
    0025
    0026 if ~isempty(fig_planview_handle) &&  ishandle(fig_planview_handle)
    0027     figure(fig_planview_handle); clf
    0028 else
    0029     fig_planview_handle = figure('name','Plan View Map'); clf
    0030     %set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
    0031 end
    0032
    0033 %% Plot Quivers on Map
    0034
    0035 toquiv(:,1) = Easting(1:QuiverSpacing:end);
    0036 toquiv(:,2) = Northing(1:QuiverSpacing:end);
    0037 toquiv(:,3) = DAVeast(1:QuiverSpacing:end);
    0038 toquiv(:,4) = DAVnorth(1:QuiverSpacing:end);
    0039 vr = sqrt(toquiv(:,3).^2+toquiv(:,4).^2);
    0040
    0041 figure(fig_planview_handle); hold on
    0042
    0043 %quiverc2wcmap(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),0,vr,1);
    0044 if ~plot_metric
    0045 %     figure(2); hold on
    0046     quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3)*3.281,toquiv(:,4)*3.281,ascale);  %*3.281 to go from m/s to ft/s
    0047     colorbar('FontSize',16,'XColor','w','YColor','w');
    0048     if sum(~isnan(vr)) == 0
    0049         errordlg('No Valid Data','Plotting Error');
    0050     end
    0051     disp(['DAV range (ft/s) = ' num2str(nanmin(vr)*3.281) ' to ' num2str(nanmax(vr)*3.281)])
    0052     caxis([nanmin(vr*3.281) nanmax(vr*3.281)])  %resets the color bar axis from 0 to 64 to span the velocity mag range
    0053     title('Depth-Averaged Velocities (ft/s)','Color','w');
    0054
    0055 else  %plot in metric units
    0056 %     figure(2); hold on
    0057     quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),ascale);
    0058 %     quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3)*0.03281,toquiv(:,4)*0.03281,ascale,...
    0059 %         minrng,...
    0060 %         maxrng,...
    0061 %         usecolormap,...
    0062 %         cptfullfile);
    0063     colorbar('FontSize',16,'XColor','w','YColor','w');
    0064     if sum(~isnan(vr)) == 0
    0065         errordlg('No Valid Data','Plotting Error');
    0066     end
    0067     disp(['DAV range (m/s) = ' num2str(nanmin(vr)) ' to ' num2str(nanmax(vr))])
    0068     caxis([nanmin(vr) nanmax(vr)])  %resets the color bar axis from 0 to 64 to span the velocity mag range
    0069     title('Depth-Averaged Velocities (m/s)','Color','w');
    0070 end
    0071 xlabel('UTM Easting (m)')
    0072 ylabel('UTM Northing (m)')
    0073 box on
    0074
    0075 % Make the changes to figure
    0076 % Defaults for Presentation Stlye Figure
    0077 % --------------------------------------
    0078 BkgdColor   = 'black';
    0079 AxColor     = 'white';
    0080 FigColor    = 'black'; % [0.3 0.3 0.3]
    0081 FntSize     = 14;
    0082 figure(fig_planview_handle)
    0083
    0084 set(gcf,'Color',BkgdColor);
    0085 set(gca,'FontSize',FntSize)
    0086 set(get(gca,'Title'),'FontSize',FntSize)
    0087 set(gca,'Color',FigColor)
    0088 set(gca,'XColor',AxColor)
    0089 set(gca,'YColor',AxColor)
    0090 set(gca,'ZColor',AxColor)
    0091 set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
    0092 set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
    0093 set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
    0094 set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
    0095
    0096 % Format the ticks for UTM and allow zooming and panning
    0097 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM
    0098 hdlzm = zoom;
    0099 set(hdlzm,'ActionPostCallback',@mypostcallback_zoom);
    0100 set(hdlzm,'Enable','on');
    0101 hdlpn = pan;
    0102 set(hdlpn,'ActionPostCallback',@mypostcallback_pan);
    0103 set(hdlpn,'Enable','on');
    0104
    0105 disp('Plotting Complete...')
    0106
    0107
    0108 %% Embedded functions
    0109 function mypostcallback_zoom(obj,evd)
    0110 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when zooming)
    0111
    0112 function mypostcallback_pan(obj,evd)
    0113 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when panning)
    0114