function theMeta = aqa2mat(theMeta, verbose) % AQA2MAT use Aquatec toolbox to prepare data for aqa2cdf % % theMeta.input_directory = 'E:\PV_2007\842_B3_geoprobe\8427abss\datafiles'; % where the .aqa files are % verbose = set to 1 for diagnostic output % % This m-file uses Aquatec's ReadAquascat1000, which will bomb if any of % the *.aqa data files are not complete. Short data files can occur during % the download process, so it is recommended that they be weeded out before % running this m-file. % get the current SVN version- the value is automatically obtained in svn % is the file's svn.keywords which is set to "Revision" rev_info = 'SVN $Revision$'; disp(sprintf('%s %s running',mfilename,rev_info)) % have to deal with the Aquatec idiosyncracies % ## directory with .aqa and .aqf files (required) if ~isfield(theMeta,'input_directory') || isempty(theMeta.input_directory) || ... isempty(dir(fullfile(theMeta.input_directory,'*.aqa'))), theMeta.input_directory = uigetdir(pwd,'Where are the .aqa files?'); if ~theMeta.input_directory, theMeta.input_directory= []; return; end end % get a *.aqa file name, needed to make ReadAquascat work right % we are first after the information filesInDir = dir(fullfile(theMeta.input_directory,'*.aqa')); if exist([filesInDir(1).name '.mat'],'file') delete([filesInDir(1).name '.mat']) end [fpath, fname] = fileparts(filesInDir(1).name); ReadAquaScat1000(fullfile(theMeta.input_directory,fname),'STRUCT'); % STRUCT gives instrument info load(fullfile(theMeta.input_directory,[filesInDir(1).name '.mat'])) theMeta.ABSSmodel = BurstInfo.IntsrumentType; % yes, it is spelled wrong theMeta.ABSSSerialNumber = BurstInfo.SerialNumber; theMeta.ABSSBoardVersion = BurstInfo.BoardVersion; % gives other data... ReadAquaScat1000(fullfile(theMeta.input_directory,fname)); load(fullfile(theMeta.input_directory,[filesInDir(1).name '.mat'])) theMeta.AbsTransducerName = AbsTransducerName; theMeta.frequency = AbsTxFrequency; % shape ntransducers x 1 theMeta.AbsTxPulseLength = AbsTxPulseLength; % shape ntransducers x 1 theMeta.BurstDuration = AbsProfileRate; % shape ntransducers x 1 theMeta.PingRate = PingRate; theMeta.NumPings = NumPings; theMeta.AbsAverage = AbsAverage; % shape ntransducers x 1 theMeta.AbsBinLengthMM = AbsBinLengthMM; % shape ntransducers x 1 theMeta.AbsBinRange = AbsBinRange; % shape nbins x ntransducers theMeta.AbsNumBins = AbsNumBins; % shape ntransducers x 1 theMeta.AbsNumProfiles = AbsNumProfiles; % shape ntransducers x 1 theMeta.AbsProfileRate = AbsProfileRate; % shape ntransducers x 1 theMeta.AbsStartingGain = AbsStartingGain; % shape ntransducers x 1 % take this directly from the shape of the data theMeta.nBins = size(AbsData,1); %number of bins theMeta.nProfiles = size(AbsData,2); %number of profiles theMeta.nXducers = size(AbsData,3); %number of xducers if verbose, disp(theMeta); end if ~isfield(theMeta, 'metaFileName'), theMeta.metaFileName = fullfile(theMeta.output_directory,[theMeta.outFileRoot 'Meta']); end disp(sprintf('saving metadata to %s',theMeta.metaFileName)) save(theMeta.metaFileName,'theMeta') disp('Commencing extraction to .mat files') % now extract all the data files filesSorted = sortrows({filesInDir.name}'); NumFiles = size(filesSorted,1); disp(sprintf('There are %d .aqa files to process', NumFiles)) for ifile = 1:NumFiles fname = fullfile(theMeta.input_directory,filesSorted{ifile}); %assumes .AQA ReadAquaScat1000(regexprep (fname, '.aqa' ,'','ignorecase')); end