Changeset 319 for trunk/src


Ignore:
Timestamp:
Dec 6, 2011, 8:14:57 PM (12 years ago)
Author:
sommeria
Message:

civ: bugs for displacement mode repaired
civ and civ_matlab prepared for batch in Matlab (file .civ.xml created)

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r317 r319  
    196196    browse=[];%initialisation
    197197else
    198     browse=get(handlesRootName,'UserData');
     198    browse=get(handles.RootName,'UserData');
    199199end
    200200browse.num_i1=num_i1;
     
    289289set(handles.num_Rho,'Value',1)
    290290set(handles.num_Rho,'String',{'1';'2'})
    291 set(handles.BATCH,'Enable','off')
     291% set(handles.BATCH,'Enable','off')
    292292
    293293% -----------------------------------------------------------------------
     
    345345num_ref_i=i1;%efaulmt ref index
    346346num_ref_j=j1;
     347browse=get(handles.RootName,'UserData');
    347348browse.incr_pair=[0 0];%default
    348349
     
    11801181                    cmd=[cmd...
    11811182                        cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n'];
     1183                    if ~isempty(errormsg)
     1184                        msgbox_uvmat('ERROR',errormsg)
     1185                        return
     1186                    end
    11821187                case 'CivAll'
    11831188                    CivAllCmd=[CivAllCmd ' civ1 '];
     
    14281433                drawnow
    14291434                if ~strcmp(compare,'stereo PIV')
    1430                     [Data,erromsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
    1431                     if isempty(errormsg)
    1432                         display([filecell.nc.civ1{ifile,j} ' written'])
     1435                    filename_xml=[OutputFile '.civ.xml'];
     1436                    t=struct2xml(Param);
     1437                    save(t,filename_xml)
     1438                    if batch   
     1439                        batch_file_list{length(batch_file_list)+1}=filename_xml;
    14331440                    else
    1434                         msgbox_uvmat('ERROR',errormsg)
    1435                     end                 
     1441                        [Data,erromsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
     1442                        if isempty(errormsg)
     1443                            display([filecell.nc.civ1{ifile,j} ' written'])
     1444                        else
     1445                            msgbox_uvmat('ERROR',errormsg)
     1446                        end
     1447                    end
    14361448                end
    14371449        end
     
    24712483%------------------------------------------------------------------------
    24722484test=get(handles.ListCompareMode,'Value');
    2473 if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV'
     2485if test==2 || test==3 % case 'displacement' or 'stereo PIV'
    24742486    filebase=get(handles.RootName,'String');
    2475     browse=get(handlesRootName,'Userdata');
     2487    browse=get(handles.RootName,'Userdata');
    24762488    browse.nom_type_ima1=browse.nom_type_ima;
    2477     set(handlesRootName,'UserData',browse);
     2489    set(handles.RootName,'UserData',browse);
    24782490    set(handles.sub_txt,'Visible','on')
    24792491    set(handles.RootName_1,'Visible','On');%mkes the second file input window visible
     
    25192531    [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name);
    25202532    set(handles.RootName_1,'String',RootFile);
    2521     browse=get(handlesRootName,'UserData');
     2533    browse=get(handles.RootName,'UserData');
    25222534    browse.nom_type_ima_1=nom_type;
    2523     set(handlesRootName,'UserData',browse)
     2535    set(handles.RootName,'UserData',browse)
    25242536   
    25252537    %check image extension
     
    25492561    set(handles.ListPairMode,'Value',1)
    25502562    set(handles.ListPairMode,'String',mode_store)
    2551     set(handles.test_stereo1,'Value',0)
     2563%     set(handles.test_stereo1,'Value',0)
    25522564    set(handles.CheckStereo,'Value',0)
    25532565    set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
    25542566end
    25552567if test==3 && get(handles.CheckPatch1,'Value')
    2556     set(handles.test_stereo1,'Visible','on')
    2557 else
    2558     set(handles.test_stereo1,'Visible','off')
     2568    set(handles.CheckStereo,'Visible','on')
     2569else
     2570    set(handles.CheckStereo,'Visible','off')
    25592571end
    25602572if test==3 && get(handles.CheckPatch2,'Value')
     
    25632575    set(handles.CheckStereo,'Visible','off')
    25642576end
    2565 mode_Callback(hObject, eventdata, handles)
     2577ListPairMode_Callback(hObject, eventdata, handles)
    25662578
    25672579
     
    27012713    displ_num(3,1)=0;
    27022714    displ_num(4,1)=0;
    2703     if nbfield > 1
     2715    if nbfield > 1 || nbfield==0
    27042716        set(handles.itext,'Visible','On')
    27052717        set(handles.first_i,'Visible','On')
     
    36563668
    36573669%% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame
    3658 PanelName=get(hparent,'tag')
     3670PanelName=get(hparent,'tag');
    36593671if strcmp(PanelName,'Civ1')
    36603672    hchildren=get(handles.Civ2,'children');
     
    40384050%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    40394051%changes : filename_cmx -> filename ( no extension )
     4052cmd='';
     4053errormsg=''; %default
    40404054filename=regexprep(filename,'.nc',''); %file name for the result
    40414055if isequal(Param.Civ1.Dt,'0')
     
    40454059Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'.png','');
    40464060fid=fopen([filename '.civ1.cmx'],'w');
     4061if isequal(fid,-1)
     4062    display(['cmd file ' filename ' cannot be created'])
     4063    return
     4064end
    40474065fprintf(fid,['##############   CMX file' '\n' ]);
    40484066fprintf(fid,   ['FirstImage ' regexprep(Param.Civ1.ImageA,'\\','\\\\') '\n' ]);% for windows compatibility
     
    43584376    Data.ListVarName={'ny','nx','A'};
    43594377    Data.VarDimName= {'ny','nx',{'ny','nx'}};
    4360 
    4361     Param=read_GUI(handles.civ)
    4362     Param.CheckOutputFile=0;
    4363     [Data,errormsg]=civ_matlab(Param,filecell.nc.civ1{1})% get the grid of x, y positions set for PIV
    4364     if ~isempty(errormsg)
    4365         msgbox_uvmat('ERROR',Data.Txt)
    4366         return
    4367     end
    4368     set(handles.TestCiv1,'BackgroundColor',[1 0 0])
     4378   
     4379    param_patch1=read_GUI(handles.Patch1);
     4380    param_patch1.CivFile=filecell.nc.civ1{1};
     4381    Param.Patch1=param_patch1;
     4382    for irho=1:7
     4383        [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV
     4384        if ~isempty(errormsg)
     4385            msgbox_uvmat('ERROR',Data.Txt)
     4386            return
     4387        end
     4388        SmoothingParam(irho)=Param.Patch1.SmoothingParam;
     4389        Data.Civ1_U_Diff=Data.Civ1_U_Diff(Data.Civ1_FF==0);
     4390        Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0);
     4391        DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff))
     4392        Param.Patch1.SmoothingParam=2*Param.Patch1.SmoothingParam;
     4393    end
     4394    figure
     4395    plot(SmoothingParam,DiffVel)
     4396    set(handles.TestPatch1,'BackgroundColor',[1 0 0])
    43694397else
    43704398    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     
    43724400        delete(corrfig)
    43734401    end
    4374     hview_field=findobj(allchild(0),'tag','view_field');% look for view_field   
     4402    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
    43754403    if ~isempty(hview_field)
    43764404        delete(hview_field)
  • trunk/src/civ_matlab.m

    r317 r319  
    4646check_patch1=0;%default
    4747
     48if ischar(Param)
     49    t=xmltree(Param);
     50    Param=convert(t);
     51end
     52
    4853%% Civ1
    4954if isfield (Param,'Civ1')
     
    6267    end
    6368    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];% {'Civ1_Time','Civ1_Dt'}];
    64 %     if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)
    65         Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
    66         Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
    67         Data.VarAttribute{1}.Role='coord_x';
    68         Data.VarAttribute{2}.Role='coord_y';
    69         Data.VarAttribute{3}.Role='vector_x';
    70         Data.VarAttribute{4}.Role='vector_y';
    71         Data.VarAttribute{5}.Role='warnflag';
     69    %     if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)
     70    Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
     71    Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
     72    Data.VarAttribute{1}.Role='coord_x';
     73    Data.VarAttribute{2}.Role='coord_y';
     74    Data.VarAttribute{3}.Role='vector_x';
     75    Data.VarAttribute{4}.Role='vector_y';
     76    Data.VarAttribute{5}.Role='warnflag';
    7277    Data.Civ1_X=reshape(xtable,[],1);
    7378    Data.Civ1_Y=reshape(Param.Civ1.ImageHeight-ytable+1,[],1);
     
    7782    Data.Civ1_F=reshape(F,[],1);
    7883    Data.CivStage=1;
    79 
     84   
    8085else
    81     Data=nc2struct(ncfile,'ListGlobalAttribute','absolut_time_T0') %look for the constant 'absolut_time_T0' to detect old civx data format
     86    if exist('ncfile','var')
     87        CivFile=ncfile;
     88    elseif isfield(Param.Patch1,'CivFile')
     89        CivFile=Param.Patch1.CivFile;
     90    end
     91    Data=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0') %look for the constant 'absolut_time_T0' to detect old civx data format
    8292    if isfield(Data,'Txt')
    83             errormsg=Data.Txt;
     93        errormsg=Data.Txt;
    8494        return
    8595    end
    8696    if ~isempty(Data.absolut_time_T0')%read civx file
    8797        check_civx=1;% test for old civx data format
    88         [Data,vardetect,ichoice]=nc2struct(ncfile);%read the variables in the netcdf file
     98        [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file
    8999    else
    90100        if isfield(Param,'Fix1')
    91             Data=nc2struct(ncfile,ListVarCiv1);%read civ1 data in the existing netcdf file
     101            Data=nc2struct(CivFile,ListVarCiv1);%read civ1 data in the existing netcdf file
    92102        else
    93             Data=nc2struct(ncfile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file
     103            Data=nc2struct(CivFile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file
    94104        end
    95105    end
    96 
    97106end
    98107
     
    296305
    297306%% write result in a netcdf file if requested
    298 if exist('ncfile','var') && ~(isfield(Param,'CheckOuputFile')&&Param.CheckOuputFile)
     307if exist('ncfile','var')
    299308    errormsg=struct2nc(ncfile,Data);
    300309end
     
    420429    iref=par_civ.Grid(ivec,1);% xindex on the image A for the middle of the correlation box
    421430    jref=par_civ.Grid(ivec,2);% yindex on the image B for the middle of the correlation box
    422 %     xtable(ivec)=iref;
    423 %     ytable(ivec)=jref;%default
     431    %     xtable(ivec)=iref;
     432    %     ytable(ivec)=jref;%default
    424433    if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask
    425         if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth
     434        if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth% we are outside the image
    426435            F(ivec)=3;
    427436        else
     
    434443                F(ivec)=3;
    435444            end
     445            %threshold on image maximum
     446            if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
     447                F(ivec)=3;
     448            end
    436449        end
    437         %threshold on image maximum
    438         if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
    439             F(ivec)=3;
    440         end
     450       
    441451        if F(ivec)~=3
    442452            image1_crop=image1_crop-image1_mean;%substract the mean
  • trunk/src/uvmat.m

    r316 r319  
    17691769NomType=get(handles.FileIndex,'UserData');
    17701770
    1771 num1=stra2num(get(handles.i1,'String'));
    1772 num2=stra2num(get(handles.i2,'String'));
    1773 num_a=stra2num(get(handles.j1,'String'));
    1774 num_b=stra2num(get(handles.j2,'String'));
     1771i1=stra2num(get(handles.i1,'String'));
     1772i2=stra2num(get(handles.i2,'String'));
     1773j1=stra2num(get(handles.j1,'String'));
     1774j2=stra2num(get(handles.j2,'String'));
    17751775
    17761776sub_value= get(handles.SubField,'Value');
    17771777if sub_value % a second input file has been entered
    17781778    [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
    1779     [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
    1780     num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
    1781     num2_1=stra2num(str2);
    1782     num_a_1=stra2num(str_a);
    1783     num_b_1=stra2num(str_b);
     1779    [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1);
     1780    i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices)
     1781    i2_1=stra2num(i2_1_str);
     1782    j1_1=stra2num(j1_1_str);
     1783    j2_1=stra2num(j2_1_str);
    17841784    NomType_1=get(handles.FileIndex_1,'UserData');
    17851785else
     
    17901790%case of scanning along the first direction (rootfile numbers)
    17911791if get(handles.scan_i,'Value')==1% case of scanning along index i   
    1792      num1=num1+increment;
    1793      num2=num2+increment;
    1794      [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
     1792     i1=i1+increment;
     1793     i2=i2+increment;
     1794     [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,subdir);
    17951795     if sub_value% set the second field name and indices
    1796         num1_1=num1_1+increment;
    1797         num2_1=num2_1+increment;
    1798         filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
     1796        i1_1=i1_1+increment;
     1797        i2_1=i2_1+increment;
     1798        filename_1=name_generator(filebase_1,i1_1,j1_1,FileExt_1,NomType_1,1,i2_1,j2_1,SubDir_1);
    17991799     end   
    18001800else % case of scanning along index j (burst numbers)
    1801     num_a=num_a+increment;
    1802     num_b=num_b+increment;
    1803     [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
     1801    j1=j1+increment;
     1802    j2=j2+increment;
     1803    [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,subdir);
    18041804    if sub_value
    1805         num_a_1=num_a_1+increment;
    1806         num_b_1=num_b_1+increment;
    1807         filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
     1805        j1_1=j1_1+increment;
     1806        j2_1=j2_1+increment;
     1807        filename_1=name_generator(filebase_1,i1_1,j1_1,FileExt_1,NomType_1,1,i2_1,j2_1,SubDir_1);
    18081808    end   
    18091809end
    18101810
    18111811% refresh plots
    1812 errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
     1812errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
    18131813if isempty(errormsg)  %update the index counters
    1814     set(handles.i1,'String',num2stra(num1,NomType,1));
    1815     if isequal(num2,num1)
    1816          set(handles.i2,'String','');
     1814    if strcmp(NomType,'*')%case of movies
     1815        set(handles.i1,'String',num2str(i1))%update the index display
    18171816    else
    1818         set(handles.i2,'String',num2stra(num2,NomType,1));
    1819     end
    1820     set(handles.j1,'String',num2stra(num_a,NomType,2));
    1821     if isequal(num_b,num_a)
    1822          set(handles.j2,'String','');
    1823     else
    1824         set(handles.j2,'String',num2stra(num_b,NomType,2));
    1825     end
    1826     [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
    1827     set(handles.FileIndex,'String',indices);
    1828     if ~isempty(filename_1)
    1829          indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
    1830          set(handles.FileIndex_1,'String',indices_1);
    1831     end
     1817        [~,~,i1_str,i2_str,j1_str,j2_str]=name2display(filename);
     1818        set(handles.i1,'String',i1_str)
     1819        set(handles.j1,'String',j1_str)
     1820        if ~isequal(movie_status,1)
     1821            set(handles.i2,'String',i2_str)
     1822            set(handles.j2,'String',j2_str)
     1823        end
     1824        [indices]=name_generator('',i1,j1,'',NomType,1,i2,j2,'');
     1825        set(handles.FileIndex,'String',indices);
     1826        if ~isempty(filename_1)
     1827            indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,'');
     1828            set(handles.FileIndex_1,'String',indices_1);
     1829        end
     1830    end
     1831    %     set(handles.i1,'String',num2stra(i1,NomType,1));
     1832    %     if isequal(i2,i1)
     1833    %          set(handles.i2,'String','');
     1834    %     else
     1835    %         set(handles.i2,'String',num2stra(num2,NomType,1));
     1836    %     end
     1837    %     set(handles.j1,'String',num2stra(j1,NomType,2));
     1838    %     if isequal(j2,j1)
     1839    %          set(handles.j2,'String','');
     1840    %     else
     1841    %         set(handles.j2,'String',num2stra(j2,NomType,2));
     1842    %     end
     1843   
    18321844    if isequal(movie_status,1)
    18331845        set(handles.movie_pair,'Value',1)
Note: See TracChangeset for help on using the changeset viewer.