function [burst,adv]=ADV_Bbq(begin,finish); % You Best be Wearing an Apron, 'CUZ it's time to COOK 'EM ADV % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % ____________________ % | ______________ |_______________________________|-| % | ______________ |~~Get your own Spatula~~~~~~~~ | | % | ______________ |~~~~~~~~~~This One's Mine!!~~~~| | % | ______________ |_______________________________| | % |____________________| |-| % % Welcome all Professional ADV data Chefs! % % This function will load bursts of ADV data one at a time, % preview the burst for user-verification and possible truncation, % and finally send the burst to CookRawADV.m for quality control % and preprocessing. % % [burst,adv]=ADV_Bbq(begin,finish); % % begin = burst you begin with % finish = burst you finish with % % Data is written to disk after you accept the quality control criteria. % With that in mind, you may Break (CNTL-C) at any time and completed % burst data will not be lost. HOWEVER, a summary log of rejected bursts % will NOT be printed to disk (not crucial, but we like full disclosure % here). % % >>>NOTE<<< PLEASE MODIFY THE DIRECTORIES WITHIN % <<< THIS CODE TO SUIT YOUR NEEDS % % >>>NOTE<<< ADV_Bbq requires a header file created with GADVHDR % <<< (refer to SonTek manual for details on how to use GADVHDR) % % This code was created September 2003 by Jason M. Fox for Paul Hill % % It Employs functions written by Chris Sherwood, USGS % % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % Now, if you're up for it. Grab your spatula and GET COOKING!!!! % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % Get out the Mesquite Briquettes and Initialize the Grill % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % customize for me MyNameIsJeff = 0; MyNameIsChris =1; % Define the header file name. if(MyNameIsJeff), %header_file_name = 'C2AA2'; header_file_name = 'C2AB2001'; % Define the data file name. adr_file_name = 'C2AB2001'; % Define ADV probe serial number ***DIGITS ONLY***. This number defines the appropriate sub-directory % in the data directory. adv_number = '220'; adv_call_num= str2num(adv_number); % Define the source file directory. data_dir = 'd:\work\ADV_Italy\adv_data\'; % Define the destination directory. cooked_dir = 'd:\work\ADV_Italy\cooked\'; % Define extension of header files that contains burst header and burst statistics. header_ext = '.hdr'; % Define extension of the SonTek ADV data file. data_ext = '.adr'; % Create full file names for header file and ADV data files. hdrfn = [data_dir, 'B', adv_number, '\', header_file_name, header_ext]; adrfn = [data_dir, 'B', adv_number, '\', adr_file_name, data_ext]; elseif(MyNameIsChris), dn = 'C:\crs\data\EuroStrat_0203\702-Flow\702adv217\' hdrfn = [dn,'C2AA1001.hdr']; adrfn = [dn,'C2AA1001.adr']; else error('Who even are you?') end % Create matrices for notification of rejected and truncated bursts rejected=[]; truncated=[]; % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % The Grill is Initialized, Now Marinate your ADV BURST % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> for i=begin:finish % Create a burst character ID Burst_ID=num2str(i); % Refresh the Truncated Series and Trash_Burst Matrices truncated_series=[]; Trash_Burst=[]; % Extract header information for this burst. header = read_hdradv(hdrfn, i:i'); burst = adr2mat(adrfn, [i i]); b_title = sprintf('ADV Burst %.0f',header.b_num); freq_title = sprintf('Samples at %.0f Hz',burst.samprate); % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % Ask the User if he Can Toss the Burst on the Grill, in the Trash, or if it needs Fat Trimmed before the grill % >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> % Prepare a figure for the user to perform the preliminary examination figure; steps=[1:1:6000]; plot(steps,burst.Vx{1},'-k',steps,burst.Vy{1},'-b',steps,burst.Vz{1},'-g'); title(b_title,'fontsize',12); xlabel(freq_title,'fontsize',12); ylabel('Velocity (cm/s) [U=black V=blue W=green]','fontsize',12); %% >>>>>>>>>>>>>BEGIN QUESTION ButtonName=non_modal_questdlg('Examine the Burst. Is it fit for the grill? Do you need to trim the fat? Should it be thrown in the garbage?', ... 'Is This a Fine Cut?', ... 'Send it to the Grill','Trim the Fat','Toss it','Send it to the Grill'); switch ButtonName, case 'Send it to the Grill', % Close the figure close; % Send the burst information to CookRawADV for processing [series,quality_report]=CookRawADV(burst,2.8,6,120,60,b_title,1); case 'Trim the Fat', % Ask the user to mark the in and out points of the truncated set prompt={'Enter the In Marker Sample Number:','Enter the Out Marker Sample Number:'}; def={'Is that a Spatula in your Pocket..?','6000'}; dlgTitle='Examine the Burst more closely with the Zoom tool'; lineNo=1; AddOpts.Resize='off'; AddOpts.WindowStyle='normal'; AddOpts.Interpreter='none'; Markers=inputdlg(prompt,dlgTitle,lineNo,def,AddOpts); % Identify the in and out markers Markers=char(Markers); In_marker=str2num(Markers(1,:)); Out_marker=str2num(Markers(2,:)); % Note the redefined sample set truncated_series=[header.b_num In_marker Out_marker]; % Truncate the matrices according to their configuration if adv_call_num==217 burst.Vx={burst.Vx{1}(In_marker:Out_marker)}; burst.Vy={burst.Vy{1}(In_marker:Out_marker)}; burst.Vz={burst.Vz{1}(In_marker:Out_marker)}; burst.amp={[burst.amp{1}(In_marker:Out_marker,1) ... burst.amp{1}(In_marker:Out_marker,2) burst.amp{1}(In_marker:Out_marker,3)]}; burst.corr={[burst.corr{1}(In_marker:Out_marker,1) ... burst.corr{1}(In_marker:Out_marker,2) burst.corr{1}(In_marker:Out_marker,3)]}; burst.heading={burst.heading{1}(In_marker:Out_marker)}; burst.pitch={burst.pitch{1}(In_marker:Out_marker)}; burst.roll={burst.roll{1}(In_marker:Out_marker)}; burst.extsensor={burst.extsensor{1}(In_marker:Out_marker)}; burst.extpress={burst.extpress{1}(In_marker:Out_marker)}; elseif adv_call_num==220 burst.Vx={burst.Vx{1}(In_marker:Out_marker)}; burst.Vy={burst.Vy{1}(In_marker:Out_marker)}; burst.Vz={burst.Vz{1}(In_marker:Out_marker)}; burst.amp={[burst.amp{1}(In_marker:Out_marker,1) ... burst.amp{1}(In_marker:Out_marker,2) burst.amp{1}(In_marker:Out_marker,3)]}; burst.corr={[burst.corr{1}(In_marker:Out_marker,1) ... burst.corr{1}(In_marker:Out_marker,2) burst.corr{1}(In_marker:Out_marker,3)]}; burst.temperature={burst.temperature{1}(In_marker:Out_marker)}; burst.pressure={burst.pressure{1}(In_marker:Out_marker)}; burst.extsensor={[burst.extsensor{1}(In_marker:Out_marker,1) burst.extsensor{1}(In_marker:Out_marker,2)]}; else break; end % Recalculate Mean and STD Values of the Truncated Set burst.mean=[mean(burst.amp{1}(:,1)) mean(burst.amp{1,1}(:,2)) ... mean(burst.amp{1}(:,3)) mean(burst.corr{1}(:,1)) mean(burst.corr{1}(:,2)) ... mean(burst.amp{1}(:,3)) mean(burst.heading{:}) ... mean(burst.pitch{:}) mean(burst.roll{:}) burst.mean(10) ... burst.mean(11) mean(burst.Vx{:}) mean(burst.Vy{:}) mean(burst.Vz{:})]; burst.std=[std(burst.amp{1}(:,1)) std(burst.amp{1,1}(:,2)) ... std(burst.amp{1}(:,3)) std(burst.corr{1}(:,1)) std(burst.corr{1}(:,2)) ... std(burst.amp{1}(:,3)) std(burst.heading{:}) ... std(burst.pitch{:}) std(burst.roll{:}) burst.std(10) ... burst.std(11) std(burst.Vx{:}) std(burst.Vy{:}) std(burst.Vz{:})]; % Close the figure close; % Now Send the burst information to CookRawADV for processing [series,quality_report]=CookRawADV(burst,2.8,6,120,60,b_title,1); case 'Toss it', % Close the figure close; % Set the Garbage device Trash_Burst=69; % Note the burst being turfed rejected=[rejected; header.b_num]; end %% >>>>>>>>>>>>>>END QUESTION % If the Burst has been rejected, Don't print the series to file if isempty(Trash_Burst)==1 % Once The ADV data has been cooked, save the new information to disk fname = sprintf('burst_%.0f.mat',i); fullname = fullfile(cooked_dir,fname); % If the series was truncated, include the in and out markers if isempty(truncated_series)==1 eval(['header_' Burst_ID '= header;']); eval(['series_' Burst_ID '= series;']); eval(['quality_report_' Burst_ID '= quality_report;']); eval(['save( fullname, ''header_' Burst_ID ''', ''series_' Burst_ID ''', ''quality_report_' Burst_ID ''' );']); eval(['clear header_' Burst_ID '; clear series_' Burst_ID '; clear quality_report_' Burst_ID ';']); else eval(['header_' Burst_ID '= header;']); eval(['series_' Burst_ID '= series;']); eval(['quality_report_' Burst_ID '= quality_report;']); eval(['truncated_series_' Burst_ID '= truncated_series;']); eval(['save( fullname, ''header_' Burst_ID ''', ''series_' Burst_ID ''', ''quality_report_' Burst_ID ''', ''truncated_series_' Burst_ID ''' );']); eval(['clear header_' Burst_ID '; clear series_' Burst_ID '; clear quality_report_' Burst_ID '; clear truncated_series_' Burst_ID ';']); truncated=[truncated; truncated_series]; end end end % Send a summary of rejected bursts to disk if isempty(rejected)==0&isempty(truncated)==0 fname = sprintf('reject_truncated_summary_from_burst_%.0f_to_%.0f.mat',begin,finish); fullname = fullfile(cooked_dir,fname); save(fullname, 'rejected', 'truncated'); elseif isempty(rejected)==1&isempty(truncated)==0 fname = sprintf('reject_truncated_summary_from_burst_%.0f_to_%.0f.mat',begin,finish); fullname = fullfile(cooked_dir,fname); save(fullname, 'truncated'); elseif isempty(rejected)==0&isempty(truncated)==1 fname = sprintf('reject_truncated_summary_from_burst_%.0f_to_%.0f.mat',begin,finish); fullname = fullfile(cooked_dir,fname); save(fullname, 'rejected'); end close all;