VMT_BatchMode

PURPOSE ^

VMT_BATCHMODE MATLAB code for VMT_BatchMode.fig

SYNOPSIS ^

function varargout = VMT_BatchMode(varargin)

DESCRIPTION ^

 VMT_BATCHMODE MATLAB code for VMT_BatchMode.fig
      VMT_BATCHMODE, by itself, creates a new VMT_BATCHMODE or raises the existing
      singleton*.

      H = VMT_BATCHMODE returns the handle to a new VMT_BATCHMODE or the handle to
      the existing singleton*.

      VMT_BATCHMODE('CALLBACK',hObject,eventData,handles,...) calls the local
      function named CALLBACK in VMT_BATCHMODE.M with the given input arguments.

      VMT_BATCHMODE('Property','Value',...) creates a new VMT_BATCHMODE or raises the
      existing singleton*.  Starting from the left, property value pairs are
      applied to the GUI before VMT_BatchMode_OpeningFcn gets called.  An
      unrecognized property name or invalid value makes property application
      stop.  All inputs are passed to VMT_BatchMode_OpeningFcn via varargin.

      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
      instance to run (singleton)".

 See also: GUIDE, GUIDATA, GUIHANDLES

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = VMT_BatchMode(varargin)
0002 % VMT_BATCHMODE MATLAB code for VMT_BatchMode.fig
0003 %      VMT_BATCHMODE, by itself, creates a new VMT_BATCHMODE or raises the existing
0004 %      singleton*.
0005 %
0006 %      H = VMT_BATCHMODE returns the handle to a new VMT_BATCHMODE or the handle to
0007 %      the existing singleton*.
0008 %
0009 %      VMT_BATCHMODE('CALLBACK',hObject,eventData,handles,...) calls the local
0010 %      function named CALLBACK in VMT_BATCHMODE.M with the given input arguments.
0011 %
0012 %      VMT_BATCHMODE('Property','Value',...) creates a new VMT_BATCHMODE or raises the
0013 %      existing singleton*.  Starting from the left, property value pairs are
0014 %      applied to the GUI before VMT_BatchMode_OpeningFcn gets called.  An
0015 %      unrecognized property name or invalid value makes property application
0016 %      stop.  All inputs are passed to VMT_BatchMode_OpeningFcn via varargin.
0017 %
0018 %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
0019 %      instance to run (singleton)".
0020 %
0021 % See also: GUIDE, GUIDATA, GUIHANDLES
0022 
0023 % Edit the above text to modify the response to help VMT_BatchMode
0024 
0025 % Last Modified by GUIDE v2.5 29-Apr-2014 13:07:42
0026 
0027 % Begin initialization code - DO NOT EDIT
0028 gui_Singleton = 1;
0029 gui_State = struct('gui_Name',       mfilename, ...
0030                    'gui_Singleton',  gui_Singleton, ...
0031                    'gui_OpeningFcn', @VMT_BatchMode_OpeningFcn, ...
0032                    'gui_OutputFcn',  @VMT_BatchMode_OutputFcn, ...
0033                    'gui_LayoutFcn',  [] , ...
0034                    'gui_Callback',   []);
0035 if nargin && ischar(varargin{1})
0036     gui_State.gui_Callback = str2func(varargin{1});
0037 end
0038 
0039 if nargout
0040     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0041 else
0042     gui_mainfcn(gui_State, varargin{:});
0043 end
0044 % End initialization code - DO NOT EDIT
0045 
0046 
0047 % --- Executes just before VMT_BatchMode is made visible.
0048 function VMT_BatchMode_OpeningFcn(hObject, eventdata, handles, varargin)
0049 % This function has no output args, see OutputFcn.
0050 % hObject    handle to figure
0051 % eventdata  reserved - to be defined in a future version of MATLAB
0052 % handles    structure with handles and user data (see GUIDATA)
0053 % varargin   command line arguments to VMT_BatchMode (see VARARGIN)
0054 
0055 % Choose default command line output for VMT_BatchMode
0056 handles.output = hObject;
0057 
0058 % Ensure path to utils & docs is available
0059 % ----------------------------------------
0060 if ~isdeployed
0061     filesep = '\'; % windows
0062     utilspath = [pwd filesep 'utils'];
0063     docspath  = [pwd filesep 'doc'];
0064     toolspath = [pwd filesep 'tools'];
0065     addpath(utilspath,docspath,toolspath)
0066 end
0067 
0068 % Update handles structure
0069 guidata(hObject, handles);
0070 
0071 % Create GUI Parameters
0072 guiparams.horizontal_smoothing_window = 1;
0073 guiparams.vertical_smoothing_window = 1;
0074 guiparams.water_surface_elevation = 0;
0075 guiparams.set_cross_section_endpoints = false;
0076 guiparams.unit_discharge_correction   = false;
0077 guiparams.mcs_id = cell(500,1);
0078 guiparams.full_path_to_ascii_file = [];
0079 guiparams.horizontal_grid_node_spacing = 1;
0080 guiparams.vertical_grid_node_spacing = 0.4;
0081 guiparams.data_folder = pwd;
0082 guiparams.data_files = [];
0083 guiparams.table_data = [];
0084 guiparams.shiptracks = [];
0085 
0086 % Store the appication data
0087 setappdata(handles.figure1,'guiparams',guiparams)
0088 
0089 % UIWAIT makes VMT_BatchMode wait for user response (see UIRESUME)
0090 % uiwait(handles.figure1);
0091 
0092 
0093 % --- Outputs from this function are returned to the command line.
0094 function varargout = VMT_BatchMode_OutputFcn(hObject, eventdata, handles) 
0095 % varargout  cell array for returning output args (see VARARGOUT);
0096 % hObject    handle to figure
0097 % eventdata  reserved - to be defined in a future version of MATLAB
0098 % handles    structure with handles and user data (see GUIDATA)
0099 
0100 % Get default command line output from handles structure
0101 varargout{1} = handles.output;
0102 
0103 
0104 
0105 % --- Executes on button press in BatchProcessVelocity.
0106 function BatchProcessVelocity_Callback(hObject, eventdata, handles)
0107 % Get the Application data:
0108 % -------------------------
0109 guiparams = getappdata(handles.figure1,'guiparams');
0110 mcs_id = guiparams.mcs_id;
0111 horizontal_grid_node_spacing = guiparams.horizontal_grid_node_spacing;
0112 data_folder = guiparams.data_folder;
0113 data_files = guiparams.data_files;
0114 table_data = guiparams.table_data;
0115 Map = [];
0116 
0117 mcs_id = cell2mat(table_data(:,1));
0118 zt      = unique(mcs_id);
0119 
0120 for zti = 1:length(zt)
0121     trans2process = data_files(mcs_id == zt(zti));
0122     
0123     % Read the file(s)
0124     % ----------------
0125     [~,~,savefile,A,z] = ...
0126         VMT_ReadFiles(data_folder,trans2process);
0127     guiparams.savefile = savefile;
0128         
0129     % Process each Transect
0130     % Preprocess the data:
0131     % --------------------
0132     A = VMT_PreProcess(z,A);
0133     
0134        
0135     % Process the transects:
0136     % ----------------------
0137     A(1).hgns = guiparams.horizontal_grid_node_spacing;
0138     A(1).vgns = guiparams.vertical_grid_node_spacing;
0139     A(1).wse  = guiparams.water_surface_elevation;  %Set the WSE to entered value
0140     [A,V,~] = VMT_ProcessTransects(z,A,...
0141         guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
0142     
0143     % Compute the smoothed variables
0144     % ------------------------------
0145     % This is required so that the V struc is complete at any point during
0146     % runtime.
0147     V = VMT_SmoothVar(V, ...
0148         ...guiparams.contour, ...
0149         guiparams.horizontal_smoothing_window, ...
0150         guiparams.vertical_smoothing_window);
0151     
0152     for zi = 1:z
0153         shiptracks{zti,zi} = [A(zi).Comp.xUTMraw A(zi).Comp.yUTMraw];
0154     end
0155     
0156     % Save each file
0157     %[pathstr,filename,extension] = fileparts([guiparams.data_folder guiparams.savefile]);
0158     %savefile = fullfile(pathstr,[filename extension]);
0159     save(savefile,'A','V','z','Map')
0160     clear A V z 
0161 end
0162 
0163 % Plot the shiptracks as groups
0164 colors = repmat('bgryck',1,500);
0165 for zti = 1:length(zt)
0166     st = cell2mat(shiptracks(zti,:)');
0167     stX = st(:,1);
0168     stY = st(:,2);
0169     
0170     figure(10)
0171     plot(stX,stY,[colors(zti) '.']); hold on
0172 end
0173 
0174 xlabel('UTM Easting (m)')
0175 ylabel('UTM Northing (m)')
0176 axis square
0177 box on
0178 grid on
0179 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM
0180 
0181 guiparams.shiptracks = shiptracks;
0182 setappdata(handles.figure1,'guiparams',guiparams)
0183     
0184 
0185 
0186 % --- Executes on button press in SelectFiles.
0187 function SelectFiles_Callback(hObject, eventdata, handles)
0188 % hObject    handle to SelectFiles (see GCBO)
0189 % eventdata  reserved - to be defined in a future version of MATLAB
0190 % handles    structure with handles and user data (see GUIDATA)
0191 % Get the Application data:
0192 % -------------------------
0193 guiparams = getappdata(handles.figure1,'guiparams');
0194 % guiprefs = getappdata(handles.figure1,'guiprefs');
0195 
0196 % Ask the user to select files:
0197 % -----------------------------
0198 current_file = pwd; %fullfile(guiprefs.ascii_path,guiprefs.ascii_file{1});
0199 [filename,pathname] = uigetfile({'*_ASC.TXT','ASCII (*_ASC.TXT)'}, ...
0200     'Select the ASCII Output Files', ...
0201     current_file, ...
0202     'MultiSelect','on');
0203 
0204 if ischar(pathname) % The user did not hit "Cancel"
0205     guiparams.data_folder = pathname;
0206     if ischar(filename)
0207         filename = {filename};
0208     end
0209     guiparams.data_files = filename;
0210 %     guiparams.mat_file = '';
0211     
0212     setappdata(handles.figure1,'guiparams',guiparams)
0213     
0214 % Populate the table
0215 % Ensure UItable is empty before filling it with current selection
0216 set(handles.TransectGroupings,'data',single.empty(500,2,0));
0217 
0218 % Construct table
0219 table_data = [num2cell(ones(numel(filename),1)) filename'];
0220 guiparams.mcs_id = num2cell(ones(numel(filename),1));
0221 
0222 % Push it to the UItable
0223 set(handles.TransectGroupings,'data',table_data);
0224 
0225 % Store parameters
0226 guiparams.table_data = table_data;
0227 setappdata(handles.figure1,'guiparams',guiparams)
0228 
0229 
0230 %     % Update the preferences:
0231 %     % -----------------------
0232 %     guiprefs = getappdata(handles.figure1,'guiprefs');
0233 %     guiprefs.ascii_path = pathname;
0234 %     guiprefs.ascii_file = filename;
0235 %     setappdata(handles.figure1,'guiprefs',guiprefs)
0236 %     store_prefs(handles.figure1,'ascii')
0237     
0238 end
0239 
0240 
0241 % --- Executes on button press in ClearList.
0242 function ClearList_Callback(hObject, eventdata, handles)
0243 % hObject    handle to ClearList (see GCBO)
0244 % eventdata  reserved - to be defined in a future version of MATLAB
0245 % handles    structure with handles and user data (see GUIDATA)
0246 
0247 % Ensure UItable is empty before filling it with current selection
0248 set(handles.TransectGroupings,'data',single.empty(500,2,0));
0249 
0250 
0251 
0252 function HorizontalGridNodeSpacing_Callback(hObject, eventdata, handles)
0253 %  Get Application Data
0254 guiparams = getappdata(handles.figure1,'guiparams');
0255 
0256 horizontal_grid_node_spacing = str2double(get(handles.HorizontalGridNodeSpacing,'String'));
0257 
0258 guiparams.horizontal_grid_node_spacing = horizontal_grid_node_spacing;
0259 setappdata(handles.figure1,'guiparams',guiparams)
0260 
0261 
0262 function ExportMultibeamBathymetry_Callback(hObject, eventdata, handles)
0263 
0264 % Get the Application data:
0265 % -------------------------
0266 guiparams = getappdata(handles.figure1,'guiparams');
0267 mcs_id = guiparams.mcs_id;
0268 horizontal_grid_node_spacing = guiparams.horizontal_grid_node_spacing;
0269 water_surface_elevation = guiparams.water_surface_elevation;
0270 data_folder = guiparams.data_folder;
0271 data_files = guiparams.data_files;
0272 table_data = guiparams.table_data;
0273 Map = [];
0274 
0275 mcs_id = cell2mat(table_data(:,1));
0276 zt      = unique(mcs_id);
0277 
0278 for zti = 1:length(zt)
0279     trans2process = data_files(mcs_id == zt(zti));
0280     
0281     % Read the file(s)
0282     % ----------------
0283     [~,~,savefile,A,z] = ...
0284         VMT_ReadFiles(data_folder,trans2process);
0285     guiparams.savefile = savefile;
0286         
0287     % Process each Transect
0288     % Preprocess the data:
0289     % --------------------
0290     A = VMT_PreProcess(z,A);
0291     
0292        
0293     % Process the transects:
0294     % ----------------------
0295     A(1).hgns = guiparams.horizontal_grid_node_spacing;
0296     A(1).wse  = guiparams.water_surface_elevation;  %Set the WSE to entered value
0297 %     [A,V,~] = VMT_ProcessTransects(z,A,...
0298 %         guiparams.set_cross_section_endpoints,guiparams.unit_discharge_correction);
0299 
0300     A = VMT_MBBathy(z,A,savefile,20,[],water_surface_elevation,1);
0301            
0302 end
0303 
0304 
0305 
0306 
0307 
0308 function VerticalGridNodeSpacing_Callback(hObject, eventdata, handles)
0309 %  Get Application Data
0310 guiparams = getappdata(handles.figure1,'guiparams');
0311 
0312 vertical_grid_node_spacing = str2double(get(handles.VerticalGridNodeSpacing,'String'));
0313 
0314 guiparams.vertical_grid_node_spacing = vertical_grid_node_spacing;
0315 setappdata(handles.figure1,'guiparams',guiparams)
0316 
0317 
0318 function WaterSurfaceElevation_Callback(hObject, eventdata, handles)
0319 %  Get Application Data
0320 guiparams = getappdata(handles.figure1,'guiparams');
0321 
0322 water_surface_elevation = str2double(get(handles.WaterSurfaceElevation,'String'));
0323 
0324 guiparams.water_surface_elevation = water_surface_elevation;
0325 setappdata(handles.figure1,'guiparams',guiparams)
0326 
0327 % --------------------------------------------------------------------
0328 function loadDataCallback(hObject, eventdata, handles)
0329 % Read Files into Data Structure using tfile.
0330 
0331 % Get the Application data:
0332 % -------------------------
0333 guiparams = getappdata(handles.figure1,'guiparams');
0334 guiprefs = getappdata(handles.figure1,'guiprefs');
0335 
0336 % Ask the user to select files:
0337 % -----------------------------
0338 current_file = fullfile(guiprefs.ascii_path,guiprefs.ascii_file{1});
0339 [filename,pathname] = uigetfile({'*_ASC.TXT','ASCII (*_ASC.TXT)'}, ...
0340     'Select the ASCII Output Files', ...
0341     current_file, ...
0342     'MultiSelect','on');
0343 
0344 if ischar(pathname) % The user did not hit "Cancel"
0345     guiparams.data_folder = pathname;
0346     if ischar(filename)
0347         filename = {filename};
0348     end
0349     guiparams.data_files = filename;
0350 %     guiparams.mat_file = '';
0351     
0352     setappdata(handles.figure1,'guiparams',guiparams)
0353     
0354    
0355     
0356 %     % Update the preferences:
0357 %     % -----------------------
0358 %     guiprefs = getappdata(handles.figure1,'guiprefs');
0359 %     guiprefs.ascii_path = pathname;
0360 %     guiprefs.ascii_file = filename;
0361 %     setappdata(handles.figure1,'guiprefs',guiprefs)
0362 %     store_prefs(handles.figure1,'ascii')
0363     
0364     
0365 %     % Read the file(s)
0366 %     % ----------------
0367 %     [~,~,savefile,A,z] = ...
0368 %         VMT_ReadFiles(guiparams.data_folder,guiparams.data_files);
0369 %     guiparams.savefile = savefile;
0370 %     guiparams.A        = A;
0371 %     guiparams.z        = z;
0372 %     setappdata(handles.figure1,'guiparams',guiparams)
0373 
0374 end
0375 % [EOF] loadDataCallback
0376 
0377 
0378 % --- Executes when entered data in editable cell(s) in TransectGroupings.
0379 function TransectGroupings_CellEditCallback(hObject, eventdata, handles)
0380 % hObject    handle to TransectGroupings (see GCBO)
0381 % eventdata  structure with the following fields (see UITABLE)
0382 %    Indices: row and column indices of the cell(s) edited
0383 %    PreviousData: previous data for the cell(s) edited
0384 %    EditData: string(s) entered by the user
0385 %    NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
0386 %    Error: error string when failed to convert EditData to appropriate value for Data
0387 % handles    structure with handles and user data (see GUIDATA)
0388 
0389 % Get the application data
0390 guiparams = getappdata(handles.figure1,'guiparams');
0391 
0392 guiparams.table_data = get(handles.TransectGroupings,'data');
0393 
0394 setappdata(handles.figure1,'guiparams',guiparams);
0395 
0396 
0397 % --- Executes on button press in SaveBatchJob.
0398 function SaveBatchJob_Callback(hObject, eventdata, handles)
0399 % hObject    handle to SaveBatchJob (see GCBO)
0400 % eventdata  reserved - to be defined in a future version of MATLAB
0401 % handles    structure with handles and user data (see GUIDATA)
0402 
0403 % Get application data
0404 guiparams = getappdata(handles.figure1,'guiparams');
0405 
0406 % Get whatever is in the UItable
0407 data = get(handles.TransectGroupings,'data');
0408 numXS = length(data);
0409 
0410 % Write to an Excel File
0411 [filename,pathname] = uiputfile('*.xlsx','Save Batch File As',guiparams.data_folder);
0412 data = [...
0413     {guiparams.data_folder, guiparams.horizontal_grid_node_spacing, guiparams.vertical_grid_node_spacing, guiparams.water_surface_elevation};...
0414     data, cell(numXS,2)];
0415 xlswrite(fullfile(pathname,filename),data);
0416 
0417 
0418 
0419 % --- Executes on button press in LoadBatchJob.
0420 function LoadBatchJob_Callback(hObject, eventdata, handles)
0421 % hObject    handle to LoadBatchJob (see GCBO)
0422 % eventdata  reserved - to be defined in a future version of MATLAB
0423 % handles    structure with handles and user data (see GUIDATA)
0424 
0425 % Get application data
0426 guiparams = getappdata(handles.figure1,'guiparams');
0427 
0428 [filename,pathname] = uigetfile('*.xlsx','Load Batch File',guiparams.data_folder);
0429 [ndata, text, alldata] = xlsread(fullfile(pathname,filename));
0430 data = alldata(2:end,1:2);
0431 set(handles.TransectGroupings,'data',data);
0432 
0433 guiparams.data_folder                  = alldata{1};
0434 guiparams.data_files                   = data(:,2);
0435 guiparams.horizontal_grid_node_spacing = ndata(1,2);
0436 guiparams.vertical_grid_node_spacing   = ndata(1,3);
0437 guiparams.water_surface_elevation      = ndata(1,4);
0438 guiparams.table_data                   = get(handles.TransectGroupings,'data');
0439 
0440 set(handles.HorizontalGridNodeSpacing, 'String', guiparams.horizontal_grid_node_spacing)
0441 set(handles.VerticalGridNodeSpacing,   'String', guiparams.vertical_grid_node_spacing)
0442 set(handles.WaterSurfaceElevation,     'String', guiparams.water_surface_elevation)
0443 
0444 setappdata(handles.figure1,'guiparams',guiparams)
0445 
0446 function mypostcallback_zoom(obj,evd)
0447 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when zooming)
0448 
0449 function mypostcallback_pan(obj,evd)
0450 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when panning)

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