% getburst - quick grab of burst data from a netCDF file % function [data, tj] = getburst(fname,iburst, vname) % where % fname = netCDF file name % iburst = burst number (as defined by Sontek, % not the burst order in the file) % vname = variable name % data = burst data % tj = julian day % Written by Marinna Martini for the U.S. Geological Survey % Coastal & Marine Program Woods Hole Field Center, Woods Hole, MA % http://woodshole.er.usgs.gov/ % Please report bugs to mmartini@usgs.gov function [data, tj] = getburst(fname,iburst, vname) if ~exist('fname'), [fname, pname, junk] = uigetfile('*b.cdf', 'Select a raw burst file'); fname = [pname fname]; end if ~exist('iburst'), iburst = inputdlg('Which burst number?'); iburst = str2num(iburst{1}); end data = []; tj = []; cdf = netcdf(fname); if isempty(cdf), disp(sprintf('getburst: could not open %s',fname)) return end disp('getburst: getting the burst numbers') burstnum = cdf{'burstNum'}(:); if isempty(burstnum), burstnum = cdf{'burst'}(:); end idx = find(burstnum == iburst); if ~isempty(idx), iburst = idx; else disp(sprintf('getburst: could not find burst %d',iburst)) return end vnames = ncnames(var(cdf)); if ~exist('vname'), [selection,ok] = listdlg('ListString',vnames,'PromptString','Select a variable') vname = vnames{selection}; end data = cdf{vname}(iburst,:); tj = cdf{'time'}(iburst,:)+cdf{'time2'}(iburst,:)./(1000*3600*24); close(cdf) if isempty(data), disp(sprintf('getburst: could not get data for variable %s',... vname)) end