Changeset 867 for trunk/src/series/aver_stat.m
 Timestamp:
 Feb 12, 2015, 9:31:47 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/aver_stat.m
r810 r867 136 136 for iview=1:NbView 137 137 if ~exist(filecell{iview,1}','file') 138 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])138 disp_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun) 139 139 return 140 140 end … … 155 155 diff_time=max(max(diff(time))); 156 156 if diff_time>0 157 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])157 disp_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun) 158 158 end 159 159 end … … 176 176 FileExtOut='.nc';% write result as .nc files for netcdf inputs 177 177 else 178 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])178 disp_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun) 179 179 return 180 180 end 181 181 if NbView==2 && ~isequal(CheckImage{1},CheckImage{2}) 182 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')182 disp_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun) 183 183 return 184 184 end … … 216 216 % index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice 217 217 nbfiles=0; 218 nbmissing=0;218 % nbmissing=0; 219 219 220 220 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% … … 275 275 [Field,errormsg]=proj_field(Field,Param.ProjObject); 276 276 if ~isempty(errormsg) 277 msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg])277 disp_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg],checkrun) 278 278 return 279 279 end … … 289 289 DataOut=Field;%default 290 290 DataOut.Conventions='uvmat'; %suppress Conventions='uvmat/civdata' for civ input files 291 for ivar=1:length(Field.ListVarName) 291 errorvar=zeros(numel(Field.ListVarName));%index of errorflag associated to each variable 292 for ivar=1:numel(Field.ListVarName) 292 293 VarName=Field.ListVarName{ivar}; 293 DataOut.(VarName)=double(DataOut.(VarName)); 294 end 295 else %current field 296 for ivar=1:length(Field.ListVarName) 297 VarName=Field.ListVarName{ivar}; 298 sizmean=size(DataOut.(VarName)); 299 siz=size(Field.(VarName)); 300 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) 301 disp_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid'],checkrun) 302 return 294 DataOut.(VarName)=zeros(size(DataOut.(VarName)));% initiate each field to zero 295 NbData.(VarName)=zeros(size(DataOut.(VarName)));% initiate the nbre of good data to zero 296 for iivar=1:length(Field.VarAttribute) 297 if isequal(Field.VarDimName{iivar},Field.VarDimName{ivar})&& isfield(Field.VarAttribute{iivar},'Role')... 298 && strcmp(Field.VarAttribute{iivar}.Role,'errorflag') 299 errorvar(ivar)=iivar; % index of the errorflag variable corresponding to ivar 300 end 301 end 302 end 303 DataOut.ListVarName(errorvar(errorvar~=0))=[]; %remove errorflag from result 304 DataOut.VarDimName(errorvar(errorvar~=0))=[]; %remove errorflag from result 305 DataOut.VarAttribute(errorvar(errorvar~=0))=[]; %remove errorflag from result 306 end %current field 307 for ivar=1:length(DataOut.ListVarName) 308 VarName=Field.ListVarName{ivar}; 309 sizmean=size(DataOut.(VarName)); 310 siz=size(Field.(VarName)); 311 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) 312 disp_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid'],checkrun) 313 return 314 else 315 if errorvar(ivar)==0 316 check_bad=isnan(Field.(VarName));%=0 for NaN data values, 1 else 303 317 else 304 DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum318 check_bad=isnan(Field.(VarName))  Field.(Field.ListVarName{errorvar(ivar)})~=0;%=0 for NaN or error flagged data values, 1 else 305 319 end 320 Field.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag 321 DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum 322 NbData.(VarName)=NbData.(VarName)+ ~check_bad;% records the number of data for each point 306 323 end 307 324 end … … 315 332 for ivar=1:length(Field.ListVarName) 316 333 VarName=Field.ListVarName{ivar}; 317 DataOut.(VarName)=DataOut.(VarName)/nbfiles; % normalize the mean 318 end 334 DataOut.(VarName)=DataOut.(VarName)./NbData.(VarName); % normalize the mean 335 end 336 nbmissing=NbFieldnbfiles; 319 337 if nbmissing~=0 320 msgbox_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted'])338 disp_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted'],checkrun) 321 339 end 322 340 if isempty(time) % time is read from files
Note: See TracChangeset
for help on using the changeset viewer.