% Script to edit a file by assigning NaN to a % designated variable in records for which the % corresponding variable in a mask file equals 1. % Fran Hotchkiss April 8, 1998 % Use dialog box to choose input file. disp ('* Select raw data file.') ding rawc = netcdf; % Use dialog box to choose mask file. disp ('* Select mask file.') ding masc = netcdf; TF = 1 first = 1 while TF % Use dialog box to designate variable that is % to be edited. if first criterion.infile = justname(name(rawc)); criterion.maskfile = justname(name(masc)); criterion.outfile = justname(name(rawc)); criterion.variable = 'P_1'; criterion.another_variable = 0; end uigetparm(criterion); load criterion TF = criterion.another_variable if first outname = criterion.outfile % Copy input file to output file. result=fcopy(name(rawc),criterion.outfile) outc = netcdf(criterion.outfile, 'write'); if isempty(outc), return, end % Update global attributes. history =[' edited using maskedit.m with mask file ' justname(name(masc)) '. :' outc.history(:)]; outc.history = history; outc.CREATION_DATE = ncchar(datestr(now,0)); outc.FILL_FLAG = nclong(1); outc.VAR_FILL = ncchar('NaN'); first = 0; end % Replace records for which designated % variable is bad. dvar = rawc{criterion.variable}(:); mvar = masc{criterion.variable}(:); i = find(mvar); if isempty(i) ding disp ('No records marked in this variable!') disp (criterion.variable) else dvar(i) = NaN; % Update global attributes. history =[criterion.variable ' , ' outc.history(:)]; outc.history = history; % Update minima and maxima of edited variable. outc{criterion.variable}.minimum = ncfloat(min(dvar)); outc{criterion.variable}.maximum = ncfloat(max(dvar)); % Update values of edited variable. n = length(dvar); outc{criterion.variable}(1:n) = dvar; end end % Update global attributes. history =[' Variables ' outc.history(:)]; outc.history = history; ncclose