Changeset 654 for trunk


Ignore:
Timestamp:
Jun 30, 2013, 11:16:45 PM (11 years ago)
Author:
sommeria
Message:

various bugs corrected

Location:
trunk/src
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_interp.m

    r650 r654  
    1 %'calc_field_interp': defines fields (velocity, vort, div...) from civ data and calculate them
    2 % for projection with linear interpolation
     1%'calc_field_interp': calculate fields (velocity, vort, div...) using linear interpolation if requested
    32%---------------------------------------------------------------------
    43% [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
     
    109%
    1110% INPUT:
    12 % Coord(nbpoints,2): matrix of x,y coordinates of theinput data points
     11% Coord(nbpoints,2): matrix of x,y coordinates of the input data points
    1312% Data: inputfield structure
    1413% FieldName: string representing the field to calculate, or cell array of fields (as displayed in uvmat/FieldName)
    15 % XI, YI: set of x and y coordiantes where the fields need to be linearly interpolated
    16 
     14% XI, YI: set of x and y coordinates where the fields need to be linearly interpolated,
     15%        if XI, YI are missing, there is no interpolation (case of colors in vector plots)
     16%
    1717function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
    1818
     
    2525if ischar(FieldName),FieldName={FieldName};end
    2626check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated
     27check_interp=ones(size(FieldName));% default, =1 to mark the variables which can be interpolated (not ancillary)
    2728Operator=cell(size(FieldName));
    2829
     
    3536        if isempty(ivar)
    3637            check_skipped(ilist)=1; %variable not found
    37         else
     38        elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
    3839            if isfield(Data.VarAttribute{ivar},'Role') &&...
    3940                (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag'))
    40                 check_skipped(ilist)=1; % ancillary variable, not interpolated     
    41             elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
    42                 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
     41                check_interp(ilist)=0; % ancillary variable, not interpolated     
    4342            end
     43            InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
    4444        end
    4545    else
     
    8888            case 'vec'
    8989                if exist('XI','var')
     90                    if check_interp
    9091                    VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
    9192                    VarVal{nbvar+2}=F.(VName{ilist})(XI,YI);
     93                    end
    9294                else
    9395                    VarVal{nbvar+1}=Data.(UName{ilist});
     
    100102            case 'norm'
    101103                if exist('XI','var')
     104                    if check_interp
    102105                    U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI);
    103106                    V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI);
     107                    end
    104108                else
    105109                    U2=Data.(UName{ilist}).*Data.(UName{ilist});
     
    111115            case {'curl','div','strain'}
    112116                if exist('XI','var')
     117                    if check_interp
    113118                    VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
     119                    end
    114120                else
    115121                    VarVal{nbvar+1}=Data.(UName{ilist});
     
    120126                if ~isempty(FieldName{ilist})
    121127                    if exist('XI','var')
     128                        if check_interp
    122129                        VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI);
     130                        end
    123131                    else
    124132                        VarVal{nbvar+1}= Data.(FieldName{ilist});
  • trunk/src/check_files.m

    r648 r654  
    5454    'fill_GUI';...%  fill a GUI with a set of parameters from a Matlab structure
    5555    'filter_tps';...% find the thin plate spline coefficients for interpolation-smoothing
     56    'find_field_bounds': % find the boounds and typical meshs of coordinates
    5657    'find_field_cells';...% group the variables of a 'field object' into 'field cells' and specify their structure
    5758    'find_file_series';...% check the content of an input file and find the corresponding file series
  • trunk/src/geometry_calib.m

    r630 r654  
    5050% Edit the above text to modify the response to help geometry_calib
    5151
    52 % Last Modified by GUIDE v2.5 29-Jul-2012 08:46:09
     52% Last Modified by GUIDE v2.5 29-Jun-2013 23:52:36
    5353
    5454% Begin initialization code - DO NOT edit
     
    208208set(handles.geometry_calib,'UserData',UserData)
    209209uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    210 MenuPlot_Callback(hObject, eventdata, handles)
     210PLOT_Callback(hObject, eventdata, handles)
    211211set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake)
    212212ListCoord_Callback(hObject, eventdata, handles)
     
    748748set(handles.ListCoord,'Value',1)% refresh the display of coordinates
    749749set(handles.ListCoord,'String',{'......'})
    750 MenuPlot_Callback(hObject, eventdata, handles)
     750PLOT_Callback(hObject, eventdata, handles)
     751
    751752
    752753%------------------------------------------------------------------------
     
    800801%update the plot
    801802ListCoord_Callback(hObject, eventdata, handles)
    802 MenuPlot_Callback(hObject, eventdata, handles)
     803PLOT_Callback(hObject, eventdata, handles)
    803804
    804805%------------------------------------------------------------------------
     
    917918plot_field(Data)
    918919
    919 %------------------------------------------------------------------------
    920 function MenuPlot_Callback(hObject, eventdata, handles)
    921 %------------------------------------------------------------------------
    922 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    923 %UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    924 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
    925 %hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
    926 h_menu_coord=findobj(huvmat,'Tag','TransformName');
    927 menu=get(h_menu_coord,'String');
    928 choice=get(h_menu_coord,'Value');
    929 if iscell(menu)
    930     option=menu{choice};
    931 else
    932     option='px'; %default
    933 end
    934 Coord_cell=get(handles.ListCoord,'String');
    935 ObjectData=read_geometry_calib(Coord_cell);
    936 %ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object
    937 if ~isempty(ObjectData.Coord)
    938     if isequal(option,'phys')
    939         ObjectData.Coord=ObjectData.Coord(:,1:3);
    940     elseif isequal(option,'px')||isequal(option,'')
    941         ObjectData.Coord=ObjectData.Coord(:,4:5);
    942     else
    943         msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ')
    944     end
    945 end
    946 
    947 set(0,'CurrentFigure',huvmat)
    948 set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
    949 hh=findobj('Tag','calib_points');
    950 if  ~isempty(ObjectData.Coord) && isempty(hh)
    951     hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
    952 elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot
    953     delete(hh)
    954 else
    955     set(hh,'XData',ObjectData.Coord(:,1))
    956     set(hh,'YData',ObjectData.Coord(:,2))
    957 end
    958 pause(.1)
    959 figure(handles.geometry_calib)
    960920
    961921% --------------------------------------------------------------------
     
    969929   web([helpfile '#geometry_calib'])
    970930end
     931
     932% --------------------------------------------------------------------
     933function MenuSetScale_Callback(hObject, eventdata, handles)
     934% hObject    handle to MenuSetScale (see GCBO)
     935% eventdata  reserved - to be defined in a future version of MATLAB
     936% handles    structure with handles and user data (see GUIDATA)
     937 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','')
     938 %create test points
     939 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
     940UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
     941Xima=0.8*[UvData.Field.XMin UvData.Field.XMax UvData.Field.XMax UvData.Field.XMin]';
     942Yima=0.8*[UvData.Field.YMin UvData.Field.YMax UvData.Field.YMax UvData.Field.YMin]';
     943x=Xima/str2num(answer);
     944y=Yima/str2num(answer);
     945for j=1:4
     946    for i=1:5
     947          Coord{j,1}=num2str(x);%
     948          Coord{j,2}=num2str(y);%
     949          Coord{j,3}='0';%
     950          Coord{j,4}=num2str(Xima);%
     951          Coord{j,5}=num2str(Yima);%
     952    end
     953end
     954
     955Tabchar=cell2tab(Coord,' | ');
     956Tabchar=[Tabchar ;{'......'}];
     957set(handles.ListCoord,'String',Tabchar)
    971958
    972959%------------------------------------------------------------------------
     
    11401127set(handles.ListCoord,'Value',1)
    11411128set(handles.ListCoord,'String',Tabchar)
    1142 MenuPlot_Callback(hObject, eventdata, handles)
     1129PLOT_Callback(hObject, eventdata, handles)
    11431130
    11441131%-----------------------------------------------------------------------
     
    12331220set(handles.ListCoord,'Value',1)
    12341221set(handles.ListCoord,'String',Tabchar)
    1235 MenuPlot_Callback(handles.geometry_calib, [], handles)
     1222PLOT_Callback(handles.geometry_calib, [], handles)
    12361223
    12371224% -----------------------------------------------------------------------
     
    12801267        set(handles.ListCoord,'String',Coord_cell)         
    12811268        ListCoord_Callback(hObject, eventdata, handles)
    1282         MenuPlot_Callback(hObject,eventdata,handles)
     1269        PLOT_Callback(hObject,eventdata,handles)
    12831270     end
    12841271end
     
    13571344    CoordCell=reshape(CoordCell,[],5);
    13581345    Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
    1359     MenuPlot_Callback(handles.geometry_calib, [], handles)
     1346    PLOT_Callback(handles.geometry_calib, [], handles)
    13601347end
    13611348set(handles.calib_type,'Value',val_cal)
     
    14051392% Hint: delete(hObject) closes the figure
    14061393delete(hObject);
     1394
     1395%------------------------------------------------------------------------
     1396% --- Executes on button press in PLOT.
     1397%------------------------------------------------------------------------
     1398function PLOT_Callback(hObject, eventdata, handles)
     1399
     1400huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
     1401%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
     1402hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
     1403%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
     1404h_menu_coord=findobj(huvmat,'Tag','TransformName');
     1405menu=get(h_menu_coord,'String');
     1406choice=get(h_menu_coord,'Value');
     1407if iscell(menu)
     1408    option=menu{choice};
     1409else
     1410    option='px'; %default
     1411end
     1412Coord_cell=get(handles.ListCoord,'String');
     1413ObjectData=read_geometry_calib(Coord_cell);
     1414%ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object
     1415if ~isempty(ObjectData.Coord)
     1416    if isequal(option,'phys')
     1417        ObjectData.Coord=ObjectData.Coord(:,1:3);
     1418    elseif isequal(option,'px')||isequal(option,'')
     1419        ObjectData.Coord=ObjectData.Coord(:,4:5);
     1420    else
     1421        msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ')
     1422    end
     1423end
     1424
     1425set(0,'CurrentFigure',huvmat)
     1426set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)
     1427hh=findobj('Tag','calib_points');
     1428if  ~isempty(ObjectData.Coord) && isempty(hh)
     1429    hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
     1430elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot
     1431    delete(hh)
     1432else
     1433    set(hh,'XData',ObjectData.Coord(:,1))
     1434    set(hh,'YData',ObjectData.Coord(:,2))
     1435end
     1436pause(.1)
     1437figure(handles.geometry_calib)
     1438
     1439
     1440 
  • trunk/src/get_field.m

    r648 r654  
    140140set(handles.ordinate,'Value',1)% fill the menu of y vector components
    141141set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components
     142if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata')
     143        set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})
     144else
     145     set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'})
     146end
    142147if Field.MaxDim>=2 % case of 2D (or 3D) fields
    143148    if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
     
    149154        set(handles.FieldOption,'Value',2)
    150155    end
     156
    151157else % case of 1D fields
    152158    set(handles.FieldOption,'Value',1)
     
    338344switch FieldOption
    339345    case '1D plot'
     346        set(handles.Coordinates,'Visible','on')
    340347        set(handles.PanelOrdinate,'Visible','on')
    341348        pos=get(handles.PanelOrdinate,'Position');
     
    352359        ordinate_Callback(hObject, eventdata, handles)
    353360    case 'scalar'
     361        set(handles.Coordinates,'Visible','on')
    354362        set(handles.PanelOrdinate,'Visible','off')
    355363        set(handles.PanelScalar,'Visible','on')
     
    364372        scalar_Callback(hObject, eventdata, handles)
    365373    case 'vectors'
     374        set(handles.Coordinates,'Visible','on')
    366375        set(handles.PanelOrdinate,'Visible','off')
    367376        set(handles.PanelScalar,'Visible','off')
     
    375384        set(handles.Y_title,'Visible','on')     
    376385        vector_Callback(handles)
     386    case 'civdata...'
     387        set(handles.PanelOrdinate,'Visible','off')
     388        set(handles.PanelScalar,'Visible','off')
     389        set(handles.PanelVectors,'Visible','off')
     390        set(handles.Coordinates,'Visible','off')
    377391end
    378392
  • trunk/src/msgbox_uvmat.m

    r599 r654  
    11%'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls
    2 % msgbox_uvmat(title,display)
     2%
     3% answer=msgbox_uvmat(title,display,default_answer,Position)
    34%
    45% OUTPUT:
  • trunk/src/proj_field.m

    r653 r654  
    893893    norm_plane(3)=OmAxis(3)*coeff+cos_om;
    894894end
    895 testangle=~isequal(PlaneAngle,[0 0 0]);% && ~test90y && ~test90x;%=1 for slanted plane
     895testangle=~isequal(PlaneAngle,[0 0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane
    896896
    897897%% mesh sizes DX and DY
     
    984984%% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
    985985[CellInfo,NbDimArray,errormsg]=find_field_cells(FieldData);
     986
    986987if ~isempty(errormsg)
    987988    errormsg=['error in proj_field/proj_plane:' errormsg];
    988989    return
    989990end
    990 
    991 %% projection modes
    992 check_grid=0;
     991check_grid=zeros(size(CellInfo));% =1 if a grid is needed , =0 otherwise, for each field cell
     992
    993993ProjMode=cell(size(CellInfo));
    994 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
    995     ProjMode{icell}=ObjectData.ProjMode;
    996     if isfield(CellInfo{icell},'ProjModeRequest')
    997         switch CellInfo{icell}.ProjModeRequest
    998             case 'interp_lin'
    999                 ProjMode{icell}='interp_lin';
    1000             case 'interp_tps'
    1001                 ProjMode{icell}='interp_tps';
    1002         end
    1003     end
    1004     if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
    1005         check_grid=1;
    1006     end
    1007 end
    1008 
    1009 %% define the new coordinates in case of interpolation on a grid
    1010 if check_grid
    1011     AYName='coord_y';
    1012     AXName='coord_x';
    1013     ProjData.ListVarName={'coord_y','coord_x'};
    1014     ProjData.VarDimName={'coord_y','coord_x'};
    1015     ProjData.VarAttribute={[],[]};
     994for icell=1:numel(CellInfo)
     995    ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object
     996end
     997    icell_grid=[];% field cell index which defines the grid
     998if ~strcmp(ObjectData.ProjMode,'projection')
     999    %% define the new coordinates in case of interpolation on a imposed grid
    10161000    if ~testYMin
    10171001        errormsg='min Y value not defined for the projection grid';return
     
    10261010        errormsg='max X value not defined for the projection grid';return
    10271011    end
    1028     ProjData.coord_y=[YMin YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
    1029     ProjData.coord_x=[XMin XMax];
    1030     coord_x_proj=XMin:DX:XMax;
    1031     coord_y_proj=YMin:DY:YMax;
    1032     [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
    1033     XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
    1034     YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
    1035 end
    1036 
     1012else
     1013    %% case of a grid requested by the input field
     1014
     1015    for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
     1016        if isfield(CellInfo{icell},'ProjModeRequest')
     1017            switch CellInfo{icell}.ProjModeRequest
     1018                case 'interp_lin'
     1019                    ProjMode{icell}='interp_lin';
     1020                case 'interp_tps'
     1021                    ProjMode{icell}='interp_tps';
     1022            end
     1023        end
     1024        if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
     1025            check_grid(icell)=1;
     1026        end
     1027        if strcmp(CellInfo{icell}.CoordType,'grid')&&NbDimArray(icell)>=2
     1028            if ~testangle && isempty(icell_grid)% if the input gridded data is not modified, choose the first one in case of multiple gridded field cells
     1029                icell_grid=icell;
     1030                ProjMode{icell}='projection';
     1031            end
     1032            check_grid(icell)=1;
     1033        end
     1034    end
     1035    if ~isempty(find(check_grid))% if a grid is requested by the input field
     1036        if isempty(icell_grid)%  if the grid is not given by cell #icell_grid
     1037            if ~isfield(FieldData,'XMax')
     1038                FieldData=find_field_bounds(FieldData);
     1039%             CellIndex=find(check_grid);
     1040%             for igrid=1:numel(CellIndex)
     1041%                 icell=CellIndex(igrid);% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
     1042%                 NbDim=NbDimArray(icell);
     1043%                 for idim=1:NbDim %loop on space dimensions
     1044%                     ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
     1045%                     Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
     1046%                     if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
     1047%                         
     1048%                         
     1049%                         
     1050%                     else
     1051%                                                     Coord_i_str=['Coord_' num2str(idim)];
     1052%                             DCoord_min(idim)=1;%default
     1053%                             Coord{idim}=[0.5 DimValue(idim)-0.5];
     1054%                             test_direct(idim)=1;
     1055%                     end
     1056%                 % default bounds, case of gridded data
     1057%                 if strcmp(CellInfo{icell}.CoordType,'grid')
     1058%                     % find default mesh
     1059%                     for idim=1:NbDim %loop on space dimensions
     1060%                         test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
     1061%                         ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
     1062%                         DimValue=size(FieldData.(FieldData.ListVarName{ivar}));
     1063%                         if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
     1064%                             Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
     1065%                             if numel(Coord{idim})==2 %input array defined on a regular grid
     1066%                                 DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);
     1067%                                 Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));
     1068%                             else
     1069%                                 DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field
     1070%                                 DCoord_min(idim)=min(DCoord);
     1071%                                 DCoord_max=max(DCoord);
     1072%                                 if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)
     1073%                                     msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'])
     1074%                                     return
     1075%                                 end
     1076%                                 test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
     1077%                             end
     1078%                             test_direct(idim)=(DCoord_min(idim)>0);
     1079%                         else  % no variable associated with the  dimension #idim, the coordinate value is set equal to the matrix index by default
     1080% %                             Coord_i_str=['Coord_' num2str(idim)];
     1081% %                             DCoord_min(idim)=1;%default
     1082% %                             Coord{idim}=[0.5 DimValue(idim)-0.5];
     1083% %                             test_direct(idim)=1;
     1084%                         end
     1085%                     end
     1086%                     if isempty(DY)
     1087%                         DY=abs(DCoord_min(NbDim-1));
     1088%                     end
     1089%                     npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
     1090%                     if isempty(DX)
     1091%                         DX=abs(DCoord_min(NbDim));
     1092%                     end
     1093%                     npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol
     1094%                     for idim=1:NbDim
     1095%                         if test_interp(idim)
     1096%                             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
     1097%                         end
     1098%                     end
     1099%                     Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);
     1100%                     test_direct_y=test_direct(NbDim-1);
     1101%                     Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);
     1102%                     test_direct_x=test_direct(NbDim);
     1103%                     DAX=DCoord_min(NbDim);
     1104%                     DAY=DCoord_min(NbDim-1);
     1105%                     minAX=min(Coord_x);
     1106%                     maxAX=max(Coord_x);
     1107%                     minAY=min(Coord_y);
     1108%                     maxAY=max(Coord_y);
     1109%                     xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes
     1110%                     ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
     1111%                     xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
     1112%                     ycor_new=-xcorner*sin_om+ycorner*cos_om;
     1113%                     if ~testXMax
     1114%                         XMax(igrid)=max(xcor_new);
     1115%                     end
     1116%                     if ~testXMin
     1117%                         XMin(igrid)=min(xcor_new);
     1118%                     end
     1119%                     if ~testYMax
     1120%                         YMax(igrid)=max(ycor_new);
     1121%                     end
     1122%                     if ~testYMin
     1123%                         YMin(igrid)=min(ycor_new);
     1124%                     end
     1125%                     DX(igrid)=(maxAX-minAX)/(DimValue(NbDim)-1);
     1126%                     DY(igrid)=(maxAY-minAY)/(DimValue(NbDim-1)-1);
     1127%                     if NbDim==3
     1128%                         DZ(igrid)=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
     1129%                         if ~test_direct(1)
     1130%                             DZ=-DZ;
     1131%                         end
     1132%                         Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
     1133%                         test_direct_z=test_direct(1);
     1134%                     end
     1135%                 else
     1136%                     
     1137%                 end
     1138%                 YMax=max(YMax);
     1139%                 YMin=min(YMin);
     1140%                 XMax=max(XMax);
     1141%                 XMin=min(XMin);
     1142            end
     1143        end
     1144    end
     1145end
     1146if ~isempty(find(check_grid))||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
     1147    if isempty(icell_grid)||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used
     1148        AYName='coord_y';
     1149        AXName='coord_x';
     1150        if ~strcmp(ObjectData.ProjMode,'projection')
     1151            ProjData.coord_y=[ObjectData.RangeY(1) ObjectData.RangeY(2)];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
     1152        ProjData.coord_x=[ObjectData.RangeX(1) ObjectData.RangeX(2)];
     1153        coord_x_proj=ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2);
     1154        coord_y_proj=ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2);
     1155        else
     1156        ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined
     1157        ProjData.coord_x=[FieldData.XMin FieldData.XMax];
     1158        coord_x_proj=FieldData.XMin:FieldData.CoordMesh:FieldData.XMax;
     1159        coord_y_proj=FieldData.YMin:FieldData.CoordMesh:FieldData.YMax;
     1160        end
     1161        [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
     1162        XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
     1163        YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
     1164    else% we use the existing grid from field cell #icell_grid
     1165        NbDim=NbDimArray(icell_grid);
     1166        AYName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection)
     1167        AXName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection)
     1168        ProjData.(AYName)=FieldData.(AYName); % new (projected ) y coordinates
     1169        ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates
     1170    end
     1171            ProjData.ListVarName={AYName,AXName};
     1172        ProjData.VarDimName={AYName,AXName};
     1173        ProjData.VarAttribute={[],[]};
     1174end
     1175   
    10371176%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1038 % LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
     1177% LOOP ON FIELD CELLS, PROJECT VARIABLES
    10391178% CellVarIndex=cells of variable index arrays
    10401179%ivar_new=0; % index of the current variable in the projected field
     
    10501189    end
    10511190    VarIndex=CellInfo{icell}.VarIndex;%  indices of the selected variables in the list FieldData.ListVarName
    1052 %     ivar_U=[];ivar_V=[];ivar_W=[];
    1053 %     if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
    1054 %         ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;
    1055 %         ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;
    1056 %     elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')
    1057 %         ivar_U=CellInfo{icell}.VarIndex_vector_x;
    1058 %         ivar_V=CellInfo{icell}.VarIndex_vector_y;
    1059 %     end
    1060 %     if isfield(CellInfo{icell},'VarIndex_vector_z')
    1061 %         ivar_W=CellInfo{icell}.VarIndex_vector_z;
    1062 %     end
     1191    %     ivar_U=[];ivar_V=[];ivar_W=[];
     1192    %     if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
     1193    %         ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;
     1194    %         ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;
     1195    %     elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')
     1196    %         ivar_U=CellInfo{icell}.VarIndex_vector_x;
     1197    %         ivar_V=CellInfo{icell}.VarIndex_vector_y;
     1198    %     end
     1199    %     if isfield(CellInfo{icell},'VarIndex_vector_z')
     1200    %         ivar_W=CellInfo{icell}.VarIndex_vector_z;
     1201    %     end
    10631202    %dimensions
    10641203    DimCell=FieldData.VarDimName{VarIndex(1)};
     
    12521391            Coord_x=[];
    12531392           
    1254             % find default mesh
    1255             for idim=1:NbDim %loop on space dimensions
    1256                 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
    1257                 ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension
    1258                 if ~isequal(ivar,0)%  a variable corresponds to the dimension #idim
    1259                     Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field
    1260                     if numel(Coord{idim})==2 %input array defined on a regular grid
    1261                         DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);
    1262                         Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));
    1263                     else
    1264                         DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field
    1265                         DCoord_min(idim)=min(DCoord);
    1266                         DCoord_max=max(DCoord);
    1267                         if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)
    1268                             msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim)  ' in proj_field.m'])
    1269                             return
    1270                         end
    1271                         test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity
    1272                     end
    1273                     test_direct(idim)=(DCoord_min(idim)>0);
    1274                 else  % no variable associated with the  dimension #idim, the coordinate value is set equal to the matrix index by default
    1275                     Coord_i_str=['Coord_' num2str(idim)];
    1276                     DCoord_min(idim)=1;%default
    1277                     Coord{idim}=[0.5 DimValue(idim)-0.5];
    1278                     test_direct(idim)=1;
    1279                 end
    1280             end
    1281             if isempty(DY)
    1282                 DY=abs(DCoord_min(NbDim-1));
    1283             end
    1284             npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
    1285             if isempty(DX)
    1286                 DX=abs(DCoord_min(NbDim));
    1287             end
    1288             npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol
    1289             for idim=1:NbDim
    1290                 if test_interp(idim)
    1291                     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
    1292                 end
    1293             end
    1294             Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);
    1295             test_direct_y=test_direct(NbDim-1);
    1296             Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);
    1297             test_direct_x=test_direct(NbDim);
    1298             DAX=DCoord_min(NbDim);
    1299             DAY=DCoord_min(NbDim-1);
    13001393           
    1301             % default bounds
    1302             minAX=min(Coord_x);
    1303             maxAX=max(Coord_x);
    1304             minAY=min(Coord_y);
    1305             maxAY=max(Coord_y);
    1306             xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes
    1307             ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
    1308             xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
    1309             ycor_new=-xcorner*sin_om+ycorner*cos_om;
    1310             if ~testXMax
    1311                 XMax=max(xcor_new);
    1312             end
    1313             if ~testXMin
    1314                 XMin=min(xcor_new);
    1315             end
    1316             if ~testYMax
    1317                 YMax=max(ycor_new);
    1318             end
    1319             if ~testYMin
    1320                 YMin=min(ycor_new);
    1321             end
    1322             DXinit=(maxAX-minAX)/(DimValue(NbDim)-1);
    1323             DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);
    1324             if DX==0
    1325                 DX=DXinit;
    1326             end
    1327             if DY==0
    1328                 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);
    1337             end
     1394           
     1395            %             % default bounds
     1396            %             minAX=min(Coord_x);
     1397            %             maxAX=max(Coord_x);
     1398            %             minAY=min(Coord_y);
     1399            %             maxAY=max(Coord_y);
     1400            %             xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes
     1401            %             ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);
     1402            %             xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame
     1403            %             ycor_new=-xcorner*sin_om+ycorner*cos_om;
     1404            %             if ~testXMax
     1405            %                 XMax=max(xcor_new);
     1406            %             end
     1407            %             if ~testXMin
     1408            %                 XMin=min(xcor_new);
     1409            %             end
     1410            %             if ~testYMax
     1411            %                 YMax=max(ycor_new);
     1412            %             end
     1413            %             if ~testYMin
     1414            %                 YMin=min(ycor_new);
     1415            %             end
     1416            %             DXinit=(maxAX-minAX)/(DimValue(NbDim)-1);
     1417            %             DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);
     1418            %             if DX==0
     1419            %                 DX=DXinit;
     1420            %             end
     1421            %             if DY==0
     1422            %                 DY=DYinit;
     1423            %             end
     1424            %             if NbDim==3
     1425            %                 DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);
     1426            %                 if ~test_direct(1)
     1427            %                     DZ=-DZ;
     1428            %                 end
     1429            %                 Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
     1430            %                 test_direct_z=test_direct(1);
     1431            %             end
    13381432            %define new coordiantes if not already done by the definition of a projection grid
    13391433            if ~check_grid
    1340                 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection)
    1341                 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection)
    1342                 ListVarName=[ListVarName {AYName} {AXName}];% update the list of projected variables
    1343                 VarDimName=[VarDimName {AYName} {AXName}];% update the corresponding list of dimensions
    1344                 VarAttribute=[VarAttribute {[]} {[]}];% update the list of attributes
    1345                 ProjData.(AYName)=[YMin YMax]; % new (projected ) y coordinates
    1346                 ProjData.(AXName)=[XMin XMax]; % new (projected ) y coordinates
     1434               
     1435               
    13471436            end
    13481437           
     
    13701459                        VarAttribute=[VarAttribute FieldData.VarAttribute(VarIndex)];
    13711460                    end
     1461                   
    13721462                    ProjData.(AYName)=FieldData.(AYName);
    13731463                    ProjData.(AXName)=FieldData.(AXName);
     
    15401630                    eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']);
    15411631                end
    1542 %                 if ~isequal(Psi,0)
    1543 %                     eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']);
    1544 %                     eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']);
    1545 %                 end
     1632                %                 if ~isequal(Psi,0)
     1633                %                     eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']);
     1634                %                     eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']);
     1635                %                 end
    15461636            end
    15471637        end
     
    15521642% SubData.VarDimName={};
    15531643% SubData.VarAttribute={};
    1554 % check_remove=zeros(size(ProjData.ListVarName)); 
     1644% check_remove=zeros(size(ProjData.ListVarName));
    15551645% for iproj=1:numel(ProjData.VarAttribute)
    15561646%     if isfield(ProjData.VarAttribute{iproj},'CheckSub')&&isequal(ProjData.VarAttribute{iproj}.CheckSub,1)
     
    15601650%         SubData.VarAttribute=[SubData.VarAttribute ProjData.VarAttribute{iproj}];
    15611651%         SubData.(VarName)=ProjData.(VarName);
    1562 %         check_remove(iproj)=1;       
     1652%         check_remove(iproj)=1;
    15631653%     end
    15641654% end
     
    15691659%     ProjData.VarAttribute(ind_remove)=[];
    15701660%     ProjData=sub_field(ProjData,[],SubData);
    1571 % end   
     1661% end
    15721662
    15731663%-----------------------------------------------------------------
    1574 %projection in a volume
    1575  function  [ProjData,errormsg] = proj_volume(FieldData, ObjectData)
     1664%projection in a volume
     1665function  [ProjData,errormsg] = proj_volume(FieldData, ObjectData)
     1666
    15761667%-----------------------------------------------------------------
    15771668ProjData=FieldData;%default output
     
    15841675end
    15851676
    1586 %% rotation angles 
    1587 VolumeAngle=[0 0 0]; 
     1677%% rotation angles
     1678VolumeAngle=[0 0 0];
    15881679norm_plane=[0 0 1];
    15891680if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 3])&& ~isequal(ObjectData.Angle,[0 0 0])
  • trunk/src/read_civdata.m

    r651 r654  
    7373        switch FieldNames{ilist}
    7474            case{'U','V','norm(U,V)'}
     75                if ~strcmp(FieldNames{1},'vec(U,V)')% if the scalar is not used as color of vectors
    7576                ProjModeRequest='interp_lin';
     77                end
    7678            case {'curl(U,V)','div(U,V)','strain(U,V)'}
    7779                ProjModeRequest='interp_tps';
  • trunk/src/read_field.m

    r648 r654  
    4949        end
    5050    end
     51    check_colorvar=zeros(size(InputField));
    5152    if isfield(ParamIn,'ColorVar')
    5253        InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
    53         check_colorvar=1;
     54        check_colorvar(numel(InputField))=1;
    5455    end
    5556end
     
    7071        for ilist=1:numel(InputField)
    7172            r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
    72             if isempty(r)
     73            if isempty(r)%  no operator used
    7374                ListVar=[ListVar InputField(ilist)];
     75                if check_colorvar(ilist)
     76                                    Role{numel(ListVar)}='ancillary';% not projected with interpolation
     77                ProjModeRequest{numel(ListVar)}='';
     78                else
    7479                Role{numel(ListVar)}='scalar';
    7580                ProjModeRequest{numel(ListVar)}='interp_lin';%scalar field (requires interpolation for plot)
    76             else
     81                end
     82            else  % an operator 'vec' or 'norm' is used
    7783                ListVar=[ListVar {r.UName,r.VName}];
    7884                Role{numel(ListVar)}='vector_y';
    7985                Role{numel(ListVar)-1}='vector_x';
    80                             switch r.Operator
    81                                 case 'norm'
     86                      if ~check_colorvar(ilist) && strcmp(r.Operator,'norm')
    8287                                    ProjModeRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot)
    8388                                    ProjModeRequest{numel(ListVar)}='interp_lin';
    84                                 otherwise
     89                      else
    8590                                   ProjModeRequest{numel(ListVar)-1}='';
    8691                                   ProjModeRequest{numel(ListVar)}='';
    8792                            end
    8893            end
    89         end
    90         if check_colorvar
    91             Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)
    9294        end
    9395        if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array
  • trunk/src/series.m

    r651 r654  
    120120
    121121%% list of builtin functions in the mebu ActionName
    122 ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
     122ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
    123123NbBuiltinAction=numel(ActionList);
    124124[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
  • trunk/src/set_col_vec.m

    r517 r654  
    5353        maxC=max(vec_C);
    5454    end
    55     colcode_out.MinC=minC;
    56     colcode_out.MaxC=maxC;
     55    colcode_out.MinVec=minC;
     56    colcode_out.MaxVec=maxC;
    5757    if strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation
    5858        if  isfield(colcode,'ColCode1')
  • trunk/src/uvmat.m

    r651 r654  
    24182418%       abstime_1=[];
    24192419% end 
     2420set(handles.TimeValue,'String',num2str(abstime))
    24202421abstime_1=[];
    24212422TimeName_1=get(handles.TimeName_1,'String');
     
    24802481
    24812482%% analyse input field
    2482 [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
    2483 if ~isempty(errormsg)
    2484     errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
    2485     return
    2486 end
    2487 
    2488 NbDim=max(NbDimArray);% spatial dimension of the input field
    2489 imax=find(NbDimArray==NbDim);% indices of field cells to consider
    2490 if isfield(UvData.Field,'NbDim')
    2491     NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
    2492 end
    2493 
    2494 %% get bounds and mesh (needed  to propose default options for projection objects)
    2495 if NbDim>1
    2496     CoordMax=zeros(numel(imax),NbDim);
    2497     CoordMin=zeros(numel(imax),NbDim);
    2498     Mesh=zeros(1,numel(imax));
    2499     for ind=1:numel(imax)
    2500         if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
    2501             CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
    2502             CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
    2503             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
    2504             CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);
    2505             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
    2506         else
    2507             XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
    2508             YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
    2509             CoordMax(ind,NbDim)=max(max(UvData.Field.(XName)));
    2510             CoordMin(ind,NbDim)=min(min(UvData.Field.(XName)));
    2511             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName)));
    2512             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName)));
    2513             %         test_x=1;%test for unstructured coordinates
    2514             if NbDim==3
    2515                 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
    2516                 CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
    2517                 CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
    2518             end
    2519         end
    2520         switch CellInfo{imax(ind)}.CoordType
    2521            
    2522             case {'scattered','tps'} %unstructured coordinates
    2523                 NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
    2524                 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
    2525             case 'grid'%structured coordinate
    2526                 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
    2527                 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));               
    2528         end
    2529     end
    2530     UvData.Field.CoordMesh=min(Mesh);
    2531     UvData.Field.XMax=max(CoordMax(:,end));
    2532     UvData.Field.XMin=min(CoordMin(:,end));
    2533     UvData.Field.YMax=max(CoordMax(:,end-1));
    2534     UvData.Field.YMin=min(CoordMin(:,end-1));
    2535     if NbDim==3
    2536         UvData.Field.ZMax=max(CoordMax(ind,1));
    2537         UvData.Field.ZMin=max(CoordMin(ind,1));
    2538     end
    2539     % adjust the mesh to a value 1, 2 , 5 *10^n
    2540     ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude
    2541     if UvData.Field.CoordMesh/ord>=5
    2542         UvData.Field.CoordMesh=5*ord;
    2543     elseif UvData.Field.CoordMesh/ord>=2
    2544         UvData.Field.CoordMesh=2*ord;
    2545     else
    2546         UvData.Field.CoordMesh=ord;
    2547     end
     2483% [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
     2484% if ~isempty(errormsg)
     2485%     errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
     2486%     return
     2487% end
     2488%
     2489% NbDim=max(NbDimArray);% spatial dimension of the input field
     2490% imax=find(NbDimArray==NbDim);% indices of field cells to consider
     2491% if isfield(UvData.Field,'NbDim')
     2492%     NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
     2493% end
     2494%
     2495% %% get bounds and mesh (needed  to propose default options for projection objects)
     2496% if NbDim>1
     2497%     CoordMax=zeros(numel(imax),NbDim);
     2498%     CoordMin=zeros(numel(imax),NbDim);
     2499%     Mesh=zeros(1,numel(imax));
     2500%     for ind=1:numel(imax)
     2501%         if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
     2502%             CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
     2503%             CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
     2504%             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
     2505%             CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);
     2506%             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
     2507%         else
     2508%             XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
     2509%             YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
     2510%             CoordMax(ind,NbDim)=max(max(UvData.Field.(XName)));
     2511%             CoordMin(ind,NbDim)=min(min(UvData.Field.(XName)));
     2512%             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName)));
     2513%             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName)));
     2514%             %         test_x=1;%test for unstructured coordinates
     2515%             if NbDim==3
     2516%                 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
     2517%                 CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
     2518%                 CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
     2519%             end
     2520%         end
     2521%         switch CellInfo{imax(ind)}.CoordType
     2522%             
     2523%             case {'scattered','tps'} %unstructured coordinates
     2524%                 NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
     2525%                 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
     2526%             case 'grid'%structured coordinate
     2527%                 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
     2528%                 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));               
     2529%         end
     2530%     end
     2531%     UvData.Field.CoordMesh=min(Mesh);
     2532%     UvData.Field.XMax=max(CoordMax(:,end));
     2533%     UvData.Field.XMin=min(CoordMin(:,end));
     2534%     UvData.Field.YMax=max(CoordMax(:,end-1));
     2535%     UvData.Field.YMin=min(CoordMin(:,end-1));
     2536%     if NbDim==3
     2537%         UvData.Field.ZMax=max(CoordMax(ind,1));
     2538%         UvData.Field.ZMin=max(CoordMin(ind,1));
     2539%     end
     2540%     % adjust the mesh to a value 1, 2 , 5 *10^n
     2541%     ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude
     2542%     if UvData.Field.CoordMesh/ord>=5
     2543%         UvData.Field.CoordMesh=5*ord;
     2544%     elseif UvData.Field.CoordMesh/ord>=2
     2545%         UvData.Field.CoordMesh=2*ord;
     2546%     else
     2547%         UvData.Field.CoordMesh=ord;
     2548%     end
     2549if UvData.Field.NbDim>1
     2550    UvData.Field=find_field_bounds(UvData.Field);
    25482551    % default projection plane
    25492552    if isempty(UvData.ProjObject{1})
     
    25552558    end
    25562559    %% 3D case (menuvolume)
    2557     if NbDim==3% && UvData.NewSeries
     2560    if UvData.Field.NbDim==3% && UvData.NewSeries
    25582561        test_set_object=1;
    25592562        hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
     
    26072610
    26082611%% usual 1D (x,y) plots
    2609 if NbDim<=1
     2612if UvData.Field.NbDim<=1
    26102613    set(handles.Objects,'Visible','off')
    26112614    set(handles.ListObject_1_title,'Visible','off')
     
    27272730                view_field(ObjectData)
    27282731            else
     2732              %  ObjectData.VarAttribute{5}.Role='scalar';TODO    CORRECT
    27292733                [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
    27302734                if imap==1
     
    31553159        set(handles.FixVelType,'visible','off')
    31563160        set(handles.VelType,'Visible','off')
    3157         set(handles.VelType_1,'Visible','off')
     3161        %set(handles.VelType_1,'Visible','off')
    31583162       
    31593163        %read selection from get_field
     
    31633167        FieldList={};
    31643168        VecColorList={};
    3165         XName=GetFieldData.Coordinates.Coord_x;
    31663169        switch GetFieldData.FieldOption
    31673170            case 'vectors'
    31683171                UName=GetFieldData.PanelVectors.vector_x;
    31693172                VName=GetFieldData.PanelVectors.vector_y;
    3170                 XName=GetFieldData.Coordinates.Coord_x;
    31713173                YName={GetFieldData.Coordinates.Coord_y};
    31723174                CName=GetFieldData.PanelVectors.vec_color;
     
    31743176            case 'scalar'
    31753177                AName=GetFieldData.PanelScalar.scalar;
    3176                 XName=GetFieldData.Coordinates.Coord_x;
    31773178                YName={GetFieldData.Coordinates.Coord_y};
    31783179                FieldList={AName};
    31793180            case '1D plot'
    31803181                YName=GetFieldData.PanelOrdinate.ordinate;
    3181                 XName=GetFieldData.Coordinates.Coord_x;
    3182         end
     3182            case 'civdata...'%return to civdata from get_field
     3183               % [FieldList,VecColorList]=set_field_list('U','V','C');
     3184                set(handles.FieldName,'Value',2)
     3185                set(handles.FixVelType,'visible','on')
     3186                set(handles.VelType,'Visible','on')
     3187        end
     3188        if ~strcmp(GetFieldData.FieldOption,'civdata...')
     3189            XName=GetFieldData.Coordinates.Coord_x;
    31833190        TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
    31843191        if strcmp(TimeNameStr,'file index')
     
    32033210        UvData.FileType{1}='netcdf';
    32043211        set(handles.uvmat,'UserData',UvData)
     3212        end
    32053213        run0_Callback(hObject, eventdata, handles)
    32063214       
     
    40764084function num_MinVec_Callback(hObject, eventdata, handles)
    40774085%------------------------------------------------------------------------
    4078 max_vec_Callback(hObject, eventdata, handles)
     4086num_MaxVec_Callback(hObject, eventdata, handles)
    40794087
    40804088%------------------------------------------------------------------------
     
    52025210function MenuPIV_Callback(hObject, eventdata, handles)
    52035211    Param=read_param(handles);
    5204     Param.ActionName='civ_series';
    5205 series(Param)
     5212%     Param.ActionName='civ_series';
     5213hseries=series(Param);
     5214hhseries=guidata(hseries);
     5215ActionMenu=get(hhseries.ActionName,'String');
     5216index_action=find(strcmp('civ_series',ActionMenu));
     5217set(hhseries.ActionName,'Value',index_action);
     5218series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
     5219
    52065220
    52075221%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.