Changeset 238
- Timestamp:
- Apr 18, 2011, 10:42:29 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r236 r238 66 66 filebase=''; % root file name ('filebase'.civ) 67 67 ext=[]; 68 testall=0; 68 set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'}) 69 69 %default input parameters: 70 70 num_i1=1; % set of field i numbers … … 106 106 end 107 107 set(handles.RootName,'String',filebase); 108 set(handles.ImaDoc,'UserData',testall);109 108 set(handles.ImaDoc,'String',ext) 110 109 … … 113 112 path_UVMAT=fileparts(path_uvmat); %path to UVMAT 114 113 errormsg=[];%default error message 115 % xmlfile=fullfile(path_UVMAT,'PARAM.xml');116 % if ~exist(xmlfile,'file')117 114 xmlfile='PARAM.xml'; 118 % end119 115 if exist(xmlfile,'file') 120 116 try … … 269 265 oldfile=filebase; 270 266 end 271 % testall=get(handles.ImaDoc,'UserData');272 267 ind_opening=1;%default 273 268 browse.incr_pair=[0 0]; %default 274 % if testall 275 % menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... 276 % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; 277 % else % menu selecting only .civ or .avi files 278 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 269 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; 279 270 '*.xml', '.xml files '; ... 280 271 '*.civ', '.civ files '; ... … … 285 276 '*.nc','.netcdf files'; ... 286 277 '*.*', 'All Files (*.*)'}; 287 % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...288 % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...289 % '*.*', 'All Files (*.*)'};290 % end291 278 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); 292 279 fileinput=[PathName FileName];%complete file name … … 442 429 end 443 430 set(handles.browse_root,'UserData',browse);% store information from browser 444 % testall=isequal(menu(filtindex,1),{'*.*'});445 % set(handles.ImaDoc,'UserData',testall);446 431 447 432 RootName_Callback(hObject, eventdata, handles); … … 1583 1568 end 1584 1569 end 1585 civAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs 1586 if civAll && isfield(sparam,'CivBin') 1570 1571 %% choose the civ program 1572 ProgList=get(handles.CivAll,'String'); 1573 index=get(handles.CivAll,'Value'); 1574 CivX=isequal(ProgList{index},'CivX'); 1575 CivAll=isequal(ProgList{index},'CivAll'); 1576 CivUvmat=isequal(ProgList{index},'CivUvmat'); 1577 %CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs 1578 if CivAll && isfield(sparam,'CivBin') 1587 1579 CivBin=sparam.CivBin; 1588 1580 if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat … … 1739 1731 cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group 1740 1732 end 1741 if civAll1742 civAllxml=xmltree;% xml contents, all parameters1743 civAllCmd='';1744 civAllxml=set(civAllxml,1,'name','CivDoc');1733 if CivAll 1734 CivAllxml=xmltree;% xml contents, all parameters 1735 CivAllCmd=''; 1736 CivAllxml=set(CivAllxml,1,'name','CivDoc'); 1745 1737 end 1746 1738 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) … … 1808 1800 % 1809 1801 i_cmd=i_cmd+1; 1810 if isequal( civAll,0)1802 if isequal(CivAll,0) 1811 1803 civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe 1812 1804 % if(isunix) … … 1818 1810 cmd=[cmd civ1_exe '\n']; 1819 1811 else 1820 civAllCmd=[civAllCmd ' civ1 '];1812 CivAllCmd=[CivAllCmd ' civ1 ']; 1821 1813 str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); 1822 1814 fieldnames=fields(str); 1823 [ civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');1815 [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); 1824 1816 for ilist=1:length(fieldnames) 1825 1817 val=eval(['str.' fieldnames{ilist}]); 1826 1818 if ischar(val) 1827 [ civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist});1828 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);1819 [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); 1820 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1829 1821 end 1830 1822 end … … 1844 1836 maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1845 1837 end 1846 if isequal(civAll,0)1838 if CivX 1847 1839 if isunix %unix system 1848 1840 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... … … 1856 1848 end 1857 1849 cmd=[cmd cmd_FIX '\n']; 1858 else 1850 elseif CivAll 1859 1851 fix1.inputFileName=filecell.nc.civ1{ifile,j} ; 1860 1852 fix1.fi1=num2str(flagindex1(1)); … … 1864 1856 fix1.threshV=num2str(thresh_vel1); 1865 1857 fieldnames=fields(fix1); 1866 [ civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1');1858 [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); 1867 1859 for ilist=1:length(fieldnames) 1868 1860 val=eval(['fix1.' fieldnames{ilist}]); 1869 1861 if ischar(val) 1870 [ civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist});1871 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);1862 [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); 1863 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1872 1864 end 1873 1865 end 1874 civAllCmd=[civAllCmd ' fix1 '];1866 CivAllCmd=[CivAllCmd ' fix1 ']; 1875 1867 end 1876 1868 end … … 1878 1870 %PATCH1 1879 1871 if box_test(3)==1 1880 if isequal( civAll,0)1872 if isequal(CivAll,0) 1881 1873 cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); 1882 1874 cmd=[cmd cmd_PATCH '\n']; … … 1912 1904 patch1.convectFlow='n'; 1913 1905 fieldnames=fields(patch1); 1914 [ civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1');1906 [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); 1915 1907 for ilist=1:length(fieldnames) 1916 1908 val=eval(['patch1.' fieldnames{ilist}]); 1917 1909 if ischar(val) 1918 [ civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist});1919 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);1910 [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); 1911 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1920 1912 end 1921 1913 end 1922 civAllCmd=[civAllCmd ' patch1 '];1914 CivAllCmd=[CivAllCmd ' patch1 ']; 1923 1915 end 1924 1916 end … … 1987 1979 flname=fullfile(Rootbat,Filebat); 1988 1980 1989 if isequal( civAll,0)1981 if isequal(CivAll,0) 1990 1982 cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 1991 1983 % if(isunix) … … 1996 1988 % end 1997 1989 else 1998 civAllCmd=[civAllCmd ' civ2 '];1990 CivAllCmd=[CivAllCmd ' civ2 ']; 1999 1991 str=CIV2_CMD_Unified(flname,'',par_civ2); 2000 1992 fieldnames=fields(str); 2001 [ civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2');1993 [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); 2002 1994 for ilist=1:length(fieldnames) 2003 1995 val=eval(['str.' fieldnames{ilist}]); 2004 1996 if ischar(val) 2005 [ civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist});2006 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);1997 [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); 1998 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2007 1999 end 2008 2000 end … … 2022 2014 maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); 2023 2015 end 2024 if isequal( civAll,0)2016 if isequal(CivAll,0) 2025 2017 if isunix 2026 2018 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... … … 2042 2034 fix2.threshV=num2str(thresh_vel2); 2043 2035 fieldnames=fields(fix2); 2044 [ civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2');2036 [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); 2045 2037 for ilist=1:length(fieldnames) 2046 2038 val=eval(['fix2.' fieldnames{ilist}]); 2047 2039 if ischar(val) 2048 [ civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist});2049 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);2040 [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); 2041 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2050 2042 end 2051 2043 end 2052 civAllCmd=[civAllCmd ' fix2 '];2044 CivAllCmd=[CivAllCmd ' fix2 ']; 2053 2045 end 2054 2046 end … … 2056 2048 %PATCH2 2057 2049 if box_test(6)==1 2058 if isequal( civAll,0)2050 if isequal(CivAll,0) 2059 2051 cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); 2060 2052 cmd=[cmd cmd_PATCH '\n']; … … 2090 2082 patch2.convectFlow='n'; 2091 2083 fieldnames=fields(patch2); 2092 [ civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');2084 [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); 2093 2085 for ilist=1:length(fieldnames) 2094 2086 val=eval(['patch2.' fieldnames{ilist}]); 2095 2087 if ischar(val) 2096 [ civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});2097 [ civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);2088 [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); 2089 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2098 2090 end 2099 2091 end 2100 civAllCmd=[civAllCmd ' patch2 '];2101 end 2102 end 2103 if isequal(civAll,1)2104 save( civAllxml,[flname '.xml']);2105 cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' civAllCmd ' >' flname '.log' '\n'];2092 CivAllCmd=[CivAllCmd ' patch2 ']; 2093 end 2094 end 2095 if CivAll 2096 save(CivAllxml,[flname '.xml']); 2097 cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; 2106 2098 end 2107 2099 % create the .bat file: … … 2120 2112 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2121 2113 end 2122 elseif ~ isequal(get(handles.CivAll,'Value'),3)2114 elseif ~CivUvmat 2123 2115 %% to lauch the jobs locally : 2124 2116 if(isunix) … … 2130 2122 disp(cmd_str); 2131 2123 else %run PIVlab if selected 2132 Data=civ_uvmat(par_civ1); 2133 % image1=imread(par_civ1.filename_ima_a); 2134 % image2=imread(par_civ1.filename_ima_b); 2135 % stepx=str2num(par_civ1.dx); 2136 % stepy=str2num(par_civ1.dy); 2137 % ibx2=ceil(str2num(par_civ1.ibx)/2); 2138 % iby2=ceil(str2num(par_civ1.iby)/2); 2139 % isx2=ceil(str2num(par_civ1.isx)/2); 2140 % isy2=ceil(str2num(par_civ1.isy)/2); 2141 % shiftx=str2num(par_civ1.shiftx); 2142 % shifty=str2num(par_civ1.shifty); 2143 % % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even 2144 % % iby=2*iby2-1; 2145 % miniy=max(1+isy2-shifty,1+iby2); 2146 % minix=max(1+isx2-shiftx,1+ibx2); 2147 % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); 2148 % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); 2149 % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); 2150 % PointCoord(:,1)=reshape(GridX,[],1); 2151 % PointCoord(:,2)=reshape(GridY,[],1); 2152 % % caluclate velocity data (y and v in indices, reverse to y component) 2153 % [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); 2154 % Data.ListGlobalAttribute={'title','Time','Dt'}; 2155 % Data.title='PIVlab'; 2156 % Data.Time=str2double(par_civ1.T0); 2157 % Data.Dt=str2double(par_civ1.Dt); 2158 % Data.ListVarName={'X','Y','U','V','C','FF'};% cell array containing the names of the fields to record 2159 % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; 2160 % Data.VarAttribute{1}.Role='coord_x'; 2161 % Data.VarAttribute{2}.Role='coord_y'; 2162 % Data.VarAttribute{3}.Role='vector_x'; 2163 % Data.VarAttribute{4}.Role='vector_y'; 2164 % Data.VarAttribute{5}.Role='errorflag'; 2165 % Data.X=reshape(xtable,[],1); 2166 % Data.Y=reshape(size(image1,1)-ytable+1,[],1); 2167 % Data.U=reshape(utable,[],1); 2168 % Data.V=reshape(-vtable,[],1); 2169 % Data.C=reshape(ctable,[],1); 2170 % Data.FF=reshape(~typevector,[],1); 2171 errormsg=struct2nc(filecell.nc.civ1{ifile,j},Data); 2124 if box_test(1)==1 2125 Param.Civ1=par_civ1; 2126 end 2127 if box_test(2)==1 2128 fix1.WarnFlags=[]; 2129 if get(handles.vec_Fmin2,'Value') 2130 fix1.WarnFlags=[fix1.WarnFlags -2]; 2131 end 2132 if get(handles.vec_F3,'Value') 2133 fix1.WarnFlags=[fix1.WarnFlags 3]; 2134 end 2135 fix1.LowerBoundCorr=thresh_vecC1; 2136 if get(handles.inf_sup1,'Value') 2137 fix1.UppperBoundVel=thresh_vel1; 2138 else 2139 fix1.LowerBoundVel=thresh_vel1; 2140 end 2141 Param.Fix1=fix1; 2142 end 2143 if box_test(3)==1 2144 Param.Patch1.Rho=rho_patch1; 2145 Param.Patch1.Threshold=thresh_patch1; 2146 Param.Patch1.SubDomain=subdomain_patch1; 2147 end 2148 [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); 2172 2149 if isempty(errormsg) 2173 2150 display([filecell.nc.civ1{ifile,j} ' written']) … … 2179 2156 end 2180 2157 2181 if ~batch && ~ isequal(get(handles.CivAll,'Value'),3)2158 if ~batch && ~CivUvmat 2182 2159 [Rootbat,Filebat,extbat]=fileparts(filename_bat); 2183 2160 filename_superbat=fullfile(Rootbat,'job_list.bat'); … … 4006 3983 end 4007 3984 par.rho=get(handles.rho,'String'); 3985 if isequal(get(handles.rho,'Style'),'popupmenu') 3986 index=get(handles.rho,'Value'); 3987 par.rho=par.rho{index}; 3988 end 4008 3989 par.dx=get(handles.dx_civ1,'String'); 4009 3990 par.dy=get(handles.dy_civ1,'String'); … … 4301 4282 end 4302 4283 4303 % ------------------------------------------------------------------------4304 % --- civ using pivlab4305 function Data=civ_uvmat(par_civ1)4306 % ------------------------------------------------------------------------4307 image1=imread(par_civ1.filename_ima_a);4308 image2=imread(par_civ1.filename_ima_b);4309 stepx=str2num(par_civ1.dx);4310 stepy=str2num(par_civ1.dy);4311 ibx2=ceil(str2num(par_civ1.ibx)/2);4312 iby2=ceil(str2num(par_civ1.iby)/2);4313 isx2=ceil(str2num(par_civ1.isx)/2);4314 isy2=ceil(str2num(par_civ1.isy)/2);4315 shiftx=str2num(par_civ1.shiftx);4316 shifty=str2num(par_civ1.shifty);4317 miniy=max(1+isy2-shifty,1+iby2);4318 minix=max(1+isx2-shiftx,1+ibx2);4319 maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);4320 maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);4321 [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);4322 PointCoord(:,1)=reshape(GridX,[],1);4323 PointCoord(:,2)=reshape(GridY,[],1);4324 % caluclate velocity data (y and v in indices, reverse to y component)4325 [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);4326 Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}];4327 Data.Conventions='uvmat/civdata';4328 Data.Program='civ_uvmat';4329 Data.CivStage=1;4330 % list_param=fieldnames(Param.Civ1);4331 % for ilist=1:length(list_param)4332 % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])4333 % end4334 Data.Time=str2double(par_civ1.T0);4335 Data.Dt=str2double(par_civ1.Dt);4336 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record4337 Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};4338 Data.VarAttribute{1}.Role='coord_x';4339 Data.VarAttribute{2}.Role='coord_y';4340 Data.VarAttribute{3}.Role='vector_x';4341 Data.VarAttribute{4}.Role='vector_y';4342 Data.VarAttribute{5}.Role='warnflag';4343 Data.Civ1_X=reshape(xtable,[],1);4344 Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);4345 Data.Civ1_U=reshape(utable,[],1);4346 Data.Civ1_V=reshape(-vtable,[],1);4347 Data.Civ1_C=reshape(ctable,[],1);4348 Data.Civ1_F=reshape(F,[],1);4284 % %------------------------------------------------------------------------ 4285 % % --- civ using pivlab 4286 % function Data=civ_uvmat(par_civ1) 4287 % %------------------------------------------------------------------------ 4288 % image1=imread(par_civ1.filename_ima_a); 4289 % image2=imread(par_civ1.filename_ima_b); 4290 % stepx=str2num(par_civ1.dx); 4291 % stepy=str2num(par_civ1.dy); 4292 % ibx2=ceil(str2num(par_civ1.ibx)/2); 4293 % iby2=ceil(str2num(par_civ1.iby)/2); 4294 % isx2=ceil(str2num(par_civ1.isx)/2); 4295 % isy2=ceil(str2num(par_civ1.isy)/2); 4296 % shiftx=str2num(par_civ1.shiftx); 4297 % shifty=str2num(par_civ1.shifty); 4298 % miniy=max(1+isy2-shifty,1+iby2); 4299 % minix=max(1+isx2-shiftx,1+ibx2); 4300 % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); 4301 % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); 4302 % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); 4303 % PointCoord(:,1)=reshape(GridX,[],1); 4304 % PointCoord(:,2)=reshape(GridY,[],1); 4305 % % caluclate velocity data (y and v in indices, reverse to y component) 4306 % [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); 4307 % Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}]; 4308 % Data.Conventions='uvmat/civdata'; 4309 % Data.Program='civ_uvmat'; 4310 % Data.CivStage=1; 4311 % % list_param=fieldnames(Param.Civ1); 4312 % % for ilist=1:length(list_param) 4313 % % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';']) 4314 % % end 4315 % Data.Time=str2double(par_civ1.T0); 4316 % Data.Dt=str2double(par_civ1.Dt); 4317 % Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record 4318 % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; 4319 % Data.VarAttribute{1}.Role='coord_x'; 4320 % Data.VarAttribute{2}.Role='coord_y'; 4321 % Data.VarAttribute{3}.Role='vector_x'; 4322 % Data.VarAttribute{4}.Role='vector_y'; 4323 % Data.VarAttribute{5}.Role='warnflag'; 4324 % Data.Civ1_X=reshape(xtable,[],1); 4325 % Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1); 4326 % Data.Civ1_U=reshape(utable,[],1); 4327 % Data.Civ1_V=reshape(-vtable,[],1); 4328 % Data.Civ1_C=reshape(ctable,[],1); 4329 % Data.Civ1_F=reshape(F,[],1); 4349 4330 4350 4331 %------------------------------------------------------------------------ … … 4918 4899 % --- Executes on button press in CivAll. 4919 4900 function CivAll_Callback(hObject, eventdata, handles) 4920 if get(handles.CivAll,'Value')==2 4921 if get(handles.PATCH1,'Value') 4922 set(handles.thresh_patch1,'Visible','on') 4923 set(handles.thresh_text1,'Visible','on') 4924 end 4925 else 4926 set(handles.thresh_patch1,'Visible','off') 4927 set(handles.thresh_text1,'Visible','off') 4928 end 4929 4901 Listprog=get(handles.CivAll,'String'); 4902 index=get(handles.CivAll,'Value'); 4903 prog=Listprog{index}; 4904 switch prog 4905 case 'CivX' 4906 set(handles.thresh_patch1,'Visible','off') 4907 set(handles.thresh_text1,'Visible','off') 4908 set(handles.rho,'Style','edit') 4909 set(handles.rho,'String','1') 4910 case 'CivAll' 4911 if get(handles.PATCH1,'Value') 4912 set(handles.thresh_patch1,'Visible','on') 4913 set(handles.thresh_text1,'Visible','on') 4914 end 4915 set(handles.rho,'Style','edit') 4916 set(handles.rho,'String','1') 4917 case 'CivUvmat' 4918 if get(handles.PATCH1,'Value') 4919 set(handles.thresh_patch1,'Visible','on') 4920 set(handles.thresh_text1,'Visible','on') 4921 end 4922 set(handles.rho,'Style','popupmenu') 4923 set(handles.rho,'Value',1) 4924 set(handles.rho,'String',{'1';'2'}) 4925 end 4926 -
trunk/src/geometry_calib.m
r231 r238 458 458 norm=abs(det(R)); 459 459 GeometryCalib.CalibrationType='linear'; 460 if (a_X1(2)/a_Y1(3))>0 461 epsilon=1; 460 462 GeometryCalib.fx_fy(1)=sqrt((a_X1(2)/a_Y1(3))*norm); 463 else 464 GeometryCalib.fx_fy(1)=-sqrt((-a_X1(2)/a_Y1(3))*norm); 465 epsilon=-1; 466 end 461 467 GeometryCalib.fx_fy(2)=(a_Y1(3)/a_X1(2))*GeometryCalib.fx_fy(1); 462 468 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 463 469 %GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1]; 464 470 GeometryCalib.Tx_Ty_Tz=[a_X1(1)/GeometryCalib.fx_fy(1) a_Y1(1)/GeometryCalib.fx_fy(2) 1]; 465 R(1,:)= R(1,:)/GeometryCalib.fx_fy(1);471 R(1,:)=epsilon*R(1,:)/GeometryCalib.fx_fy(1); 466 472 R(2,:)=R(2,:)/GeometryCalib.fx_fy(2); 467 473 R=[R;[0 0]]; 468 GeometryCalib.R=[R [0;0; 1]];469 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0] ;474 GeometryCalib.R=[R [0;0;-1]]; 475 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0] 470 476 %------------------------------------------------------------------------ 471 477 % determine the tsai parameters for a view normal to the grid plane -
trunk/src/mouse_down.m
r231 r238 109 109 haxes=[];%mouse out of axes 110 110 end 111 break 112 elseif isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on') 113 msgbox(get(hchild(ichild),'String'),get(hchild(ichild),'Tag')) 114 break 111 115 end 112 116 end -
trunk/src/pivlab.m
r236 r238 90 90 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 91 91 %Find the correlation max, at 255 92 [y,x] = find(result_conv==255 );93 if ~isnan(y) & ~isnan(x)92 [y,x] = find(result_conv==255,1); 93 if ~isnan(y) && ~isnan(x) 94 94 try 95 95 if subpixfinder==1 96 [vector ] = SUBPIXGAUSS (result_conv,x,y);96 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 97 97 elseif subpixfinder==2 98 [vector ] = SUBPIX2DGAUSS (result_conv,x,y);98 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 99 99 end 100 100 sum_square=sum(sum(image1_crop.*image1_crop)); 101 101 ctable(ivec)=corrmax/sum_square;% correlation value 102 if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder103 F(ivec)=-2;%vector reaches the border of the search zone104 end102 % if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder 103 % F(ivec)=-2;%vector reaches the border of the search zone 104 % end 105 105 catch ME 106 106 vector=[0 0]; %if something goes wrong with cross correlation..... … … 125 125 126 126 127 function [vector] = SUBPIXGAUSS (result_conv,x,y) 127 function [vector,F] = SUBPIXGAUSS (result_conv,x,y) 128 vector=[0 0]; %default 129 F=0; 130 [npy,npx]=size(result_conv); 128 131 129 if size(x,1)>1 %if there are more than 1 peaks just take the first 130 x=x(1:1); 131 end 132 if size(y,1)>1 %if there are more than 1 peaks just take the first 133 y=y(1:1); 134 end 135 if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1) 132 % if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1) 136 133 %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion Israel Institute of Technology 137 134 %http://urapiv.wordpress.com 138 f0 = log(result_conv(y,x)); 139 f1 = log(result_conv(y-1,x)); 140 f2 = log(result_conv(y+1,x)); 141 peaky = y+ (f1-f2)/(2*f1-4*f0+2*f2); 142 f0 = log(result_conv(y,x)); 143 f1 = log(result_conv(y,x-1)); 144 f2 = log(result_conv(y,x+1)); 145 peakx = x+ (f1-f2)/(2*f1-4*f0+2*f2); 146 [npy,npx]=size(result_conv); 135 peaky = y; 136 if y <= npy-1 && y >= 1 137 f0 = log(result_conv(y,x)); 138 f1 = log(result_conv(y-1,x)); 139 f2 = log(result_conv(y+1,x)); 140 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 141 else 142 F=-2; % warning flag for vector truncated by the limited search box 143 end 144 peakx=x; 145 if x <= npx-1 && x >= 1 146 f0 = log(result_conv(y,x)); 147 f1 = log(result_conv(y,x-1)); 148 f2 = log(result_conv(y,x+1)); 149 peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 150 else 151 F=-2; % warning flag for vector truncated by the limited search box 152 end 147 153 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 148 else149 vector=[NaN NaN];150 end154 % else 155 % vector=[NaN NaN]; 156 % end 151 157 152 function [vector ] = SUBPIX2DGAUSS (result_conv,x,y)153 if size(x,1)>1 %if there are more than 1 peaks just take the first154 x=x(1:1);155 end 156 if size(y,1)>1 %if there are more than 1 peaks just take the first 157 y=y(1:1);158 end 159 if (x <= (size(result_conv,1)-1)) && (y <= (size(result_conv,1)-1)) && (x >= 1) && (y >= 1) 158 function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y) 159 vector=[0 0]; %default 160 F=-2; 161 peaky=y; 162 peakx=x; 163 [npy,npx]=size(result_conv); 164 if (x <= npx-1) && (y <= npy-1) && (x >= 1) && (y >= 1) 165 F=0; 160 166 for i=-1:1 161 167 for j=-1:1 … … 181 187 deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2); 182 188 deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2); 183 peakx=x+deltax; 184 peaky=y+deltay; 185 186 [npy,npx]=size(result_conv); 187 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 188 % SubpixelX=peakx-(ibx/2)-SubPixOffset; 189 % SubpixelY=peaky-(iby/2)-SubPixOffset; 190 % vector=[SubpixelX, SubpixelY]; 191 else 192 vector=[NaN NaN]; 189 if abs(deltax)<1 190 peakx=x+deltax; 191 end 192 if abs(deltay)<1 193 peaky=y+deltay; 194 end 193 195 end 196 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; -
trunk/src/plot_field.m
r231 r238 900 900 if MinA<MaxA 901 901 set(haxes,'CLim',[MinA MaxA]) 902 %caxis([MinA MaxA])903 902 else 904 set(haxes,'CLim',[MinA MaxA]) 905 %caxis([MaxA-1 MaxA]) 903 set(haxes,'CLim',[MinA MaxA+1]) 906 904 end 907 905 set(hima,'XData',AX); … … 909 907 end 910 908 end 911 % if ~isstruct(AxeData)912 % AxeData=[];913 % end914 909 test_ima=1; 915 910 -
trunk/src/series.m
r206 r238 122 122 FieldCell{1}=param.list_fields{param.index_fields}; 123 123 end 124 if isfield(param,'civ1')&& islogical(param.civ1) && isfield(param,'civ2')&& islogical(param.civ2)&... 125 isfield(param,'interp1')&& islogical(param.interp1)&&isfield(param,'interp2')&& islogical(param.interp2)&... 126 isfield(param,'filter1')&& islogical(param.filter1)&&isfield(param,'filter2')&& islogical(param.filter2) 127 set(handles.civ1,'Value',param.civ1); 128 set(handles.civ2,'Value',param.civ1); 129 set(handles.interp1,'Value',param.interp1); 130 set(handles.interp2,'Value',param.interp2); 131 set(handles.filter1,'Value',param.filter1); 132 set(handles.filter2,'Value',param.filter2); 133 end 124 % if isfield(param,'velTypeMenu')&&isfield(param,'velTypeIndex') 125 % set(handles.VelTypeMenu,'Value',param.VelTypeIndex) 126 % set(handles.VelTypeMenu,'String',param.VelTypeMenu) 127 % end 134 128 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) 135 129 NomType_Callback(hObject, eventdata, handles) -
trunk/src/uvmat.m
r236 r238 2427 2427 UvData.Field=Field{1}; 2428 2428 end 2429 2429 UvData.Field 2430 max(max(UvData.Field.A)) 2431 min(min(UvData.Field.A)) 2430 2432 %% get bounds and mesh (needed for mouse action and to open set_object) 2431 2433 test_x=0; … … 3927 3929 set(handles.list_object_1,'Value',1) 3928 3930 set(handles.list_object_1,'String',{''}) 3929 set(handles.list_object_2,'Value', 2)3931 set(handles.list_object_2,'Value',1) 3930 3932 set(handles.list_object_2,'String',{''}) 3931 3933 list_object_2_Callback(hObject, eventdata, handles) … … 4306 4308 function list_object_2_Callback(hObject, eventdata, handles) 4307 4309 %------------------------------------------------------------------------ 4308 list_str=get(handles.list_object_2,'String') ;4309 IndexObj=get(handles.list_object_2,'Value') ;4310 list_str=get(handles.list_object_2,'String') 4311 IndexObj=get(handles.list_object_2,'Value') 4310 4312 if ischar(list_str) || isempty(list_str{IndexObj})% || strcmp(list_str{IndexObj},'...') 4311 4313 hview_field=findobj(allchild(0),'Tag','view_field'); … … 4738 4740 param.index_fields_1=param.index_fields_1-1; 4739 4741 end 4740 param.civ1=get(handles.VelType,'Value'); 4741 param.civ2=get(handles.civ2,'Value'); 4742 param.interp1=get(handles.interp1,'Value'); 4743 param.interp2=get(handles.interp2,'Value'); 4744 param.filter1=get(handles.filter1,'Value'); 4745 param.filter2=get(handles.filter2,'Value'); 4742 % if isequal(get(handles.VelType,'Visible'),'on') 4743 % param.VelTypeMenu=get(handles.VelType,'String'); 4744 % param.VelTypeIndex=get(handles.VelType,'Value'); 4745 % end 4746 % param.civ1=get(handles.VelType,'Value'); 4747 % param.civ2=get(handles.civ2,'Value'); 4748 % param.interp1=get(handles.interp1,'Value'); 4749 % param.interp2=get(handles.interp2,'Value'); 4750 % param.filter1=get(handles.filter1,'Value'); 4751 % param.filter2=get(handles.filter2,'Value'); 4746 4752 param.menu_coord_str=get(handles.transform_fct,'String'); 4747 4753 param.menu_coord_val=get(handles.transform_fct,'Value');
Note: See TracChangeset
for help on using the changeset viewer.