Changeset 515 for trunk/src/uvmat.m


Ignore:
Timestamp:
Aug 15, 2012, 11:36:12 PM (12 years ago)
Author:
sommeria
Message:

improvement of calc-field and combination of two fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r512 r515  
    7070%                        (calc_tps.m)               calculate tps coefficients (for filter projection or spatial derivatives).
    7171%                            |
    72 %                       (calc_field.m)               calculate field
    73 %                            |
    7472%                       UvData.Field-------------->histogram
    7573%               _____________|____________
    7674%              |                          |                   
    77 %        proj_field.m               proj_field.m       project the field on the projection objects              
     75%        proj_field.m               proj_field.m       project the field on the projection objects (use calc_field.m)           
    7876%              |                          |
    7977%         UvData.PlotAxes          ViewData.PlotAxes (on view_field)
    8078%              |                          |
    8179%       plot_field.m (uvmat)       plot_field.m (view_field)      plot the projected fields
    82 %
    83 % rmq: calc_field can be performed instead at the level of proj_field when needed
    8480%
    8581%
     
    209205
    210206%% TRANSFORM menu: builtin fcts
    211 transform_menu={'';'phys';'px';'phys_polar'};
     207transform_menu={'';'sub_field';'phys';'phys_polar'};
    212208UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions
    213209path_list=(num2cell(blanks(UvData.OpenParam.NbBuiltin)))';%initialize a cell array of nbvar blanks
     
    299295
    300296%% plot input field if exists
    301 if testinputfield
    302     %delete drawn objects
    303     hother=findobj(handles.PlotAxes,'Tag','proj_object');%find all the proj objects
    304     for iobj=1:length(hother)
    305         delete_object(hother(iobj))
    306     end 
    307     if isempty(inputfile)
    308         errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
    309         set(handles.MenuTools,'Enable','on')
    310         set(handles.OBJECT_txt,'Visible','on')
    311         set(handles.edit_object,'Visible','on')
    312 %         set(handles.ListObject_1,'Visible','on')
    313         set(handles.frame_object,'Visible','on')
    314         if ~isempty(errormsg)
    315             msgbox_uvmat('ERROR',errormsg)
    316         end
    317     end
    318 end
     297% if testinputfield
     298%     %delete drawn objects
     299%     hother=findobj(handles.PlotAxes,'Tag','proj_object');%find all the proj objects
     300%     for iobj=1:length(hother)
     301%         delete_object(hother(iobj))
     302%     end 
     303%     if isempty(inputfile)
     304%         errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
     305%         set(handles.MenuTools,'Enable','on')
     306%         set(handles.OBJECT_txt,'Visible','on')
     307%         set(handles.edit_object,'Visible','on')
     308% %         set(handles.ListObject_1,'Visible','on')
     309%         set(handles.frame_object,'Visible','on')
     310%         if ~isempty(errormsg)
     311%             msgbox_uvmat('ERROR',errormsg)
     312%         end
     313%     end
     314% end
    319315
    320316set_vec_col_bar(handles) %update the display of color code for vectors
     
    679675            set(handles.j1,'String',num2stra(j1,NomType));
    680676            set(handles.j2,'String',num2stra(j2,NomType));
    681         else %read the current field index if the second file series is opened
    682             i1=str2num(get(handles.i1,'String'));
    683             i2=str2num(get(handles.i2,'String'));
    684             j1=stra2num(get(handles.j1,'String'));
    685             j2=stra2num(get(handles.j2,'String'));
     677        else %read the current field index to synchronise with the first series
     678            i1_s=str2num(get(handles.i1,'String'));
     679            i2_0=str2num(get(handles.i2,'String'));
     680            if ~isempty(i2_0)
     681                i2_s=i2_0;
     682            else
     683               i2_s=i2;
     684            end
     685            j1_0=stra2num(get(handles.j1,'String'));
     686            if ~isempty(j1_0)
     687                j1_s=j1_0;
     688            else
     689                j1_s=j1;
     690            end
     691            j2_0=stra2num(get(handles.j2,'String'));
     692            if ~isempty(j2_0)
     693                j2_s=j2_0;
     694            else
     695                j2_s=j2;
     696            end
    686697        end
    687698       
     
    705716            end
    706717            %updtate the indices of the second field series to correspond to the newly opened one
    707             FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2);
     718            FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
    708719            if exist(FileName_1,'file')
     720                FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s);
     721            else
    709722                FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2);
    710                 set(handles.FileIndex_1,'String',FileIndex_1)
    711             else
    712723                msgbox_uvmat('WARNING','unable to synchronise the indices of the two series')
    713724            end
     725            set(handles.FileIndex_1,'String',FileIndex_1)
    714726        end
    715727       
     
    757769% --- Update information about a new field series (indices to scan, timing,
    758770%     calibration from an xml file, then refresh current plots
     771
    759772function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index)
    760773%------------------------------------------------------------------------
     
    943956        end
    944957        if ~get(handles.CheckFixLimits,'Value')
    945             set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
     958            set(handles.transform_fct,'Value',3); % phys transform by default if fixedLimits is off
    946959        end
    947960        if isfield(GeometryCalib,'SliceCoord')           
     
    10141027    end
    10151028end
    1016 [ref_j,ref_i]=find(i1_series);
     1029[ref_j,ref_i]=find(squeeze(i1_series(1,:,:)));
    10171030if ~isempty(j1_series)
    10181031        state_j='on';
    10191032        if index==1
    1020             if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first vzlue
     1033            if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value
    10211034                scan_option='j'; %scan j indext               
    10221035            end
     
    10571070
    10581071%% apply the effect of the transform fct and view the field 
     1072transform=get(handles.path_transform,'UserData');
     1073if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3)
     1074    set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
     1075end
    10591076transform_fct_Callback([],[],handles)
    1060 %run0_Callback([],[], handles); %view field
    10611077mask_test=get(handles.CheckMask,'value');
    10621078if mask_test
     
    11061122function i1_Callback(hObject, eventdata, handles)
    11071123%------------------------------------------------------------------------
    1108 set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
     1124update_ij(handles,1)
     1125
     1126%------------------------------------------------------------------------
     1127function i2_Callback(hObject, eventdata, handles)
     1128%------------------------------------------------------------------------
     1129update_ij(handles,2)
     1130
     1131%------------------------------------------------------------------------
     1132function j1_Callback(hObject, eventdata, handles)
     1133%------------------------------------------------------------------------
     1134update_ij(handles,3)
     1135
     1136%------------------------------------------------------------------------
     1137function j2_Callback(hObject, eventdata, handles)
     1138%------------------------------------------------------------------------
     1139update_ij(handles,4)
     1140
     1141%------------------------------------------------------------------------
     1142%--- update the index display after action on edit boxes i1, i2, j1 or j2
     1143function update_ij(handles,index_rank)
    11091144NomType=get(handles.NomType,'String');
    1110 i1=stra2num(get(handles.i1,'String'));
    1111 i2=stra2num(get(handles.i2,'String'));
    1112 j1=stra2num(get(handles.j1,'String'));
    1113 j2=stra2num(get(handles.j2,'String'));
    1114 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    1115 %indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
     1145indices=get(handles.FileIndex,'String');
     1146[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex
     1147switch index_rank
     1148    case 1
     1149        indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
     1150        set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1151    case 2
     1152        indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
     1153        set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1154    case 3
     1155        indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
     1156        set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1157    case 4
     1158        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
     1159        set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1160end
    11161161set(handles.FileIndex,'String',indices)
    1117 set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
    1118 if get(handles.SubField,'Value')==1
     1162set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1163% update the second index if relevant
     1164if strcmp(get(handles.FileIndex_1,'Visible'),'on')
    11191165    NomType_1=get(handles.NomType_1,'String');
    1120     indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    1121      %indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
    1122      set(handles.FileIndex_1,'String',indices)
    1123      set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
    1124 end
    1125 
    1126 %------------------------------------------------------------------------
    1127 function i2_Callback(hObject, eventdata, handles)
    1128 %------------------------------------------------------------------------
    1129 set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
    1130 i1_Callback(hObject, eventdata, handles)
    1131 
    1132 %------------------------------------------------------------------------
    1133 function j1_Callback(hObject, eventdata, handles)
    1134 %------------------------------------------------------------------------
    1135 set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
    1136 i1_Callback(hObject, eventdata, handles)
    1137 
    1138 %------------------------------------------------------------------------
    1139 function j2_Callback(hObject, eventdata, handles)
    1140 %------------------------------------------------------------------------
    1141 set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
    1142 i1_Callback(hObject, eventdata, handles)
     1166    indices_1=get(handles.FileIndex_1,'String');
     1167    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(indices_1);% the indices for the second series taken from FileIndex_1
     1168    switch index_rank
     1169        case 1
     1170            indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1);
     1171        case 2
     1172            indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1);
     1173        case 3
     1174            indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1);
     1175        case 4
     1176            indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String')));
     1177    end
     1178    set(handles.FileIndex_1,'String',indices_1)
     1179    set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1180end
     1181   
     1182%------------------------------------------------------------------------
    11431183
    11441184%------------------------------------------------------------------------
     
    15231563if sub_value % a second input file has been entered
    15241564     [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles);   
    1525     [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);
     1565    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1
    15261566else
    15271567    filename_1=[];
     
    15291569
    15301570%% increment (or decrement) the field indices and update the input filename(s)
    1531 CheckSearch=0;
    15321571if isempty(increment)
    1533     CheckSearch=1;% search for the next available file
    15341572    set(handles.CheckFixPair,'Value',0)
    15351573end
     
    15451583            i2_1=i2_1+increment;
    15461584        end
     1585       
    15471586    else % case of scanning along index j (burst numbers)
    15481587        j1=j1+increment;
     
    16041643    if ~isempty(errormsg),return,end
    16051644    siz=size(UvData.i1_series{1});
    1606     ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1);   
     1645    ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1);
    16071646    i1_subseries=UvData.i1_series{1}(ref_indices);
    16081647    ref_indices=ref_indices(i1_subseries>0);
    16091648    if isempty(ref_indices)% case of pairs (free index i)
    1610         ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); 
     1649        ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2);
    16111650        i1_subseries=UvData.i1_series{1}(ref_indices);
    16121651        ref_indices=ref_indices(i1_subseries>0);
     
    16231662    if ~isempty(UvData.j2_series{1})
    16241663        j2=UvData.j2_series{1}(ref_indices(end));
    1625     end 
    1626     % case of a second file series (TODO:revise)
    1627     if numel(UvData.i1_series)>=2
    1628         i1_subseries=UvData.i1_series{2}(ref_i+1,ref_j+1,:);
    1629         i1_subseries=i1_subseries(i1_subseries>0);
    1630         i1_1=i1_subseries(end);
     1664    end
     1665   
     1666    % case of a second file series
     1667    if sub_value
     1668        ref_i_1=i1_1;
     1669        if ~isempty(i2_1)
     1670            ref_i_1=floor((i1_1+i2_1)/2);% current reference index i
     1671        end
     1672        ref_j_1=1;
     1673        if ~isempty(j1_1)
     1674            ref_j_1=j1_1;
     1675            if ~isempty(j2_1)
     1676                ref_j_1=floor((j1_1+j2_1)/2);% current reference index j
     1677            end
     1678        end
     1679        if ~isempty(increment)
     1680            if get(handles.scan_i,'Value')==1% case of scanning along index i
     1681                ref_i_1=ref_i_1+increment;% increment the current reference index i
     1682            else % case of scanning along index j (burst numbers)
     1683                ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used
     1684            end
     1685        else % free increment, synchronise the ref indices with the first series
     1686            ref_i_1=ref_i;
     1687            ref_j_1=ref_j;
     1688        end
     1689        if numel(UvData.i1_series)==1
     1690            UvData.i1_series{2}=UvData.i1_series{1};
     1691            UvData.j1_series{2}=UvData.j1_series{1};
     1692            UvData.i2_series{2}=UvData.i2_series{1};
     1693            UvData.j2_series{2}=UvData.j2_series{1};
     1694        end
     1695        if ref_i_1<0
     1696            errormsg='minimum i index reached';
     1697        elseif ref_j_1<0
     1698            errormsg='minimum j index reached';
     1699        elseif ref_i_1+1>size(UvData.i1_series{2},3)
     1700            errormsg='maximum i index reached for the second series (reload the input file to update the index bound)';
     1701        elseif ref_j_1+1>size(UvData.i1_series{2},2)
     1702            errormsg='maximum j index reached for the second series(reload the input file to update the index bound)';
     1703        end
     1704        if ~isempty(errormsg),return,end
     1705        siz=size(UvData.i1_series{2});
     1706        ref_indices=ref_i_1*siz(1)*siz(2)+ref_j_1*siz(1)+1:ref_i_1*siz(1)*siz(2)+(ref_j_1+1)*siz(1);
     1707        i1_subseries=UvData.i1_series{2}(ref_indices);
     1708        ref_indices=ref_indices(i1_subseries>0);
     1709        if isempty(ref_indices)% case of pairs (free index i)
     1710            ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2);
     1711            i1_subseries=UvData.i1_series{2}(ref_indices);
     1712            ref_indices=ref_indices(i1_subseries>0);
     1713        end
     1714        i1_1=UvData.i1_series{2}(ref_indices(end));
    16311715        if ~isempty(UvData.i2_series{2})
    1632             i2_subseries=UvData.i2_series{2}(ref_i+1,ref_j+1,:);
    1633             i2_subseries=i2_subseries(i2_subseries>0);
    1634             i2_1=i2_subseries(end);
     1716            i2_1=UvData.i2_series{2}(ref_indices(end));
    16351717        end
    16361718        if ~isempty(UvData.j1_series{2})
    1637             j1_subseries=UvData.j1_series{2}(ref_i+1,ref_j+1,:);
    1638             j1_subseries=j1_subseries(j1_subseries>0);
    1639             j1_1=j1_subseries(end);
     1719            j1_1=UvData.j1_series{2}(ref_indices(end));
    16401720        end
    16411721        if ~isempty(UvData.j2_series{2})
    1642             j2_subseries=UvData.j2_series{2}(ref_i+1,ref_j+1,:);
    1643             j2_subseries=j2_subseries(j2_subseries>0);
    1644             j2_1=j2_subseries(end);
    1645         end
     1722            j2_1=UvData.j2_series{1}(ref_indices(end));
     1723        end   
     1724    else% the second series (if needed) is the same file as the first
     1725        i1_1=i1;
     1726        i2_1=i2;
     1727        j1_1=j1;
     1728        j2_1=j2;
    16461729    end
    16471730end
     
    16521735
    16531736%% refresh plots
    1654 errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
     1737errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);
    16551738
    16561739%% update the index counters if the index move is successfull
     
    18461929set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
    18471930drawnow
    1848 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    1849 filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    1850 filename_1=[];%default
     1931[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     1932filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
     1933filename_1='';%default
     1934FileIndex_1='';
    18511935if get(handles.SubField,'Value')
    1852     [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    1853     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     1936    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
     1937    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    18541938end
    18551939num_i1=stra2num(get(handles.i1,'String'));
     
    18571941num_j1=stra2num(get(handles.j1,'String'));
    18581942num_j2=stra2num(get(handles.j2,'String'));
    1859 
    1860 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
     1943[tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);
     1944
     1945errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    18611946
    18621947if ~isempty(errormsg)
     
    18831968% Field: structure describing an optional input field (then replace the input file)
    18841969
    1885 function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,Field)
     1970function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1)
    18861971%------------------------------------------------------------------------
    18871972
     
    19232008if length(masknumber)>=z_index
    19242009    set(handles.masklevel,'Value',z_index)
     2010end
     2011
     2012%% test for need of tps
     2013check_proj_tps=0;
     2014if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
     2015    for iobj=1:numel(UvData.Object)
     2016        if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
     2017            check_proj_tps=1;
     2018            break
     2019        end
     2020    end
    19252021end
    19262022
     
    19772073ParamIn.VelType=VelType;
    19782074ParamIn.GUIName='get_field';
     2075end
     2076check_tps=0;         
     2077if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...')
     2078       check_tps=1;%tps needed to get the requested field
    19792079end
    19802080[Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
     
    20302130            ParamIn_1=UvData.MovieObject{2};
    20312131                        if ~strcmp(NomType_1,'*')
    2032                 frame_index_1=num_j1;%frame index for movies or multimage
     2132                frame_index_1=j1_1;%frame index for movies or multimage
    20332133            else
    2034                 frame_index_1=num_i1;
     2134                frame_index_1=i1_1;
    20352135            end 
    20362136         case 'multimage'
    20372137            if ~strcmp(NomType_1,'*')
    2038                 frame_index_1=num_j1;%frame index for movies or multimage
     2138                frame_index_1=j1_1;%frame index for movies or multimage
    20392139            else
    2040                 frame_index_1=num_i1;
     2140                frame_index_1=i1_1;
    20412141            end   
    20422142        case 'vol' %TODO: update
     
    20552155    end
    20562156    test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
    2057     if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
    2058         if isfield(UvData,'FileName_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
    2059             test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
    2060         end
     2157    if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1')
     2158           test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1);
    20612159    end
    20622160    if test_keepdata_1
     
    20682166        ParamIn_1.VelType=VelType_1;
    20692167        ParamIn_1.GUIName='get_field_1';
    2070         end
     2168        end 
    20712169        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1);
    20722170        if ~isempty(errormsg)
    20732171            errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg];
    20742172            return
     2173        end
     2174        if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))...
     2175                &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
     2176            if ~check_proj_tps
     2177             %   Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
     2178            end
    20752179        end
    20762180    end
     
    21302234        test_veltype_1=1;
    21312235        set(handles.VelType_1,'Visible','on')
    2132         menu=set_veltype_display(ParamOut_1.CivStage);
     2236        menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2});
    21332237        index_menu=strcmp(ParamOut_1.VelType,menu);
    21342238        set(handles.VelType_1,'Value',1+find(index_menu,1))
     
    22192323    end
    22202324    if numel(UvData.XmlData)==2
    2221         [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
    2222         if isempty(num_i2)
    2223             num_i2=num_i1;
    2224         end
    2225         if isempty(num_j1)
    2226             num_j1=1;
    2227         end
    2228         if isempty(num_j2)
    2229             num_j2=num_j1;
     2325        if isempty(i2_1)
     2326            i2_1=num_i1;
     2327        end
     2328        if isempty(j1_1)
     2329            j1_1=1;
     2330        end
     2331        if isempty(j2_1)
     2332            j2_1=j1_1;
    22302333        end
    22312334        siz=size(UvData.XmlData{2}.Time);
    2232         if ~isempty(num_i1) && siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
    2233             abstime_1=(UvData.XmlData{2}.Time(num_i1,num_j1)+UvData.XmlData{2}.Time(num_i2,num_j2))/2;%overset the time read from files
    2234             Field{2}.Dt=(UvData.XmlData{2}.Time(num_i2,num_j2)-UvData.XmlData{2}.Time(num_i1,num_j1));
     2335        if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1)
     2336            abstime_1=(UvData.XmlData{2}.Time(i1_1,j1_1)+UvData.XmlData{2}.Time(i2_1,j2_1))/2;%overset the time read from files
     2337            Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1));
    22352338        end
    22362339    end
     
    22642367%% apply coordinate transform or other user fct
    22652368transform=get(handles.path_transform,'UserData');
    2266 if ~isempty(transform)
     2369if isempty(transform)
     2370    UvData.Field=Field{1};
     2371else
    22672372    XmlData=[];%default
    22682373    XmlData_1=[];%default
     
    22942399end
    22952400
    2296 %% check whether tps is needed, then calculate tps coefficients if needed
    2297 check_proj_tps=0;
    2298 if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
    2299     for iobj=1:numel(UvData.Object)
    2300         if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
    2301             check_proj_tps=1;
    2302             break
    2303         end
    2304     end
    2305 end
    2306 check_tps=0;         
    2307 if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamOut.FieldName,'velocity')&&~strcmp(ParamOut.FieldName,'get_field...')
    2308        check_tps=1;%tps needed to get the requested field
    2309 end
    2310 if (check_tps ||check_proj_tps)&&~isfield(UvData.Field,'Coord_tps')
    2311     UvData.Field=calc_tps(UvData.Field);
    2312 end
    2313 UvData.Field.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    2314 
    2315 %% calculate scalar
    2316 if isstruct(ParamOut)&&~strcmp(ParamOut.FieldName,'get_field...')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))...
    2317          &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut.FieldName,'get_field...')
    2318     if ~check_proj_tps
    2319         UvData.Field=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],UvData.Field);
    2320     end
    2321 end
    2322 if isstruct(ParamOut_1)&& numel(Field)==2 && ~strcmp(ParamOut_1.FieldName,'get_field...')&& ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))...
    2323         &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...')
    2324     if check_proj_tps
    2325         Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}];
    2326     else
    2327      Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
    2328     end
    2329 end
    2330 
     2401%% calculate tps coefficients if needed
     2402UvData.Field=calc_tps(UvData.Field,check_proj_tps);
    23312403
    23322404%% analyse input field
     
    29423014    end
    29433015    set(handles.uvmat,'UserData',UvData);
    2944     run0_Callback(hObject, eventdata, handles); %run
     3016    transform_fct_list=get(handles.transform_fct,'String');
     3017    transform_fct=transform_fct_list(get(handles.transform_fct,'Value'));
     3018    if strcmp(transform_fct,'sub_field')
     3019        set(handles.transform_fct,'Value',1)%suppress the sub_field transform
     3020        transform_fct_Callback(hObject, eventdata, handles);
     3021    else
     3022        run0_Callback(hObject, eventdata, handles)
     3023    end 
    29453024else
    29463025    MenuBrowse_1_Callback(hObject, eventdata, handles)
     
    31143193FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    31153194[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    3116 % set(handles.FileIndex_1,'Visible','on')
    3117 % set(handles.FileExt_1,'Visible','on')
    31183195switch field_1
    31193196    case 'get_field...'
     
    31283205        set(hhget_field.list_fig,'Value',1)
    31293206        set(hhget_field.list_fig,'String',{'uvmat'})
    3130 %         set(handles.transform_fct,'Value',1)% no transform by default
    3131 %         set(handles.path_transform,'String','')
    31323207        if check_new
    31333208            UvData.FileType{2}=UvData.FileType{1};
    31343209            set(handles.FileIndex_1,'String',get(handles.FileIndex,'String'))
    3135 %             set(handles.FileExt_1,'String',get(handles.FileExt,'String'))
    31363210              set(handles.uvmat,'UserData',UvData)
    31373211        end
     
    32393313
    32403314%------------------------------------------------------------------------
    3241 % --- Executes on button press in VelType_1.
     3315% --- Executes on choice selection in VelType_1.
    32423316function VelType_1_Callback(hObject, eventdata, handles)
    32433317%------------------------------------------------------------------------
    32443318set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
    32453319UvData=get(handles.uvmat,'UserData');
    3246 %refresh field with a second FileName=first file name
    3247 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
     3320set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation
    32483321drawnow   
    3249 InputFile=read_GUI(handles.InputFile);
    3250 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    3251 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3252 
     3322InputFile=read_GUI(handles.InputFile);% read the input file parameters
     3323[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     3324[RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
     3325FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file
     3326
     3327check_refresh=0;
    32533328if isempty(InputFile.VelType_1)
    3254         FileName_1='';% we plot the current field without the second field
     3329        FileName_1='';% we plot the first input field without the second field
    32553330        set(handles.SubField,'Value',0)
    3256         SubField_Callback(hObject, eventdata, handles)
     3331        SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field
    32573332elseif get(handles.SubField,'Value')% if subfield is already 'on'
    3258       [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    3259      FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
    3260 else
    3261      FileName_1=FileName;% we compare two fields in the same file by default
     3333     FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file
     3334     check_refresh=1;%will refresh the current display
     3335else% we introduce the same file (with a different field) for the second series
     3336     FileName_1=FileName;% we compare two fields in the same file
    32623337     UvData.FileType{2}=UvData.FileType{1};
     3338     UvData.XmlData{2}= UvData.XmlData{1};
    32633339     set(handles.SubField,'Value',1)
    3264 end
    3265 if isfield(UvData,'Field_1')
    3266     UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists
    3267 end
    3268 UvData.FileName_1='';% desactivate the use of a constant second file
    3269 set(handles.uvmat,'UserData',UvData)
    3270 num_i1=stra2num(get(handles.i1,'String'));
    3271 num_i2=stra2num(get(handles.i2,'String'));
    3272 num_j1=stra2num(get(handles.j1,'String'));
    3273 num_j2=stra2num(get(handles.j2,'String'));
    3274 
    3275 errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2);
    3276 
    3277 if ~isempty(errormsg)
    3278     msgbox_uvmat('ERROR',errormsg);
    3279 else
    3280     set(handles.i1,'BackgroundColor',[1 1 1])
    3281     set(handles.i2,'BackgroundColor',[1 1 1])
    3282     set(handles.j1,'BackgroundColor',[1 1 1])
    3283     set(handles.j2,'BackgroundColor',[1 1 1])
    3284     set(handles.FileIndex,'BackgroundColor',[1 1 1])
    3285     set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
    3286 end
    3287 set(handles.run0,'BackgroundColor',[1 0 0])
     3340     transform=get(handles.path_transform,'UserData');
     3341     if (~isa(transform,'function_handle')||nargin(transform)<3)
     3342        set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
     3343        transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display
     3344     else
     3345         check_refresh=1;
     3346     end 
     3347end
     3348
     3349% refresh the current display if it has not been done previously
     3350if check_refresh
     3351    UvData.FileName_1='';% desactivate the use of a constant second file
     3352    set(handles.uvmat,'UserData',UvData)
     3353    num_i1=stra2num(get(handles.i1,'String'));
     3354    num_i2=stra2num(get(handles.i2,'String'));
     3355    num_j1=stra2num(get(handles.j1,'String'));
     3356    num_j2=stra2num(get(handles.j2,'String'));
     3357    [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]);
     3358    errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
     3359    if ~isempty(errormsg)
     3360        msgbox_uvmat('ERROR',errormsg);
     3361    else
     3362        set(handles.i1,'BackgroundColor',[1 1 1])
     3363        set(handles.i2,'BackgroundColor',[1 1 1])
     3364        set(handles.j1,'BackgroundColor',[1 1 1])
     3365        set(handles.j2,'BackgroundColor',[1 1 1])
     3366        set(handles.FileIndex,'BackgroundColor',[1 1 1])
     3367        set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
     3368    end
     3369    set(handles.run0,'BackgroundColor',[1 0 0])
     3370end
    32883371
    32893372%-----------------------------------------------
     
    36053688
    36063689%% refresh the current plot
    3607 run0_Callback(hObject, eventdata, handles)
    3608 
    3609 
     3690if isempty(list_path{ichoice}) || nargin(transform_handle)<3
     3691    set(handles.SubField,'Value',0)
     3692    SubField_Callback(hObject, eventdata, handles)
     3693else
     3694    run0_Callback(hObject, eventdata, handles)
     3695end
    36103696
    36113697%------------------------------------------------
     
    39614047%replot all the objects within the new projected field
    39624048for IndexObj=1:numel(list_str)
    3963     IndexObj
    3964         hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat
     4049        hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
    39654050        if isempty(hobject) || ~ishandle(hobject)
    3966             hobject=handles.PlotAxes
     4051            hobject=handles.PlotAxes;
    39674052        end
    39684053        if isequal(IndexObj,get(handles.ListObject,'Value'))
     
    41514236        data.Type='plane';
    41524237    end
    4153     if isfield(UvData,'Field')
    4154         Field=UvData.Field;
    4155         if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
    4156             data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    4157             if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
    4158                 data.RangeY=UvData.Field.Mesh;
    4159             else
    4160                 data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
    4161             end
    4162             data.DX=UvData.Field.Mesh;
    4163             data.DY=UvData.Field.Mesh;
    4164         end
    4165         if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
    4166             data.Coord=[0 0 0]; %default
    4167         end
    4168         if isfield(Field,'CoordUnit')
    4169             data.CoordUnit=Field.CoordUnit;
    4170         end
    4171     end
     4238%     if isfield(UvData,'Field')
     4239%         Field=UvData.Field;
     4240%         if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
     4241%             data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     4242%             if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
     4243%                 data.RangeY=UvData.Field.Mesh;
     4244%             else
     4245%                 data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     4246%             end
     4247%             data.DX=UvData.Field.Mesh;
     4248%             data.DY=UvData.Field.Mesh;
     4249%         end
     4250%         if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     4251%             data.Coord=[0 0 0]; %default
     4252%         end
     4253%         if isfield(Field,'CoordUnit')
     4254%             data.CoordUnit=Field.CoordUnit;
     4255%         end
     4256%     end
    41724257    hset_object=set_object(data,[],ZBounds);
    41734258    hhset_object=guidata(hset_object);
     
    42974382UvData=get(huvmat,'UserData');
    42984383%[xx,xx,FileBase]=read_file_boxes(handles);
    4299 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     4384[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    43004385FileBase=fullfile(RootPath,RootFile);
    43014386 %read the current input file name
     
    45874672pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
    45884673pos(2)=pos(2)-0.02;
    4589 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    4590 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4674[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     4675FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    45914676set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
    45924677if isfield(UvData.OpenParam,'CalOrigin')
     
    47204805
    47214806%prepare display of the set_grid GUI
    4722 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    4723 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4807[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     4808FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    47244809CoordList=get(handles.transform_fct,'String');
    47254810val=get(handles.transform_fct,'Value');
     
    47464831%------------------------------------------------------------------------
    47474832series; %first display of the GUI to fill waiting time
    4748 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    4749 param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4833[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     4834param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    47504835if isequal(get(handles.SubField,'Value'),1)
    4751     [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles);
    4752     FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1];
     4836    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
     4837    FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    47534838    if ~isequal(FileName_1,param.FileName)
    47544839        param.FileName_1=FileName_1;
     
    47884873function MenuPIV_Callback(hObject, eventdata, handles)
    47894874%------------------------------------------------------------------------
    4790  [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    4791  FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
     4875 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     4876 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    47924877civ(FileName);% interface de civ(not in the uvmat file)
    47934878
Note: See TracChangeset for help on using the changeset viewer.