Changeset 526 for trunk/src/series


Ignore:
Timestamp:
Aug 20, 2012, 12:32:31 PM (12 years ago)
Author:
sommeria
Message:

bugs corrected; Posiibility of usual 1D plots introduced with the new way of using get_field. time_series and aver_stat updated

Location:
trunk/src/series
Files:
2 edited

Legend:

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

    r494 r526  
    182182
    183183%% MAIN LOOP ON SLICES
    184 %%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
    185184for i_slice=1:NbSlice
    186185    index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
     
    196195            stopstate='queue';
    197196        end
    198        
     197        if isequal(stopstate,'queue')% enable STOP command
     198           
    199199        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    200200        for iview=1:nbview
     
    209209            end
    210210        end
    211         Field=[]; % initiate the current input field structure
     211        else
     212            errormsg='stop';
     213        end
    212214        %%%%%%%%%%%%%%%% end loop on views (input lines) %%%%%%%%%%%%%%%%
    213215        %%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
    214216        % EDIT FROM HERE
    215        
     217   
    216218        if isempty(errormsg)
    217             % coordinate transform (or other user defined transform)
     219            Field=Data{1}; % default input field structure
     220            %% coordinate transform (or other user defined transform)
    218221            if ~isempty(transform_fct)
    219                 if nbview==2
    220                     [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
    221                     if isempty(Data{2})
    222                         Data(2)=[];
    223                     end
    224                 else
    225                     Data{1}=transform_fct(Data{1},XmlData{1});
     222                switch nargin(transform_fct)
     223                    case 4
     224                        if length(Data)==2
     225                            Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
     226                        else
     227                            Field=transform_fct(Data{1},XmlData{1});
     228                        end
     229                    case 3
     230                        if length(Data)==2
     231                            Field=transform_fct(Data{1},XmlData{1},Data{2});
     232                        else
     233                            Field=transform_fct(Data{1},XmlData{1});
     234                        end
     235                    case 2
     236                        Field=transform_fct(Data{1},XmlData{1});
     237                    case 1
     238                        Field=transform_fct(Data{1});
    226239                end
    227240            end
    228241           
    229             %% check whether tps is needed, then calculate tps coefficients if needed
    230             check_tps=0;
    231             if ischar(Param.InputFields.FieldName)
    232                 Param.InputFields.FieldName={Param.InputFields.FieldName};
    233             end
    234             for ilist=1:numel(Param.InputFields.FieldName)
    235                 switch Param.InputFields.FieldName{ilist}
    236                     case {'vort','div','strain'}
    237                         check_tps=1;
    238                 end
    239             end
    240             if strcmp(Param.ProjObject.ProjMode,'filter')
    241                 check_tps=1;
    242             end
    243             if check_tps
    244                 SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps
    245                 if isfield(Data{iview},'SubDomain')
    246                     SubDomain=Data{iview}.SubDomain;%
    247                 end
    248                 [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =...
    249                     filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0);
    250                 nbvar=numel(Data{iview}.ListVarName);
    251                 Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}];
    252                 Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},...
    253                     {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}];
    254                 Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps';
    255                 Data{iview}.VarAttribute{nbvar+4}.Role='vector_x';
    256                 Data{iview}.VarAttribute{nbvar+5}.Role='vector_y';
    257                 if isfield(Data{iview},'ListDimName')%cleaning
    258                     Data{iview}=rmfield(Data{iview},'ListDimName');
    259                 end
    260                 if isfield(Data{iview},'DimValue')%cleaning
    261                     Data{iview}=rmfield(Data{iview},'DimValue');
    262                 end
    263             end
    264                  
    265             % field calculation (vort, div...)   
    266             if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civdata')
    267                 if isfield(Data{1},'Coord_tps')
    268                     Data{1}.FieldList=Param.InputFields.FieldName;
    269                 else
    270                     Data{1}=calc_field(Param.InputFields.FieldName,Data{1});%calculate field (vort..)
    271                 end
    272             end
    273          
    274             % field substration (for two input file series)
    275             if length(Data)==2
    276                 if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civdata')
    277                     if isfield(Data{2},'Coord_tps')
    278                         Data{2}.FieldList=Param.InputFields.FieldName;
    279                     else
    280                         Data{2}=calc_field(Param.InputFields.FieldName,Data{2});%calculate field (vort..)
    281                     end
    282                 end
    283                 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
    284                 if ~isempty(errormsg)
    285                     msgbox_uvmat('ERROR',['error in aver_stat/sub_field:' errormsg])
    286                     return
    287                 end
    288             else
    289                 Field=Data{1};
    290             end
    291            
     242            %% calculate tps coefficients if needed
     243            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
     244                Field=calc_tps(Field,check_proj_tps);
     245            end
     246
    292247            %field projection on an object
    293248            if Param.CheckObject
     
    356311    end
    357312   
    358     %writing the result file
     313    %writting the result file
    359314    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
    360315    if CheckImage{1} %case of images
     
    381336%% open the result file with uvmat (in RUN mode)
    382337if checkrun
    383     hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    384     delete(hget_field)
     338%     hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
     339%     delete(hget_field)
    385340    uvmat(OutputFile)% open the last result file with uvmat
    386341end
  • trunk/src/series/time_series.m

    r524 r526  
    6363end
    6464
    65 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
     65%%%%%%%%%%%% STANDARD PART %%%%%%%%%%%%
    6666%% select different modes,  RUN, parameter input, BATCH
    6767% BATCH  case: read the xml file for batch case
     
    8787NomType=Param.InputTable(:,4);
    8888FileExt=Param.InputTable(:,5);
    89 
    90 % get the set of input file names (cell array filecell), and the lists of
    91 % input file or frame indices i1_series,i2_series,j1_series,j2_series
    9289[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    93 % filecell{iview,fileindex}: cell array representing the list of file names
     90%%%%%%%%%%%%
     91% The cell array filecell is the list of input file names, while
     92% filecell{iview,fileindex}:
    9493%        iview: line in the table corresponding to a given file series
    9594%        fileindex: file index within  the file series,
    9695% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
    9796% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    98 % set of frame indices used for movie or multimage input
    99 % numbers of slices and file indices
    100 
     97%%%%%%%%%%%%
    10198NbSlice=1;%default
    10299if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     
    138135
    139136%% coordinate transform or other user defined transform
    140 transform_fct='';%default
     137transform_fct=[];%default
    141138if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    142139    addpath(Param.FieldTransform.TransformPath)
     
    148145 % EDIT FROM HERE
    149146
    150 %% check the validity of  input file types
     147%% check the validity of  ctinput file types
    151148if CheckImage{1}
    152149    FileExtOut='.png'; % write result as .png images for image inputs
     
    162159end
    163160NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
    164 % if NbSlice~=nbfield_j
    165 %     answer=_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
    166 %     if ~strcmp(answer,'Yes')
    167 %         return
    168 %     end
    169 % end
    170161if checkrun==1
    171162    return % stop here for input checks
     
    189180    end
    190181end
    191 %%% TO UPDATE
    192 if isequal(InputFields{1},'get_field...')
    193     hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    194     if numel(hget_field)>1
    195         delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld
    196     elseif isempty(hget_field)
    197         filename=filecell{1,1};
    198       % filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1});
    199        idetect(iview)=exist(filename,'file');
    200        hget_field=get_field(filename);
    201        return
    202     end
    203     SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
    204     if isempty(SubField)
    205         delete(hget_field)
    206         filename=filecell{1,1};
    207        %filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),j2_series{1}(1),SubDir{1});
    208         hget_field=get_field(filename);
    209         SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
    210     end
    211 end
    212 %%%%%%%
    213182
    214183%% Initiate output fields
     
    255224            stopstate='queue';
    256225        end
    257        
    258         %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    259226        if isequal(stopstate,'queue')% enable STOP command
    260227            Data=cell(1,nbview);%initiate the set Data
    261228            nbtime=0;
    262229            dt=[];
    263             % loop on views (in case of multiple input series)
     230            %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    264231            for iview=1:nbview
    265232                % reading input file(s)
    266                 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
     233                [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index));
    267234                if ~isempty(errormsg)
    268235                    errormsg=['time_series/read_field/' errormsg];
     
    280247            end
    281248           
     249            Field=Data{1}; % default input field structure
    282250            % coordinate transform (or other user defined transform)
    283251            if ~isempty(transform_fct)
    284                 if nbview==2
    285                     [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
    286                     if isempty(Data{2})
    287                         Data(2)=[];
    288                     end
    289                 else
    290                     Data{1}=transform_fct(Data{1},XmlData{1});
    291                 end
    292             end
    293            
    294             % field substration (for two input file series)
    295             if length(Data)==2
    296                 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
    297             else
    298                 Field=Data{1};
    299             end
     252                switch nargin(transform_fct)
     253                    case 4
     254                        if length(Data)==2
     255                            Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
     256                        else
     257                            Field=transform_fct(Data{1},XmlData{1});
     258                        end
     259                    case 3
     260                        if length(Data)==2
     261                            Field=transform_fct(Data{1},XmlData{1},Data{2});
     262                        else
     263                            Field=transform_fct(Data{1},XmlData{1});
     264                        end
     265                    case 2
     266                        Field=transform_fct(Data{1},XmlData{1});
     267                    case 1
     268                        Field=transform_fct(Data{1});
     269                end
     270            end
     271           
     272            % calculate tps coefficients if needed
     273            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
     274                Field=calc_tps(Field,check_proj_tps);
     275            end
     276           
     277            %field projection on an object
    300278            if Param.CheckObject
    301279                [Field,errormsg]=proj_field(Field,Param.ProjObject);
     280                if ~isempty(errormsg)
     281                    msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg])
     282                    return
     283                end
    302284            end
    303285            nbfile=nbfile+1;
Note: See TracChangeset for help on using the changeset viewer.