Changeset 526


Ignore:
Timestamp:
Aug 20, 2012, 12:32:31 PM (9 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
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field.m

    r521 r526  
    831831function RUN_Callback(hObject, eventdata, handles)
    832832%---------------------------------------------------------
    833 % set(handles.RUN,'BackgroundColor',[1 1 0])% mark use of RUN action
    834 % test_fig=get(handles.SelectFigure,'Value');
    835 %
    836 % % plot requested in uvmat
    837 % if ~test_fig
    838 %     inputfile=get(handles.inputfile,'String');
    839 %     huvmat=findobj(allchild(0),'tag','uvmat');
    840 %     if isempty(huvmat)
    841 %         input.InputFile=inputfile;
    842 %         input.FieldsString={'get_field...'};
    843 %         uvmat(input)
    844 %     else
    845 %         set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases)
    846 %         hhuvmat=guidata(huvmat);
    847 %         set(hhuvmat.Fields,'Value',1)
    848 %         set(hhuvmat.Fields,'String',{'get_field...'})
    849 %         uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
    850 %     end
    851 %   
    852 % % other kind of plot
    853 % else  %TODO: check and update: add plot on an existing axes
    854 %     figcell=get(handles.list_fig,'String');
    855 %     index=get(handles.list_fig,'value');
    856 %     figstring=figcell{index};
    857 %     index=get(handles.ACTION,'Value');
    858 %     list_func=get(handles.ACTION,'UserData');
    859 %     h_fun=list_func{index};
    860 %     set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    861 %     drawnow
    862 %     SubField=h_fun(handles.get_field);%handles.figure1 =handles of the GUI get_field
    863 %     if ~isempty(SubField)
    864 %         plot_get_field(SubField,handles)
    865 %     end
    866 %     browse_fig(handles.list_fig); %update the list of new existing figures
    867 % end
    868 % set(handles.RUN,'BackgroundColor',[1 0 0])
     833hfield=[];
    869834huvmat=findobj(allchild(0),'tag','uvmat');
    870 hhuvmat=guidata(huvmat);
    871 FieldsMenu=get(hhuvmat.Fields,'String');
    872 Fields=FieldsMenu{get(hhuvmat.Fields,'Value')};
    873 check_first=strcmp(Fields,'get_field...'); % =1 if the first field sereis is selected, =0 else
     835hseries=findobj(allchild(0),'tag','series');
     836check_series=0;
    874837if ~isempty(huvmat)
    875          get_field_GUI=read_GUI(handles.get_field);
    876          if isfield(get_field_GUI,'PanelVectors')
    877              set(hhuvmat.Coord_x,'value',1)
    878              set(hhuvmat.Coord_y,'value',1)
    879              set(hhuvmat.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors})
    880              set(hhuvmat.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors})
    881              UName=get_field_GUI.PanelVectors.vector_x;
    882              VName=get_field_GUI.PanelVectors.vector_y;
    883              menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}];
    884              menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}];
    885              if check_first
    886                   set(hhuvmat.Fields,'Value',1)
    887                  set(hhuvmat.Fields,'String',menu_str)
    888              else %get_field has been called by Fields_1
    889                   set(hhuvmat.Fields_1,'Value',1)
    890                  set(hhuvmat.Fields_1,'String',menu_str)
    891              end
    892              ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color));
    893              if ~isempty(ind_menu)
    894              set(hhuvmat.ColorScalar,'Value',ind_menu)
    895              else
    896                  set(hhuvmat.ColorScalar,'Value',1)
    897              end
    898                set(hhuvmat.ColorScalar,'String',menu_color)
    899          elseif isfield(get_field_GUI,'PanelScalar')
    900              set(hhuvmat.Coord_x,'value',1)
    901              set(hhuvmat.Coord_y,'value',1)
    902              set(hhuvmat.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar})
    903              set(hhuvmat.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar})
    904              AName=get_field_GUI.PanelScalar.scalar;
    905              if check_first
    906                 menu=get(hhuvmat.Fields,'String');
    907              else
    908                 menu=get(hhuvmat.Fields_1,'String');
    909              end
    910              ind_select=find(strcmp(AName,menu));
    911              if isempty(ind_select)
    912                  menu=[menu(1:end-1);{AName};{'get_field...'}];
    913                  ind_select=numel(menu)-1;
    914              end   
    915              if check_first
    916                 set(hhuvmat.Fields,'Value',ind_select);
    917                 set(hhuvmat.Fields,'String',menu);
    918              else
    919                 set(hhuvmat.Fields_1,'Value',ind_select);
    920                 set(hhuvmat.Fields_1,'String',menu);
    921              end
    922          end
    923          if ~strcmp(get(gcbf,'tag'),'uvmat')%if uvmat is not already active
    924          uvmat('run0_Callback',hObject,eventdata,hhuvmat); %refresh uvmat
    925          end
     838    hh=guidata(huvmat);
     839    FieldMenu=get(hh.FieldName,'String');
     840    FieldName=FieldMenu{get(hh.FieldName,'Value')};
     841    if strcmp(FieldName,'get_field...')
     842        hfield=hh.FieldName; %FieldName on uvmat
     843    elseif strcmp(get(hh.FieldName_1,'Visible'),'on')
     844        FieldMenu=get(hh.FieldName_1,'String');
     845        if ~isempty(FieldMenu)
     846            FieldName=FieldMenu{get(hh.FieldName_1,'Value')};
     847            if strcmp(FieldName,'get_field...')
     848                hfield=hh.FieldName_1; %FieldName_1 on uvmat
     849            end
     850        end
     851    end
     852end
     853if isempty(hfield) && ~isempty(hseries)
     854    check_series=1;
     855        hh=guidata(hseries);
     856    FieldMenu=get(hh.FieldName,'String');
     857    FieldName=FieldMenu{get(hh.FieldName,'Value')};
     858    if strcmp(FieldName,'get_field...')
     859        hfield=hh.FieldName; %FieldName on series
     860    else
     861       FieldMenu=get(hh.FieldName_1,'String');
     862       FieldName=FieldMenu{get(hh.FieldName_1,'Value')};
     863       if strcmp(FieldName,'get_field...')
     864            hfield=hh.FieldName_1; %FieldName_1 on series
     865       end
     866    end
     867end
     868if ~isempty(hfield)
     869    get_field_GUI=read_GUI(handles.get_field);
     870    if isfield(get_field_GUI,'PanelVectors')
     871        set(hh.Coord_x,'value',1)
     872        set(hh.Coord_y,'value',1)
     873        set(hh.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors})
     874        set(hh.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors})
     875        UName=get_field_GUI.PanelVectors.vector_x;
     876        VName=get_field_GUI.PanelVectors.vector_y;
     877        menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}];
     878        menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}];
     879        set(hfield,'Value',1)
     880        set(hfield,'String',menu_str)
     881        if ~check_series
     882            ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color));
     883            if ~isempty(ind_menu)
     884                set(hh.ColorScalar,'Value',ind_menu)
     885            else
     886                set(hh.ColorScalar,'Value',1)
     887            end
     888            set(hh.ColorScalar,'String',menu_color)
     889        end
     890    elseif isfield(get_field_GUI,'PanelScalar')
     891        set(hh.Coord_x,'value',1)
     892        set(hh.Coord_y,'value',1)
     893        set(hh.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar})
     894        set(hh.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar})
     895        AName=get_field_GUI.PanelScalar.scalar;
     896        menu=get(hfield,'String');
     897        ind_select=find(strcmp(AName,menu));
     898        if isempty(ind_select)
     899            menu=[menu(1:end-1);{AName};{'get_field...'}];
     900            ind_select=numel(menu)-1;
     901        end
     902        set(hfield,'Value',ind_select);
     903        set(hfield,'String',menu);
     904    elseif isfield(get_field_GUI,'Panel1Dplot')
     905        set(hh.Coord_x,'Value',1)
     906        set(hh.Coord_x,'String',{get_field_GUI.Panel1Dplot.abscissa})
     907        set(hh.Coord_y,'String',{get_field_GUI.Panel1Dplot.ordinate})
     908        set(hh.Coord_y,'Value',1:numel(get_field_GUI.Panel1Dplot.ordinate))
     909        set(hfield,'Value',1)
     910        set(hfield,'String',[{''};{'get_field...'}])
     911    end
     912    if  ~check_series && strcmp(get(gcbf,'tag'),'get_field')%get_field is not called by another GUI (uvmat)
     913        uvmat('run0_Callback',hObject,eventdata,hh); %refresh uvmat
     914    end
    926915end
    927916delete(handles.get_field)
    928 %         set(hhuvmat.Fields,'String',{'get_field...'})
    929 %         uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
    930 %     end
    931917
    932918%------------------------------------------------------------------------
  • trunk/src/read_field.m

    r521 r526  
    3939% end
    4040A=[];
    41 if ischar(ParamIn.FieldName)
    42     ParamIn.FieldName={ParamIn.FieldName};
     41if isstruct(ParamIn)
     42    if isfield(ParamIn,'FieldName')&& ischar(ParamIn.FieldName)
     43        ParamIn.FieldName={ParamIn.FieldName};
     44    end
     45    if isfield(ParamIn,'ColorVar')
     46        InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
     47        check_colorvar=1;
     48    else
     49        InputField= ParamIn.FieldName;
     50        check_colorvar=0;
     51    end
    4352end
    44             if isfield(ParamIn,'ColorVar')
    45                 InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
    46                 check_colorvar=1;
    47             else
    48                 InputField= ParamIn.FieldName;
    49                 check_colorvar=0;
    50             end
    5153%% distingush different input file types
    5254try
     
    7375                    Role{numel(ListVar)}='vector_y';
    7476                    Role{numel(ListVar)-1}='vector_x';
    75 %                     switch r.Operator
     77%                    TODO; introduce that for unstructured coordinates
     78%                     switch r.Operator TODO; introduce that for unstructured coordinates
    7679%                         case 'norm'
    7780%                             FieldRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot)
     
    8588                Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)
    8689            end
    87             [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.CoordName ListVar]);
     90            [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x ParamIn.Coord_y ListVar]);
    8891            for ivar=1:numel(ListVar)
    8992                Field.VarAttribute{ivar+2}.Role=Role{ivar};
    9093%                 Field.VarAttribute{ivar+2}.FieldRequest=FieldRequest{ivar};
    9194            end
    92             %             GUIName='get_field'; %default name of the GUI get_field
    93             %             if isfield(ParamIn,'GUIName')
    94             %                 GUIName=ParamIn.GUIName;
    95             %             end
    96             %             CivStage=0;
    97             % %             if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data
    98             %                 FieldList=calc_field;%list of possible fields for Civx data
    99             %                 ParamOut.ColorVar='';%default
    100             %                 if ischar(ParamIn.FieldName)
    101             %                     FieldName=ParamIn.FieldName;
    102             %                 else
    103             %                     FieldName=ParamIn.FieldName{1};
    104             %                 end
    105             %                 field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    106             %                 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    107             %                     Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
    108             %                     % case of new civdata conventions
    109             %                     if isequal(Data.Conventions,'uvmat/civdata')
    110             %
    111             %                         %case of old civx conventions
    112             %                     elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
    113             %                         ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
    114             %                         ParamOut.ColorVar='ima_cor';
    115             %                         InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    116             %                         [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType);
    117             %                         if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    118             %                         CivStage=Field.CivStage;
    119             %                         ParamOut.CivStage=Field.CivStage;
    120             %                         % not cvix file, fields will be chosen through the GUI get_field
    121             %                     else
    122             %                         ParamOut.FieldName='get_field...';
    123             %                         hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    124             %                         if ~isempty(hget_field)
    125             %                             delete(hget_field)%delete  get_field for reinitialisation
    126             %                         end
    127             %                     end
    128             %                 else
    129             %                     InputField=ParamOut.FieldName;
    130             %                     if ischar(InputField)
    131             %                         InputField={InputField};
    132             %                     end
    133             %                     if isfield(ParamIn,'ColorVar')
    134             %                         ParamOut.ColorVar=ParamIn.ColorVar;
    135             %                         InputField=[InputField {ParamOut.ColorVar}];
    136             %                     end
    137             %                     [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType);
    138             %                     if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    139             %                     CivStage=Field.CivStage;
    140             %                     ParamOut.CivStage=Field.CivStage;
    141             %                 end
    142             %                 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    143             %             end
    144             %             if CivStage==0% read the field names on the interface get_field.
    145             %                 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    146             %                 if isempty(hget_field)% open the GUI get_field if it is not found
    147             %                     hget_field= get_field(FileName);%open the get_field GUI
    148             %                     set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
    149             %                 end
    150             %                 hhget_field=guidata(hget_field);
    151             %                 %% update  the get_field GUI
    152             %                 set(hhget_field.inputfile,'String',FileName)
    153             %                 set(hhget_field.list_fig,'Value',1)
    154             %                 if exist('num','var')&&~isnan(num)
    155             %                     set(hhget_field.TimeIndexValue,'String',num2str(num))
    156             %                 end
    157             % %                 funct_list=get(hhget_field.ACTION,'UserData');
    158             % %                 funct_index=get(hhget_field.ACTION,'Value');
    159             % %                 funct=funct_list{funct_index};%select  the current action in get_field, e;g. PLOT
    160             % %                 Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
    161             %                 [Field,errormsg]=read_get_field(hget_field);
    162             %                 Tabchar={''};%default
    163             %                 Tabcell=[];
    164             %                 set(hhget_field.inputfile,'String',FileName)
    165             %                 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
    166             %                     for iline=1:length(Field.ListGlobalAttribute)
    167             %                         Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
    168             %                         if isfield(Field, Field.ListGlobalAttribute{iline})
    169             %                             val=Field.(Field.ListGlobalAttribute{iline});
    170             %                             if ischar(val);
    171             %                                 Tabcell{iline,2}=val;
    172             %                             else
    173             %                                 Tabcell{iline,2}=num2str(val);
    174             %                             end
    175             %                         end
    176             %                     end
    177             %                     if ~isempty(Tabcell)
    178             %                         Tabchar=cell2tab(Tabcell,'=');
    179             %                         Tabchar=[{''};Tabchar];
    180             %                     end
    181             %                 end
    182             %                 ParamOut.CivStage=0;
    183             %                 ParamOut.VelType=[];
    184             %                 if isfield(Field,'TimeIndex')
    185             %                     ParamOut.TimeIndex=Field.TimeIndex;
    186             %                 end
    187             %                 if isfield(Field,'TimeValue')
    188             %                     ParamOut.TimeValue=Field.TimeValue;
    189             %                 end
    190             %                 ParamOut.FieldList={'get_field...'};
    19195           
    19296        case 'video'
  • trunk/src/series.m

    r525 r526  
    6868drawnow
    6969set(hObject,'Units','pixels')
     70set(handles.PairString,'ColumnName',{'pairs'})
    7071set(handles.PairString,'ColumnEditable',logical(0))
    7172set(handles.PairString,'ColumnFormat',{'char'})
    72 set(handles.PairString,'ColumnWidth',{60})
    7373set(handles.PairString,'Data',{''})
     74series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
    7475set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
    7576dir_perso=prefdir;
     
    9293
    9394%% file name and browser initialisation
    94 if isfield(param,'menu_coord_str')
    95     set(handles.TransformName,'String',param.menu_coord_str)
    96 end
    97 if isfield(param,'menu_coord_val')
    98     set(handles.TransformName,'Value',param.menu_coord_val);
     95if isfield(param,'transform_str')
     96    set(handles.TransformName,'String',param.transform_str)
     97end
     98if isfield(param,'transform_val')
     99    set(handles.TransformName,'Value',param.transform_val);
    99100else
    100101     set(handles.TransformName,'Value',1);%default
     
    121122    set(handles.FieldName,'String',param.list_fields);% list menu fields
    122123    set(handles.FieldName,'Value',param.index_fields);% selected string index
    123 %     FieldCell{1}=param.list_fields{param.index_fields};
     124end
     125if isfield(param,'Coord_x_str')&& isfield(param,'Coord_x_val')
     126        set(handles.Coord_x,'String',param.Coord_x_str);% list menu fields
     127    set(handles.Coord_x,'Value',param.Coord_x_val);% selected string index
     128end
     129if isfield(param,'Coord_y_str')&& isfield(param,'Coord_y_val')
     130        set(handles.Coord_y,'String',param.Coord_y_str);% list menu fields
     131    set(handles.Coord_y,'Value',param.Coord_y_val);% selected string index
    124132end
    125133
     
    585593
    586594%% display the min and max indices for the file series
     595if size(i1_series,2)==1
     596    MinIndex_j=1;
     597    MaxIndex_j=1;
     598    MinIndex_i=min(find(i1_series));
     599    MaxIndex_i=max(find(i1_series));
     600else
    587601pair_max=squeeze(max(i1_series,[],1)); %max on pair index
    588602j_max=max(pair_max,[],1);
     
    590604MaxIndex_i=max(find(j_max))-1;% max ref index i
    591605MinIndex_i=min(find(j_max))-1;% min ref index i
     606diff_i_max=diff(j_max);
     607    if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
     608        set(handles.num_incr_i,'String',num2str(diff_i_max(1)))
     609    end
    592610i_max=max(pair_max,[],2);
    593611MaxIndex_j=max(find(i_max))-1;% max ref index i
    594612MinIndex_j=min(find(i_max))-1;% min ref index i
     613diff_j_max=diff(i_max);
     614    if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
     615        set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
     616    end
     617end
    595618MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
    596619MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
     
    611634elseif first_i < MinIndex_i
    612635    first_i=MinIndex_i;
     636elseif first_i >MaxIndex_i
     637    first_i=MinIndex_i;
    613638end
    614639first_j=str2num(get(handles.num_first_j,'String'));
     
    617642elseif first_j<MinIndex_j
    618643    first_j=MinIndex_j;
     644elseif first_j >MaxIndex_j
     645    first_j=MinIndex_j;
    619646end
    620647last_i=str2num(get(handles.num_last_i,'String'));
     
    623650elseif last_i > MaxIndex_i
    624651    last_i=MaxIndex_i;
     652elseif last_i<first_i
     653    last_i=first_i;
    625654end
    626655last_j=str2num(get(handles.num_first_j,'String'));
     
    629658elseif last_j>MaxIndex_j
    630659    last_j=MaxIndex_j;
     660elseif last_i<first_i
     661    last_i=first_i;
    631662end
    632663set(handles.num_first_i,'String',num2str(first_i));
     
    635666set(handles.num_last_j,'String',num2str(last_j));
    636667
    637 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     668%% read timing and total frame number from the current file (movie files) may be overrid by xml file
    638669InputTable=get(handles.InputTable,'Data');
    639670FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
     
    644675        imainfo=get(VideoObject);
    645676        time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
    646         set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     677       % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    647678        ColorType='truecolor';
    648679    elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     
    771802for iview=1:nbview
    772803    pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index
    773     if strcmp(get(handles.num_first_j,'Visible'),'off')
     804    if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1)
    774805        pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index
    775806    end
     
    831862        set(handles.Coord_y,'String',{'Y'});
    832863    case 'netcdf'
    833         set(handles_Fields,'Value',1)
    834         set(handles_Fields,'String',{'get_field...'})
     864        set(handles.FieldName,'Value',1)
     865        set(handles.FieldName,'String',{'get_field...'})
     866        if isempty(i2_series)
     867            i2=[];
     868        else
     869            i2=i2_series(1,ref_j+1,ref_i+1);
     870        end
     871        if isempty(j1_series)
     872            j1=[];j2=[];
     873        else
     874            j1=j1_series(1,ref_j+1,ref_i+1);
     875            if isempty(j2_series)
     876                j2=[];
     877            else
     878                j2=j2_series(1,ref_j+1,ref_i+1);
     879            end
     880        end
     881        FileName=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1_series(1,ref_j+1,ref_i+1),i2,j1,j2);
    835882        hget_field=get_field(FileName);
    836883        hhget_field=guidata(hget_field);
    837884        get_field('RUN_Callback',hhget_field.RUN,[],hhget_field);
    838885    otherwise
    839         set(handles_Fields,'Value',1) % set menu to 'image'
    840         set(handles_Fields,'String',{'image'})
     886        set(handles.FieldName,'Value',1) % set menu to 'image'
     887        set(handles.FieldName,'String',{'image'})
    841888        set(handles.Coord_x,'Value',1);
    842889        set(handles.Coord_x,'String',{'AX'});
     
    844891        set(handles.Coord_y,'String',{'AY'});
    845892end
    846 % %% set default options in menu 'Fields'%% TODO: check VelType
    847 % if ~testima
    848 %     testcivx=0;
    849 %     if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
    850 %         set(handles_Fields,'Value',1)
    851 %         set(handles_Fields,'String',{'get_field...'})
    852 %         UvData=rmfield(UvData,'FieldsString');
    853 %     else
    854 %         Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
    855 %         if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
    856 %             FieldList=calc_field;
    857 %             set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    858 %             set(handles_Fields,'Value',2) % set menu to 'velocity'
    859 %             col_vec=FieldList;
    860 %             col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
    861 %             testcivx=1;
    862 %         end
    863 %         if ~testcivx
    864 %             set(handles_Fields,'Value',1) % set menu to 'get_field...
    865 %             set(handles_Fields,'String',{'get_field...'})
    866 %             col_vec={'get_field...'};
    867 %         end
    868 %         set(handles.ColorScalar,'String',col_vec)
    869 %     end
    870 % end
    871 % set(handles.uvmat,'UserData',UvData)
    872 %
    873 % %% set index navigation options and refresh plots
    874 % scan_option='i';%default
    875 % state_j='off'; %default
    876 % if index==2
    877 %     if get(handles.scan_j,'Value')
    878 %         scan_option='j'; %keep the scan option for the second fiel series
    879 %     end
    880 %     if strcmp(get(handles.j1,'Visible'),'on')
    881 %         state_j='on';
    882 %     end
    883 % end
    884 % if ~isempty(j1_series)
    885 %         state_j='on';
    886 %         if isequal(nbfield,1) &&index==1
    887 %             scan_option='j'; %scan j index by default if nbfield=1               
    888 %         end
    889 % end
    890 % if isequal(scan_option,'i')
    891 %      set(handles.scan_i,'Value',1)
    892 %      scan_i_Callback([],[], handles);
    893 % else
    894 %      set(handles.scan_j,'Value',1)
    895 %      scan_j_Callback([],[], handles);
    896 % end
    897 % set(handles.scan_j,'Visible',state_j)
    898 % set(handles.j1,'Visible',state_j)
    899 % set(handles.j2,'Visible',state_j)
    900 % set(handles.last_j,'Visible',state_j);
    901 % set(handles.frame_j,'Visible',state_j);
    902 % set(handles.j_text,'Visible',state_j);
    903 % if ~isempty(i2_series)||~isempty(j2_series)
    904 %     set(handles.CheckFixPair,'Visible','on')
    905 % elseif index==1
    906 %     set(handles.CheckFixPair,'Visible','off')
    907 % end
    908 %
    909 %
    910 % mode_Callback(hObject, eventdata, handles)
    911 %
    912 % set(handles.REFRESH,'BackgroundColor',[0.7 0.7 0.7])
    913 % InputTable=get(handles.InputTable,'Data');
    914 % check_lines=get(handles.REFRESH,'UserData');
    915 %
    916 % %% check the indices and FileTypes for each series (limited to the new ones to save time)
    917 % for ind_list=1:length(check_lines)
    918 %     if  check_lines(ind_list)
    919 %         InputLine=InputTable(ind_list,:);
    920 %         detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
    921 %         detect_idem=detect_idem(detect_idem>0);
    922 %         if ~isempty (detect_idem)
    923 %             InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
    924 %             set(handles.InputTable,'Data',InputTable)
    925 %         end
    926 %         fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
    927 %         %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
    928 %         %update file series defined by the selected line
    929 %         [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
    930 %         if ~isempty(errormsg)
    931 %                 msgbox_uvmat('ERROR',errormsg)
    932 %                 return
    933 %         end
    934 %     end
    935 % end
    936 % set(handles.InputTable,'Data',InputTable)
    937 % SeriesData=get(handles.series,'UserData');
    938 %
    939 % state_j='off';
    940 % state_Pairs='off';
    941 % state_InputFields='off';
    942 % val=get(handles.ListView,'Value');
    943 % ListViewString={''};
    944 % if ~isempty(SeriesData)
    945 % %     ListViewString={};
    946 %     for iview=1:size(InputTable,1)
    947 %         if ~isempty(SeriesData.j1_series{iview})
    948 %             state_j='on';
    949 %         end
    950 %         if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
    951 %             state_Pairs='on';
    952 %             ListViewString{iview}=num2str(iview);
    953 %             if check_lines(iview)
    954 %                 val=iview;%select the last pair if it is a new entry
    955 %             end
    956 %         end
    957 %         if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata')
    958 %             state_InputFields='on';
    959 %         end
    960 %     end
    961 % end
    962 % set(handles.ListView,'Value',val)
    963 % set(handles.ListView,'String',ListViewString)
    964 % if strcmp(state_Pairs,'on')
    965 %     ListView_Callback(hObject,eventdata,handles)
    966 % end
    967 % set(handles.PairString,'Visible',state_Pairs)
    968 % enable_j(handles,state_j)
    969893
    970894%------------------------------------------------------------------------
     
    1059983% end
    1060984for iview=1:numel(SeriesData.i1_series)
    1061     index_min(iview)=min(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
    1062     index_max(iview)=max(find(SeriesData.i1_series{iview}(1,2:end,2:end)>0));
     985    pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index
     986    if (strcmp(get(handles.num_first_j,'Visible'),'off')&& size(pair_max{iview},2)~=1)
     987        pair_max{iview}=squeeze(max(pair_max{iview},[],1)); % consider only the i index
     988    end
     989    pair_max{iview}=reshape(pair_max{iview},1,[]);
     990    index_min(iview)=find(pair_max{iview}>0, 1 );
     991    index_max(iview)=find(pair_max{iview}>0, 1, 'last' );
    1063992end
    1064993[index_min,iview_min]=min(index_min);
    1065994[index_max,iview_max]=min(index_max);
    1066 index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
    1067 index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     995if size(SeriesData.i1_series{iview_min},2)==1% movie
     996  index_first=ref_i(1);
     997  index_last=ref_i(2);
     998else
     999%index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
     1000%index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     1001index_first=(ref_i(1))*(size(SeriesData.i1_series{iview_min},2))+ref_j(1)+1;
     1002index_last=(ref_i(2))*(size(SeriesData.i1_series{iview_max},2))+ref_j(2)+1;
     1003end
    10681004range=index_max-index_min+1;
    10691005coeff_min=(index_first-index_min)/range;
     
    13341270function enable_j(handles,state)
    13351271set(handles.j_txt,'Visible',state)
    1336 % set(handles.num_MinIndex_j,'Visible',state)
    13371272set(handles.num_first_j,'Visible',state)
    13381273set(handles.num_last_j,'Visible',state)
    13391274set(handles.num_incr_j,'Visible',state)
    1340 % set(handles.num_MaxIndex_j,'Visible',state)
    13411275set(handles.num_ref_j,'Visible',state)
    13421276set(handles.ref_j_text,'Visible',state)
     1277% if strcmp(state,'off')
     1278%     set(handles.MinIndex,'ColumnName',{'imax'})
     1279% set(handles.MinIndex,'ColumnEditable',logical(0))
     1280% else
     1281%         set(handles.MinIndex,'ColumnName',{'imax','jmax'})
     1282% end
    13431283
    13441284
     
    20672007function RunMode_Callback(hObject, eventdata, handles)
    20682008
    2069 
    2070 % --- Executes on selection change in popupmenu14.
    2071 function popupmenu14_Callback(hObject, eventdata, handles)
    2072 % hObject    handle to popupmenu14 (see GCBO)
    2073 % eventdata  reserved - to be defined in a future version of MATLAB
    2074 % handles    structure with handles and user data (see GUIDATA)
    2075 
    2076 % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu14 contents as cell array
    2077 %        contents{get(hObject,'Value')} returns selected item from popupmenu14
    2078 
    2079 
    2080 % --- Executes during object creation, after setting all properties.
    2081 function popupmenu14_CreateFcn(hObject, eventdata, handles)
    2082 % hObject    handle to popupmenu14 (see GCBO)
    2083 % eventdata  reserved - to be defined in a future version of MATLAB
    2084 % handles    empty - handles not created until after all CreateFcns called
    2085 
    2086 % Hint: popupmenu controls usually have a white background on Windows.
    2087 %       See ISPC and COMPUTER.
    2088 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    2089     set(hObject,'BackgroundColor','white');
    2090 end
     2009% --- Executes on selection change in Coord_x.
     2010function Coord_x_Callback(hObject, eventdata, handles)
     2011
     2012
     2013% --- Executes on selection change in Coord_y.
     2014function Coord_y_Callback(hObject, eventdata, handles)
     2015
     2016
     2017
     2018% --- Executes when series is resized.
     2019function series_ResizeFcn(hObject, eventdata, handles)
     2020%% input table
     2021set(handles.InputTable,'Unit','pixel')
     2022Pos=get(handles.InputTable,'Position');
     2023set(handles.InputTable,'Unit','normalized')
     2024ColumnWidth=round([0.5 0.14 0.14 0.14 0.08]*(Pos(3)-52));
     2025ColumnWidth=num2cell(ColumnWidth);
     2026set(handles.InputTable,'ColumnWidth',ColumnWidth)
     2027
     2028%% MinIndex and MaxIndex
     2029set(handles.MinIndex,'Unit','pixel')
     2030Pos=get(handles.MinIndex,'Position');
     2031set(handles.MinIndex,'Unit','normalized')
     2032ColumnWidth=get(handles.MinIndex,'ColumnWidth');
     2033if numel(ColumnWidth)==2
     2034    ColumnWidth=num2cell(floor([0.5 0.5]*(Pos(3)-20)));
     2035else
     2036    ColumnWidth={Pos(3)-5};
     2037end   
     2038set(handles.MinIndex,'ColumnWidth',ColumnWidth)
     2039set(handles.MaxIndex,'ColumnWidth',ColumnWidth)
     2040
     2041%% TimeTable
     2042set(handles.TimeTable,'Unit','pixel')
     2043Pos=get(handles.TimeTable,'Position');
     2044set(handles.TimeTable,'Unit','normalized')
     2045ColumnWidth=get(handles.TimeTable,'ColumnWidth');
     2046ColumnWidth=num2cell(floor([0.25 0.25 0.25 0.25]*(Pos(3)-20)));
     2047set(handles.TimeTable,'ColumnWidth',ColumnWidth)
     2048
     2049
     2050%% PairString
     2051set(handles.PairString,'Unit','pixel')
     2052Pos=get(handles.PairString,'Position');
     2053set(handles.PairString,'Unit','normalized')
     2054set(handles.PairString,'ColumnWidth',{Pos(3)-5})
  • 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;
  • trunk/src/struct2nc.m

    r404 r526  
    9898            attr_names=fields(VarAttribute{ivar});
    9999            for iattr=1:length(attr_names)
    100                 eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
    101                 if ~isempty(attr_names{iattr})&& ~isempty(attr_val)
     100                attr_val=VarAttribute{ivar}.(attr_names{iattr});
     101                if ~isempty(attr_names{iattr})&& ~isempty(attr_val)&&~iscell(attr_val)
    102102                    netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
    103103                end
  • trunk/src/uvmat.m

    r525 r526  
    99%INPUT:
    1010% input: input file name (if character chain), or input image matrix to
    11 % visualize, or Matlab structure representing  netcdf fields (with fields
     11% visualize, or Matlab structure representing  netcdf fieldname (with fieldname
    1212% ListVarName....)
    1313%
     
    4242%          .MovieObject: current movie object
    4343%          .TimeUnit: unit for time
    44 %          .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fields (containing timing  and geometry calibration)
     44%          .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing  and geometry calibration)
    4545%          .Field: cell array of 1 or 2 structures representing the current  input field(s)
    4646%          .PlotAxes: field structure representing the current field plotted  on the main axes  (used for mouse operations)
     
    5454% 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes
    5555% 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file)
    56 % 4) Then fields are opened and visualised by the main sub-function 'uvmat/refresh_field.m'
     56% 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m'
    5757% The function first reads the name of the input file(s) (one or two) from the edit boxes  of the GUI
    5858% It then reads the input file(s) with the function read_field.m and perform the following list of operations:
     
    6666%                 Field{1}            Field{2}               
    6767%                    |                   |                                 
    68 %                    --->transform fct<---             transform (e.g. phys.m) and combine input fields 
     68%                    --->transform fct<---             transform (e.g. phys.m) and combine input fieldname 
    6969%                            |                                   
    7070%                        (calc_tps.m)               calculate tps coefficients (for filter projection or spatial derivatives).
     
    7777%         UvData.PlotAxes          ViewData.PlotAxes (on view_field)
    7878%              |                          |
    79 %       plot_field.m (uvmat)       plot_field.m (view_field)      plot the projected fields
     79%       plot_field.m (uvmat)       plot_field.m (view_field)      plot the projected fieldname
    8080%
    8181%
     
    200200% set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field
    201201% set(handles.ListObject_1,'String',{''})
    202 set(handles.Fields,'Value',1)
    203 set(handles.Fields,'string',{''})
     202set(handles.FieldName,'Value',1)
     203set(handles.FieldName,'string',{''})
    204204UvData.Object={[]};
    205205
     
    294294    testinputfield=1;
    295295end
    296 
    297 %% plot input field if exists
    298 % if testinputfield
    299 %     %delete drawn objects
    300 %     hother=findobj(handles.PlotAxes,'Tag','proj_object');%find all the proj objects
    301 %     for iobj=1:length(hother)
    302 %         delete_object(hother(iobj))
    303 %     end 
    304 %     if isempty(inputfile)
    305 %         errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
    306 %         set(handles.MenuTools,'Enable','on')
    307 %         set(handles.OBJECT_txt,'Visible','on')
    308 %         set(handles.edit_object,'Visible','on')
    309 % %         set(handles.ListObject_1,'Visible','on')
    310 %         set(handles.frame_object,'Visible','on')
    311 %         if ~isempty(errormsg)
    312 %             msgbox_uvmat('ERROR',errormsg)
    313 %         end
    314 %     end
    315 % end
    316296
    317297set_vec_col_bar(handles) %update the display of color code for vectors
     
    530510function SubDir_Callback(hObject, eventdata, handles)
    531511%------------------------------------------------------------------------
    532 %refresh the menu of input fields
     512%refresh the menu of input fieldname
    533513Fields_Callback(hObject, eventdata, handles);
    534514% refresh the current field view
     
    779759if index==1
    780760    handles_RootPath=handles.RootPath;
    781     handles_Fields=handles.Fields;
     761    handles_Fields=handles.FieldName;
    782762elseif index==2
    783763    handles_RootPath=handles.RootPath_1;
    784     handles_Fields=handles.Fields_1;
     764    handles_Fields=handles.FieldName_1;
    785765end
    786766
    787767set(handles_RootPath,'BackgroundColor',[1 1 0])
    788768drawnow
    789 set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
     769set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening
    790770UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
    791771UvData.NewSeries=1; %flag for run0: begin a new series
     
    990970end
    991971
    992 %% set default options in menu 'Fields'
     972%% set default options in menu 'FieldName'
    993973switch FileType
    994974    case {'civx','civdata'}
     
    14261406%------------------------------------------------------------------------
    14271407% --- Executes on button press in runplus: make one step forward and call
    1428 % --- run0. The step forward is along the fields series 1 or 2 depending on
     1408% --- run0. The step forward is along the fieldname series 1 or 2 depending on
    14291409% --- the scan_i and scan_j check box (exclusive each other)
    14301410function runplus_Callback(hObject, eventdata, handles)
     
    14461426%------------------------------------------------------------------------
    14471427% --- Executes on button press in runmin: make one step backward and call
    1448 % --- run0. The step backward is along the fields series 1 or 2 depending on
     1428% --- run0. The step backward is along the fieldname series 1 or 2 depending on
    14491429% --- the scan_i and scan_j check box (exclusive each other)
    14501430function runmin_Callback(hObject, eventdata, handles)
     
    17831763set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
    17841764drawnow
    1785 list_fields=get(handles.Fields,'String');% list menu fields
    1786 index_fields=get(handles.Fields,'Value');% selected string index
     1765list_fields=get(handles.FieldName,'String');% list menu fields
     1766index_fields=get(handles.FieldName,'Value');% selected string index
    17871767FieldName=list_fields{index_fields}; % selected field
    17881768UvData=get(handles.uvmat,'UserData');
     
    17921772    NomType=get(handles.NomType,'String');
    17931773else
    1794     list_fields=get(handles.Fields_1,'String');% list menu fields
    1795     index_fields=get(handles.Fields_1,'Value');% selected string index
     1774    list_fields=get(handles.FieldName_1,'String');% list menu fields
     1775    index_fields=get(handles.FieldName_1,'Value');% selected string index
    17961776    FieldName=list_fields{index_fields}; % selected field
    17971777    if isequal(FieldName,'image')
     
    20262006ParamIn.ColorVar='';%default variable name for vector color
    20272007frame_index=1;%default
    2028 % if ~isempty(FileName)
    20292008FieldName='';%default
    20302009VelType='';%default
    2031 %     FileType=UvData.FileType{1};
    20322010switch UvData.FileType{1}
    20332011    case {'civx','civdata','netcdf'};
    2034         list_fields=get(handles.Fields,'String');% list menu fields
    2035         FieldName= list_fields{get(handles.Fields,'Value')}; % selected field
     2012        list_fields=get(handles.FieldName,'String');% list menu fields
     2013        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
    20362014        if ~strcmp(FieldName,'get_field...')
    20372015            if get(handles.FixVelType,'Value')
     
    20752053    ParamIn.VelType=VelType;
    20762054    XNameMenu=get(handles.Coord_x,'String');
    2077     ParamIn.CoordName=XNameMenu{get(handles.Coord_x,'Value')};
     2055    ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value'));
    20782056    YNameMenu=get(handles.Coord_y,'String');
    2079     ParamIn.CoordName={ParamIn.CoordName, YNameMenu{get(handles.Coord_y,'Value')}};
     2057    ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));
    20802058end
    20812059check_tps = 0;         
     
    21152093    switch UvData.FileType{2}
    21162094        case {'civx','civdata','netcdf'};
    2117             list_fields=get(handles.Fields_1,'String');% list menu fields
     2095            list_fields=get(handles.FieldName_1,'String');% list menu fields
    21182096            if ischar(list_fields),list_fields={list_fields};end
    2119             FieldName_1= list_fields{get(handles.Fields_1,'Value')}; % selected field
     2097            FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
    21202098            if ~strcmp(FieldName,'get_field...')
    21212099                if get(handles.FixVelType,'Value')
     
    22202198    set(handles.VelType,'Visible','off')
    22212199end
    2222 % display the Fields menu from the input file and pick the selected one:
     2200% display the FieldName menu from the input file and pick the selected one:
    22232201% if isstruct(ParamOut)
    22242202%     field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
    2225 %     set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
    2226 %     set(handles.Fields,'Value',find(field_index,1))
     2203%     set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu
     2204%     set(handles.FieldName,'Value',find(field_index,1))
    22272205% end
    22282206
     
    22302208test_veltype_1=0;
    22312209if isempty(FileName_1)
    2232 %     set(handles.Fields_1,'Value',1); %update the field menu
     2210%     set(handles.FieldName_1,'Value',1); %update the field menu
    22332211%     if isstruct(ParamOut)
    2234 %     set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
     2212%     set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    22352213%     end
    22362214elseif ~test_keepdata_1
     
    22472225    % update the second field menu: the same quantity
    22482226    if isstruct(ParamOut_1)
    2249     set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
    2250     % display the Fields menu from the input file and pick the selected one:
     2227    set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
     2228    % display the FieldName menu from the input file and pick the selected one:
    22512229    field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2252     set(handles.Fields_1,'Value',find(field_index,1)+1) 
     2230    set(handles.FieldName_1,'Value',find(field_index,1)+1) 
    22532231    end
    22542232   
     
    22612239
    22622240% field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2263 % set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
    2264 % set(handles.Fields,'Value',find(field_index,1))
     2241% set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu
     2242% set(handles.FieldName,'Value',find(field_index,1))
    22652243   
    22662244%% introduce w as background image by default for a new series (only for nbdim=2)
     
    22772255        set(handles.FileIndex_1,'String',indices)
    22782256        set(handles.FileExt_1,'String','"');
    2279         set(handles.Fields_1,'Visible','on');
    2280         set(handles.Fields_1,'Visible','on');
     2257        set(handles.FieldName_1,'Visible','on');
     2258        set(handles.FieldName_1,'Visible','on');
    22812259        set(handles.RootPath_1,'Visible','on')
    22822260        set(handles.RootFile_1,'Visible','on')
     
    22842262        set(handles.FileIndex_1,'Visible','on');
    22852263        set(handles.FileExt_1,'Visible','on');
    2286         set(handles.Fields_1,'Visible','on');
     2264        set(handles.FieldName_1,'Visible','on');
    22872265        Field{1}.AName='w';
    22882266end           
     
    23642342
    23652343
    2366 %% store the current open names, fields and vel types in uvmat interface
     2344%% store the current open names, fieldname and vel types in uvmat interface
    23672345UvData.FileName_1=FileName_1;
    23682346UvData.ParamOut_1=ParamOut_1;
     
    25892567    write_plot_param(handles,PlotParamOut) %update the auto plot parameters
    25902568   
    2591 %% 2D or 3D fields are generally projected
     2569%% 2D or 3D fieldname are generally projected
    25922570else
    25932571    set(handles.Objects,'Visible','on')
     
    30102988    set(handles.FileIndex_1,'Visible','off');
    30112989    set(handles.FileExt_1,'Visible','off');
    3012     set(handles.Fields_1,'Value',1);%set to blank state
     2990    set(handles.FieldName_1,'Value',1);%set to blank state
    30132991    set(handles.VelType_1,'Value',1);%set to blank state
    30142992    set(handles.num_Opacity,'String','')% desactivate opacity setting
     
    30763054end
    30773055%------------------------------------------------------------------------
    3078 % --- Executes on menu selection Fields
    3079 function Fields_Callback(hObject, eventdata, handles)
    3080 %------------------------------------------------------------------------
    3081 list_fields=get(handles.Fields,'String');% list menu fields
    3082 index_fields=get(handles.Fields,'Value');% selected string index
     3056% --- Executes on menu selection FieldName
     3057function FieldName_Callback(hObject, eventdata, handles)
     3058%------------------------------------------------------------------------
     3059list_fields=get(handles.FieldName,'String');% list menu fields
     3060index_fields=get(handles.FieldName,'Value');% selected string index
    30833061field= list_fields{index_fields(1)}; % selected string
    30843062if isequal(field,'get_field...')
     
    30923070        delete(hget_field)
    30933071    end
    3094     hget_field=get_field(FileName);
    3095 %     set(hget_field,'Name','get_field')
    3096 %     hhget_field=guidata(hget_field);
    3097 %     set(hhget_field.list_fig,'Value',1)
    3098 %     set(hhget_field.list_fig,'String',{'uvmat'})
    3099   %  set(handles.transform_fct,'Value',1)% no transform by default
    3100   %  set(handles.path_transform,'String','')
     3072    get_field(FileName);
    31013073    return %no further action
    31023074end
     
    31513123
    31523124%common to Fields_1_Callback
    3153 list_fields_1=get(handles.Fields_1,'String');% list menu fields
     3125list_fields_1=get(handles.FieldName_1,'String');% list menu fields
    31543126field_1='';
    31553127if ~isempty(list_fields_1)
    3156 field_1= list_fields_1{get(handles.Fields_1,'Value')}; % selected string
     3128field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string
    31573129end
    31583130if isequal(field,'image')||isequal(field_1,'image')
     
    31723144
    31733145%---------------------------------------------------
    3174 % --- Executes on menu selection Fields
    3175 function Fields_1_Callback(hObject, eventdata, handles)
     3146% --- Executes on menu selection FieldName
     3147function FieldName_1_Callback(hObject, eventdata, handles)
    31763148%-------------------------------------------------
    31773149%% read input data
     
    31853157end
    31863158UvData.FileName_1='';% desactivate the use of a constant second file
    3187 list_fields=get(handles.Fields,'String');% list menu fields
    3188 field= list_fields{get(handles.Fields,'Value')}; % selected string
    3189 list_fields=get(handles.Fields_1,'String');% list menu fields
    3190 field_1= list_fields{get(handles.Fields_1,'Value')}; % selected string for the second field
     3159list_fields=get(handles.FieldName,'String');% list menu fields
     3160field= list_fields{get(handles.FieldName,'Value')}; % selected string
     3161list_fields=get(handles.FieldName_1,'String');% list menu fields
     3162field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field
    31913163if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image'))
    31923164    set(handles.SubField,'Value',0)
     
    48374809series; %first display of the GUI to fill waiting time
    48384810[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    4839 param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     4811Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name
    48404812if isequal(get(handles.SubField,'Value'),1)
    48414813    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    48424814    FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    4843     if ~isequal(FileName_1,param.FileName)
    4844         param.FileName_1=FileName_1;
    4845     end
    4846 end
    4847 param.NomType=get(handles.NomType,'String');
    4848 param.NomType_1=get(handles.NomType_1,'String');
    4849 param.CheckFixPair=get(handles.CheckFixPair,'Value');
    4850 huvmat=get(handles.MenuSeries,'parent');
    4851 UvData=get(huvmat,'UserData');
     4815    if ~isequal(FileName_1,Param.FileName)
     4816        Param.FileName_1=FileName_1;%second input file name if relevant
     4817    end
     4818end
     4819Param.NomType=get(handles.NomType,'String');
     4820Param.NomType_1=get(handles.NomType_1,'String');
     4821Param.CheckFixPair=get(handles.CheckFixPair,'Value');
     4822UvData=get(handles.uvmat,'UserData');
    48524823if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time')
    4853     param.Time=UvData.XmlData{1}.Time;
     4824    Param.Time=UvData.XmlData{1}.Time;
    48544825end
    48554826if isequal(get(handles.scan_i,'Value'),1)
    4856     param.incr_i=str2num(get(handles.num_IndexIncrement,'String'));
     4827    Param.incr_i=str2num(get(handles.num_IndexIncrement,'String'));
    48574828elseif isequal(get(handles.scan_j,'Value'),1)
    4858     param.incr_j=str2num(get(handles.num_IndexIncrement,'String'));
    4859 end
    4860 param.list_fields=get(handles.Fields,'String');% list menu fields
    4861 FieldName=param.list_fields{get(handles.Fields,'Value')};
    4862 ind_image=find(strcmp('image',param.list_fields));
    4863 if ~isempty(ind_image) && numel(param.list_fields)>1
    4864 param.list_fields(ind_image)=[]; %suppress  'image' option
    4865 end
    4866 param.index_fields=find(strcmp(FieldName,param.list_fields));% selected string index
    4867 % if param.index_fields>1
    4868 %     param.index_fields=param.index_fields-1;
    4869 % end
    4870 param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
    4871 if ischar(param.list_fields_1),param.list_fields_1={param.list_fields_1};end
    4872 FieldName_1=param.list_fields_1{get(handles.Fields_1,'Value')};
    4873 ind_image=find(strcmp('image',param.list_fields_1));
    4874 if ~isempty(ind_image) && numel(param.list_fields_1)>1
    4875 param.list_fields_1(ind_image)=[]; %suppress  'image' option
    4876 end
    4877 param.index_fields_1=find(strcmp(FieldName_1,param.list_fields_1));% selected string index
    4878 %param.index_fields=find(strcmp(FieldName,param.list_fields));% selected string index
    4879 % param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
    4880 % if param.index_fields_1>1
    4881 %     param.index_fields_1=param.index_fields_1-1;
    4882 % end
    4883 param.menu_coord_str=get(handles.transform_fct,'String');
    4884 param.menu_coord_val=get(handles.transform_fct,'Value');
    4885 series(param); %run the series interface
     4829    Param.incr_j=str2num(get(handles.num_IndexIncrement,'String'));
     4830end
     4831
     4832%% transfer fields and coordinate names
     4833Param.list_fields=get(handles.FieldName,'String');% list menu fields
     4834FieldName=Param.list_fields{get(handles.FieldName,'Value')};
     4835ind_image=find(strcmp('image',Param.list_fields));
     4836if ~isempty(ind_image) && numel(Param.list_fields)>1
     4837    Param.list_fields(ind_image)=[]; %suppress  'image' option
     4838end
     4839Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index
     4840Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields
     4841if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end
     4842FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')};
     4843ind_image=find(strcmp('image',Param.list_fields_1));
     4844if ~isempty(ind_image) && numel(Param.list_fields_1)>1
     4845    Param.list_fields_1(ind_image)=[]; %suppress  'image' option
     4846end
     4847Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index
     4848Param.transform_str=get(handles.transform_fct,'String');
     4849Param.transform_val=get(handles.transform_fct,'Value');
     4850Param.Coord_x_str=get(handles.Coord_x,'String');
     4851Param.Coord_x_val=get(handles.Coord_x,'Value');
     4852Param.Coord_y_str=get(handles.Coord_y,'String');
     4853Param.Coord_y_val=get(handles.Coord_y,'Value');
     4854series(Param); %run the series interface
    48864855
    48874856%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.