Ignore:
Timestamp:
Sep 7, 2018, 8:51:09 PM (6 years ago)
Author:
sommeria
Message:

merge_proj_polar updated + other corrected bugs

File:
1 edited

Legend:

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

    r1027 r1058  
    100100HeadData.ListVarName= {'radius','azimuth'} ;
    101101HeadData.VarDimName={'radius','azimuth'};
    102 HeadData.VarAttribute={'coord_y','coord_x'} ;
     102HeadData.VarAttribute{1}.Role='coord_y';
     103HeadData.VarAttribute{2}.Role='coord_x';
    103104HeadData.radius=radius_shifted;
    104105HeadData.azimuth=azimuth_arclength;   
     
    373374        ProjData{iview}.ListVarName= [ProjData{iview}.ListVarName ListVarName];
    374375        ProjData{iview}.VarDimName={'radius','azimuth'};
    375         ProjData{iview}.VarAttribute=[{'coord_x'} {'coord_y'} VarAttribute];
     376%         ProjData{iview}.VarAttribute{1}.Role='coord_y';
     377%         ProjData{iview}.VarAttribute{2}.Role='coord_x';
     378        ProjData{iview}.VarAttribute=[ProjData{iview}.VarAttribute VarAttribute];
    376379        for ivar=1:numel(ListVarName)
    377380            ProjData{iview}.VarDimName{ivar+2}={'radius','azimuth'};
     
    457460disp([ num2str(ellapsed_time/(60*NbField),3) ' minutes per iteration'])
    458461
     462% %'merge_field': concatene fields
     463% %------------------------------------------------------------------------
     464% function [MergeData,errormsg]=merge_field(Data)
     465% %% default output
     466% if isempty(Data)||~iscell(Data)
     467%     MergeData=[];
     468%     return
     469% end
     470% errormsg='';
     471% MergeData=Data{1};% merged field= first field by default, reproduces the global attributes of the first field
     472% NbView=length(Data);
     473% if NbView==1% if there is only one field, just reproduce it in MergeData
     474%     return
     475% end
     476%
     477% %% group the variables (fields of 'Data') in cells of variables with the same dimensions
     478% [CellInfo,NbDim,errormsg]=find_field_cells(Data{1});
     479% if ~isempty(errormsg)
     480%     return
     481% end
     482%
     483% %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
     484% for icell=1:length(CellInfo)
     485%     if NbDim(icell)~=1 % skip field cells which are of dim 1
     486%         switch CellInfo{icell}.CoordType
     487%             case 'scattered'  %case of input fields with unstructured coordinates: just concatene data
     488%                 for ivar=CellInfo{icell}.VarIndex %  indices of the selected variables in the list FieldData.ListVarName
     489%                     VarName=Data{1}.ListVarName{ivar};
     490%                     for iview=2:NbView
     491%                         MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)];
     492%                     end
     493%                 end
     494%             case 'grid'        %case of fields defined on a structured  grid
     495%                 FFName='';
     496%                 if isfield(CellInfo{icell},'VarIndex_errorflag') && ~isempty(CellInfo{icell}.VarIndex_errorflag)
     497%                     FFName=Data{1}.ListVarName{CellInfo{icell}.VarIndex_errorflag};% name of errorflag variable
     498%                     MergeData.ListVarName(CellInfo{icell}.VarIndex_errorflag)=[];%remove error flag variable in MergeData (will use NaN instead)
     499%                     MergeData.VarDimName(CellInfo{icell}.VarIndex_errorflag)=[];
     500%                     MergeData.VarAttribute(CellInfo{icell}.VarIndex_errorflag)=[];
     501%                 end
     502%                 % select good data on each view
     503%                 for ivar=CellInfo{icell}.VarIndex  %  indices of the selected variables in the list FieldData.ListVarName
     504%                     VarName=Data{1}.ListVarName{ivar};
     505%                     for iview=1:NbView
     506%                         if isempty(FFName)
     507%                             check_bad=isnan(Data{iview}.(VarName));%=0 for NaN data values, 1 else
     508%                         else
     509%                             check_bad=isnan(Data{iview}.(VarName)) | Data{iview}.(FFName)~=0;%=0 for NaN or error flagged data values, 1 else
     510%                         end
     511%                         Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
     512%                         if iview==1
     513%                             %MergeData.(VarName)=Data{1}.(VarName);% initiate MergeData with the first field
     514%                             MergeData.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
     515%                             NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point
     516%                         elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName))
     517%                             errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
     518%                             return
     519%                         else
     520%                             MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data
     521%                             NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
     522%                         end
     523%                     end
     524%                     MergeData.(VarName)(NbAver~=0)=MergeData.(VarName)(NbAver~=0)./NbAver(NbAver~=0);% take average of defined data at each point
     525%                     MergeData.(VarName)(NbAver==0)=NaN;% set to NaN the points with no good data
     526%                 end
     527%         end
     528%   
     529%     end
     530% end
     531
     532
    459533%'merge_field': concatene fields
    460534%------------------------------------------------------------------------
     
    469543NbView=length(Data);
    470544if NbView==1% if there is only one field, just reproduce it in MergeData
    471     return
     545    return 
    472546end
    473547
     
    514588                            errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
    515589                            return
    516                         else
     590                        else                             
    517591                            MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data
    518592                            NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
     
    523597                end
    524598        end
    525         %         if isempty(FFName)
    526         %             FFName='FF';
    527         %         end
    528         %         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
    529         %         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
    530     end
    531 end
    532 
    533 
    534    
     599    end
     600end   
Note: See TracChangeset for help on using the changeset viewer.