Changeset 867 for trunk/src/series
- Timestamp:
- Feb 12, 2015, 9:31:47 PM (10 years ago)
- Location:
- trunk/src/series
- Files:
-
- 1 added
- 3 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=NbField-nbfiles; 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 -
trunk/src/series/merge_proj.m
r857 r867 196 196 FileExtOut='.nc'; %netcdf output 197 197 end 198 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series198 %NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series 199 199 RootFileOut=RootFile{1}; 200 200 for iview=2:NbView … … 403 403 end 404 404 errormsg=''; 405 MergeData=Data{1};% merged field= first field by default, reproduces the gl abal attributes of the first field405 MergeData=Data{1};% merged field= first field by default, reproduces the global attributes of the first field 406 406 NbView=length(Data); 407 if NbView==1 408 return 407 if NbView==1% if there is only one field, just reproduce it in MergeData 408 return 409 409 end 410 410 … … 419 419 if NbDim(icell)~=1 % skip field cells which are of dim 1 420 420 switch CellInfo{icell}.CoordType 421 case 'scattered' %case of input fields with unstructured coordinates: just conca cene data421 case 'scattered' %case of input fields with unstructured coordinates: just concatene data 422 422 for ivar=CellInfo{icell}.VarIndex % indices of the selected variables in the list FieldData.ListVarName 423 423 VarName=Data{1}.ListVarName{ivar}; 424 %MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field425 424 for iview=2:NbView 426 425 MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)]; … … 431 430 if isfield(CellInfo{icell},'VarIndex_errorflag') && ~isempty(CellInfo{icell}.VarIndex_errorflag) 432 431 FFName=Data{1}.ListVarName{CellInfo{icell}.VarIndex_errorflag};% name of errorflag variable 432 MergeData.ListVarName(CellInfo{icell}.VarIndex_errorflag)=[];%remove error flag variable in MergeData (will use NaN instead) 433 MergeData.VarDimName(CellInfo{icell}.VarIndex_errorflag)=[]; 434 MergeData.VarAttribute(CellInfo{icell}.VarIndex_errorflag)=[]; 433 435 end 434 436 % select good data on each view … … 441 443 check_bad=isnan(Data{iview}.(VarName)) | Data{iview}.(FFName)~=0;%=0 for NaN or error flagged data values, 1 else 442 444 end 443 Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or masked data445 Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag 444 446 if iview==1 445 MergeData.(VarName)=Data{1}.(VarName);% correct the field of MergeData447 %MergeData.(VarName)=Data{1}.(VarName);% initiate MergeData with the first field 446 448 NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point 447 449 elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName)) 448 450 errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object'; 449 451 return 450 else 451 452 MergeData.(VarName)=MergeData.(VarName) + Data{iview}.(VarName);%add data 452 else 453 MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data 453 454 NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else 454 455 end 455 456 end 456 457 MergeData.(VarName)(NbAver~=0)=MergeData.(VarName)(NbAver~=0)./NbAver(NbAver~=0);% take average of defined data at each point 458 MergeData.(VarName)(NbAver==0)=NaN;% set to NaN the points with no good data 457 459 end 458 460 end 459 if isempty(FFName)460 FFName='FF';461 end462 MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data463 MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data461 % if isempty(FFName) 462 % FFName='FF'; 463 % end 464 % MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data 465 % MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data 464 466 end 465 467 end -
trunk/src/series/time_series.m
r810 r867 207 207 %% Set field names and velocity types 208 208 InputFields{1}=[];%default (case of images) 209 if nbview==2 210 InputFields{2}=[];%default (case of images) 211 end 209 212 if isfield(Param,'InputFields') 210 213 InputFields{1}=Param.InputFields; 211 end 212 if nbview==2 213 InputFields{2}=[];%default (case of images) 214 if isfield(Param,'InputFields') 215 InputFields{2}=Param.InputFields{1};%default 214 if nbview==2 215 InputFields{2}=Param.InputFields;%default 216 216 if isfield(Param.InputFields,'FieldName_1') 217 217 InputFields{2}.FieldName=Param.InputFields.FieldName_1;
Note: See TracChangeset
for help on using the changeset viewer.