Ignore:
Timestamp:
Jan 23, 2015, 9:48:26 AM (9 years ago)
Author:
sommeria
Message:

testcivadded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/civ_input.m

    r854 r855  
    8383    set(handles.CheckThreshold,'Visible','on')
    8484    set(handles.CheckDeformation,'Value',0)% desactivate (work in progress)
    85     set(handles.CheckDecimal,'Value',0)% desactivate (work in progress)
     85    %set(handles.CheckDecimal,'Value',0)% desactivate (work in progress)
    8686end
    8787switch Param.Action.ActionName
     
    169169
    170170%% display the min and max indices for the whole file series
     171if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i)
     172    msgbox_uvmat('ERROR','REFRESH the input files in the GUI series')
     173     return
     174end
    171175MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image);
    172176MinIndex_i=Param.IndexRange.MinIndex_i(iview_image);
     
    281285    end
    282286else  %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed
    283     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) && ~isfield(Param.ActionInput,'ConfigSource')
    284         answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']);
    285         if strcmp(answer,'Yes')
     287    if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
     288            ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
     289%         answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']);
     290%         if strcmp(answer,'Yes')
    286291            for index = 1:min(ind_opening,5)
    287292                set(handles.(ListOptions{index}),'value',0)
     
    294299            end
    295300            checkrefresh=1;
    296         end
     301%         end
    297302    end
    298303    if ind_opening>=3
    299         set(handles.iterate,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
     304        set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
    300305    else
    301         set(handles.iterate,'Visible','off')
     306        set(handles.CheckCiv3,'Visible','off')
    302307    end
    303308end
     
    493498end
    494499if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3
    495     set(handles.iterate,'Visible','on')
    496 else
    497     set(handles.iterate,'Visible','off')
     500    set(handles.CheckCiv3,'Visible','on')
     501else
     502    set(handles.CheckCiv3,'Visible','off')
    498503end
    499504
     
    513518%------------------------------------------------------------------------
    514519
    515 ActionInput=read_GUI(handles.civ_input);
    516 
    517 %% correct inpput inconsistencies
     520ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input
     521
     522%% correct input inconsistencies
    518523if isfield(ActionInput,'Civ1')
    519524    checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0);
     
    531536end
    532537
     538%% correct mask or grid name for Windows system (replace '\' by '/')
     539if isfield(ActionInput,'Civ1')
     540    if isfield(ActionInput.Civ1,'Mask')
     541        ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/');
     542    end
     543    if isfield(ActionInput.Civ1,'Grid')
     544        ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/');
     545    end
     546end
     547if isfield(ActionInput,'Civ2')
     548    if isfield(ActionInput.Civ2,'Mask')
     549        ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/');
     550    end
     551    if isfield(ActionInput.Civ2,'Grid')
     552        ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/');
     553    end
     554end
     555
     556%% exit the GUI and close it
    533557handles.output.ActionInput=ActionInput;
    534 % correct mask or grid name for Windows system (replace '\' by '/')
    535 if isfield(handles.output.ActionInput,'Civ1')
    536     if isfield(handles.output.ActionInput.Civ1,'Mask')
    537         handles.output.ActionInput.Civ1.Mask=regexprep(handles.output.ActionInput.Civ1.Mask,'\','/');
    538     end
    539     if isfield(handles.output.ActionInput.Civ1,'Grid')
    540         handles.output.ActionInput.Civ1.Grid=regexprep(handles.output.ActionInput.Civ1.Grid,'\','/');
    541     end
    542 end
    543 if isfield(handles.output.ActionInput,'Civ2')
    544     if isfield(handles.output.ActionInput.Civ2,'Mask')
    545         handles.output.ActionInput.Civ2.Mask=regexprep(handles.output.ActionInput.Civ2.Mask,'\','/');
    546     end
    547     if isfield(handles.output.ActionInput.Civ2,'Grid')
    548         handles.output.ActionInput.Civ2.Grid=regexprep(handles.output.ActionInput.Civ2.Grid,'\','/');
    549     end
    550 end
    551558guidata(hObject, handles);% Update handles structure
    552559uiresume(handles.civ_input);
     
    16891696drawnow
    16901697if get(handles.TestCiv1,'Value')
    1691     set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch
    1692     [Data,Param.Civ1]=get_param_civ1(handles);
    1693     Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV
    1694     hview_field=view_field(Data); %view the image in the GUI view_field
     1698    set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 
     1699    %Param.Action.RUN=1;
     1700    Param.ActionInput=read_GUI(handles.civ_input);
     1701    par_civ=Param.ActionInput.Civ1;
     1702    [Data,ImageName_B]=get_param_civ1(handles);
     1703
     1704    %% create the figure view_field for image visualization
     1705    hview_field=view_field(Data); %view the image in the GUI view_field
    16951706    set(0,'CurrentFigure',hview_field)
    16961707    hhview_field=guihandles(hview_field);
     
    16981709    ViewData=get(hview_field,'UserData');
    16991710    ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
    1700     ViewData.PlotAxes.B=imread(Param.Civ1.ImageName_B);%store the second image in the UserData of the GUI view_field
    1701     ViewData.PlotAxes.X=Grid.Civ1_X; %keep the set of points in memeory
    1702     ViewData.PlotAxes.Y=Grid.Civ1_Y;
    1703     set(hview_field,'UserData',ViewData)
    1704     corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     1711    ViewData.PlotAxes.B=imread(ImageName_B);%store the second image in the UserData of the GUI view_field
     1712   
     1713    %% prepare measurement grid
     1714    if isfield(par_civ,'Grid')% grid points set as input
     1715            par_civ.Grid=dlmread(par_civ.Grid);
     1716            par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
     1717    else% automatic grid
     1718        minix=floor(par_civ.Dx/2)-0.5;
     1719        maxix=minix+par_civ.Dx*floor((size(Data.A,2)-1)/par_civ.Dx);
     1720        miniy=floor(par_civ.Dy/2)-0.5;
     1721        maxiy=minix+par_civ.Dy*floor((size(Data.A,1)-1)/par_civ.Dy);
     1722        [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy);
     1723        ViewData.PlotAxes.X=reshape(GridX,[],1);
     1724        ViewData.PlotAxes.Y=reshape(GridY,[],1);
     1725    end
     1726
     1727    set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
     1728   
     1729    %% look for a current figure for image correlation display
     1730    corrfig=findobj(allchild(0),'tag','corrfig');
    17051731    if isempty(corrfig)
    17061732        corrfig=figure;
     
    17081734        set(corrfig,'name','image correlation')
    17091735        set(corrfig,'DeleteFcn',{@closeview_field})%
    1710         % end
    17111736        set(handles.TestCiv1,'BackgroundColor',[1 0 0])
    17121737    else
     
    17331758function TestPatch1_Callback(hObject, eventdata, handles)
    17341759
    1735 if get(handles.TestPatch1,'Value')
    1736     if get(handles.CheckCiv1,'Value')
    1737         if ~get(handles.CheckFix1,'Value')
    1738             msgbox_uvmat('ERROR','perform FIX1 before testing Patch1')
    1739             return
    1740         end
    1741         set(handles.TestPatch1,'BackgroundColor',[1 1 0])
    1742         drawnow
    1743         [Data,Param.Civ1]=get_param_civ1(handles);
    1744         Param.Fix1=read_GUI(handles.Fix1);
    1745         [Data,errormsg]=civ_matlab(Param);% get the civ1 results
    1746         errormsg=struct2nc('test_civ1.nc',Data);
    1747         InputFile='test_civ1.nc';
    1748         if ~isempty(errormsg)
    1749             msgbox_uvmat('ERROR',['error in temporary file writing: ' errormsg])
    1750             return
    1751         end
    1752     else
    1753         hseries=findobj(allchild(0),'Tag','series');
    1754         hhseries=guidata(hseries);
    1755         InputTable=get(hhseries.InputTable,'Data');
    1756         if ~strcmp(InputTable{1,5},'.nc');
    1757             msgbox_uvmat('ERROR', 'To test patch, first perform Civ1 and Fix1, then open the resulting netcdf file with ''series''')
    1758             return
    1759         end
    1760         set(handles.TestPatch1,'BackgroundColor',[1 1 0])
    1761         drawnow       
    1762         ref_i=str2double(get(handles.ref_i,'String'));
    1763         if strcmp(get(handles.ref_j,'Visible'),'on')
    1764             ref_j=str2double(get(handles.ref_j,'String'));
    1765         else
    1766             ref_j=1;%default
    1767         end
    1768         PairString=get(hhseries.PairString,'Data');
    1769         [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString{1});
    1770         InputFile=fullfile_uvmat(InputTable{1,1},InputTable{1,2},InputTable{1,3},InputTable{1,5},InputTable{1,4},...
    1771             i1,i2,j1,j2);
    1772     end
    1773     Param=[];
    1774     Param.Patch1=read_GUI(handles.Patch1);
    1775     Param.Patch1.CivFile=InputFile;
    1776     SmoothingParam=(Param.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    1777     Data=nc2struct(InputFile);
     1760if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
     1761     set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to induicate activation
     1762     hseries=findobj(allchild(0),'Tag','series');
     1763     Param=read_GUI(hseries);
     1764     Param.Action.RUN=1;
     1765     Param.ActionInput=read_GUI(handles.civ_input);
     1766     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1767     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1768     
     1769     %% prepare Param for iterative Patch processing without input file reading
     1770     Param.Civ1_X=Data.Civ1_X;
     1771     Param.Civ1_Y=Data.Civ1_Y;
     1772     Param.Civ1_U=Data.Civ1_U;
     1773     Param.Civ1_V=Data.Civ1_V;
     1774     Param.Civ1_FF=Data.Civ1_FF;
     1775     Param=rmfield(Param,'InputTable');%desactivate input file reading
     1776    if isfield(Param.ActionInput,'Civ1')
     1777        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     1778    end
     1779    if isfield(Param.ActionInput,'Fix1')
     1780        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
     1781    end
     1782    SmoothingParam=(Param.ActionInput.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    17781783    NbGood=numel(find(Data.Civ1_FF==0));
    17791784    for irho=1:7
    1780         Param.Patch1.FieldSmooth=SmoothingParam(irho);
    1781         [Data,errormsg]=civ_matlab(Param);% get the grid of x, y positions set for PIV
     1785        Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
     1786        [Data,errormsg]= civ_series(Param);%apply the processing fct
    17821787        if ~isempty(errormsg)
    17831788            msgbox_uvmat('ERROR',errormsg)
     
    17941799    grid on
    17951800    legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)')
    1796     XLabel('smoothing parameter')
    1797     YLabel('smoothing effect')
     1801    xlabel('smoothing parameter')
     1802    ylabel('smoothing effect')
    17981803    set(handles.TestPatch1,'BackgroundColor',[1 0 0])
    17991804else
     
    20202025
    20212026%------------------------------------------------------------------------
    2022 function [Data,par_civ1]=get_param_civ1(handles)
     2027function [Data,ImageName_B]=get_param_civ1(handles)
    20232028
    20242029 ref_i=str2double(get(handles.ref_i,'String'));% read reference i index
     
    20682073 Data.nx=[1 size(Data.A,2)];
    20692074 Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly
    2070  par_civ1=read_GUI(handles.Civ1);
    2071  FileInfo=get_file_info(ImageName_A);
    2072  par_civ1.FileTypeA=FileInfo.FileType;
    2073  par_civ1.ImageWidth=size(Data.A,2);
    2074  par_civ1.ImageHeight=size(Data.A,1);
    2075  par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
    2076  par_civ1.FrameIndexA=num2str(i1);
    2077  par_civ1.FrameIndexB=num2str(i2);
    2078  par_civ1.ImageName_B=ImageName_B;
     2075% par_civ1=read_GUI(handles.Civ1);
     2076% FileInfo=get_file_info(ImageName_A);
     2077% par_civ1.FileTypeA=FileInfo.FileType;
     2078% par_civ1.ImageWidth=size(Data.A,2);
     2079% par_civ1.ImageHeight=size(Data.A,1);
     2080% par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
     2081% par_civ1.FrameIndexA=num2str(i1);
     2082% par_civ1.FrameIndexB=num2str(i2);
     2083% par_civ1.ImageName_B=ImageName_B;
    20792084
    20802085%------------------------------------------------------------------------
     
    21222127end
    21232128
    2124 % --- Executes on selection change in iterate.
    2125 function iterate_Callback(hObject, eventdata, handles)
     2129% --- Executes on selection change in CheckCiv3.
     2130function CheckCiv3_Callback(hObject, eventdata, handles)
    21262131   
    21272132%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.