Changeset 867 for trunk/src/series/merge_proj.m
- Timestamp:
- Feb 12, 2015, 9:31:47 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.