function stat=rep_var_wfillv(fname,var_name) % rep_var_wfillv - replaces the whole timeseries of the specified variable % with its _fillvalue % usage: stat=rep_var_wfillv('8911wh-part000.nc','P_1294') % Operates on single dimensioned variables in ordinary or wavesfiles. % this won't work for burst files, or sonar images. % used for data repair prior to BBV % emontgomery 11/3/10 % Make sure you've got a file if ~exist(fname,'file') disp('The file name entered does not exist- use the GUI to pick another'); [fn, pathname, filterindex] = uigetfile('*.*', 'Pick another file'); fname=[pathname '/' fn]; end nc=netcdf(fname,'write'); dimn= size(nc{var_name}); ldim=length(dimn); fv=nc{var_name}.FillValue_(:); if strfind(fname,'-cal') & ldim >3 % for the bursts nan_fill=ones(1,dimn(2)).*fv; else nan_fill=ones(dimn(1),1).*fv; end if (ldim==4) | (length(ldim)==2) for ik=1:dimn(1) % bursts are 1st dimension: do all if (ldim==4) & (dimn(2) > 1) nc{var_name}(ik,:,1,1)=nan_fill; %burst Tx_1211 elseif (ldim==2) nc{var_name}(ik,:)=nan_fill; % else nc{var_name}(:)=nan_fill; % stats or current Tx1211 end end else if (ldim==3) nc{var_name}(:,1,1)=nan_fill; %waves wp_4060, P_4023 else nc{var_name}(:)=nan_fill; % stats or current Tx1211 end end nc{var_name}.NOTE=ncchar('sensor malfunctioned- bad bursts replaced with fillValue'); close(nc) stat=1; end