% make a barometric pressure merge file from NOAA station data % you may have to merge a couple of NOAA files. % this will read the format that comes from NOAA ASCII files such as: % YYYY MM DD hh mm WD WSPD GST WVHT DPD APD MWD BARO ATMP WTMP DEWP VIS TIDE % 2006 04 01 00 00 185 9.4 10.4 99.00 99.00 99.00 999 1017.5 999.0 10.6 999.0 99.0 99.00 % bad data flagged by 999 are omitted % and output the barometric pressure in th format % MM/DD/YY HH:MM:SS P % P can be in psia or millibars, be sure to select the units in Seasoft % Waves when merging barometric pressure function makebaro(noaaFile) if ~exist('noaaFile','var') || ~exist(noaaFile,'file'), [theFile, thePath] = uigetfile('*.txt', 'Select NOAA Data File:'); if isequal(theFile,0) || isequal(thePath,0), disp('User pressed cancel') return; end disp(['User selected ', thePath, theFile]) noaaFile = fullfile(thePath, theFile); end [thePath, theFile] = fileparts(noaaFile); outFile = fullfile(thePath, [theFile,'.bp']); noaaFid = fopen(noaaFile,'r'); bpFid = fopen(outFile,'w+'); % skip header line fgetl(noaaFid); while ftell(noaaFid) > 0, [data, count] = fscanf(noaaFid,'%f',18); if count == 18, if data < 9000, yy = data(1)-2000; fprintf(bpFid,'%02d/%02d/%02d %02d:%02d:00 %f\n',data(2),data(3),yy,data(4),data(5),data(13)); end else break; end end fclose(noaaFid) fclose(bpFid)