function muse_gashound(inDir, outFile) % MUSE_GASHOUND - Process gashound data files into a single file % % Use as: muse_gashound(inDir, outFile) % % Inputs: inDir = name of the directory containing only daily oasis % microcat files created using extract % outFile = name of file to create. This file will contain % the following columns: 1) time: epic seconds, % 2) temperature, and 3) salinity % % Brian Schlining % 15 Aug 2000 % Check input arguments if nargin < 2 fprintf(1, 'Error: Incorrect usage\n\n') help muse_microcat return end if ~isdir(inDir) error([inDir ' is not a directory']); end %======================== % Set defualt parameters %======================== time = 1; volts = 2; % BatteryVolts ePrs = 3; % EquilibratorPressure eTmp = 4; % EquilibratorTemperature eCO2 = 5; % EquilibratorPCO2 zPrs = 6; % ZeroPressure zTmp = 7; % ZeroTemperature zCO2 = 8; % ZeroPCO2 aPrs = 9; % AirPressure aTmp = 10; % AirTemperature aCO2 = 11; % AirPCO2 %========= % Process %========= % Get a list of all files in the input directory fileList = getfname(inDir); numFiles = size(fileList, 1); % open the outFile for writing the data to fid = fopen(outFile, 'wt'); if fid < 0 error(['Unable to write to ' outFile]) end % Add a header hdr = {'#',... '# GasHound data header', ... '#',... '# Gashound data records in this file contain 2 values for 1 sensor', ... '# The overall format is:', ... '#', ... '# time airCO2 eqCO2', ... '#', ... '# time: GMT time. Format is epic seconds (since Jan 01 1070 00:00:00)', ... '# airCO2: Vapor Corrected CO2 in air in microatm', ... '# eqCO2: Vapor Corrected CO2 in water in microatm', ... '#'}; for i = 1:length(hdr) fprintf(fid, '%s\n', hdr{i}); end % Process each data file for i = 1:numFiles try filename = deblank(fileList(i,:)); fprintf(1, 'Processing %s\n', filename); OK = 0; x = readflatfile([inDir filesep filename]); % Extract the times Month = floor(x(:,time)/1000000); Day = floor((x(:,time) - (Month*1000000))/10000); Hour = floor((x(:,time) - (Month*1000000) - (Day*10000))/100); Minute = floor((x(:,time) - (Month*1000000) - (Day*10000) - (Hour*100))); Year = ones(size(Month)).* sscanf(filename(1:4), '%f'); t = datenum(Year, Month, Day, Hour, Minute, 0); t = sdn2utc(t); % Corrected CO2 eCorr = ((50 - x(:,eTmp))*0.0017*(eCO2 - zCO2)) + (eCO2 - zCO2) + 6; aCorr = ((50 - x(:,aTmp))*0.0017*(aCO2 - zCO2)) + (aCO2 - zCO2) + 6; % Vapor corrected C02 eCorr = (eCorr * 0.01) + eCorr; aCorr = (aCorr * 0.01) + aCorr; OK = 1; catch warning(['Unable to process ' inDir filesep filename]); end if OK data = [t aCorr eCorr]; fprintf(fid, '%10.0f\t%8.5f\t%8.5f\n', data'); end end fclose(fid);