Ignore:
Timestamp:
Feb 12, 2015, 9:31:47 PM (10 years ago)
Author:
sommeria
Message:

python option added in series and bug corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/merge_proj.m

    r857 r867  
    196196    FileExtOut='.nc'; %netcdf output
    197197end
    198 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
     198%NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
    199199RootFileOut=RootFile{1};
    200200for iview=2:NbView
     
    403403end
    404404errormsg='';
    405 MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field
     405MergeData=Data{1};% merged field= first field by default, reproduces the global attributes of the first field
    406406NbView=length(Data);
    407 if NbView==1
    408     return
     407if NbView==1% if there is only one field, just reproduce it in MergeData
     408    return 
    409409end
    410410
     
    419419    if NbDim(icell)~=1 % skip field cells which are of dim 1
    420420        switch CellInfo{icell}.CoordType
    421             case 'scattered'  %case of input fields with unstructured coordinates: just concacene data
     421            case 'scattered'  %case of input fields with unstructured coordinates: just concatene data
    422422                for ivar=CellInfo{icell}.VarIndex %  indices of the selected variables in the list FieldData.ListVarName
    423423                    VarName=Data{1}.ListVarName{ivar};
    424                     %MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field
    425424                    for iview=2:NbView
    426425                        MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)];
     
    431430                if isfield(CellInfo{icell},'VarIndex_errorflag') && ~isempty(CellInfo{icell}.VarIndex_errorflag)
    432431                    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)=[];
    433435                end
    434436                % select good data on each view
     
    441443                            check_bad=isnan(Data{iview}.(VarName)) | Data{iview}.(FFName)~=0;%=0 for NaN or error flagged data values, 1 else
    442444                        end
    443                         Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or masked data
     445                        Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
    444446                        if iview==1
    445                             MergeData.(VarName)=Data{1}.(VarName);% correct the field of MergeData
     447                            %MergeData.(VarName)=Data{1}.(VarName);% initiate MergeData with the first field
    446448                            NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point
    447449                        elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName))
    448450                            errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
    449451                            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
    453454                            NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
    454455                        end
    455456                    end
    456457                    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
    457459                end
    458460        end
    459         if isempty(FFName)
    460             FFName='FF';
    461         end
    462         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
    463         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
     461%         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
    464466    end
    465467end
Note: See TracChangeset for help on using the changeset viewer.