function ABSSp = readABSSPersonalityGS(aqaFile) % readABSSPersonalityGS - get the ABSS descriptive information, USGS version % function ABSSp = readABSSPersonalityGS(aqaFile) % ABSSp is a struct with all the information % for the most curious, it dumps out *everything* % % taken from Aquatec ReadAquaSca1000.m to simply get the logger info, % all of it. % logger info is the first part of each .aqa file % according to AQUAscat 1000 File Format % Manual revision 5.01, 5 Oct 2006 % adapted by Marinna Martini % Woods Hole Science Center % 12 May 2008 % 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)) ABSSp = []; if ~exist('aqaFile','var') || ~exist(aqaFile,'file') , [aqaFile,aqaPath] = uigetfile('*.aqa','Select an AQUAscat data file'); aqaFile = fullfile(aqaPath,aqaFile); end ABSSp.aqaFile = aqaFile; fid = fopen(aqaFile,'r'); [status pktSize] = findAQUAscat1000Packet(fid,53); %Read Personality Details if 0==status fprintf('\nPersonality Packet not found abort'); return else % Note that the personality is about 4KB, it is not stored in every file on the logger but is added to every burst % file during data upload. When extracting multiple files only one personality file is required as this remains % constant for an instrument, unless specifically changed by contacting Aquatec. Note changing the regime % does not change the personality. % The personality contains the additional information about the transducers, and the conversion parameters for % the auxiliary data samples. Please consult Aquatec for help in using this information to convert auxillary % samples or refer to our example code. % assume the personality ID byte has already been read PktStartPos = ftell(fid); % 0 unsigned short Size of personality (words) PktSize = fread(fid,1,'uint16'); % 1 unsigned short Board revision . mod revision 1.0 == 0x0100 Major(MSB) Minor(LSB) temp = fread(fid,1,'uint16'); ABSSp.BoardVersion = sprintf('%i',temp); % 2 unsigned short Serial Number [Type] e.g. 971 % 3 unsigned short Serial Number [number] e.g. 001 ABSSp.SerialNum = sprintf('%i-%i',fread(fid,1,'uint16'),fread(fid,1,'uint16')); % 4 unsigned short Memory Size KB ABSSp.MemorySize = fread(fid,1,'uint16'); % 5->21 char[ 32 ] Logger type string e.g. “AQUAscat 1000-R” ABSSp.LoggerType = cleanString((fread(fid,32,'char=>char'))); %GV-10 skip = fread(fid,1,'uint16'); % 22 unsigned short Number of ABS channels 0 .. Max allowed (4) ABSSp.NumAbsChannels = fread(fid,1,'uint16'); % Number of ABS channels the system supports % 23 unsigned short Number of auxiliary channels 0 .. Max allowed (8) ABSSp.NumAuxChannels = fread(fid,1,'uint16'); % Number of AUX channels the system supports (8) % 24 unsigned short Num of transducer registered 1 .. Max allowed (8) ABSSp.NumAbsTransducers = fread(fid,1,'uint16'); % Number of ABS Transducer Information that exist in personality table % 25 Float Battery Capacity WH ABSSp.BatteryCapacity = fread(fid,1,'float'); % not recorded at this time % 27 Float Standby Power WH ABSSp.StandbyPower = fread(fid,1,'float'); % " % 29 Float Active Power WH ABSSp.ActivePower = fread(fid,1,'float'); % " % 31 unsigned short RESERVED % 32 unsigned short RESERVED % 33?55 unsigned short RESERVED % 56 unsigned short pointer to auxiliary channels Offset from start of packet body % 57 unsigned short pointer to transducer info Offset from start of packet body % 58? 99 RESERVED fseek(fid,PktStartPos + 112,'bof'); PtrToAuxInfo = fread(fid,1,'uint16'); % These are the offsets into the Packet PtrToTransducerInfo = fread(fid,1,'uint16'); % %% % The starting point of the Auxiliary channel personalities is defined by % the pointer to the Auxiliary channels. % AUX Channel Personality –[Repeated for all 8 channels] SIZE = 40 + (4*40) = 200 % % Read in the important information for the Aux Channels % First Need to assign the multiple dimension arrays % for i = 1 :ABSSp.NumAuxChannels PtrToThisAux = PktStartPos + PtrToAuxInfo*2 + 400*(i-1); fseek(fid,PtrToThisAux,'bof'); %Move to the start of the ABS information % +0 unsigned short Channel type Analogue / Pulse / Count etc ABSSp.AuxChannelType(i) = fread(fid,1,'uint16'); % +1 unsigned short Sensor type Temperature, Turbidity etc ABSSp.AuxSensorType(i) = fread(fid,1,'uint16'); % +2->9 char[16] Sensor ID string “Turbidity” ABSSp.AuxChannelName(i,:) = cleanString(fread(fid,16,'char=>char')); % +10 unsigned short RESERVED skip = fread(fid,1,'uint16'); % +11->14 char[8] Sensor units string “FTU” ABSSp.AuxChannelUnit(i,:) = cleanString(fread(fid,8,'char=>char'))'; % +15 unsigned short RESERVED “FTU” skip = fread(fid,1,'uint16'); % +16 unsigned short Channel flags 0 = Temperature compensated ABSSp.AuxFlags(i) = fread(fid,1,'uint16'); % +17 unsigned short Power up delay mS % +18 unsigned short Settling delay mS skip = fread(fid,2,'uint16'); %Power up & Settling Delays % +19 unsigned short Number of gain options 1 .. 4 ABSSp.AuxNumGain(i) = fread(fid,1,'uint16'); % +20 unsigned short Acquisitions per Sample % +21 unsigned short Time between Acquisitions mS (0 == as fast as possible) skip = fread(fid,2,'uint16'); %Acq per sample + time between Acq % +22 float Sensor active power W skip = fread(fid,1,'float'); %Sensor active power % +24 unsigned short RESERVED (Report) skip = fread(fid,1,'uint16'); %Report % +25?32 char[16] Calibration date ABSSp.AuxCalDate(:,i) = fread(fid,16,'char=>char'); % +33 unsigned short RESERVED skip = fread(fid,1,'uint16'); % +34 Unsigned short Max coefficients 2 .. 5 ABSSp.AuxNumCoeff(i) = fread(fid,1,'uint16'); % +35 Unsigned short RESERVED ADC Cmd skip = fread(fid,5,'uint16'); % +36 RESERVED % +37 RESERVED % +38 RESERVED % +39 RESERVED % Gain information - [Repeated for all 4 gains] SIZE = 40 fseek(fid,PtrToThisAux + 80,'bof'); %ensures aligned for j= 1 : AuxNumGain(i) %Only import Coefficients for used gains % +40,41 char[4] Gain value Purely for user to see ABSSp.AuxGainLabel(j,i,:) = cleanString(fread(fid,4,'char=>char')); % +42 unsigned short Gain threshold rising ADC counts % +43 unsigned short Gain threshold falling ADC counts % +44 unsigned short Saturation threshold ADC counts % +45 unsigned short Alarm Threshold ADC counts skip = fread(fid,4,'uint16'); % +46->55 float[5] Coefficients for Gain ABSSp.AuxGainCoeff(:,j,i) = fread(fid,5,'float'); % +56,57 float Min for Gain ABSSp.AuxGainMin(j,i) = fread(fid,1,'float'); % Minimum value used in calibration data % +58,59 float Max for Gain ABSSp.AuxGainMax(j,i) = fread(fid,1,'float'); % Maximum value used in calibration data % +60->69 float[5] % +70->79 float[5] % +80? Repeat of Gain Information (40-79) for Gain 1 % +120? Repeat of Gain Information (40-79) for Gain 2 % +160? Repeat of Gain Information (40-79) for Gain 3 skip = fread(fid,10,'float'); end end %% % The starting offset for the first transducer personality is provided by the pointer to the transducer info. The % number of transducer personalities is defined in the personality structure. The majority of this structure is % reserved for use in storing calibration information for the transducer. The maximum number of transducers % can exceed the number of channels as transducers can be interchanged. % ABS Transducer Personality SIZE = 100 % Now Jump to the Transducer Info % for i = 1: ABSSp.NumAbsTransducers fseek(fid,PktStartPos + PtrToTransducerInfo*2 + 200*(i-1),'bof'); %Move to the start of the ABS information % 0->9 char[20] Label / Serial number “471-0700-003 1MHz” % 0->9 char[20] Label / Serial number “471-0700-003 1MHz” ABSSp.TransducerSerialNum(i,:) = cleanString(fread(fid,20,'char=>char')); % GV-10 % 10 unsigned short Transducer Type 1 = Std ABS transducer % 2 = Sidescan % (Bit 15 = indicates built in) ABSSp.TransducerType(i) = fread(fid,1,'uint16'); % 11 float Frequency Hz ABSSp.TransducerFrequency(i) = fread(fid,1,'float'); % In Hz % 13 float Radius M ABSSp.TransducerRadius(i) = fread(fid,1,'float'); % In meters % 15 float Vertical Full Beam Width Degrees ABSSp.TransducerVBeamWidth(i) = fread(fid,1,'float'); % In Degrees (3dB beamdidth, derived from acoustic beam pattern) % 17 float Horizontal Full Beam Width Degrees % % 1MHz 2MHz 2.5MHz 4MHz 5MHz % +/- 2.4 2.3 1.8 1.2 0.9 degrees beamwidth % 18mm 9.6mm 10mm 9.7mm 10.4mm Diameters % ABSSp.TransducerHBeamWidth(i,:) = fread(fid,4,'float'); ABSSp.TransducerKt(i) = fread(fid,1,'float'); % This is only if set in the personality % 19->99 Float RESERVED For future calibration information end end fclose(fid); return function [strOut] = cleanString(strIn) strOut = char(zeros(size(strIn))'); strTmp = deblank(strIn); strOut(1:size(strTmp)) = strTmp; return %-------------------------------------------------------------------------- % The following functions are used by the main function to search and read % file packet headers. %-------------------------------------------------------------------------- function [Status PktType PktSize] = readNextAQUAscat1000Header(fid) PktType=fread(fid,1,'uint8'); % PktVersion=fread(fid,1,'uint8'); %Packet Version PktSize=fread(fid,1,'uint16'); %size of packet body PktChecksum=fread(fid,1,'uint16'); if 0 == feof(fid) Status = 1; else Status = 0; %Need to test the checksum end return function [status pktSize] = findAQUAscat1000Packet(fid, type), % % This function looks for the specific packet type and returns once it has % been found. It always starts from the beginning of the file and reads in % a header at a time. If header not required then jumps to next. % fseek(fid,0,'bof'); while (0 == feof(fid)) [status pktType pktSize] = readNextAQUAscat1000Header(fid); if 0 == status break; else if pktType == type break; else fseek(fid,pktSize*2,'cof'); %Skip past packet content end end end return