Changeset 582


Ignore:
Timestamp:
Mar 13, 2013, 12:46:21 AM (8 years ago)
Author:
sommeria
Message:

various bugs corrected

Location:
trunk/src
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r581 r582  
    493493        end
    494494    end
    495     if isfield(XmlData,'TimeUnit')
    496         TimeUnit=XmlData.TimeUnit;
     495    if isfield(XmlData,'Camera') && isfield(XmlData.Camera,'TimeUnit')
     496        TimeUnit=XmlData.Camera.TimeUnit;
    497497    end
    498498    if isfield(XmlData,'GeometryCalib')
     
    27042704    last_i=str2double(get(handles.last_i,'String'));
    27052705    incr_i=str2double(get(handles.incr_i,'String'));
    2706     num1=first_i:incr_i:last_i;
     2706    num_i=first_i:incr_i:last_i;
    27072707    lastfield=str2double(get(handles.nb_field,'String'));
    27082708    if ~isnan(lastfield)
    2709         test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    2710             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
    2711         num1=num1(test_find);
    2712     end
    2713     set(handles.first_i,'String',num2str(num1(1)));
    2714     set(handles.last_i,'String',num2str(num1(end)));
     2709        test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ...
     2710            (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield);
     2711        num_i=num_i(test_find);
     2712    end
     2713    set(handles.first_i,'String',num2str(num_i(1)));
     2714    set(handles.last_i,'String',num2str(num_i(end)));
    27152715elseif isequal(mode,'series(Dj)')
    27162716    first_j=str2double(get(handles.first_j,'String'));
     
    27222722        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    27232723            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
    2724         num1=num_j(test_find);
    2725     end
    2726     set(handles.first_j,'String',num2str(num1(1)));
    2727     set(handles.last_j,'String',num2str(num1(end)));
     2724        num_j=num_j(test_find);
     2725    end
     2726    set(handles.first_j,'String',num2str(num_j(1)));
     2727    set(handles.last_j,'String',num2str(num_j(end)));
    27282728end
    27292729
     
    27422742    last_i=str2double(get(handles.last_i,'String'));
    27432743    incr_i=str2double(get(handles.incr_i,'String'));
    2744     num1=first_i:incr_i:last_i;
     2744    num_i=first_i:incr_i:last_i;
    27452745    lastfield=str2double(get(handles.nb_field,'String'));
    27462746    if ~isnan(lastfield)
    2747         test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ...
    2748             (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield);
    2749         num1=num1(test_find);
    2750     end
    2751     set(handles.first_i,'String',num2str(num1(1)));
    2752     set(handles.last_i,'String',num2str(num1(end)));
     2747        test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ...
     2748            (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield);
     2749        num_i=num_i(test_find);
     2750    end
     2751    set(handles.first_i,'String',num2str(num_i(1)));
     2752    set(handles.last_i,'String',num2str(num_i(end)));
    27532753elseif isequal(mode,'series(Dj)')
    27542754    first_j=str2double(get(handles.first_j,'String'));
     
    27602760        test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    27612761            (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
    2762         num1=num_j(test_find);
    2763     end
    2764     set(handles.first_j,'String',num2str(num1(1)));
    2765     set(handles.last_j,'String',num2str(num1(end)));
     2762        num_j=num_j(test_find);
     2763    end
     2764    set(handles.first_j,'String',num2str(num_j(1)));
     2765    set(handles.last_j,'String',num2str(num_j(end)));
    27662766end
    27672767
  • trunk/src/civ_matlab.m

    r581 r582  
    169169    Data.Patch1_SubDomainSize=Param.Patch1.SubDomainSize;
    170170    nbvar=length(Data.ListVarName);
    171     Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
    172     Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},...
     171    Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
     172    Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},'nb_subdomain_1',...
    173173        {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
    174174    Data.VarAttribute{nbvar+1}.Role='vector_x';
     
    184184        ind_good=1:numel(Data.Civ1_X);
    185185    end
    186     [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
     186    [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    187187        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
    188188    Data.Civ1_U_smooth(ind_good)=Ures;
     
    268268    % get the guess from patch1
    269269    for isub=1:NbSubDomain
    270         nbvec_sub=Data.Civ1_NbSites(isub);
     270        nbvec_sub=Data.Civ1_NbCentres(isub);
    271271        ind_sel=find(GridX>=Data.Civ1_SubRange(1,1,isub) & GridX<=Data.Civ1_SubRange(1,2,isub) & GridY>=Data.Civ1_SubRange(2,1,isub) & GridY<=Data.Civ1_SubRange(2,2,isub));
    272272        epoints = [GridX(ind_sel) GridY(ind_sel)];% coordinates of interpolation sites
     
    375375    Data.Patch2_FieldSmooth=Param.Patch2.FieldSmooth;
    376376    Data.Patch2_MaxDiff=Param.Patch2.MaxDiff;
    377     Data.Patch2_SubDomainSize=Param.Patch2.SubdomainSize;
     377    Data.Patch2_SubDomainSize=Param.Patch2.SubDomainSize;
    378378    nbvar=length(Data.ListVarName);
    379     Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     379    Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
    380380    Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
    381381        {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
     
    393393        ind_good=1:numel(Data.Civ2_X);
    394394    end
    395     [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
     395    [Data.Civ2_SubRange,Data.Civ2_NbCentres,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
    396396        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff);
    397397    Data.Civ2_U_smooth(ind_good)=Ures;
  • trunk/src/filter_tps.m

    r581 r582  
    4646%% default output
    4747SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
    48 NbCentres=zeros(NbSubDomain);%number of interpolated values per subdomain, =0 by default
    49 Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
    50 U_tps=zeros(NbVec,NbSubDomain);%default spline
    51 V_tps=zeros(NbVec,NbSubDomain);%default spline
     48NbCentres=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default
     49%Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
     50%U_tps=zeros(NbVec,NbSubDomain);%default spline
     51%V_tps=zeros(NbVec,NbSubDomain);%default spline
    5252W_tps=[];%default (2 component case)
    5353U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions
  • trunk/src/find_field_cells.m

    r581 r582  
    165165for icell_tps=1:numel(ivar_tps)
    166166    check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell
    167     check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected
     167    check_cell(ivar_tps(icell_tps))=1;% mark the coordinate variable as selected
    168168    DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable
    169169    icell=numel(CellInfo)+icell_tps; % new field cell index
  • trunk/src/get_field.m

    r581 r582  
    6363        msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])
    6464    else
    65         set(handles.get_field,'UserData',Field);
    6665        if ~exist('ParamIn','var')
    6766            ParamIn=[];
     
    8079pos_view_field(2)=ScreenSize(2);
    8180set(hObject,'Position',pos_view_field)
    82 
    83 % if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
    84 %     hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
    85 %     if length(hget_field)>1
    86 %         delete(hget_field(2))
    87 %     end
    88 % else
    89 %     set(hObject,'name','get_field_1')
    90 % end
    9181set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
    9282drawnow
    93  uiwait(handles.get_field);
    94 
    95 %------------------------------------------------------------------------
    96 % --- Outputs from this function are returned to the command line.
    97 function varargout = get_field_OutputFcn(hObject, eventdata, handles)
    98 %------------------------------------------------------------------------
    99 varargout{1} = handles.output;
    100 delete(handles.get_field)
    101 
    102 %------------------------------------------------------------------------
    103 % --- Executes when a new input file name is introduced.
    104 function inputfile_Callback(hObject, eventdata, handles)
    105 %------------------------------------------------------------------------
    106 inputfile=get(handles.inputfile,'String');
    107 Field=nc2struct(inputfile,[]);% reads the  field description, without data
    108 if isfield(Field,'Txt')
    109     msgbox_uvmat('ERROR',Field.Txt)
    110 else
    111 set(handles.get_field,'UserData',Field);
    112 Field_input(handles,Field);
    113 end
    114 huvmat=findobj(allchild(0),'tag','uvmat');
    115 if ~isempty(huvmat)
    116     delete(huvmat)%delete uvmat for plot reinitialisation
    117 end
     83uiwait(handles.get_field);
    11884
    11985%------------------------------------------------------------------------
    12086% --- update the display when a new field is introduced.
    121 function Field_input(handles,Field,ParamInput)
    122 %------------------------------------------------------------------------
     87function Field_input(handles,Field,ParamIn)
     88%------------------------------------------------------------------------
     89
     90%% fill the list and values of dimensions
    12391if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
    12492    Tabcell(:,1)=Field.ListDimName;
     
    132100    return
    133101end
     102
     103%% fill the list of variables
    134104Txt=Field.ListVarName;
    135105set(handles.variables,'Value',1)
     
    137107variables_Callback(handles.variables,[], handles)
    138108
    139 if exist('ParamInput','var')
    140     fill_GUI(ParamInput,handles);
    141     return
    142 else
    143 set(handles.abscissa,'String',[{''} Txt ])
     109% set(handles.abscissa,'String',[{''} Txt ])
    144110set(handles.ordinate,'String',Txt)
    145111set(handles.vector_x,'String',[Txt ])
     
    147113set(handles.vector_z,'String',[{''} Txt ])
    148114set(handles.vec_color,'String',[{''} Txt ])
    149 % set(handles.XVarName,'String',[{''} Txt ])
    150 % set(handles.ZVarName,'String',[{''} Txt ])
     115set(handles.XVarName,'String',[{''} Txt ])
     116set(handles.YVarName,'String',[{''} Txt ])
     117set(handles.ZVarName,'String',[{''} Txt ])
    151118% set(handles.coord_x_vectors,'String',[{''} Txt ])
    152119% set(handles.coord_y_vectors,'String',[{''} Txt ])
     
    154121% set(handles.TimeVarName,'String',[{''} Txt ])
    155122set(handles.scalar,'Value',1)
    156 
    157123set(handles.scalar,'String', Txt )
     124
     125%% ananlyse the input field cells
    158126[CellInfo,NbDim,errormsg]=find_field_cells(Field);
    159127if ~isempty(errormsg) 
     
    161129    return
    162130end 
    163 [maxdim,imax]=max(NbDim);
     131[Field.MaxDim,imax]=max(NbDim);
     132% look at variables with a single dimension
     133for ilist=1:numel(Field.VarDimName)
     134    if ischar(Field.VarDimName{ilist})
     135        Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell
     136    end
     137    NbDim=numel(Field.VarDimName{ilist});% TODO eliminate singleton dimensions
     138    check_singleton=false(1,NbDim);
     139    for idim=1:NbDim
     140        dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);
     141        check_singleton(idim)=isequal(Field.DimValue(dim_index),1);
     142    end
     143    Field.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);
     144    Field.NbDim(ilist)=numel(Field.VarDimName{ilist});
     145    if Field.NbDim(ilist)==1
     146        Field.VarDimName{ilist}=cell2mat(Field.VarDimName{ilist});
     147    end
     148end
     149SingleVarName=Field.ListVarName(Field.NbDim==1);%list of variables with a single dim
     150MultiVarName=Field.ListVarName(Field.NbDim>1);
     151check_dim=zeros(size(Field.VarDimName));
     152for ilist=1:numel(Field.VarDimName);
     153    if iscell(Field.VarDimName{ilist})% exclude single dim
     154        for idim=1:numel(Field.VarDimName{ilist})
     155            check_dim=check_dim|strcmp(Field.VarDimName{ilist}{idim},Field.VarDimName);
     156        end
     157    end
     158end
     159Field.SingleVarName=Field.ListVarName(find(check_dim));%list of variables with a single dim
     160Field.SingleDimName=Field.VarDimName(find(check_dim));% corresponding list of dimensions for variables with a single dim
     161Field.MaxDim=max(Field.NbDim);
    164162
    165163%% set time mode
    166 if maxdim>=4
    167     set(handles.SwitchVarIndexTime,'Value',4)
     164ListSwitchVarIndexTime={'file index'};
     165% look at global attributes with numerical values
     166check_numvalue=false;
     167check_time=false;
     168    for ilist=1:numel(Field.ListGlobalAttribute)
     169        Value=Field.(Field.ListGlobalAttribute{ilist});
     170        check_numvalue(ilist)=isnumeric(Value);
     171        check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1));
     172    end 
     173Field.ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value
     174if ~isempty(Field.ListNumAttributes)
     175ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];
     176end
     177nboption=numel(ListSwitchVarIndexTime);
     178if Field.MaxDim>=2
     179    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];
     180end
     181if Field.MaxDim>=4
     182        option=nboption+1;
     183elseif ~isempty(find(check_time, 1))
     184    option=2;
    168185else
    169     time_index=[];
    170     if isfield(Field,'ListGlobalAttribute')
    171     time_index=find(~cellfun('isempty',regexp(Field.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time'
    172     end
    173     if isempty(time_index)
    174         set(handles.SwitchVarIndexTime,'Value',1)
    175     else
    176         set(handles.SwitchVarIndexTime,'Value',2)
    177     end
    178 end
     186    option=1;
     187end
     188set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime)
     189set(handles.SwitchVarIndexTime,'Value',option)
     190set(handles.get_field,'UserData',Field);% record the finput field structure
    179191SwitchVarIndexTime_Callback([],[], handles)
    180192
    181 if maxdim>=3
     193%% set z coordinate menu if relevant
     194if Field.MaxDim>=3
    182195    set(handles.vector_z,'Visible','on')
    183196    set(handles.vector_z,'String',[{''} Txt ])
     
    185198    set(handles.SwitchVarIndexZ,'Visible','on')
    186199    set(handles.Z_title,'Visible','on')
    187 %     set(handles.TimeVarName,'Visible','on')
    188 %     set(handles.TimeVarName,'String',[{''} Txt ])
    189 %     set(handles.YVarName,'Visible','on')
    190 %     set(handles.YVarName,'String',[{''} Txt ])
    191200else
    192201    set(handles.vector_z,'Visible','off')
     
    195204    set(handles.Z_title,'Visible','off')
    196205end
    197 if maxdim>=2
     206
     207%% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields
     208if Field.MaxDim>=2 % case of 2D (or 3D) fields
    198209    set(handles.CheckPlot1D,'Value',0)
    199210    if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
     
    202213        set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
    203214        set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
    204 %         if strcmp(CellInfo{imax}.CoordType,'scattered')
    205 %             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))
    206 %             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))
    207 %         elseif strcmp(CellInfo{imax}.CoordType,'grid')
    208 %             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)
    209 %             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
    210 %         end
    211215    else
    212216        set(handles.CheckScalar,'Value',1)
    213217        set(handles.CheckVector,'Value',0)
    214 %         if isfield(CellInfo{imax},'VarIndex_scalar')
    215 %             set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1))
    216 %                 set(handles.XVarName,'Value',CellInfo{imax}.CoordIndex(end)+1)
    217 %                 set(handles.ZVarName,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
    218 %             if numel(CellInfo{imax}.CoordIndex)==3
    219 %                 set(handles.YVarName,'Value',CellInfo{imax}.CoordIndex(1)+1)
    220 %             end
    221 %         end
    222     end
    223 else
     218    end
     219else % case of 1D fields
    224220    set(handles.CheckPlot1D,'Value',1)
    225221    set(handles.CheckScalar,'Value',0)
    226222    set(handles.CheckVector,'Value',0)
    227223end
     224
     225%% Make choices in menus from input
     226if exist('ParamIn','var')&&~isempty(ParamIn)
     227    fill_GUI(ParamIn,handles);
    228228end
    229229CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
     
    232232
    233233%------------------------------------------------------------------------
     234% --- Outputs from this function are returned to the command line.
     235function varargout = get_field_OutputFcn(hObject, eventdata, handles)
     236%------------------------------------------------------------------------
     237varargout{1} = handles.output;
     238delete(handles.get_field)
     239
     240
     241% -----------------------------------------------------------------------
     242% --- Activated by selection in the list of variables
     243function variables_Callback(hObject, eventdata, handles)
     244% -----------------------------------------------------------------------
     245Tabchar={''};%default
     246Tabcell=[];
     247hselect_field=get(handles.variables,'parent');
     248Field=get(handles.get_field,'UserData');
     249index=get(handles.variables,'Value');%index in the list 'variables'
     250
     251%% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected
     252if isequal(index,1)
     253    set(handles.attributes_txt,'String','global attributes')
     254    if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute)
     255        for iline=1:length(Field.ListGlobalAttribute)
     256            Tabcell{iline,1}=Field.ListGlobalAttribute{iline};   
     257            if isfield(Field, Field.ListGlobalAttribute{iline})
     258                eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
     259                if ischar(val);% attribute value is char string
     260                    Tabcell{iline,2}=val;
     261                elseif size(val,1)==1 %attribute value is a number or matlab vector
     262                    Tabcell{iline,2}=num2str(val);
     263                end
     264            end
     265        end
     266        Tabchar=cell2tab(Tabcell,'=');
     267    end
     268%% list Attribute names and values associated to the Variable # index-1   
     269else
     270    list_var=get(handles.variables,'String');
     271    var_select=list_var{index};
     272    set(handles.attributes_txt,'String', ['attributes of ' var_select])
     273    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
     274%         nbline=0;
     275        VarAttr=Field.VarAttribute{index-1};
     276        if isstruct(VarAttr)
     277            attr_list=fieldnames(VarAttr);
     278            for iline=1:length(attr_list)
     279                Tabcell{iline,1}=attr_list{iline};
     280                eval(['val=VarAttr.' attr_list{iline} ';'])
     281                if ischar(val);
     282                    Tabcell{iline,2}=val;
     283                else
     284                     Tabcell{iline,2}=num2str(val);
     285                end
     286            end
     287        end
     288    end
     289
     290end
     291if ~isempty(Tabcell)
     292    Tabchar=cell2tab(Tabcell,'=');
     293    Tabchar=[{''};Tabchar];
     294end
     295set(handles.attributes,'Value',1);% select the first item
     296set(handles.attributes,'String',Tabchar);
     297
     298%% update dimensions;
     299if isfield(Field,'ListDimName')
     300    Tabdim={};%default
     301    if isequal(index,1)%list all dimensions
     302        dim_indices=1:length(Field.ListDimName);
     303        set(handles.dimensions_txt,'String', 'dimensions')
     304    else
     305        DimCell=Field.VarDimName{index-1};
     306        if ischar(DimCell)
     307            DimCell={DimCell};
     308        end   
     309        dim_indices=[];
     310        for idim=1:length(DimCell)
     311            dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0
     312            dim_index=find(dim_index,1);
     313            dim_indices=[dim_indices dim_index];
     314        end
     315        set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
     316    end
     317    for iline=1:length(dim_indices)
     318        Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)};
     319        Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline)));
     320    end
     321    Tabchar=cell2tab(Tabdim,' = ');
     322    Tabchar=[{''} ;Tabchar];
     323    set(handles.dimensions,'Value',1)
     324    set(handles.dimensions,'String',Tabchar) 
     325end 
     326
     327
     328
     329%------------------------------------------------------------------------
     330% --- Executes on button press in CheckPlot1D.
     331function CheckPlot1D_Callback(hObject, eventdata, handles)
     332%------------------------------------------------------------------------
     333val=get(handles.CheckPlot1D,'Value');
     334if isequal(val,0)
     335    set(handles.Panel1Dplot,'Visible','off')
     336else
     337    set(handles.Panel1Dplot,'Visible','on')
     338    set(handles.PanelScalar,'Visible','off')
     339    set(handles.CheckScalar,'Value',0)
     340    set(handles.PanelVectors,'Visible','off')
     341    set(handles.CheckVector,'Value',0)
     342    set(handles.XVarName,'Visible','on')
     343    set(handles.SwitchVarIndexX,'Visible','on')
     344    set(handles.X_title,'Visible','on')
     345    set(handles.YVarName,'Visible','off')
     346    set(handles.SwitchVarIndexY,'Visible','off')
     347    set(handles.Y_title,'Visible','off')
     348    set(handles.ZVarName,'Visible','off')
     349    set(handles.SwitchVarIndexZ,'Visible','off')
     350    set(handles.Z_title,'Visible','off')
     351    ordinate_Callback(hObject, eventdata, handles)
     352end
     353
     354%------------------------------------------------------------------------
    234355function ordinate_Callback(hObject, eventdata, handles)
    235356%------------------------------------------------------------------------
    236 hselect_field=get(handles.inputfile,'parent');
    237 Field=get(hselect_field,'UserData');
     357Field=get(handles.get_field,'UserData');
    238358list=get(handles.ordinate,'String');
    239359yindex=get(handles.ordinate,'Value');
     
    245365[CellInfo,NbDim,errormsg]=find_field_cells(Field);
    246366%[CellVarIndex,NbDim,VarRole,errormsg]=find_field_cells(Field);
    247 % for icell=1:numel(CellInfo) TODO: adapt to new convention
    248 %     VarIndex=CellInfo{icell}.VarIndex;
    249 %     if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarRole{icell}.coord_x)||~isequal(VarRole{icell}.coord_x,VarIndex))
    250 %         cell_select=icell;
    251 %         break
    252 %     end
    253 % end
    254 %
    255 % val=get(handles.abscissa,'Value');
    256 % set(handles.abscissa,'Value',min(val,2));
    257 % coord_x_index=VarRole{cell_select}.coord;
    258 % coord_x_index=coord_x_index(coord_x_index~=0);
    259 % set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
     367for icell=1:numel(CellInfo)
     368    VarIndex=CellInfo{icell}.VarIndex;
     369    if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarRole{icell}.coord_x)||~isequal(VarRole{icell}.coord_x,VarIndex))
     370        cell_select=icell;
     371        break
     372    end
     373end
     374val=get(handles.abscissa,'Value');
     375set(handles.abscissa,'Value',min(val,2));
     376coord_x_index=VarRole{cell_select}.coord;
     377coord_x_index=coord_x_index(coord_x_index~=0);
     378set(handles.XVarname,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
     379
     380%------------------------------------------------------------------------
     381% --- Executes on button press in CheckScalar.
     382function CheckScalar_Callback(hObject, eventdata, handles)
     383%------------------------------------------------------------------------
     384val=get(handles.CheckScalar,'Value');
     385if isequal(val,0)
     386    set(handles.PanelScalar,'Visible','off')
     387else
     388    set(handles.Panel1Dplot,'Visible','off')
     389    set(handles.CheckPlot1D,'Value',0)
     390    set(handles.PanelScalar,'Visible','on')
     391    set(handles.PanelVectors,'Visible','off')
     392    set(handles.CheckVector,'Value',0)
     393end
     394
     395%------------------------------------------------------------------------
     396% --- Executes on button press in CheckVector.
     397function CheckVector_Callback(hObject, eventdata, handles)
     398%------------------------------------------------------------------------
     399val=get(handles.CheckVector,'Value');
     400if isequal(val,0)
     401    set(handles.PanelVectors,'Visible','off')
     402else
     403    set(handles.Panel1Dplot,'Visible','off')
     404    set(handles.CheckPlot1D,'Value',0)
     405    set(handles.PanelScalar,'Visible','off')
     406    set(handles.CheckScalar,'Value',0)
     407    set(handles.PanelVectors,'Visible','on')
     408end
     409
     410
     411%------------------------------------------------------------------------
     412% --- Executes on selection change in scalar menu.
     413function scalar_Callback(hObject, eventdata, handles)
     414%------------------------------------------------------------------------
     415index=get(handles.scalar,'Value');
     416string=get(handles.scalar,'String');
     417VarName=string{index};
     418update_field(hObject, eventdata, handles,VarName)
     419
     420%eliminate time
     421TimeDimName='';%default
     422if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on')
     423    TimeDimList=get(handles.TimeDimensionMenu,'String');
     424    TimeDimIndex=get(handles.TimeDimensionMenu,'Value');
     425    TimeDimName=TimeDimList{TimeDimIndex};
     426end
     427
     428%check possible coordinates
     429Field=get(handles.get_field,'UserData');
     430dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar
     431test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate
     432for ilist=1:numel(Field.VarDimName)
     433    dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist
     434    if isequal(dimnames,{TimeDimName})
     435        test_coord(ilist)=0;%mark time variables fo elimination
     436    end
     437    for idim=1:numel(dimnames)
     438        if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable
     439            test_coord(ilist)=0;
     440            break
     441        end
     442    end
     443end
     444test_coord(index)=0;%the coordinate variable must be different from the scalar
     445
     446string_coord=[{''};string(test_coord==1)];
     447val=get(handles.XVarName,'Value');
     448if val>numel(string_coord)
     449    set(handles.XVarName,'Value',1)
     450end
     451set(handles.XVarName,'String',string_coord);
     452val=get(handles.ZVarName,'Value');
     453if val>numel(string_coord)
     454    set(handles.ZVarName,'Value',1)
     455end
     456set(handles.ZVarName,'String',string_coord);
     457val=get(handles.ZVarName,'Value');
     458if val>numel(string_coord)
     459    set(handles.ZVarName,'Value',1)
     460end
     461set(handles.YVarName,'String',string_coord);
     462
    260463
    261464%------------------------------------------------------------------------
     
    301504% update_UserData(handles)
    302505
    303 %------------------------------------------------------------------------
    304 % --- Executes on selection change in scalar menu.
    305 function scalar_Callback(hObject, eventdata, handles)
    306 %------------------------------------------------------------------------
    307 index=get(handles.scalar,'Value');
    308 string=get(handles.scalar,'String');
    309 VarName=string{index};
    310 update_field(hObject, eventdata, handles,VarName)
    311 
    312 %eliminate time
    313 TimeDimName='';%default
    314 if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on')
    315     TimeDimList=get(handles.TimeDimensionMenu,'String');
    316     TimeDimIndex=get(handles.TimeDimensionMenu,'Value');
    317     TimeDimName=TimeDimList{TimeDimIndex};
    318 end
    319 
    320 %check possible coordinates
    321 Field=get(handles.get_field,'UserData');
    322 dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar
    323 test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate
    324 for ilist=1:numel(Field.VarDimName)
    325     dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist
    326     if isequal(dimnames,{TimeDimName})
    327         test_coord(ilist)=0;%mark time variables fo elimination
    328     end
    329     for idim=1:numel(dimnames)
    330         if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable
    331             test_coord(ilist)=0;
    332             break
    333         end
    334     end
    335 end
    336 test_coord(index)=0;%the coordinate variable must be different from the scalar
    337 
    338 string_coord=[{''};string(test_coord==1)];
    339 val=get(handles.XVarName,'Value');
    340 if val>numel(string_coord)
    341     set(handles.XVarName,'Value',1)
    342 end
    343 set(handles.XVarName,'String',string_coord);
    344 val=get(handles.ZVarName,'Value');
    345 if val>numel(string_coord)
    346     set(handles.ZVarName,'Value',1)
    347 end
    348 set(handles.ZVarName,'String',string_coord);
    349 val=get(handles.ZVarName,'Value');
    350 if val>numel(string_coord)
    351     set(handles.ZVarName,'Value',1)
    352 end
    353 set(handles.YVarName,'String',string_coord);
    354506
    355507
     
    391543%check possible coordinates
    392544Field=get(handles.get_field,'UserData');
    393 dim_var=Field.VarDimName{index};%list of dimensions of the selected scalar
     545dim_var=Field.VarDimName{index};%list of dimensions of the selected variable
    394546test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate
    395547test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component
     
    429581set(handles.vec_color,'String',[{''};string(test_component==1)])
    430582string_coord=[{''};string(test_coord==1)];
    431 val=get(handles.coord_x_vectors,'Value');
     583val=get(handles.XVarName,'Value');
    432584if val>numel(string_coord)
    433     set(handles.coord_x_vectors,'Value',1)
    434 end
    435 set(handles.coord_x_vectors,'String',string_coord);
    436 val=get(handles.coord_y_vectors,'Value');
     585    set(handles.XVarName,'Value',1)
     586end
     587set(handles.XVarName,'Visible','on');
     588set(handles.XVarName,'String',string_coord);
     589val=get(handles.YVarName,'Value');
    437590if val>numel(string_coord)
    438     set(handles.coord_y_vectors,'Value',1)
    439 end
    440 set(handles.coord_y_vectors,'String',string_coord);
     591    set(handles.YVarName,'Value',1)
     592end
     593set(handles.YVarName,'Visible','on');
     594set(handles.YVarName,'String',string_coord);
    441595val=get(handles.TimeVarName,'Value');
    442596if val>numel(string_coord)
     
    8701024delete(handles.get_field)
    8711025
    872 %------------------------------------------------------------------------
    873 % --- Function for plotting the current subfield
    874 function plot_get_field(SubField,handles)
    875 %------------------------------------------------------------------------
    876 list_fig=get(handles.list_fig,'String');
    877 val=get(handles.list_fig,'Value');
    878 if strcmp(list_fig{val},'uvmat')
    879     set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
    880     set(handles.OK,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)
    881     set(handles.MenuOpen,'Visible','off')
    882     set(handles.MenuExport,'Visible','off')
    883     uvmat(get(handles.inputfile,'String'))
    884 elseif strcmp(list_fig{val},'view_field')
    885     view_field(SubField)
    886 else
    887     hfig=str2double(list_fig{val});% chosen figure number from tyhe GUI
    888     if isnan(hfig)
    889         hfig=figure;
    890         list_fig=[list_fig;num2str(hfig)];
    891         set(handles.list_fig,'String',list_fig);
    892         haxes=axes;
    893     else
    894         figure(hfig);
    895     end
    896     haxes=findobj(hfig,'Type','axes');
    897     plot_field(SubField,haxes)
    898 end
    899 
    900 % %------------------------------------------------
    901 % % --- Executes on button press in Plot_histo.
    902 % %OK global histograms
    903 % %-------------------------------------------------
    904 % function RUN_histo_Callback(hObject, eventdata, handles)
    905 % % hObject    handle to OK (see GCBO)
    906 % % eventdata  reserved - to be defined in a future version of MATLAB
    907 % % handles    structure with handles and user data (see GUIDATA)
    908 %
    909 % %timename plots
    910 % leg={};
    911 % n=0;
    912 % if (get(handles.cm_switch,'Value')==1)
    913 %     Uval_p=Uval_cm;
    914 %     Vval_p=Vval_cm;
    915 %     Uhist_p=Uhist_cm;
    916 %     Vhist_p=Vhist_cm;
    917 %     xlab='velocity (cm/s)';
    918 % else
    919 %     Uval_p=Uval;
    920 %     Vval_p=Vval;
    921 %     Uhist_p=Uhist;
    922 %     Vhist_p=Vhist;
    923 %     xlab='velocity (pixels)';
    924 % end
    925 % if (get(handles.vector_y,'Value') == 1)
    926 %    hhh=figure(2);
    927 %    hold on
    928 %    title([filebase ', ' strindex ', ' fieldtitle])
    929 %    plot(Uval_p,Uhist_p,'b-')
    930 %    n=n+1;
    931 %    leg{n}='Uhist';
    932 %    xlabel(xlab)
    933 % end
    934 % if (get(handles.Vhist_input,'Value') == 1)
    935 %    hhh=figure(2);
    936 %    hold on
    937 %    title([filebase ', ' strindex ', ' fieldtitle])
    938 %    plot(Vval_p,Vhist_p,'r-')
    939 %    n=n+1;
    940 %    leg{n}='Vhist';
    941 %    xlabel(xlab);
    942 % end
    943 % if (get(handles.Chist_input,'Value') == 1)
    944 %    hhhh=figure(3);
    945 %    hold on
    946 %    title([filebase ', ' strindex ', ' fieldtitle])
    947 %    plot(Cval,Chist,'k-')
    948 %    leg{1}='Chist';
    949 % end
    950 % % hold off
    951 % grid on
    952 % legend(leg);
    953 
    954 % %-------------------------------------------------------------
    955 % % --- Executes on button press in Save_input.
    956 % function Save_input_Callback(hObject, eventdata, handles)
    957 % list_str=get(handles.abscissa,'String');
    958 % val=get(handles.abscissa,'Value');
    959 % var=list_str{val};
    960 % hselect_field=get(handles.Save_input,'parent')
    961 % set(hselect_field,'UserData',var);
    962 % set(hselect_field,'Tag','idle')
    963 
    964 %     
    965 % %-------------------------------------------------------------
    966 % % --- Executes on button press in save_histo.
    967 % function save_histo_Callback(hObject, eventdata, handles)
    968 % global filebase
    969 %
    970 % pathstr = fileparts(filebase)
    971 % if (get(handles.Chist_input,'Value') == 1)
    972 %     def = {[pathstr pathstr(1) 'PIV_corr_histo.fig']};
    973 %     else
    974 
    975 %     def = {[pathstr pathstr(1) 'vel_histo.fig']};
    976 % end
    977 % prompt={'save figure(2) as'}
    978 % dlg_title = 'save figure';
    979 % num_lines= 1;
    980 % answer = inputdlg(prompt,dlg_title,num_lines,def)
    981 % saveas(2,answer{1})
    982  
    983 
    984 %%-------------------------------------------------------
    985 % --- Executes on button press in peaklocking.
    986 %-------------------------------------------------
    987 function peaklocking(handles)
    988 %evaluation of peacklocking errors
    989 %use splinhist: give spline coeff cc for a smooth histo (call spline4)
    990 %use histsmooth(x,cc): calculate the smooth histo for any value x
    991 %use histder(x,cc): calculate the derivative of the smooth histo
    992 global hfig1 hfig2 hfig3
    993 global nbb Uval Vval Uhist Vhist % nbb resolution of the histogram nbb=10: 10 values in unity interval
    994 global xval xerror yval yerror
    995 
    996 set(handles.vector_y,'Value',1)% trigger the option Uhist on the interface
    997 set(handles.Vhist_input,'Value',1)
    998 set(handles.cm_switch,'Value',0) % put the switch to 'pixel'
    999 
    1000 %adjust the extremal values of the histogram in U with respect to integer
    1001 %values
    1002 minimU=round(min(Uval)-0.5)+0.5; %first value of the histogram with integer bins
    1003 maximU=round(max(Uval)-0.5)+0.5;
    1004 minim_fin=(minimU-0.5+1/(2*nbb)); % first bin valueat the beginning of an integer interval
    1005 maxim_fin=(maximU+0.5-1/(2*nbb)); % last integer value
    1006 nb_bin_min= round(-(minim_fin - min(Uval))*nbb); % nbre of bins added below
    1007 nb_bin_max=round((maxim_fin -max(Uval))*nbb); %nbre of bins added above
    1008 Uval=[minim_fin:(1/nbb):maxim_fin];
    1009 histu_min=zeros(nb_bin_min,1);
    1010 histu_max=zeros(nb_bin_max,1);
    1011 Uhist=[histu_min; Uhist ;histu_max]; % column vector
    1012 
    1013 %adjust the extremal values of the histogram in V
    1014 minimV=round(min(Vval-0.5)+0.5);
    1015 maximV=round(max(Vval-0.5)+0.5);
    1016 minim_fin=minimV-0.5+1/(2*nbb); % first bin valueat the beginning of an integer interval
    1017 maxim_fin=maximV+0.5-1/(2*nbb); % last integer value
    1018 nb_bin_min=round((min(Vval) - minim_fin)*nbb); % nbre of bins added below
    1019 nb_bin_max=round((maxim_fin -max(Vval))*nbb);
    1020 Vval=[minim_fin:(1/nbb):maxim_fin];
    1021 histu_min=zeros(nb_bin_min,1);
    1022 histu_max=zeros(nb_bin_max,1);
    1023 Vhist=[histu_min; Vhist ;histu_max]; % column vector
    1024 
    1025 % RUN_histo_Callback(hObject, eventdata, handles)
    1026 % %adjust the histogram to integer values:
    1027 
    1028 %histoU and V
    1029 [Uhistinter,xval,xerror]=peaklock(nbb,minimU,maximU,Uhist);
    1030 [Vhistinter,yval,yerror]=peaklock(nbb,minimV,maximV,Vhist);
    1031 
    1032 % selection of value ranges such that histo>=10 (enough statistics)
    1033 Uval_ind=find(Uhist>=10);
    1034 ind_min=min(Uval_ind);
    1035 ind_max=max(Uval_ind);
    1036 U_min=Uval(ind_min);% minimum allowed value
    1037 U_max=Uval(ind_max);%maximum allowed value
    1038 
    1039 % selection of value ranges such that histo>=10 (enough statistics)
    1040 Vval_ind=find(Vhist>=10);
    1041 ind_min=min(Vval_ind);
    1042 ind_max=max(Vval_ind);
    1043 V_min=Vval(ind_min);% minimum allowed value
    1044 V_max=Vval(ind_max);%maximum allowed value
    1045 
    1046 figure(4)% plot U histogram with smoothed one
    1047 plot(Uval,Uhist,'b')
    1048 grid on
    1049 hold on
    1050 plot(Uval,Uhistinter,'r');
    1051 hold off
    1052 
    1053 figure(5)% plot V histogram with smoothed one
    1054 plot(Vval,Vhist,'b')
    1055 grid on
    1056 hold on
    1057 plot(Vval,Vhistinter,'r');
    1058 hold off
    1059 
    1060 figure(6)% plot pixel error in two subplots
    1061 hfig4=subplot(2,1,1);
    1062 hfig5=subplot(2,1,2);
    1063 axes(hfig4)
    1064 plot(xval,xerror)
    1065 axis([U_min U_max -0.4 0.4])
    1066 xlabel('velocity u (pix)')
    1067 ylabel('peaklocking error (pix)')
    1068 grid on
    1069 axes(hfig5)
    1070 plot(yval,yerror)
    1071 axis([V_min V_max -0.4 0.4]);
    1072 xlabel('velocity v (pix)')
    1073 ylabel('peaklocking error (pix)')
    1074 grid on
    1075 
    1076 
    1077 % ------------------------------------------------------------------
    1078 function variables_Callback(hObject, eventdata, handles)
    1079 Tabchar={''};%default
    1080 Tabcell=[];
    1081 hselect_field=get(handles.variables,'parent');
    1082 Field=get(handles.get_field,'UserData');
    1083 index=get(handles.variables,'Value');%index in the list 'variables'
    1084 
    1085 %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected
    1086 if isequal(index,1)
    1087     set(handles.attributes_txt,'String','global attributes')
    1088     if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute)
    1089         for iline=1:length(Field.ListGlobalAttribute)
    1090             Tabcell{iline,1}=Field.ListGlobalAttribute{iline};   
    1091             if isfield(Field, Field.ListGlobalAttribute{iline})
    1092                 eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])
    1093                 if ischar(val);% attribute value is char string
    1094                     Tabcell{iline,2}=val;
    1095                 elseif size(val,1)==1 %attribute value is a number or matlab vector
    1096                     Tabcell{iline,2}=num2str(val);
    1097                 end
    1098             end
    1099         end
    1100         Tabchar=cell2tab(Tabcell,'=');
    1101     end
    1102 %% list Attribute names and values associated to the Variable # index-1   
    1103 else
    1104     list_var=get(handles.variables,'String');
    1105     var_select=list_var{index};
    1106     set(handles.attributes_txt,'String', ['attributes of ' var_select])
    1107     if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
    1108 %         nbline=0;
    1109         VarAttr=Field.VarAttribute{index-1};
    1110         if isstruct(VarAttr)
    1111             attr_list=fieldnames(VarAttr);
    1112             for iline=1:length(attr_list)
    1113                 Tabcell{iline,1}=attr_list{iline};
    1114                 eval(['val=VarAttr.' attr_list{iline} ';'])
    1115                 if ischar(val);
    1116                     Tabcell{iline,2}=val;
    1117                 else
    1118                      Tabcell{iline,2}=num2str(val);
    1119                 end
    1120             end
    1121         end
    1122     end
    1123 
    1124 end
    1125 if ~isempty(Tabcell)
    1126     Tabchar=cell2tab(Tabcell,'=');
    1127     Tabchar=[{''};Tabchar];
    1128 end
    1129 set(handles.attributes,'Value',1);% select the first item
    1130 set(handles.attributes,'String',Tabchar);
    1131 
    1132 %% update dimensions;
    1133 if isfield(Field,'ListDimName')
    1134     Tabdim={};%default
    1135     if isequal(index,1)%list all dimensions
    1136         dim_indices=1:length(Field.ListDimName);
    1137         set(handles.dimensions_txt,'String', 'dimensions')
    1138     else
    1139         DimCell=Field.VarDimName{index-1};
    1140         if ischar(DimCell)
    1141             DimCell={DimCell};
    1142         end   
    1143         dim_indices=[];
    1144         for idim=1:length(DimCell)
    1145             dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0
    1146             dim_index=find(dim_index,1);
    1147             dim_indices=[dim_indices dim_index];
    1148         end
    1149         set(handles.dimensions_txt,'String', ['dimensions of ' var_select])
    1150     end
    1151     for iline=1:length(dim_indices)
    1152         Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)};
    1153         Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline)));
    1154     end
    1155     Tabchar=cell2tab(Tabdim,' = ');
    1156     Tabchar=[{''} ;Tabchar];
    1157     set(handles.dimensions,'Value',1)
    1158     set(handles.dimensions,'String',Tabchar) 
    1159 end 
    1160 
    1161 %------------------------------------------------------------------------
    1162 % --- Executes on button press in CheckPlot1D.
    1163 function CheckPlot1D_Callback(hObject, eventdata, handles)
    1164 %------------------------------------------------------------------------
    1165 val=get(handles.CheckPlot1D,'Value');
    1166 if isequal(val,0)
    1167     set(handles.Panel1Dplot,'Visible','off')
    1168 else
    1169     set(handles.Panel1Dplot,'Visible','on')
    1170     set(handles.PanelScalar,'Visible','off')
    1171     set(handles.CheckScalar,'Value',0)
    1172     set(handles.PanelVectors,'Visible','off')
    1173     set(handles.CheckVector,'Value',0)
    1174 end
    1175 
    1176 %------------------------------------------------------------------------
    1177 % --- Executes on button press in CheckScalar.
    1178 function CheckScalar_Callback(hObject, eventdata, handles)
    1179 %------------------------------------------------------------------------
    1180 val=get(handles.CheckScalar,'Value');
    1181 if isequal(val,0)
    1182     set(handles.PanelScalar,'Visible','off')
    1183 else
    1184     set(handles.Panel1Dplot,'Visible','off')
    1185     set(handles.CheckPlot1D,'Value',0)
    1186     set(handles.PanelScalar,'Visible','on')
    1187     set(handles.PanelVectors,'Visible','off')
    1188     set(handles.CheckVector,'Value',0)
    1189 end
    1190 
    1191 %------------------------------------------------------------------------
    1192 % --- Executes on button press in CheckVector.
    1193 function CheckVector_Callback(hObject, eventdata, handles)
    1194 %------------------------------------------------------------------------
    1195 val=get(handles.CheckVector,'Value');
    1196 if isequal(val,0)
    1197     set(handles.PanelVectors,'Visible','off')
    1198 else
    1199     set(handles.Panel1Dplot,'Visible','off')
    1200     set(handles.CheckPlot1D,'Value',0)
    1201     set(handles.PanelScalar,'Visible','off')
    1202     set(handles.CheckScalar,'Value',0)
    1203     set(handles.PanelVectors,'Visible','on')
    1204 end
     1026
    12051027
    12061028% %------------------------------------------------------------------------
     
    17791601menu=get(handles.SwitchVarIndexTime,'String');
    17801602option=menu{get(handles.SwitchVarIndexTime,'Value')};
     1603Field=get(handles.get_field,'UserData');
    17811604switch option
    17821605    case 'file index'
     
    17851608        set(handles.TimeVarName, 'Visible','on')
    17861609        time_index=[];
    1787         ListAttributes=get(handles.attributes,'String');
    1788         if ~isempty(ListAttributes)
    1789             time_index=find(~cellfun('isempty',regexp(ListAttributes,'Time')));% index of the attributes containing the string 'Time'
     1610        PreviousList=get(handles.TimeVarName, 'String');
     1611         index=[];
     1612        if ~isempty(PreviousList)
     1613        PreviousAttr=PreviousList{get(handles.TimeVarName, 'Value')};
     1614        index=find(strcmp(PreviousAttr,Field.ListNumAttributes));
     1615        end
     1616        if isempty(index)
     1617            time_index=find(~cellfun('isempty',regexp(Field.ListNumAttributes,'Time')));% index of the attributes containing the string 'Time'
    17901618        end
    17911619        if ~isempty(time_index)
     
    17941622            set(handles.TimeVarName,'Value',1)
    17951623        end
    1796         set(handles.TimeVarName, 'String',ListAttributes)
     1624        set(handles.TimeVarName, 'String',Field.ListNumAttributes)
    17971625    case 'variable'
    1798         ListDim=get(handles.dimensions,'String');
    1799         Field=get(handles.get_field,'UserData');
    1800         for idim=1:numel(ListDim)
    1801             var_count=[];
    1802             for ilist=1:numel(Field.VarDimName)
    1803                 DimName=Field.VarDimName{ilist};
    1804                 if strcmp(DimName,ListDim{idim})||strcmp(DimName,{ListDim{idim}}) %if the variable has a single dim ( 1D array)
    1805                     var_count=[var_count ilist];
    1806                 end
    1807             end
    1808             if numel(var_count)==1
    1809                 TimeVarName=[TimeVarName;Field.ListVarName{var_count}];
    1810             end
    1811         end
    18121626        set(handles.TimeVarName, 'Visible','on')
     1627        TimeVarName=Field.SingleVarName;
    18131628        List=get(handles.TimeVarName,'String');
    18141629        option=List{get(handles.TimeVarName,'Value')};
    1815         ind=find(strcmp(option,get(handles.dimensions,'String')));
     1630        ind=find(strcmp(option,TimeVarName));
    18161631        if isempty(ind)
    18171632            set(handles.TimeVarName, 'Value',1);
     
    18221637    case 'dim index'
    18231638        set(handles.TimeVarName, 'Visible','on')
     1639        TimeVarName=Field.SingleDimName;
    18241640        List=get(handles.TimeVarName,'String');
    18251641        option=List{get(handles.TimeVarName,'Value')};
    1826         ind=find(strcmp(option,get(handles.dimensions,'String')));
     1642        ind=find(strcmp(option,TimeVarName));
    18271643        if isempty(ind)
    18281644            set(handles.TimeVarName, 'Value',1);
     
    18301646            set(handles.TimeVarName, 'Value',ind);
    18311647        end
    1832         set(handles.TimeVarName, 'String',get(handles.dimensions,'String'))
    1833 end
    1834 
    1835    
     1648        set(handles.TimeVarName, 'String',TimeVarName)
     1649end
     1650
     1651
  • trunk/src/imadoc2struct.m

    r565 r582  
    5454    for k=1:length(Timing)
    5555        Frequency=1;
    56         if isfield(Timing{k},'Frequency')
     56        if isfield(Timing{k},'FrameFrequency')
    5757            Frequency=Timing{k}.FrameFrequency;
    5858        end
  • trunk/src/plot_field.m

    r581 r582  
    104104if ~isfield(PlotParam,'Coordinates')
    105105    PlotParam.Coordinates=[];
     106    if isfield(Data,'CoordUnit')
     107        PlotParam.Coordinates.CheckFixAspectRatio=1;
     108        PlotParam.Coordinates.AspectRatio=1; %set axes equal by default if CoordUnit is defined
     109    end
    106110end
    107111PlotParamOut=PlotParam;%default
  • trunk/src/read_civdata.m

    r581 r582  
    198198    %    units={'pixel','pixel','pixel','pixel','pixel','pixel','','',''};
    199199    case 'filter1'
    200         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
     200        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentres','NbCentres';...
    201201            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    202             'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbSites'};
     202            'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentres','Civ1_NbSites'};
    203203        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    204             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
    205      %   units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     204            'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary'};
     205     %  rmq: NbSites obsolete replaced by NbCentres, kept for consistency with previous data
    206206    case 'civ2'
    207207        var={'X','Y','Z','U','V','W','C','F','FF';...
    208208            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
    209209        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    210       %  units={'pixel','pixel','pixel','pixel','pixel','pixel','','',''};
    211210    case 'filter2'
    212         var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbSites';...
     211        var={'X','Y','Z','U','V','W','C','F','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentres','NbCentres';...
    213212            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U_smooth','Civ2_V_smooth','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    214             'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbSites'};
     213            'Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps','','Civ2_SubRange','Civ2_NbCentres','Civ2_NbSites'};
    215214        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','coord_tps','vector_x_tps',...
    216             'vector_y_tps','vector_z_tps','ancillary','ancillary'};
    217        % units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
     215            'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary'};
    218216end
    219217if ~strcmp(ProjModeRequest,'interp_tps')
  • trunk/src/uvmat.m

    r581 r582  
    18441844num_i2=str2num(get(handles.i2,'String'));
    18451845num_j2=stra2num(get(handles.j2,'String'));
     1846imaname_1='';
    18461847if isempty(num_j2)
    1847     if isempty(num_i2)   
    1848         msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
    1849         set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    1850          set(handles.movie_pair,'Value',0)
    1851         return
     1848    if isempty(num_i2)
     1849        if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
     1850            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1);
     1851        end
     1852        if exist(imaname_1,'file')
     1853            num_j2=num_j1+1;
     1854            set(handles.j2,'String',num2str(num_j2));
     1855        else
     1856            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1);
     1857            if exist(imaname_1,'file')
     1858                num_i2=num_i1+1;
     1859                set(handles.i2,'String',num2str(num_i2));
     1860            else
     1861                msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
     1862                set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     1863                set(handles.movie_pair,'Value',0)
     1864                return
     1865            end
     1866        end
    18521867    else
    18531868        num_j2=num_j1;%repeat the index i1 by default
     
    30503065%% fill the coordinates and variables from selections in get_field
    30513066if isequal(field,'get_field...')
     3067    ParamIn=[];
    30523068    if strcmp(get(handles.VelType,'Visible'),'on')
    30533069        % we use the civ choice as default input
     
    30603076                 ParamIn.vector_x='Civ1_U';
    30613077                 ParamIn.vector_y='Civ1_V';
     3078                 ParamIn.vec_color='Civ1_C';               
    30623079            case 'filter1'
    30633080                 ParamIn.TimeVarName='Civ1_Time';
     
    30723089                 ParamIn.vector_x='Civ2_U_smooth';
    30733090                 ParamIn.vector_y='Civ2_V_smooth';
     3091                 ParamIn.vec_color='Civ2_C';
    30743092        end
    30753093    end
Note: See TracChangeset for help on using the changeset viewer.