Changeset 179


Ignore:
Timestamp:
Jan 9, 2011, 12:56:28 PM (13 years ago)
Author:
sommeria
Message:

various bug repairs, in particular for 3D fields

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r178 r179  
    46234623box_test(4)=get(handles.CIV2,'Value');
    46244624box_test(5)=get(handles.FIX2,'Value');
    4625 box_test(6)=get(handles.PATCH2,'Value');
    4626 option=listtype{max(box_test(find(box_test)))};
     4625box_test(6)=get(handles.PATCH2,'Value')
     4626find(box_test)
     4627option_civ=max(find(box_test))
    46274628filecell=get(handles.civ,'UserData');
    46284629if ~isfield(filecell,'nc')
     
    46554656    for ifile=1:nbfiles
    46564657        detect=exist(civ_files{ifile},'file'); % check the existence of the file
     4658        option=0;
    46574659        if detect==0
    4658             lastfield='not created';
     4660            option_str='not created';
    46594661        else
    46604662            datfile=dir(civ_files{ifile});
     
    46654667            Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix');
    46664668            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    4667                 lastfield='patch2';
     4669                option=6;
     4670                option_str='patch2';
    46684671            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    4669                 lastfield='fix2';
     4672                option=5;
     4673                option_str='fix2';
    46704674            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    4671                 lastfield='civ2';
     4675                option=4;
     4676                option_str='civ2';
    46724677            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    4673                 lastfield='patch1';
     4678                option=3;
     4679                option_str='patch1';
    46744680            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    4675                 lastfield='fix1';
     4681                option=2;
     4682                option_str='fix1';
    46764683            else
    4677                 lastfield='civ1';
    4678             end
    4679         end
    4680         if strcmp(lastfield,option)
     4684                option=1;
     4685                option_str='civ1';
     4686            end
     4687        end
     4688        if option >= option_civ
    46814689            count=count+1;
    46824690        end
    46834691        [rr,filename,ext]=fileparts(civ_files{ifile});
    4684         Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' lastfield];
     4692        Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext  '...' option_str];
    46854693    end
    46864694    if isempty(datnum)
  • trunk/src/get_field.m

    r150 r179  
    796796function RUN_Callback(hObject, eventdata, handles)
    797797%---------------------------------------------------------
    798 figstring=get(handles.list_fig,'String');
    799 if isequal(figstring,{'uvmat'})
     798figcell=get(handles.list_fig,'String');
     799index=get(handles.list_fig,'value');
     800figstring=figcell{index};
     801if isequal(figstring,'uvmat')
    800802    huvmat=findobj(allchild(0),'tag','uvmat');
    801803    hhuvmat=guidata(huvmat);
    802     uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     804    uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat
    803805else
     806    huvmat=findobj(allchild(0),'tag','uvmat');
     807    delete(huvmat)%
    804808    index=get(handles.ACTION,'Value');
    805809    list_func=get(handles.ACTION,'UserData');
  • trunk/src/plot_field.m

    r156 r179  
    164164end
    165165
    166 % check the cells of fields :
    167 % testnbdim=1;
     166%% check the cells of fields :
    168167[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
    169168
     169%% plot if the input field is valid
    170170if ~isempty(errormsg)
    171     msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg])
    172     display(['input of plot_field: ' errormsg])
    173     return
    174 end
    175 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot
    176     [Data.NbDim]=max(NbDim);
    177 end
    178 errormsg=[];
    179 if isequal(Data.NbDim,0)
    180         AxeData=plot_text(Data,htext);
    181         PlotType='text';
     171    errormsg=['input of plot_field/find_field_indices: ' errormsg];
     172else
     173    if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot
     174        [Data.NbDim]=max(NbDim);
     175    end
     176    if isequal(Data.NbDim,0)
     177            AxeData=plot_text(Data,htext);
     178            PlotType='text';
     179            errormsg=[];
     180    elseif isequal(Data.NbDim,1)
     181        [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
     182        if testzoomaxes
     183            [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
     184            AxeData.ZoomAxes=zoomaxes;
     185        end
     186        PlotType='line';
    182187        errormsg=[];
    183 elseif isequal(Data.NbDim,1)
    184     [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
    185     if testzoomaxes
    186         [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
    187         AxeData.ZoomAxes=zoomaxes;
    188     end
    189     PlotType='line';
    190     errormsg=[];
    191 elseif isequal(Data.NbDim,2)
    192     ind_select=find(NbDim>=2);
    193     if numel(ind_select)>2
    194         errormsg='more than two fields to map';
    195     else
    196         [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
    197         if testzoomaxes && isempty(errormsg)
    198             [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
    199             Data.ZoomAxes=zoomaxes;
    200         end
    201     end
    202 elseif isequal(Data.NbDim,3)
    203     errormsg='volume plot not implemented yet';
    204 end
    205 if ~isempty(errormsg)
    206     msgbox_uvmat('ERROR','volume plot not implemented yet')
    207     return
    208 end
    209 
    210 %display (or delete) error message
    211 htext=findobj(haxes,'Tag','hTxt');
    212 if isfield(Data,'Txt')
    213     if isempty(htext)
    214         Xlim=get(haxes,'XLim');
    215         Ylim=get(haxes,'YLim');
    216         htext=text(Xlim(1),(Ylim(1)+Ylim(2))/2,Data.Txt,'Tag','hTxt','Color','r');
    217         set(htext,'Interpreter','none')
    218     else
    219         set(htext,'String',Data.Txt)
    220     end
    221 elseif ~isempty(htext)
    222     delete(htext)
    223 end
    224 
    225 % % set graph aspect ratio
    226 % if isfield(AxeData,'Mesh')
    227 %     Data.Mesh=AxeData.Mesh;
    228 % end
    229 
    230 %set(haxes,'UserData',AxeData)
    231 set(haxes,'UserData',Data)
    232 % if ~testnewfig
    233 % %set(0,'Children',hstack);%put back the initial figure stack after plot creation
    234 %
    235 % end
     188    elseif isequal(Data.NbDim,2)
     189        ind_select=find(NbDim>=2);
     190        if numel(ind_select)>2
     191            errormsg='more than two fields to map';
     192        else
     193            [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);
     194            if testzoomaxes && isempty(errormsg)
     195                [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
     196                Data.ZoomAxes=zoomaxes;
     197            end
     198        end
     199    elseif isequal(Data.NbDim,3)
     200        errormsg='volume plot not implemented yet';
     201    end
     202end
     203
     204if isempty(errormsg)
     205    set(haxes,'UserData',Data)
     206else
     207    msgbox_uvmat('ERROR', errormsg)
     208end
    236209
    237210
  • trunk/src/proj_field.m

    r174 r179  
    4040%       Role = 'scalar':  (default) represents a scalar field
    4141%            = 'coord':  represents a set of unstructured coordinates, whose
    42 %                     space dimension is given by the last array dimension (called 'nb_dim').
     42%                     space dimension is given by the last array dimension (called 'NbDim').
    4343%            = 'coord_x', 'coord_y',  'coord_z': represents a separate set of
    4444%                        unstructured coordinate x, y  or z
    4545%            = 'vector': represents a vector field whose number of components
    46 %                is given by the last dimension (called 'nb_dim')
     46%                is given by the last dimension (called 'NbDim')
    4747%            = 'vector_x', 'vector_y', 'vector_z'  :represents the x, y or z  component of a vector 
    4848%            = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning
     
    100100end
    101101       
    102 % OBSOLETE
     102%% OBSOLETE
    103103if isfield(ObjectData,'XMax') && ~isempty(ObjectData.XMax)
    104104    ObjectData.RangeX(1)=ObjectData.XMax;
     
    120120end
    121121%%%%%%%%%%
     122
     123%% apply projection depending on the object style
    122124switch ObjectData.Style
    123125    case 'points'
     
    131133            [ProjData,errormsg] = proj_line(FieldData,ObjectData);
    132134        end
    133      %A FAIRE : GERER MASK
    134135    case 'plane'
    135 %         if isfield(FieldData,'NbDim') & isequal(FieldData.NbDim,3)
    136 %             ProjData= proj_plane3D(FieldData,ObjectData);%
    137 %         else
    138136            [ProjData,errormsg] = proj_plane(FieldData,ObjectData);
    139 %         end
    140137    case 'volume'
    141138        [ProjData,errormsg] = proj_volume(FieldData,ObjectData);
     
    300297            %DimIndices(ind_1)=[]; %suppress singleton dimensions
    301298%             indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
    302             %nb_dim=length(DimIndices)%number of space dimensions
    303             nb_dim=numel(VarType.coord);
     299            %NbDim=length(DimIndices)%number of space dimensions
     300            NbDim=numel(VarType.coord);
    304301            Coord_z=[];
    305302            Coord_y=[];
    306303            Coord_x=[];   
    307             for idim=1:nb_dim %loop on space dimensions
     304            for idim=1:NbDim %loop on space dimensions
    308305                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
    309306                test_coord(idim)=0;%test for defined coordinates, =0 by default
     
    10051002%-----------------------------------------------------------------
    10061003idimvar=0;
    1007 [CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_indices(FieldData);
     1004[CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_indices(FieldData);
    10081005if ~isempty(errormsg)
    10091006    errormsg=['error in proj_field/proj_plane:' errormsg];
     
    10161013icoord=0;
    10171014nbcoord=0;%number of added coordinate variables brought by projection
     1015nbvar=0;
    10181016for icell=1:length(CellVarIndex)
    1019     if NbDim(icell)<2
     1017    NbDim=NbDimVec(icell);
     1018    if NbDim<2
    10201019        continue
    10211020    end
     
    11291128            %ProjData.DimValue=[ProjData.
    11301129             %length(coord_X)];
    1131             nbvar=0;
     1130
    11321131            for ivar=VarIndex %transfer variables to the projection plane
    11331132                VarName=FieldData.ListVarName{ivar};
     
    11431142                    ProjData.VarDimName=[ProjData.VarDimName DimCell];
    11441143                    nbvar=nbvar+1;
    1145                     if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar
     1144                    if isfield(FieldData,'VarAttribute') && length(FieldData.VarAttribute) >=ivar
    11461145                        ProjData.VarAttribute{nbvar}=FieldData.VarAttribute{ivar};
    11471146                    end
     
    12151214       
    12161215%% case of input fields defined on a structured  grid
    1217     else 
    1218         AYName=FieldData.ListVarName{VarType.coord(1)};%name of input x coordinate (name preserved on projection)
    1219         AXName=FieldData.ListVarName{VarType.coord(2)};%name of input y coordinate (name preserved on projection)
     1216    else
     1217        VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions
     1218        eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions
     1219        DimValue(find(DimValue==1))=[];%remove singleton dimensions       
     1220        NbDim=numel(DimValue);%update number of space dimensions
     1221        nbcolor=1; %default number of 'color' components: third matrix index without corresponding coordinate
     1222        if NbDim>=3
     1223            if NbDim>3
     1224                errormsg='matrices with more than 3 dimensions not handled';
     1225                return
     1226            else
     1227                VarType.coord
     1228                if numel(find(VarType.coord))==2% the third matrix dimension does not correspond to a space coordinate
     1229                    nbcolor=DimValue(3);
     1230                    DimValue(3)=[]; %number of 'color' components updated
     1231                    NbDim=2;% space dimension set to 2
     1232                end
     1233            end
     1234        end
     1235        AYName=FieldData.ListVarName{VarType.coord(NbDim-1)};%name of input x coordinate (name preserved on projection)
     1236        AXName=FieldData.ListVarName{VarType.coord(NbDim)};%name of input y coordinate (name preserved on projection)   
    12201237        eval(['AX=FieldData.' AXName ';'])
    12211238        eval(['AY=FieldData.' AYName ';'])
    1222         VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions
    1223         eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions
    12241239        ListDimName=FieldData.VarDimName{VarIndex(1)};
    1225         ProjData.ListVarName=[{AYName} {AXName} ProjData.ListVarName]; %TODO: check if it already exists in Projdata (several cells)
    1226         ProjData.VarDimName=[{AYName} {AXName} ProjData.VarDimName];
    1227         nbcolor=1; %default
    1228         for idim=1:length(ListDimName)
    1229             DimName=ListDimName{idim};
    1230             if strcmp(DimName,'rgb')||strcmp(DimName,'nb_coord')||strcmp(DimName,'nb_coord_i')
    1231                nbcolor=DimValue(idim);
    1232                DimValue(idim)=[];
    1233             end
    1234             if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
    1235                 DimValue(idim)=[];
    1236             end
    1237         end 
    1238         ind_1=find(DimValue==1);
     1240        ProjData.ListVarName=[ProjData.ListVarName {AYName} {AXName}]; %TODO: check if it already exists in Projdata (several cells)
     1241        ProjData.VarDimName=[ProjData.VarDimName {AYName} {AXName}];
     1242
     1243%         for idim=1:length(ListDimName)
     1244%             DimName=ListDimName{idim};
     1245%             if strcmp(DimName,'rgb')||strcmp(DimName,'nb_coord')||strcmp(DimName,'nb_coord_i')
     1246%                nbcolor=DimValue(idim);
     1247%                DimValue(idim)=[];
     1248%             end
     1249%             if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED
     1250%                 DimValue(idim)=[];
     1251%             end
     1252%         end 
    12391253        Coord_z=[];
    12401254        Coord_y=[];
    12411255        Coord_x=[];   
    1242         nb_dim=numel(DimValue);
    1243         for idim=1:nb_dim %loop on space dimensions
     1256
     1257        for idim=1:NbDim %loop on space dimensions
    12441258            test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
    12451259            ivar=VarType.coord(idim);% index of the variable corresponding to the current dimension
     
    12681282        end
    12691283        if DY==0
    1270             DY=abs(DCoord_min(nb_dim-1));
    1271         end
    1272         npY=1+round(abs(Coord{nb_dim-1}(end)-Coord{nb_dim-1}(1))/DY);%nbre of points after interpol
     1284            DY=abs(DCoord_min(NbDim-1));
     1285        end
     1286        npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
    12731287        if DX==0
    1274             DX=abs(DCoord_min(nb_dim));
    1275         end
    1276         npX=1+round(abs(Coord{nb_dim}(end)-Coord{nb_dim}(1))/DX);%nbre of points after interpol
    1277         for idim=[1:nb_dim]
     1288            DX=abs(DCoord_min(NbDim));
     1289        end
     1290        npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol
     1291        for idim=[1:NbDim]
    12781292            if test_interp(idim)
    12791293                DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri
    12801294            end
    12811295        end       
    1282         Coord_y=linspace(Coord{nb_dim-1}(1),Coord{nb_dim-1}(end),npY);
    1283         test_direct_y=test_direct(nb_dim-1);
    1284         Coord_x=linspace(Coord{nb_dim}(1),Coord{nb_dim}(end),npX);
    1285         test_direct_x=test_direct(nb_dim);
    1286         DAX=DCoord_min(nb_dim);
    1287         DAY=DCoord_min(nb_dim-1);
    1288         if nb_dim==3
    1289             DZ=abs(DCoord_min(1));
    1290             Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
    1291             test_direct_z=test_direct(1);
    1292         end 
     1296        Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);
     1297        test_direct_y=test_direct(NbDim-1);
     1298        Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);
     1299        test_direct_x=test_direct(NbDim);
     1300        DAX=DCoord_min(NbDim);
     1301        DAY=DCoord_min(NbDim-1); 
    12931302        minAX=min(Coord_x);
    12941303        maxAX=max(Coord_x);
     
    13111320            YMin=min(ycor_new);
    13121321        end
    1313         DXinit=(maxAX-minAX)/(DimValue(2)-1);
    1314         DYinit=(maxAY-minAY)/(DimValue(1)-1);
     1322        DXinit=(maxAX-minAX)/(DimValue(NbDim)-1);
     1323        DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);
    13151324        if DX==0
    13161325            DX=DXinit;
     
    13181327        if DY==0
    13191328            DY=DYinit;
     1329        end
     1330        if NbDim==3
     1331            DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
     1332            if ~test_direct(1)
     1333                DZ=-DZ;
     1334            end
     1335            Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
     1336            test_direct_z=test_direct(1);
    13201337        end
    13211338        npX=floor((XMax-XMin)/DX+1);
     
    13341351        % case with no rotation and interpolation
    13351352        if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
    1336             if ~testXMin && ~testXMax && ~testYMin && ~testYMax && nb_dim==2
     1353            if ~testXMin && ~testXMax && ~testYMin && ~testYMax && NbDim==2
    13371354                ProjData=FieldData;
    13381355            else
    1339                 if test_direct(1)
    1340                     min_ind1=ceil((YMin-Coord{1}(1))/DYinit)+1;
    1341                     max_ind1=floor((YMax-Coord{1}(1))/DYinit)+1;
    1342                     Ybound(1)=Coord{1}(1)+DYinit*(min_ind1-1);
    1343                     Ybound(2)=Coord{1}(1)+DYinit*(max_ind1-1);
     1356                indY=NbDim-1;
     1357                if test_direct(indY)
     1358                    min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1;
     1359                    max_indy=floor((YMax-Coord{indY}(1))/DYinit)+1;
     1360                    Ybound(1)=Coord{indY}(1)+DYinit*(min_indy-1);
     1361                    Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1);
    13441362                else
    1345                     min_ind1=ceil((Coord{1}(1)-YMax)/DYinit)+1;
    1346                     max_ind1=floor((Coord{1}(1)-YMin)/DYinit)+1;
    1347                     Ybound(2)=Coord{1}(1)-DYinit*(max_ind1-1);
    1348                     Ybound(1)=Coord{1}(1)-DYinit*(min_ind1-1);
    1349                 end              
    1350                 if test_direct(2)==1
    1351                     min_ind2=ceil((XMin-Coord{2}(1))/DXinit)+1;
    1352                     max_ind2=floor((XMax-Coord{2}(1))/DXinit)+1;
    1353                     Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
    1354                     Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
     1363                    min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1;
     1364                    max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1;
     1365                    Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1);
     1366                    Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1);
     1367                end   
     1368                if test_direct(NbDim)==1
     1369                    min_indx=ceil((XMin-Coord{NbDim}(1))/DXinit)+1;
     1370                    max_indx=floor((XMax-Coord{NbDim}(1))/DXinit)+1;
     1371                    Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1);
     1372                    Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);
    13551373                else
    1356                     min_ind2=ceil((Coord{2}(1)-XMax)/DXinit)+1;
    1357                     max_ind2=floor((Coord{2}(1)-XMin)/DXinit)+1;
    1358                     Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
    1359                     Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
     1374                    min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1;
     1375                    max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1;
     1376                    Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);
     1377                    Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1);
    13601378                end
    1361                 if nb_dim==3 %TODO: to update
    1362                     min_ind3=ceil((Coord{1}(1)-ZMax)/DZinit)+1;
    1363                     max_ind2=floor((Coord{1}(2)-XMin)/DZinit)+1;
    1364                     Zbound(2)=Coord{1}(1)+DXinit*(max_ind2-1);
    1365                     Zbound(1)=Coord{1}(1)+DXinit*(min_ind2-1);
     1379                iz_str=':'; %default
     1380                if NbDim==3
     1381                    DimCell(1)=[]; %suppress z variable
     1382                    DimValue(1)=[];
     1383                                        %structured coordinates
     1384                    if test_direct(1)
     1385                        iz=ceil((ObjectData.Coord(1,3)-Coord{1}(1))/DZ)+1;
     1386                    else
     1387                        iz=ceil((Coord{1}(1)-ObjectData.Coord(1,3))/DZ)+1;
     1388                    end
    13661389                end
    1367                 min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
    1368                 min_ind2=max(min_ind2,1);
    1369                 max_ind1=min(max_ind1,DimValue(1));
    1370                 max_ind2=min(max_ind2,DimValue(2));
    1371                 for ivar=VarIndex
     1390                min_indy=max(min_indy,1);% deals with margin (bound lower than the first index)
     1391                min_indx=max(min_indx,1);
     1392                max_indy=min(max_indy,DimValue(1));
     1393                max_indx=min(max_indx,DimValue(2));
     1394                for ivar=VarIndex% loop on non coordinate variables
    13721395                    VarName=FieldData.ListVarName{ivar};
    13731396                    ProjData.ListVarName=[ProjData.ListVarName VarName];
     
    13761399                        ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar};
    13771400                    end
    1378                     eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2,:) ;']);
     1401                    if NbDim==3
     1402                        eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,min_indy:max_indy,min_indx:max_indx));']);
     1403                    else
     1404                        eval(['ProjData.' VarName '=FieldData.' VarName '(min_indy:max_indy,min_indx:max_indx,:);']);
     1405                    end
    13791406                end 
    13801407                eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
     
    13821409            end
    13831410        else       % case with rotation and/or interpolation
    1384             if isempty(Coord_z) %2D case
     1411            if NbDim==2 %2D case
    13851412                [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
    13861413                XIMA=ObjectData.Coord(1,1)+(X)*cos(Phi)-Y*sin(Phi);%corresponding coordinates in the original image
     
    14361463            else %3D case
    14371464                if isequal(Theta,0) & isequal(Phi,0)       
     1465                    % unstructured z coordinate
    14381466                    test_sup=(Coord{1}>=ObjectData.Coord(1,3));
    14391467                    iz_sup=find(test_sup);
     
    14481476                            eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
    14491477                            %TODO : do a vertical average for a thick plane
    1450                             if test_interp(2) | test_interp(3)
     1478                            if test_interp(2) || test_interp(3)
    14511479                                eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');'])
    14521480                            end
     
    14611489        end
    14621490    end
    1463    
     1491
    14641492    %% projection of  velocity components in the rotated coordinates
    14651493    if ~isequal(Phi,0) && length(ivar_U)==1
     
    15231551% test for 3D fields
    15241552test3D=0;
    1525 if isfield(FieldData,'nb_dim')
    1526     test3D=isequal(FieldData.nb_dim,3);
     1553if isfield(FieldData,'NbDim')
     1554    test3D=isequal(FieldData.NbDim,3);
    15271555end
    15281556test3C=test3D; %default 3 vel components
     
    18291857        DimIndices(ind_1)=[]; %suppress singleton dimensions
    18301858%         indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero)
    1831         nb_dim=length(DimIndices);%number of space dimensions
     1859        NbDim=length(DimIndices);%number of space dimensions
    18321860        Coord_z=[];
    18331861        Coord_y=[];
    18341862        Coord_x=[];   
    18351863   
    1836         for idim=1:nb_dim %loop on space dimensions
     1864        for idim=1:NbDim %loop on space dimensions
    18371865            test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
    18381866            ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension
     
    18561884            end
    18571885        end
    1858         if nb_dim==2
     1886        if NbDim==2
    18591887            if DY==0
    18601888                DY=abs(DCoord_min(1));
     
    18731901            DAX=DCoord_min(2);
    18741902            DAY=DCoord_min(1);
    1875         elseif nb_dim==3
     1903        elseif NbDim==3
    18761904            DZ=abs(DCoord_min(1));
    18771905            npz=1+round(abs(Coord{1}(end)-Coord{1}(1))/DZ);%nbre of points after interpolation
     
    19371965        if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
    19381966            if test_direct(1)
    1939                 min_ind1=ceil((YMin-Coord{1}(1))/DYinit)+1;
    1940                 max_ind1=floor((YMax-Coord{1}(1))/DYinit)+1;
    1941                 Ybound(1)=Coord{1}(1)+DYinit*(min_ind1-1);
    1942                 Ybound(2)=Coord{1}(1)+DYinit*(max_ind1-1);
     1967                min_indy=ceil((YMin-Coord{1}(1))/DYinit)+1;
     1968                max_indy=floor((YMax-Coord{1}(1))/DYinit)+1;
     1969                Ybound(1)=Coord{1}(1)+DYinit*(min_indy-1);
     1970                Ybound(2)=Coord{1}(1)+DYinit*(max_indy-1);
    19431971            else
    1944                 min_ind1=ceil((Coord{1}(1)-YMax)/DYinit)+1;
    1945                 max_ind1=floor((Coord{1}(1)-YMin)/DYinit)+1;
    1946                 Ybound(2)=Coord{1}(1)-DYinit*(max_ind1-1);
    1947                 Ybound(1)=Coord{1}(1)-DYinit*(min_ind1-1);
     1972                min_indy=ceil((Coord{1}(1)-YMax)/DYinit)+1;
     1973                max_indy=floor((Coord{1}(1)-YMin)/DYinit)+1;
     1974                Ybound(2)=Coord{1}(1)-DYinit*(max_indy-1);
     1975                Ybound(1)=Coord{1}(1)-DYinit*(min_indy-1);
    19481976            end             
    19491977            if test_direct(2)==1
    1950                 min_ind2=ceil((XMin-Coord{2}(1))/DXinit)+1;
    1951                 max_ind2=floor((XMax-Coord{2}(1))/DXinit)+1;
    1952                 Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
    1953                 Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
     1978                min_indx=ceil((XMin-Coord{2}(1))/DXinit)+1;
     1979                max_indx=floor((XMax-Coord{2}(1))/DXinit)+1;
     1980                Xbound(1)=Coord{2}(1)+DXinit*(min_indx-1);
     1981                Xbound(2)=Coord{2}(1)+DXinit*(max_indx-1);
    19541982            else
    1955                 min_ind2=ceil((Coord{2}(1)-XMax)/DXinit)+1;
    1956                 max_ind2=floor((Coord{2}(1)-XMin)/DXinit)+1;
    1957                 Xbound(2)=Coord{2}(1)+DXinit*(max_ind2-1);
    1958                 Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
     1983                min_indx=ceil((Coord{2}(1)-XMax)/DXinit)+1;
     1984                max_indx=floor((Coord{2}(1)-XMin)/DXinit)+1;
     1985                Xbound(2)=Coord{2}(1)+DXinit*(max_indx-1);
     1986                Xbound(1)=Coord{2}(1)+DXinit*(min_indx-1);
    19591987            end
    1960             min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
    1961             min_ind2=max(min_ind2,1);
    1962             max_ind1=min(max_ind1,DimValue(1));
    1963             max_ind2=min(max_ind2,DimValue(2));
     1988            min_indy=max(min_indy,1);% deals with margin (bound lower than the first index)
     1989            min_indx=max(min_indx,1);
     1990            max_indy=min(max_indy,DimValue(1));
     1991            max_indx=min(max_indx,DimValue(2));
    19641992            for ivar=VarIndex
    19651993                VarName=FieldData.ListVarName{ivar};
    19661994                ProjData.ListVarName=[ProjData.ListVarName VarName];
    1967                 %ProjData.VarDimIndex=[ProjData.VarDimIndex [nb_dim-1 nb_dim]];
     1995                %ProjData.VarDimIndex=[ProjData.VarDimIndex [NbDim-1 NbDim]];
    19681996                if length(FieldData.VarAttribute)>=ivar
    19691997                    ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar};
    19701998                end
    1971                 eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2) ;']);
     1999                eval(['ProjData.' VarName '=FieldData.' VarName '(min_indy:max_indy,min_indx:max_indx) ;']);
    19722000            end         
    19732001        else
  • trunk/src/read_civxdata.m

    r159 r179  
    55%
    66% OUTPUT:
    7 % nb_coord,nb_dim,
    8 % Civ: =0 or 1, indicates whether the data is civ (A SUPPRIMER ?)
    9 % CivStage: =0, ??? A UTILISER POUR REMPLACER civ
    10 %           =1, civ1 has been performed only
    11 %           =2, fix1 has been performed
    12 %           =3, pacth1 has been performed
    13 %           =4, civ2 has been performed
    14 %           =5, fix2 has been performed
    15 %           =6, pacth2 has been performed
    16 % time: absolute time
    17 % Field
     7% Field: structure representing the selected field, containing
    188%            .Txt: (char string) error message if any
    19 %            .NbDim: number of dimensions (=0 by default)
    20 %            .NbCoord: number of vector components
    21 %            .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
    22 %            .dt: time interval for the corresponding image pair
    23 %            .CivStage: =0,
    24 %                   =1, civ1 has been performed only
    25 %                   =2, fix1 has been performed
    26 %                   =3, pacth1 has been performed
    27 %                   =4, civ2 has been performed
    28 %                   =5, fix2 has been performed
    29 %                   =6, pacth2 has been performed
    30 %            .X, .Y, .Z: set of vector coordinates
    31 %            .U,.V,.W: corresponding set of vector components
    32 %            .F: warning flags
    33 %            .FF: error flag, =0 for good vectors
    34 %            .C: scalar associated with velocity (used for vector colors)
    35 %            .CoordType
    36 %            .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,
    37 %            DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY
    38 %            .A, .AX, .AY: additional scalar
    39 % dt:time interval of the image pair red from a single file, or vector with
    40 % pixcmx,pixcmy: scaling factors (from the first file)
    41 % vel_type_out: string representing the selected velocity type (civ1,civ2,filter1...)
     9%            .ListGlobalAttribute: list of global attributes containing:
     10%                    .NbCoord: number of vector components
     11%                    .NbDim: number of dimensions (=2 or 3)
     12%                    .dt: time interval for the corresponding image pair
     13%                    .Time: absolute time (average of the initial image pair)
     14%                    .CivStage: =0,
     15%                       =1, civ1 has been performed only
     16%                       =2, fix1 has been performed
     17%                       =3, pacth1 has been performed
     18%                       =4, civ2 has been performed
     19%                       =5, fix2 has been performed
     20%                       =6, pacth2 has been performed
     21%                     .CoordUnit: 'pixel'
     22%             .ListVarName: {'X'  'Y'  'U'  'V'  'F'  'FF'}
     23%                   .X, .Y, .Z: set of vector coordinates
     24%                    .U,.V,.W: corresponding set of vector components
     25%                    .F: warning flags
     26%                    .FF: error flag, =0 for good vectors
     27%                     .C: scalar associated with velocity (used for vector colors)
     28%                    .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,
     29%                        DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY
     30%
     31% VelTypeOut: velocity type corresponding to the selected field: ='civ1','interp1','interp2','civ2'....
    4232%
    4333% INPUT:
     
    9585    Field.VarAttribute(end-2:end)=[];
    9686end
     87
     88%renaiming for standard conventions
     89Field.NbCoord=Field.nb_coord;
     90Field.NbDim=Field.nb_dim;
    9791
    9892%determine the appropriate constant for time and dt for the PIV pair
     
    125119end
    126120
    127 %update list of global attributes
    128 List=Field.ListGlobalAttribute;
    129 ind_remove=[];
    130 for ilist=1:length(List)
    131     switch(List{ilist})
    132         case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2'}
    133             ind_remove=[ind_remove ilist];
    134             Field=rmfield(Field,List{ilist});
    135     end
    136 end
    137 List(ind_remove)=[];
    138 Field.ListGlobalAttribute=[List {'Time','CivStage','CoordUnit'}];
    139 
    140 % rescale to pixel coordiantes
     121%% rescale fields to pixel coordinates
    141122if isfield(Field,'pixcmx')
    142123    Field.pixcmx=double(Field.pixcmx);
     
    157138    end
    158139end
    159 %Field.CoordType='px';% TODO: abandon, use COORdUnit instead ? (to adapt 'px' and 'phys')
     140
     141%% update list of global attributes
     142List=Field.ListGlobalAttribute;
     143ind_remove=[];
     144for ilist=1:length(List)
     145    switch(List{ilist})
     146        case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2','nb_coord','nb_dim','pixcmx','pixcmy'}
     147            ind_remove=[ind_remove ilist];
     148            Field=rmfield(Field,List{ilist});
     149    end
     150end
     151List(ind_remove)=[];
     152Field.ListGlobalAttribute=[{'NbCoord'},{'NbDim'} List {'Time','CivStage','CoordUnit'}];
    160153Field.CoordUnit='pixel';
    161154
  • trunk/src/read_get_field.m

    r105 r179  
    179179    else
    180180        dimname_y=Field.VarDimName{VarIndex};
    181          %check consistency of dimensions
    182181        nbvar=nbvar+1;
    183182        ListVarName{nbvar}=Field.ListVarName{VarIndex};
     
    201200            SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates
    202201        end
    203 %         if isequal(dimname_y,dimname_x)
    204 %             errormsg='identical x and y coordinates selected in get_field';
    205 %             return
    206 %         end
    207202    end
    208203
     
    214209        VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
    215210        if isempty(VarIndex)% default abscissa = matrix index
    216 %             coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity
    217 %            empty_coord_z=1;
     211            empty_coord_z=1;
    218212        else
    219213            dimname_z=Field.VarDimName{VarIndex};
    220              %check consistency of dimensions
    221             if ~isequal(dimname_z,dimname_A)
    222                 for icoord=1:numel(dimname_A)
    223                     if strcmp(dimname_z,dimname_A{icoord})%  a dimension variable
    224                          dim_z=icoord;
    225                         break
     214            nbvar=nbvar+1;
     215            ListVarName{nbvar}=Field.ListVarName{VarIndex};
     216            VarDimName{nbvar}=dimname_y;
     217            if numel(VarAttribute)>=VarIndex
     218                SubVarAttribute{nbvar}=VarAttribute{VarIndex};
     219            end
     220            %check consistency of dimensions
     221            if ~isequal(dimname_y,dimname_A)% case of dimension variables
     222                if iscell(dimname_y)
     223                    if numel(dimname_y)==1
     224                        dimname_y=dimname_y{1};%transform to char chain
     225                    else
     226                        errormsg='invalid y coordinate selection in get_field';
     227                        return
    226228                    end
    227229                end
    228                 if ~dim_z
    229                     errormsg='inconsistent dimensions for coordinate z';
    230                     return
    231                 end
    232             end
    233             nbvar=nbvar+1;
    234             ListVarName{nbvar}=Field.ListVarName{VarIndex};
    235             VarDimName{nbvar}=dimname_z;
    236             if numel(VarAttribute)>=VarIndex
    237                 SubVarAttribute{nbvar}=VarAttribute{VarIndex};
    238             end
    239             if dim_z
     230                test_zdimvar=1;
    240231                SubVarAttribute{nbvar}.Role='dimvar';% dimension variable
    241232            else
    242                 SubVarAttribute{nbvar}.Role='coord_z';%z coordinate with unstructured coordinates
     233                SubVarAttribute{nbvar}.Role='coord_z';%abcissa with unstructured coordinates
    243234            end
    244235        end
     
    456447%permute indices if coord_y is not the first matrix index: scalar case
    457448if test_scalar
    458     VarNameA=Field.ListVarName{VarIndexA};
    459     DimCellA=Field.VarDimName{VarIndexA};   
    460     eval(['npxy=size(SubField.' VarNameA ');'])
     449    VarNameA=Field.ListVarName{VarIndexA};%name of the scalar variable
     450    DimCellA=Field.VarDimName{VarIndexA};  %dimension names for the scalar variable
     451    eval(['npxy=size(SubField.' VarNameA ');'])%zize of the scalar variable
    461452    SingleCellA={};
    462453    if numel(npxy) < numel(DimCellA)
     
    464455        DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions
    465456    end
    466     ind_single=find(npxy==1);
    467     if ~isempty(ind_single)
    468     %SingleCellA=[SingleCellA DimCellA(ind_single)];TO CHECK
    469     end
     457    %ind_single=find(npxy==1);
    470458    ind_select=find(npxy~=1);%look for non singleton dimensions
    471     DimCellA=DimCellA(ind_select);
     459    DimCellA=DimCellA(ind_select);%dimension names for the scalar variable, after removing singletons
    472460    npxy=npxy(ind_select);
    473461    dimA=[];
    474462    if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
    475         for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    476             if strcmp(dimname_z,SingleCellA{icoord})% a singleton dimension
    477                 errormsg=['the singleton dimension ' dimname_z ' has been selected for z'];
    478                 return
    479             end
    480         end
    481         for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    482              if strcmp(dimname_z,DimCellA{icoord})% a dimension variable
    483                  dimA=[dimA icoord];
    484                  break
    485              end
    486         end
     463        ind_singleton=find(strcmp(dimname_z,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions
     464        if ~isempty(ind_singleton)
     465             errormsg=['the singleton dimension ' dimname_z ' has been selected for z'];
     466             return
     467        end
     468        icoord=find(strcmp(dimname_z,DimCellA),1);% a dimension variable
     469        dimA=[dimA icoord];
     470%         for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar
     471%              if strcmp(dimname_z,DimCellA{icoord})% a dimension variable
     472%                  dimA=[dimA icoord];
     473%                  break
     474%              end
     475%         end
    487476    end
    488477    if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
    489         for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    490             if strcmp(dimname_y,SingleCellA{icoord})% a singleton dimension
    491                 errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate'];
    492                 return
    493             end
    494         end
    495         for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    496              if strcmp(dimname_y,DimCellA{icoord})% a dimension variable
    497                  dimA=[dimA icoord];
    498                  break
    499              end
    500         end
    501     end
    502     if test_xdimvar%dim_x && dim_y && ~isempty(VarSubIndexA)
    503         for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    504             if strcmp(dimname_x,SingleCellA{icoord})% a singleton dimension
    505                 errormsg=['the singleton dimension ' dimname_x ' has been selected for abscissa'];
    506                 return
    507             end
    508         end
    509         for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar
    510              if strcmp(dimname_x,DimCellA{icoord})% a dimension variable
    511                  dimA=[dimA icoord];
    512                  break
    513              end
    514         end
     478        ind_singleton=find(strcmp(dimname_y,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions
     479        if ~isempty(ind_singleton)
     480             errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate'];
     481             return
     482        end
     483        icoord=find(strcmp(dimname_y,DimCellA),1);% a dimension variable
     484        dimA=[dimA icoord];
     485    end
     486    if test_xdimvar
     487        ind_singleton=find(strcmp(dimname_x,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions
     488        if ~isempty(ind_singleton)
     489             errormsg=['the singleton dimension ' dimname_x ' has been selected for ordinate'];
     490             return
     491        end
     492        icoord=find(strcmp(dimname_x,DimCellA),1);% a dimension variable
     493        dimA=[dimA icoord];
    515494    end
    516495    dimextra=(1:numel(DimCellA));
  • trunk/src/series.m

    r158 r179  
    16941694end
    16951695eval(['h_function=@' ACTION ';']);
     1696[fid,errormsg] =fopen([ACTION '.m']);
     1697InputText=textscan(fid,'%s',1,'delimiter','\n');
     1698fclose(fid)
    16961699if ~isequal(path_series,PathName)
    16971700    rmpath(PathName)
    16981701end
    1699 
     1702set(handles.ACTION,'ToolTipString',InputText{1}{1})
    17001703varargout=h_function();
    17011704Param_list={};
  • trunk/src/set_object.m

    r159 r179  
    733733if isequal(get(hhuvmat.list_object_2,'Visible'),'on')
    734734    IndexObj_2=get(hhuvmat.list_object_2,'Value');
     735    List2=get(hhuvmat.list_object_2,'String')
     736    if IndexObj_2==length(List2)
     737        IndexObj_2=[];% '...' selected
     738    end
    735739else
    736740    IndexObj_2=[];
  • trunk/src/sub_field.m

    r165 r179  
    1 %'sub_field': combines two input fields
     1%'sub_field': combines two input fields
     2%
     3% the two fields are subtstracted when of the same nature (scalar or
     4% vector), if the coordinates do not coincide, the second field is
     5% interpolated on the cooridintes of the first one
     6%
     7% when scalar and vectors are combined, the fields are just merged in a single matlab structure for common visualisation
    28%-----------------------------------------------------------------------
    39% function SubData=sub_field(Field,Field_1)
     
    713%
    814% INPUT:
    9 % UvData: main structure UvData associated to the uvmat GUI as 'UserData'
    10 % Field: cell of Matlab structures representing the input fields
    11 %
    12 %    -- TODO: need to be rationalized --
     15% Field: matlab structure representing the first field
     16% Field_1:matlab structure representing the second field
    1317
    1418function [SubData,errormsg]=sub_field(Field,Field_1)
     
    7781    return
    7882end
    79 % VarIndex=CellVarIndex{iselect};
    80 % VarIndex_1=CellVarIndex_1{iselect_1};
    8183VarType=VarTypeCell{iselect};
    8284VarType_1=VarTypeCell_1{iselect_1};
     
    8587testU=~isempty(VarType.vector_x)&& ~isempty(VarType.vector_y);%vector field
    8688testU_1=~isempty(VarType_1.vector_x)&& ~isempty(VarType_1.vector_y);%vector field
    87 % testfalse=~isempty(VarType.errorflag);
    8889testfalse_1=~isempty(VarType_1.errorflag);
    8990ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields
     
    101102if (testU && testU_1) || (~testU && ~testU_1)
    102103   %check coincidence in positions
    103    %unstructured coordinates
    104    if testX     
     104   %unstructured coordinates for the first field
     105   if testX 
     106       XName=Field.ListVarName{VarType.coord_x};
     107       YName=Field.ListVarName{VarType.coord_y};
     108       eval(['vec_X=Field.' XName ';'])
     109       eval(['vec_Y=Field.' YName ';'])
     110       nbpoints=numel(vec_X);
     111       vec_X=reshape(vec_X,nbpoints,1);
     112       vec_Y=reshape(vec_Y,nbpoints,1);
     113       if testX_1 %unstructured coordinates for the second field
     114            X_1_Name=Field_1.ListVarName{VarType_1.coord_x};
     115            Y_1_Name=Field_1.ListVarName{VarType_1.coord_y};
     116            eval(['vec_X_1=Field_1.' X_1_Name ';'])
     117            eval(['vec_Y_1=Field_1.' Y_1_Name ';'])
     118
     119       else   %structured coordinates for the second field
     120           y_1_Name=Field_1.ListVarName{VarType_1.coord(1)};
     121           x_1_Name=Field_1.ListVarName{VarType_1.coord(2)};
     122           eval(['y_1=Field_1.' y_1_Name ';'])
     123           eval(['x_1=Field_1.' x_1_Name ';'])
     124           if isequal(numel(x_1),2) 
     125               x_1=linspace(x_1(1),x_1(2),nbpoints_x_1);
     126           end
     127           if isequal(numel(y_1),2) 
     128               y_1=linspace(y_1(1),y_1(2),nbpoints_y_1);
     129           end
     130           [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1);
     131       end
     132       vec_X_1=reshape(vec_X_1,[],1);
     133       vec_Y_1=reshape(vec_Y_1,[],1);
     134       if testfalse_1
     135           FFName_1=Field_1.ListVarName{VarType_1.errorflag};         
     136           eval(['vec_FF_1=Field_1.' FFName_1 ';'])
     137           vec_FF_1=reshape(vec_FF_1,[],1);
     138           indsel=find(~vec_FF_1);
     139           vec_X_1=vec_X_1(indsel);
     140           vec_Y_1=vec_Y_1(indsel);
     141       end
    105142       if testU % vector fields
    106143            U_1_Name=Field_1.ListVarName{VarType_1.vector_x};
     
    126163           end
    127164       end
    128        XName=Field.ListVarName{VarType.coord_x};
    129        YName=Field.ListVarName{VarType.coord_y};
    130        eval(['vec_X=Field.' XName ';'])
    131        eval(['vec_Y=Field.' YName ';'])
    132        nbpoints=numel(vec_X);
    133        vec_X=reshape(vec_X,nbpoints,1);
    134        vec_Y=reshape(vec_Y,nbpoints,1);
    135        if testX_1 %unstructured coordinates for the second field
    136             X_1_Name=Field_1.ListVarName{VarType_1.coord_x};
    137             Y_1_Name=Field_1.ListVarName{VarType_1.coord_y};
    138             eval(['vec_X_1=Field_1.' X_1_Name ';'])
    139             eval(['vec_Y_1=Field_1.' Y_1_Name ';'])
    140 
    141        else   %structured coordinates for the second field
    142            y_1_Name=Field_1.ListVarName{VarType_1.coord(1)};
    143            x_1_Name=Field_1.ListVarName{VarType_1.coord(2)};
    144            eval(['y_1=Field_1.' y_1_Name ';'])
    145            eval(['x_1=Field_1.' x_1_Name ';'])
    146            if isequal(numel(x_1),2) 
    147                x_1=linspace(x_1(1),x_1(2),nbpoints_x_1);
    148            end
    149            if isequal(numel(y_1),2) 
    150                y_1=linspace(y_1(1),y_1(2),nbpoints_y_1);
    151            end
    152            [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1);
    153        end
    154        vec_X_1=reshape(vec_X_1,nbpoints_x_1*nbpoints_y_1,1);
    155        vec_Y_1=reshape(vec_Y_1,nbpoints_x_1*nbpoints_y_1,1);
    156        if testfalse_1
    157            FFName_1=Field_1.ListVarName{VarType_1.errorflag};         
    158            eval(['vec_FF_1=Field_1.' FFName_1 ';'])
    159            vec_FF_1=reshape(vec_FF_1,nbpoints_1,1);
    160            indsel=find(~vec_FF_1);
    161            vec_X_1=vec_X_1(indsel);
    162            vec_Y_1=vec_Y_1(indsel);
    163        end
     165
    164166       if ~isequal(vec_X_1,vec_X) && ~isequal(vec_Y_1,vec_Y) % if the unstructured positions are not the same
    165167           if testU
     
    228230if testU && ~testU_1
    229231    AName_1=Field_1.ListVarName{ivar_C_1};
    230     if isfield(Field_1,'VarAttribute') && numel(Field_1.VarAttribute)>=ivar_C_1
     232    if isfield(Field_1,'VarAttribute') & numel(Field_1.VarAttribute)>=ivar_C_1
    231233        AAttr=Field_1.VarAttribute{ivar_C_1} ;
    232234    else
     
    236238       XName_1=Field_1.ListVarName{VarType_1.coord_x};
    237239       YName_1=Field_1.ListVarName{VarType_1.coord_y};
    238        %SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];
    239240       DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]);
    240241       if isfield(Field_1,'VarAttribute')
    241242           if numel(Field_1.VarAttribute)>=VarType_1.coord_x
    242                 XAttr=Field_1.VarAttribute{VarType_1.coord_x} ;
     243                XAttr=Field_1.VarAttribute{VarType_1.coord_x};
    243244           else
    244245                XAttr=[];
    245246           end
    246247           if numel(Field_1.VarAttribute)>=VarType_1.coord_y
    247                YAttr=Field_1.VarAttribute{VarType_1.coord_y} ;
     248               YAttr=Field_1.VarAttribute{VarType_1.coord_y};
    248249           else
    249250               YAttr=[];
     
    361362    eval(['SubData.' VName_1_1 '=Field_1.' VName_1 ';']) 
    362363end
    363 
    364364 
  • trunk/src/update_obj.m

    r159 r179  
    2121
    2222%% default input and output
    23 % Object_out{IndexObj}=ObjectData;%default
    24 % if  isfield(UvData,'Object')
    25 %     Object_set=UvData.Object;
    26 % else
    27 %     Object_set={};%create the object
    28 % end
    2923Object_out=UvData.Object;
    3024
    31 %% plot the field projected on the object
    32 % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
    33 % if ~isempty(ProjData)   
    34 %     plotaxes=[];%default
    35 %     if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
    36 %         plotaxes=Object_set{IndexObj}.plotaxes;
    37 %         [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
    38 %         plotfig=get(plotaxes,'parent');
    39 %         ViewData=get(plotfig,'UserData');
    40 %         eval(
    41 %     else
    42 %         hview_field=view_field(ProjData);%create a new field plot with view_field
    43 %         hhview_field=guidata(hview_field);
    44 %         plotaxes=hhview_field.axes3;
    45 %     end
    46 %     Object_out{IndexObj}.plotaxes=plotaxes;
    47 % end
    4825
    4926%%  representation of the different objects in the plots uvmat and view_field
    50 
    5127%plot uvmat
    5228    for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_1
    5329         hobject=[];
    5430        if isfield(Object_out{iobj},'DisplayHandle_uvmat') && ~isempty(Object_out{iobj}.DisplayHandle_uvmat) && ishandle(Object_out{iobj}.DisplayHandle_uvmat)
    55             hobject=Object_out{iobj}.DisplayHandle_uvmat;
     31            hobject=Object_out{iobj}.DisplayHandle_uvmat;%graphic handle of object #iobj in the uvmat plot
    5632        end
    5733        Object_out{iobj}.DisplayHandle_uvmat=plot_object(Object_out{iobj},Object_out{IndexObj_1},hobject,'m');%update the object representation
     
    6238        hobject=[];
    6339        if isfield(Object_out{iobj},'DisplayHandle_view_field') &&  ~isempty(Object_out{iobj}.DisplayHandle_view_field) && ishandle(Object_out{iobj}.DisplayHandle_view_field)
    64             hobject=Object_out{iobj}.DisplayHandle_view_field;
    65 %         else
    66 %             hobject=plotaxes;
     40            hobject=Object_out{iobj}.DisplayHandle_view_field;%graphic handle of object #iobj in the view_field plot
    6741        end
    6842        Object_out{iobj}.DisplayHandle_view_field=plot_object(Object_out{iobj},Object_out{IndexObj_2},hobject,'m');%update the object representation
    6943    end
    7044end
    71 %  end
    72 
    73 %     if isfield(Object_set{iobj},'plotaxes')
    74 %         haxes=Object_set{iobj}.plotaxes;% axes for the field plot
    75 %         if ishandle(haxes) && isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
    76 %             testupdate=0;
    77 %             HandlesDisplay=[];%default
    78 %             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
    79 %                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
    80 %             end
    81 %             hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes
    82 %             for ih=1:length(HandlesDisplay)
    83 %                 plot_detect=find(hplot_list==HandlesDisplay(ih));
    84 %                 if ~isempty(plot_detect)
    85 %                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iobj},HandlesDisplay(ih),'m');%update the the object representation
    86 %                     testupdate=1;
    87 %                     break
    88 %                 end
    89 %             end
    90 %             if ~testupdate% draw new object plot
    91 %                 hh=plot_object(ObjectData,Object_set{iobj},haxes,'m');%draw the object with the new object data
    92 %                 if isfield(Object_out,'HandlesDisplay')
    93 %                     Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
    94 %                 else
    95 %                     Object_out.HandlesDisplay=hh;
    96 %                 end
    97 %                 PlotData=get(hh,'UserData');
    98 %                 PlotData.IndexObj=IndexObj;
    99 %                 set(hh,'UserData',PlotData); %record the object index in the graph
    100 %             end
    101 %         end
    102 %     end
    103 % end
    10445
    10546
    10647
    10748
     49
  • trunk/src/uvmat.m

    r178 r179  
    5252%          .VelType_1: last velocity type (civ1, civ2...) for the second input series
    5353%          .FieldName_1: last field name(velocity, vorticity...) for the second input series
    54 %          .NbDim: number of space dimensions of the input field
    5554%          .ZMin, .ZMax: range of the z coordinate
    5655%..... to complement
     
    12251224    nburst_1=1;
    12261225    set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
    1227     time=[0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';
     1226    time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
    12281227    ColorType=imainfo.ImageType;%='truecolor' for color images
    12291228    hhh=which('mmreader');
     
    13331332else
    13341333    UvData.GeometryCalib_1=GeometryCalib;
    1335     if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
    1336         (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
     1334    if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
     1335        (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
    13371336        set(handles.pxcm,'String','var')
    13381337        set(handles.pycm,'String','var')
     
    15911590end
    15921591num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
    1593 MaskData.NomType
    15941592MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
    15951593huvmat=get(handles.mask_test,'parent');
     
    22272225            if isfield(UvData.XmlData,'Npy')
    22282226                Npz=size(A,1)/UvData.XmlData.Npy;
    2229                 A=reshape(A,Npz,UvData.XmlData.Npy,UvData.XmlData.Npx);
     2227                A=reshape(A',UvData.XmlData.Npx,UvData.XmlData.Npy,Npz);
     2228                A=permute(A,[3 2 1]);
    22302229            end
    22312230        case 'multimage'
     
    22392238    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    22402239    Rangy=[npxy(1)-0.5 0.5]; %
     2240    Field{1}.NbDim=2;%default
    22412241    Field{1}.AName='image';
    22422242    Field{1}.ListVarName={'AY','AX','A'}; %
     
    22472247             Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    22482248        else
     2249            Field{1}.NbDim=3;
    22492250            Field{1}.ListVarName=['AZ' Field{1}.ListVarName];
    22502251            Field{1}.VarDimName={'AZ','AY','AX',{'AZ','AY','AX'}};
    2251             Field{1}.AZ=[0.5 npxy(1)-0.5];
     2252            Field{1}.AZ=[npxy(1)-0.5 0.5];
    22522253            Field{1}.AY=[npxy(2)-0.5 0.5];
    22532254            Field{1}.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers
     
    23422343            end
    23432344            CivStage=Field{1}.CivStage;
    2344             UvData.NbDim=Field{1}.nb_dim;
     2345            %UvData.NbDim=Field{1}.NbDim;
    23452346        end
    23462347    end
     
    24112412end
    24122413%put W as background image by default if NbDim=2:
    2413 if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
    2414     if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
     2414if  UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
    24152415        set(handles.SubField,'Value',1);
    24162416        %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
     
    24302430        set(handles.Fields_1,'Visible','on');
    24312431        Field{1}.AName='w';
    2432 %         testscal=1;
    2433     end
    24342432end           
    24352433
    24362434%multislice case
    2437 if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
    2438       isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
    2439        siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
    2440 %        if siz(1)>1
    2441 %            NbSlice=siz(1);
    2442 %        else
    2443 %            NbSlice=1;
    2444 %        end
    2445 end
     2435% if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
     2436%       isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
     2437%        siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
     2438% end
    24462439
    24472440%store the current open names, fields and vel types in uvmat interface
     
    24932486    Field{2}=calc_field(InputField_1,Field{2});
    24942487end
    2495 % combine the two input fields (e.g. substract velocity fields)
     2488
     2489%% combine the two input fields (e.g. substract velocity fields)
    24962490if numel(Field)==2
    2497    UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
     2491   UvData.Field=sub_field(Field{1},Field{2});
    24982492else
    24992493   UvData.Field=Field{1};
     
    25032497test_x=0;
    25042498test_z=0;% test for unstructured z coordinate
    2505 % UvData.ZMax=0;
    2506 % UvData.ZMin=0;%default
    2507 %UvData.Mesh=1; %default
    25082499[UvData.Field,errormsg]=check_field_structure(UvData.Field);
    25092500if ~isempty(errormsg)
     
    25132504[CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
    25142505[NbDim,imax]=max(NbDim);
    2515 % if isempty(imax)
    2516 % %    DimVarIndex=0;   
    2517 %     coord_x=[];
    2518 % else
    2519 % %     VarIndex=CellVarIndex{imax};
    2520 %     coord_x=VarType{imax}.coord_x;
    2521 % end
    2522 % if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
    2523 %     NbDim=UvData.NbDim;
    2524 % else 
    2525 UvData.NbDim=NbDim;
    2526 % end
    25272506if ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinates
    25282507    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
     
    25302509    eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
    25312510    test_x=1;%test for unstructured coordinates
    2532 elseif NbDim==2
    2533     YName=UvData.Field.ListVarName{VarType{imax}.coord(1)}; %structured coordinates
    2534     XName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
    2535 elseif NbDim==3
     2511else %structured coordinate
     2512    YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
     2513    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
     2514end
     2515if NbDim==3
    25362516    ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
    2537     YName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
    2538     XName=UvData.Field.ListVarName{VarType{imax}.coord(3)};
    25392517    eval(['ZMax=max(UvData.Field.' ZName ');'])
    25402518    eval(['ZMin=min(UvData.Field.' ZName ');'])
     2519    test_z=1;
     2520    if isequal(ZMin,ZMax)%no z dependency
     2521        NbDim=2;
     2522        test_z=0;
     2523    end
    25412524end
    25422525eval(['XMax=max(UvData.Field.' XName ');'])
     
    25452528eval(['YMin=min(UvData.Field.' YName ');'])
    25462529eval(['nbvec=length(UvData.Field.' XName ');'])
    2547 if NbDim==3%
    2548     if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
    2549 %         ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
    2550         eval(['ZMax=max(UvData.Field.' ZName ');'])
    2551         eval(['ZMin=min(UvData.Field.' ZName ');'])
    2552         test_z=1;   
    2553     elseif isfield(UvData,'Z')% usual civ data
    2554         ZMax=max(UvData.Z);
    2555         ZMin=min(UvData.Z);
    2556         test_z=1;
    2557     end
    2558     if isequal(ZMin,ZMax)%no z dependency
    2559         NbDim=2;
    2560         test_z=0;
    2561     end
    2562 end
    2563 if test_x
     2530if test_x %unstructured coordinates
    25642531    if test_z
    25652532        UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
     
    25712538    VarIndex=CellVarIndex{imax}; % list of variable indices
    25722539    DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2573     nbpoints_y=UvData.Field.DimValue(DimIndex(1));
    2574     nbpoints_x=UvData.Field.DimValue(DimIndex(2));
    2575     DX=(XMax-XMin)/nbpoints_x;
    2576     DY=(YMax-YMin)/nbpoints_y;
    2577     UvData.Field.Mesh=sqrt(DX*DY);
    2578 end
     2540    nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
     2541    nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
     2542    DX=(XMax-XMin)/(nbpoints_x-1);
     2543    DY=(YMax-YMin)/(nbpoints_y-1);
     2544    if NbDim==3
     2545        nbpoints_z=UvData.Field.DimValue(DimIndex(1));
     2546        DZ=(ZMax-ZMin)/(nbpoints_z-1);
     2547        UvData.Field.Mesh=sqrt(DX*DY*DZ);
     2548        UvData.Field.ZMax=ZMax;
     2549        UvData.Field.ZMin=ZMin;
     2550    else
     2551        UvData.Field.Mesh=sqrt(DX*DY);
     2552    end
     2553end
     2554UvData.Field.NbDim=NbDim;
    25792555UvData.Field.XMax=XMax;
    25802556UvData.Field.XMin=XMin;
    2581 UvData.Field.YMax=XMax;
    2582 UvData.Field.YMin=XMin;
    2583 if NbDim==3
    2584     UvData.Field.ZMax=ZMax;
    2585     UvData.Field.ZMin=ZMin;
    2586 end
    2587 
    2588 %case of structured coordinates
    2589 
    2590 % if  isempty(coord_x) && ~isempty(CellVarIndex)
    2591 %     VarIndex=CellVarIndex{imax}; % list of variable indices
    2592 %     DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2593 %     if NbDim==3
    2594 %         nbpoints=UvData.Field.DimValue(DimIndex(1));
    2595 %         if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
    2596 %             ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
    2597 %             eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
    2598 %             eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
    2599 %         else
    2600 %             testcoord_z=0;
    2601 %             if length(UvData.Field.VarAttribute)>=VarIndex(1)
    2602 %                 if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
    2603 %                     Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
    2604 %                     UvData.ZMax=max(Coord_z);
    2605 %                     UvData.ZMin=min(Coord_z);
    2606 %                     testcoord_z=1;
    2607 %                 end
    2608 %             end
    2609 %             if ~testcoord_z
    2610 %                   UvData.ZMin=1;
    2611 %                   UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
    2612 %             end
    2613 %         end
    2614 %         Field.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
    2615 %     elseif NbDim==2
    2616 %         nbpoints_y=UvData.Field.DimValue(DimIndex(1));       
    2617 %         Yvar=VarType{imax}.coord_y;
    2618 %         if Yvar~=0  % x is a dimension variable
    2619 %             YName=UvData.Field.ListVarName{Yvar};
    2620 %             eval(['UvData.YMax=max(UvData.Field.' YName ');'])
    2621 %             eval(['UvData.YMin=min(UvData.Field.' YName ');'])
    2622 %         else
    2623 %             testcoord_y=0;
    2624 %             if ~testcoord_y
    2625 %                   UvData.YMin=1;
    2626 %                   UvData.YMax=UvData.Field.DimValue(DimIndex(1));
    2627 %             end
    2628 %         end
    2629 %         DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
    2630 %         nbpoints_x=UvData.Field.DimValue(DimIndex(2));
    2631 %         Xvar=VarType{imax}.coord_x;
    2632 %         if Xvar~=0  % x is a dimension variable
    2633 %             XName=UvData.Field.ListVarName{Xvar};
    2634 %             eval(['UvData.XMax=max(UvData.Field.' XName ');'])
    2635 %             eval(['UvData.XMin=min(UvData.Field.' XName ');'])
    2636 %         else
    2637 %             testcoord_x=0;
    2638 %             if ~testcoord_x
    2639 %                   UvData.XMin=1;
    2640 %                   UvData.XMax=UvData.Field.DimValue(DimIndex(2));
    2641 %             end
    2642 %         end
    2643 %         DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
    2644 %         Field.Mesh= sqrt(DX*DY);
    2645 %     end
    2646 % end
    2647 
    2648 %create a default projection menuplane
     2557UvData.Field.YMax=YMax;
     2558UvData.Field.YMin=YMin;
     2559
     2560%% create a default projection menuplane
    26492561UvData.Object{1}.Style='plane';%main plotting plane
    26502562UvData.Object{1}.ProjMode='projection';%main plotting plane
     2563UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
     2564
     2565
     2566%% 3D case (menuvolume)
     2567if NbDim==3% && UvData.NewSeries
     2568    test_set_object=1;
     2569    hset_object=findobj(allchild(0),'tag','set_object');
     2570    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     2571    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
     2572    if ~isempty(hset_object)
     2573        hhset_object=guidata(hset_object);
     2574        ZBounds_old(1)=get(hhset_object.z_slider,'Min');
     2575        ZBounds_old(2)=get(hhset_object.z_slider,'Max');
     2576        if isequal(ZBounds_old,ZBounds)
     2577            test_set_object=0;
     2578        else
     2579            delete(test_set_object);
     2580        end
     2581    end
     2582    if test_set_object% reinitiate set_object
     2583        delete_object(1);
     2584        UvData.Object{1}.Style='plane';%main plotting plane
     2585        UvData.Object{1}.ProjMode='projection';%main plotting plane
     2586        UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
     2587        UvData.Object{1}.NbDim=NbDim;%test for 3D objects
     2588        UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
     2589        UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
     2590        UvData.Object{1}.Phi=0;
     2591        UvData.Object{1}.Theta=0;
     2592        UvData.Object{1}.Psi=0;
     2593        UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
     2594        PlotHandles=get_plot_handles(handles);
     2595        UvData.Object{1}.Name='1-PLANE';
     2596        UvData.Object{1}.enable_plot=1;
     2597        set_object(UvData.Object{1},PlotHandles,ZBounds);
     2598        set(handles.list_object_1,'Value',1);
     2599    end
     2600    %multilevel case (single menuplane in a 3D space)
     2601elseif isfield(UvData,'Z')
     2602    if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
     2603        XmlData=UvData.XmlData;
     2604        if isfield(XmlData,'PlanePos')
     2605            UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
     2606        end
     2607        if isfield(XmlData,'PlaneAngle')
     2608            siz=size(XmlData.PlaneAngle);
     2609            indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
     2610            UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
     2611            UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
     2612            UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
     2613        end
     2614    elseif isfield(UvData,'ZIndex')
     2615        UvData.Object{1}.ZObject=UvData.ZIndex;
     2616    end
     2617end
    26512618if ~isfield(UvData.Object{1},'plotaxes')
    26522619    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    26532620    set(handles.list_object_1,'Value',1);
    26542621    set(handles.list_object_1,'String',{'1-PLANE'}); 
    2655 end
    2656 
    2657 %3D case (menuvolume)
    2658 if NbDim==3 && UvData.NewSeries
    2659     UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
    2660     UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
    2661     UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
    2662     UvData.Object{1}.Phi=0;
    2663     UvData.Object{1}.Theta=0;
    2664     UvData.Object{1}.Psi=0;
    2665     UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 
    2666     PlotHandles=get_plot_handles(handles);
    2667     ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
    2668     ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    2669     UvData.Object{1}.Name='1-PLANE';
    2670     UvData.Object{1}.enable_plot=1;
    2671     set_object(UvData.Object{1},PlotHandles,ZBounds);
    2672     set(handles.list_object_1,'Value',1);
    2673 %multilevel case (single menuplane in a 3D space)
    2674 elseif isfield(UvData,'Z')
    2675     if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
    2676         XmlData=UvData.XmlData;
    2677         if isfield(XmlData,'PlanePos')
    2678              UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
    2679         end
    2680         if isfield(XmlData,'PlaneAngle')
    2681             siz=size(XmlData.PlaneAngle);
    2682             indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)             
    2683             UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
    2684             UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
    2685             UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
    2686         end
    2687     elseif isfield(UvData,'ZIndex')
    2688         UvData.Object{1}.ZObject=UvData.ZIndex;
    2689     end
    26902622end
    26912623
     
    35693501set(handles.uvmat,'UserData',UvData)
    35703502setfield(handles);% update the field structure ('civ1'....)
    3571 if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
     3503if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
    35723504    run0_Callback(hObject, eventdata, handles)
    35733505end
     
    38303762npx=size(UvData.Field.A,2);
    38313763npy=size(UvData.Field.A,1);
    3832 xi=[0.5:npx-0.5];
    3833 yi=[0.5:npy-0.5];
     3764xi=0.5:npx-0.5;
     3765yi=0.5:npy-0.5;
    38343766[Xi,Yi]=meshgrid(xi,yi);
    38353767if isfield(UvData,'Object')
     
    38843816RootPath=get(handles.RootPath,'String');
    38853817RootFile=get(handles.RootFile,'String');
    3886 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
     3818if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    38873819        RootFile(1)=[];
    38883820end
     
    41844116    Amax=double(max(max(max(FieldHisto))));%max of image
    41854117    if isequal(Amin,Amax)
    4186        Histo.Txt=['uniform field =' num2str(Amin)];
     4118        msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
    41874119    else
    4188     Histo.ListVarName={FieldName,'histo'};
    4189     if numel(nxy)==2
    4190         Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
    4191     else %color images
    4192         Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
    4193     end
    4194     %unit
    4195     units=[]; %default
    4196     for ivar=1:numel(Field.ListVarName)   
    4197         if strcmp(Field.ListVarName{ivar},FieldName)
    4198             if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
    4199                 units=Field.VarAttribute{ivar}.units;
    4200                 break
     4120        Histo.ListVarName={FieldName,'histo'};
     4121        if isequal(Field.NbDim,3)
     4122            Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
     4123        else
     4124            if numel(nxy)==2
     4125                Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
     4126            else
     4127                Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
    42014128            end
    42024129        end
    4203     end
    4204     if ~isempty(units)
    4205         Histo.VarAttribute{1}.units=units;
    4206     end
    4207     eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
    4208     for col=1:size(FieldHisto,3)
    4209         B=FieldHisto(:,:,col);
    4210         C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
    4211        eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']);  %calculate histogram
    4212     end
    4213     set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
    4214     set(haxes,'YLimMode','auto')
    4215     plot_field(Histo,haxes);
     4130        %unit
     4131        units=[]; %default
     4132        for ivar=1:numel(Field.ListVarName)
     4133            if strcmp(Field.ListVarName{ivar},FieldName)
     4134                if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
     4135                    units=Field.VarAttribute{ivar}.units;
     4136                    break
     4137                end
     4138            end
     4139        end
     4140        if ~isempty(units)
     4141            Histo.VarAttribute{1}.units=units;
     4142        end
     4143        eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
     4144        if isequal(Field.NbDim,3)
     4145            C=reshape(double(FieldHisto),1,[]);% reshape in a vector
     4146            eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']);  %calculate histogram
     4147        else
     4148            for col=1:size(FieldHisto,3)
     4149                B=FieldHisto(:,:,col);
     4150                C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
     4151                eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']);  %calculate histogram
     4152            end
     4153        end
     4154        set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
     4155        set(haxes,'YLimMode','auto')
     4156        plot_field(Histo,haxes);
    42164157    end
    42174158end
     
    43764317% colcode.CName= list_code{index_code(1)}; % selected field used for vector color
    43774318colcode.FixedCbounds=1;
    4378 vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
     4319vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
    43794320[colorlist,col_vec]=set_col_vec(colcode,vec_C);
    43804321oneheight=ones(1,height);
     
    45104451hother=findobj('Tag','proj_object');%find all the proj objects
    45114452for iobj=1:length(hother)
    4512     if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
     4453    if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
    45134454        set(hother(iobj),'EdgeColor','b')
    45144455        if isequal(get(hother(iobj),'FaceColor'),'m')
     
    47914732        end
    47924733    end
    4793     % flag=~flag;
     4734   
    47944735    %mask name
    47954736    RootPath=get(handles.RootPath,'String');
    47964737    RootFile=get(handles.RootFile,'String');
    4797     if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
     4738    if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
    47984739        RootFile(1)=[];
    47994740    end
Note: See TracChangeset for help on using the changeset viewer.