Changeset 855 for trunk/src/series/civ_input.m
- Timestamp:
- Jan 23, 2015, 9:48:26 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_input.m
r854 r855 83 83 set(handles.CheckThreshold,'Visible','on') 84 84 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) 86 86 end 87 87 switch Param.Action.ActionName … … 169 169 170 170 %% display the min and max indices for the whole file series 171 if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i) 172 msgbox_uvmat('ERROR','REFRESH the input files in the GUI series') 173 return 174 end 171 175 MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image); 172 176 MinIndex_i=Param.IndexRange.MinIndex_i(iview_image); … … 281 285 end 282 286 else %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') 286 291 for index = 1:min(ind_opening,5) 287 292 set(handles.(ListOptions{index}),'value',0) … … 294 299 end 295 300 checkrefresh=1; 296 end301 % end 297 302 end 298 303 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. 300 305 else 301 set(handles. iterate,'Visible','off')306 set(handles.CheckCiv3,'Visible','off') 302 307 end 303 308 end … … 493 498 end 494 499 if 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') 501 else 502 set(handles.CheckCiv3,'Visible','off') 498 503 end 499 504 … … 513 518 %------------------------------------------------------------------------ 514 519 515 ActionInput=read_GUI(handles.civ_input); 516 517 %% correct inp put inconsistencies520 ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input 521 522 %% correct input inconsistencies 518 523 if isfield(ActionInput,'Civ1') 519 524 checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); … … 531 536 end 532 537 538 %% correct mask or grid name for Windows system (replace '\' by '/') 539 if 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 546 end 547 if 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 554 end 555 556 %% exit the GUI and close it 533 557 handles.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 end539 if isfield(handles.output.ActionInput.Civ1,'Grid')540 handles.output.ActionInput.Civ1.Grid=regexprep(handles.output.ActionInput.Civ1.Grid,'\','/');541 end542 end543 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 end547 if isfield(handles.output.ActionInput.Civ2,'Grid')548 handles.output.ActionInput.Civ2.Grid=regexprep(handles.output.ActionInput.Civ2.Grid,'\','/');549 end550 end551 558 guidata(hObject, handles);% Update handles structure 552 559 uiresume(handles.civ_input); … … 1689 1696 drawnow 1690 1697 if 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 1695 1706 set(0,'CurrentFigure',hview_field) 1696 1707 hhview_field=guihandles(hview_field); … … 1698 1709 ViewData=get(hview_field,'UserData'); 1699 1710 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'); 1705 1731 if isempty(corrfig) 1706 1732 corrfig=figure; … … 1708 1734 set(corrfig,'name','image correlation') 1709 1735 set(corrfig,'DeleteFcn',{@closeview_field})% 1710 % end1711 1736 set(handles.TestCiv1,'BackgroundColor',[1 0 0]) 1712 1737 else … … 1733 1758 function TestPatch1_Callback(hObject, eventdata, handles) 1734 1759 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); 1760 if 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 1778 1783 NbGood=numel(find(Data.Civ1_FF==0)); 1779 1784 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 PIV1785 Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); 1786 [Data,errormsg]= civ_series(Param);%apply the processing fct 1782 1787 if ~isempty(errormsg) 1783 1788 msgbox_uvmat('ERROR',errormsg) … … 1794 1799 grid on 1795 1800 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') 1798 1803 set(handles.TestPatch1,'BackgroundColor',[1 0 0]) 1799 1804 else … … 2020 2025 2021 2026 %------------------------------------------------------------------------ 2022 function [Data, par_civ1]=get_param_civ1(handles)2027 function [Data,ImageName_B]=get_param_civ1(handles) 2023 2028 2024 2029 ref_i=str2double(get(handles.ref_i,'String'));% read reference i index … … 2068 2073 Data.nx=[1 size(Data.A,2)]; 2069 2074 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 correlation2076 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; 2079 2084 2080 2085 %------------------------------------------------------------------------ … … 2122 2127 end 2123 2128 2124 % --- Executes on selection change in iterate.2125 function iterate_Callback(hObject, eventdata, handles)2129 % --- Executes on selection change in CheckCiv3. 2130 function CheckCiv3_Callback(hObject, eventdata, handles) 2126 2131 2127 2132 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.