Changeset 67 for trunk/src/civ.m
- Timestamp:
- Mar 25, 2010, 6:48:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r66 r67 51 51 % handles structure with handles and user data (see GUIDATA) 52 52 % varargin command line arguments to civ (see VARARGIN) 53 global test_batch patch_new _exe%=1 if patch processing available53 global test_batch patch_newBin%=1 if patch processing available 54 54 %filebase: root name 55 55 %nom_type: nomencalture used ('png_old','_i_j'...) … … 132 132 msgbox_uvmat('ERROR',errormsg); 133 133 end 134 patch_new _exe='';134 patch_newBin=''; 135 135 % todo_patch=''; 136 136 sge=0; 137 137 138 if isfield(sparam,'PatchNew _exe')139 patch_new _exe=sparam.PatchNew_exe;138 if isfield(sparam,'PatchNewBin') 139 patch_newBin=sparam.PatchNewBin; 140 140 end 141 141 … … 1557 1557 %------------------------------------------------------------------------ 1558 1558 % --- Executes on button press in RUN. 1559 1560 1561 1562 % compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) 1563 % %check the list of operations: 1564 % operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; 1565 % run_flag=1; 1566 % box_test(1)=get(handles.CIV1,'Value'); 1567 % box_test(2)=get(handles.FIX1,'Value'); 1568 % box_test(3)=get(handles.PATCH1,'Value'); 1569 % box_test(4)=get(handles.CIV2,'Value'); 1570 % box_test(5)=get(handles.FIX2,'Value'); 1571 % box_test(6)=get(handles.PATCH2,'Value'); 1572 % index=find(box_test==1); 1573 % if isempty(index) 1574 % msgbox_uvmat('ERROR','no selected operation') 1575 % return 1576 % end 1577 % index_first=min(index); 1578 % index_last=max(index); 1579 % box_used=box_test([index_first : index_last]); 1580 % [box_missing,ind_missing]=min(box_used); 1581 % if isequal(box_missing,0) 1582 % msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); 1583 % return 1584 % end 1585 % 1586 % %root name 1587 % filebase=get(handles.displ_filebase,'String'); 1588 % if isempty(filebase)||isequal(filebase,'') 1589 % msgbox_uvmat('ERROR','no input files') 1590 % return 1591 % end 1592 % %check mask if selecetd 1593 % if isequal(get(handles.get_mask_civ1,'Value'),1) 1594 % maskname=get(handles.mask_civ1,'String'); 1595 % if ~exist(maskname,'file') 1596 % get_mask_civ1_Callback(hObject, eventdata, handles); 1597 % end 1598 % end 1599 % if isequal(get(handles.get_mask_fix1,'Value'),1) 1600 % maskname=get(handles.mask_fix1,'String'); 1601 % if ~exist(maskname,'file') 1602 % get_mask_fix1_Callback(hObject, eventdata, handles); 1603 % end 1604 % end 1605 % if isequal(get(handles.get_mask_civ2,'Value'),1) 1606 % maskname=get(handles.mask_civ2,'String'); 1607 % if ~exist(maskname,'file') 1608 % get_mask_civ2_Callback(hObject, eventdata, handles); 1609 % end 1610 % end 1611 % if isequal(get(handles.get_mask_fix2,'Value'),1) 1612 % maskname=get(handles.mask_fix2,'String'); 1613 % if ~exist(maskname,'file') 1614 % get_mask_fix2_Callback(hObject, eventdata, handles); 1615 % end 1616 % end 1617 % 1618 % %read names of the .exe file 1619 % if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 1620 % path_uvmat=which('uvmat');% check the path detected for source file uvmat 1621 % path_UVMAT=fileparts(path_uvmat); %path to UVMAT 1622 % %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names 1623 % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); 1624 % if exist(xmlfile,'file') 1625 % t=xmltree(xmlfile); 1626 % sparam=convert(t); 1627 % end 1628 % if isfield(sparam,'Civ1Bin') 1629 % civ1Bin=sparam.Civ1Bin; 1630 % if ~exist(civ1Bin,'file') 1631 % civ1Bin=fullfile(path_UVMAT,civ1Bin); 1632 % end 1633 % end 1634 % if isfield(sparam,'Civ2Bin') 1635 % civ2Bin=sparam.Civ2Bin; 1636 % if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting 1637 % civ2_exe=fullfile(path_UVMAT,civ2_exe); 1638 % end 1639 % end 1640 % if isfield(sparam,'Patch_exe') 1641 % patch_exe=sparam.Patch_exe; 1642 % if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting 1643 % patch_exe=fullfile(path_UVMAT,patch_exe); 1644 % end 1645 % end 1646 % if isfield(sparam,'Stinterp_exe') 1647 % stinterp_exe=sparam.Stinterp_exe; 1648 % end 1649 % if isfield(sparam,'SGE') 1650 % sge=str2double(sparam.SGE); 1651 % end 1652 % if ~isunix % for windows system, check whether the Matlab working dir is a UBC name 1653 % dircur=pwd; 1654 % if ~isequal(dircur([2 3]),':\') 1655 % msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') 1656 % return; 1657 % end 1658 % end 1659 % end 1660 % 1661 % %initialize the waitbars 1662 % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) 1663 % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) 1664 % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) 1665 % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) 1666 % set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) 1667 % set(handles.RUN, 'Enable','Off') 1668 % drawnow 1669 % 1670 % % get the list of file names and check the files 1671 % display('checking the files...') 1672 % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... 1673 % set_civ_filenames(handles,compare,box_test); 1674 % nbfield=numel(num1_civ1); 1675 % nbslice=size(num_a_civ1); 1676 % 1677 % if isempty(filecell) 1678 % set(handles.RUN, 'Enable','On') 1679 % set(handles.RUN,'BackgroundColor',[1 0 0]) 1680 % set(handles.BATCH, 'Enable','On') 1681 % set(handles.BATCH,'BackgroundColor',[1 0 0]) 1682 % return 1683 % end 1684 % display('files OK, processing...') 1685 % nbfield=size(num1_civ1,2); 1686 % nbslice=size(num1_civ1,1); 1687 % 1688 % %RUN CIV1 1689 % if box_test(1)==1 1690 % RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) 1691 % if compare==3 1692 % RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) 1693 % end 1694 % end 1695 % 1696 % %RUN FIX1 1697 % if box_test(2)==1 1698 % filebase=get(handles.displ_filebase,'String'); 1699 % %names of the civ1 fields 1700 % field1.vel_type='civ1'; 1701 % field1.nb='nb_vectors'; 1702 % % field1.X='vec_X'; 1703 % % field1.Y='vec_Y'; 1704 % % field1.U='vec_U'; 1705 % % field1.V='vec_V'; 1706 % field1.fixflag='vec_FixFlag'; 1707 % flagindex(1)=get(handles.vec_Fmin2, 'Value'); 1708 % flagindex(2)=get(handles.vec_F3, 'Value'); 1709 % flagindex(3)=get(handles.vec_F2, 'Value'); 1710 % thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C 1711 % thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus 1712 % inf_sup=get(handles.inf_sup1,'Value'); 1713 % menu=get(handles.field_ref1,'String'); 1714 % index=get(handles.field_ref1,'Value'); 1715 % if isempty(menu) 1716 % fieldchoice=''; 1717 % else 1718 % fieldchoice=menu{index}; 1719 % end 1720 % h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar 1721 % test_mask=get(handles.get_mask_fix1,'Value'); 1722 % if test_mask 1723 % maskdispl=get(handles.mask_fix1,'String'); 1724 % if exist(maskdispl,'file') 1725 % test_mask=2; 1726 % maskname=maskdispl; 1727 % else 1728 % maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name 1729 % end 1730 % end 1731 % for ifile=1:nbfield 1732 % waitbar(ifile/nbfield); %update the waitbar 1733 % for j=1:nbslice 1734 % if test_mask==0 1735 % maskname='noFile use default'; 1736 % maskflag=0; 1737 % elseif test_mask==1 1738 % nbslice_mask=str2double(maskdispl(1:end-4)); % 1739 % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; 1740 % maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair 1741 % maskflag= exist(maskname,'file')==2; 1742 % if ~maskflag; 1743 % maskname='noFile use default'; 1744 % end 1745 % end 1746 % if ~isempty(file_ref_fix1) 1747 % file_ref=file_ref_fix1{ifile,j}; 1748 % else 1749 % file_ref=''; 1750 % end 1751 % error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... 1752 % thresh_vel,inf_sup,file_ref,fieldchoice); 1753 % 1754 % if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) 1755 % if test_mask==0 1756 % maskname='noFile use default'; 1757 % maskflag=0; 1758 % else 1759 % maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name 1760 % nbslice_mask=str2num(maskdispl(1:end-4)); % 1761 % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; 1762 % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1763 % maskflag= exist(maskname,'file')==2; 1764 % if ~maskflag; 1765 % maskname='noFile use default'; 1766 % end 1767 % end 1768 % error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... 1769 % thresh_vel,inf_sup,file_ref,fieldchoice); 1770 % if ~isempty(error) 1771 % msgbox_uvmat('ERROR',error) 1772 % return 1773 % end 1774 % end 1775 % end 1776 % end 1777 % close(h) 1778 % end 1779 % 1780 % % RUN PATCH1 1781 % if box_test(3)==1 1782 % rho_patch1=str2num(get(handles.rho_patch1,'String')); 1783 % if isempty(rho_patch1) 1784 % rho_patch1='1000'; 1785 % set(handles.rho_patch1,'String','1') 1786 % else 1787 % rho_patch1=num2str(1000*rho_patch1); 1788 % end 1789 % nx_patch1=get(handles.nx_patch1,'String'); 1790 % if isequal(str2num(nx_patch1),[]) 1791 % nx_patch1='50' ;%default 1792 % set(handles.nx_patch1,'String','50'); 1793 % end 1794 % ny_patch1=get(handles.ny_patch1,'String'); 1795 % if isequal(str2num(ny_patch1),[]) 1796 % ny_patch1='50' ;%default 1797 % set(handles.ny_patch1,'String','50'); 1798 % end 1799 % subdomain_patch1=get(handles.subdomain_patch1,'String'); 1800 % thresh_patch1=get(handles.thresh_patch1,'String'); 1801 % test_interp=get(handles.test_interp,'Value'); 1802 % icount=0; 1803 % for ifile=1:nbfield 1804 % for j=1:nbslice 1805 % icount=icount+1; 1806 % barlength=0.188*icount/(nbfield*nbslice); 1807 % set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) 1808 % drawnow 1809 % if isequal(get(handles.test_stereo1,'Value'),0) 1810 % cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); 1811 % s=-1; 1812 % if sge 1813 % [s,w]=unix(['qrsh -q -fast.q ' cmd]); 1814 % end 1815 % if s~=0 1816 % display(['!' cmd]) 1817 % eval(['!' cmd]); 1818 % end 1819 % 1820 % %stereo case: 1821 % elseif isequal(get(handles.test_stereo1,'Value'),1) 1822 % if exist('stinterp_exe','var')%Prog Gauthier 1823 % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... 1824 % nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); 1825 % display(['!' cmd]) 1826 % eval(['!' cmd]); 1827 % else 1828 % RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... 1829 % str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); 1830 % end 1831 % end 1832 % if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) 1833 % cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); 1834 % s=-1; 1835 % if sge 1836 % [s,w]=unix(['qrsh -q -fast.q ' cmd]); 1837 % end 1838 % if s~=0 1839 % display(['!' cmd]) 1840 % eval(['!' cmd]); 1841 % end 1842 % end 1843 % end 1844 % end 1845 % end 1846 % 1847 % % CIV2 1848 % if box_test(4)==1 1849 % RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... 1850 % num_a_civ2,num_b_civ2,nom_type_nc) 1851 % end 1852 % 1853 % % FIX2 1854 % if box_test(5)==1 1855 % %names of the civ2 fields 1856 % field2.vel_type='civ2'; 1857 % field2.nb='nb_vectors2'; 1858 % field2.X='vec2_X'; 1859 % field2.Y='vec2_Y'; 1860 % field2.U='vec2_U'; 1861 % field2.V='vec2_V'; 1862 % field2.fixflag='vec2_FixFlag'; 1863 % flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); 1864 % flagindex(2)=get(handles.vec_F3_2, 'Value'); 1865 % flagindex(3)=get(handles.vec_F4, 'Value'); 1866 % thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C 1867 % thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus 1868 % inf_sup=get(handles.inf_sup2,'Value'); 1869 % menu=get(handles.field_ref2,'String'); 1870 % index=get(handles.field_ref2,'Value'); 1871 % if isempty(menu) 1872 % fieldchoice=''; 1873 % else 1874 % fieldchoice=menu{index}; 1875 % end 1876 % h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar 1877 % test_mask=get(handles.get_mask_fix2,'Value'); 1878 % if test_mask 1879 % maskdispl=get(handles.mask_fix2,'String'); 1880 % if exist(maskdispl,'file') 1881 % test_mask=2; 1882 % maskname=maskdispl; 1883 % else 1884 % maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name 1885 % end 1886 % end 1887 % for ifile=1:nbfield 1888 % waitbar(ifile/nbfield); %update the waitbar 1889 % for j=1:nbslice 1890 % if test_mask==0 1891 % maskname='noFile use default'; 1892 % maskflag=0; 1893 % elseif test_mask==1 1894 % nbslice_mask=str2num(maskdispl(1:end-4)); % 1895 % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; 1896 % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1897 % maskflag= exist(maskname,'file')==2; 1898 % if ~maskflag; 1899 % maskname='noFile use default'; 1900 % end 1901 % end 1902 % if ~isempty(file_ref_fix2) 1903 % file_ref=file_ref_fix2{ifile,j}; 1904 % else 1905 % file_ref=''; 1906 % end 1907 % error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... 1908 % thresh_vel2,inf_sup,file_ref,fieldchoice); 1909 % if ~isempty(error) 1910 % msgbox_uvmat('ERROR',error) 1911 % return 1912 % end 1913 % if compare==3 1914 % if test_mask==0 1915 % maskname='noFile use default'; 1916 % maskflag=0; 1917 % else 1918 % maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name 1919 % nbslice_mask=str2num(maskdispl(1:end-4)); % 1920 % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; 1921 % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1922 % maskflag= exist(maskname,'file')==2; 1923 % if ~maskflag; 1924 % maskname='noFile use default'; 1925 % end 1926 % end 1927 % error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... 1928 % thresh_vel2,inf_sup,file_ref,fieldchoice); 1929 % if ~isempty(error) 1930 % msgbox_uvmat('ERROR',error) 1931 % return 1932 % end 1933 % end 1934 % end 1935 % end 1936 % close(h) 1937 % end 1938 % 1939 % %PATCH 2 1940 % if box_test(6)==1 1941 % rho_patch2=str2num(get(handles.rho_patch2,'String')); 1942 % if isempty(rho_patch2) 1943 % rho_patch2='1000'; 1944 % set(handles.rho_patch2,'String','1') 1945 % else 1946 % rho_patch2=num2str(1000*rho_patch2); 1947 % end 1948 % nx_patch2=get(handles.nx_patch2,'String'); 1949 % ny_patch2=get(handles.ny_patch2,'String'); 1950 % thresh_patch2=get(handles.thresh_patch2,'String'); 1951 % if isequal(str2num(nx_patch2),[]) 1952 % nx_patch2='50' ;%default 1953 % set(handles.nx_patch2,'String','50'); 1954 % end 1955 % if isequal(str2num(ny_patch2),[]) 1956 % ny_patch2='50' ;%default 1957 % set(handles.ny_patch2,'String','50'); 1958 % end 1959 % subdomain_patch2=get(handles.subdomain_patch2,'String'); 1960 % icount=0; 1961 % for ifile=1:nbfield 1962 % for j=1:nbslice 1963 % icount=icount+1; 1964 % barlength=0.188*icount/(nbfield*nbslice); 1965 % set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) 1966 % drawnow 1967 % if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) 1968 % cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); 1969 % s=-1; 1970 % if sge 1971 % [s,w]=unix(['qrsh -q -fast.q ' cmd]); 1972 % end 1973 % if s~=0 1974 % display(['!' cmd]) 1975 % eval(['!' cmd]); 1976 % end 1977 % elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) 1978 % if exist('stinterp_exe','var')%Prog Gauthier 1979 % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... 1980 % nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); 1981 % display(['!' cmd]) 1982 % eval(['!' cmd]) 1983 % else 1984 % RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... 1985 % str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) 1986 % end 1987 % end 1988 % if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) 1989 % cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); 1990 % s=-1; 1991 % if sge 1992 % [s,w]=unix(['qrsh -q -fast.q ' cmd]); 1993 % end 1994 % if s~=0 1995 % display(['!' cmd]) 1996 % eval(['!' cmd]); 1997 % end 1998 % end 1999 % end 2000 % end 2001 % end 2002 % 2003 % set(handles.RUN, 'Enable','On') 2004 % set(handles.RUN,'BackgroundColor',[1 0 0]) 2005 % 2006 % %save the current interface setting as figure namefig, append .0 to the name if it already exists 2007 % if isfield(filecell,'st') 2008 % fileresu=filecell.st{1,1}; 2009 % elseif isfield(filecell,'nc') 2010 % if isfield(filecell.nc,'civ2') 2011 % fileresu=filecell.nc.civ2{1,1}; 2012 % else 2013 % fileresu=filecell.nc.civ1{1,1}; 2014 % end 2015 % end 2016 % [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); 2017 % namedoc=fullfile(RootPath,subdir,RootFile); 2018 % detect=1; 2019 % while detect==1 2020 % namefigfull=[namedoc '.fig']; 2021 % hh=dir(namefigfull); 2022 % if ~isempty(hh) 2023 % detect=1; 2024 % namedoc=[namedoc '.0']; 2025 % else 2026 % detect=0; 2027 % end 2028 % end 2029 % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) 2030 1559 2031 function RUN_Callback(hObject, eventdata, handles) 1560 2032 %------------------------------------------------------------------------ 1561 global civ1_exe civ2_exe patch_exe patch_new_exe sge 2033 % global civ1_exe civ2_exe patch_exe patch_new_exe sge 2034 2035 batch=0; 2036 launch_jobs(hObject, eventdata, handles,batch); 2037 2038 2039 %------------------------------------------------------------------------ 2040 % --- Executes on button press in BATCH: remote processing 2041 function BATCH_Callback(hObject, eventdata, handles) 2042 %------------------------------------------------------------------------ 2043 %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove 2044 batch=1; 2045 launch_jobs(hObject, eventdata, handles, batch) 2046 2047 %------------------------------------------------------------------------ 2048 % --- Executes on button press in BATCH: remote processing 2049 function launch_jobs(hObject, eventdata, handles, batch) 2050 %----------------------------------------------------------------------- 2051 % global civ2Bin patchBin patch_newBin fixBin CivBin % probabely to remove 1562 2052 1563 2053 compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) 2054 1564 2055 %check the list of operations: 1565 2056 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; … … 1591 2082 return 1592 2083 end 1593 %check mask if selecetd1594 if isequal(get(handles.get_mask_civ1,'Value'),1)1595 maskname=get(handles.mask_civ1,'String');1596 if ~exist(maskname,'file')1597 get_mask_civ1_Callback(hObject, eventdata, handles);1598 end1599 end1600 if isequal(get(handles.get_mask_fix1,'Value'),1)1601 maskname=get(handles.mask_fix1,'String');1602 if ~exist(maskname,'file')1603 get_mask_fix1_Callback(hObject, eventdata, handles);1604 end1605 end1606 if isequal(get(handles.get_mask_civ2,'Value'),1)1607 maskname=get(handles.mask_civ2,'String');1608 if ~exist(maskname,'file')1609 get_mask_civ2_Callback(hObject, eventdata, handles);1610 end1611 end1612 if isequal(get(handles.get_mask_fix2,'Value'),1)1613 maskname=get(handles.mask_fix2,'String');1614 if ~exist(maskname,'file')1615 get_mask_fix2_Callback(hObject, eventdata, handles);1616 end1617 end1618 1619 %read names of the .exe file1620 if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==11621 path_uvmat=which('uvmat');% check the path detected for source file uvmat1622 path_UVMAT=fileparts(path_uvmat); %path to UVMAT1623 %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names1624 xmlfile=fullfile(path_UVMAT,'PARAM.xml');1625 if exist(xmlfile,'file')1626 t=xmltree(xmlfile);1627 sparam=convert(t);1628 end1629 if isfield(sparam,'Civ1_exe')1630 civ1_exe=sparam.Civ1_exe;1631 if ~exist(civ1_exe,'file')1632 civ1_exe=fullfile(path_UVMAT,civ1_exe);1633 end1634 end1635 if isfield(sparam,'Civ2_exe')1636 civ2_exe=sparam.Civ2_exe;1637 if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting1638 civ2_exe=fullfile(path_UVMAT,civ2_exe);1639 end1640 end1641 if isfield(sparam,'Patch_exe')1642 patch_exe=sparam.Patch_exe;1643 if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting1644 patch_exe=fullfile(path_UVMAT,patch_exe);1645 end1646 end1647 if isfield(sparam,'Stinterp_exe')1648 stinterp_exe=sparam.Stinterp_exe;1649 end1650 if isfield(sparam,'SGE')1651 sge=str2double(sparam.SGE);1652 end1653 if ~isunix % for windows system, check whether the Matlab working dir is a UBC name1654 dircur=pwd;1655 if ~isequal(dircur([2 3]),':\')1656 msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...')1657 return;1658 end1659 end1660 end1661 1662 %initialize the waitbars1663 set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001])1664 set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001])1665 set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001])1666 set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])1667 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])1668 set(handles.RUN, 'Enable','Off')1669 drawnow1670 1671 % get the list of file names and check the files1672 display('checking the files...')1673 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...1674 set_civ_filenames(handles,compare,box_test);1675 nbfield=numel(num1_civ1);1676 nbslice=size(num_a_civ1);1677 1678 if isempty(filecell)1679 set(handles.RUN, 'Enable','On')1680 set(handles.RUN,'BackgroundColor',[1 0 0])1681 set(handles.BATCH, 'Enable','On')1682 set(handles.BATCH,'BackgroundColor',[1 0 0])1683 return1684 end1685 display('files OK, processing...')1686 nbfield=size(num1_civ1,2);1687 nbslice=size(num1_civ1,1);1688 1689 %RUN CIV11690 if box_test(1)==11691 RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)1692 if compare==31693 RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc)1694 end1695 end1696 1697 %RUN FIX11698 if box_test(2)==11699 filebase=get(handles.displ_filebase,'String');1700 %names of the civ1 fields1701 field1.vel_type='civ1';1702 field1.nb='nb_vectors';1703 % field1.X='vec_X';1704 % field1.Y='vec_Y';1705 % field1.U='vec_U';1706 % field1.V='vec_V';1707 field1.fixflag='vec_FixFlag';1708 flagindex(1)=get(handles.vec_Fmin2, 'Value');1709 flagindex(2)=get(handles.vec_F3, 'Value');1710 flagindex(3)=get(handles.vec_F2, 'Value');1711 thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C1712 thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus1713 inf_sup=get(handles.inf_sup1,'Value');1714 menu=get(handles.field_ref1,'String');1715 index=get(handles.field_ref1,'Value');1716 if isempty(menu)1717 fieldchoice='';1718 else1719 fieldchoice=menu{index};1720 end1721 h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar1722 test_mask=get(handles.get_mask_fix1,'Value');1723 if test_mask1724 maskdispl=get(handles.mask_fix1,'String');1725 if exist(maskdispl,'file')1726 test_mask=2;1727 maskname=maskdispl;1728 else1729 maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name1730 end1731 end1732 for ifile=1:nbfield1733 waitbar(ifile/nbfield); %update the waitbar1734 for j=1:nbslice1735 if test_mask==01736 maskname='noFile use default';1737 maskflag=0;1738 elseif test_mask==11739 nbslice_mask=str2double(maskdispl(1:end-4)); %1740 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;1741 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair1742 maskflag= exist(maskname,'file')==2;1743 if ~maskflag;1744 maskname='noFile use default';1745 end1746 end1747 if ~isempty(file_ref_fix1)1748 file_ref=file_ref_fix1{ifile,j};1749 else1750 file_ref='';1751 end1752 error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...1753 thresh_vel,inf_sup,file_ref,fieldchoice);1754 1755 if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)'))1756 if test_mask==01757 maskname='noFile use default';1758 maskflag=0;1759 else1760 maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name1761 nbslice_mask=str2num(maskdispl(1:end-4)); %1762 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;1763 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');1764 maskflag= exist(maskname,'file')==2;1765 if ~maskflag;1766 maskname='noFile use default';1767 end1768 end1769 error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,...1770 thresh_vel,inf_sup,file_ref,fieldchoice);1771 if ~isempty(error)1772 msgbox_uvmat('ERROR',error)1773 return1774 end1775 end1776 end1777 end1778 close(h)1779 end1780 1781 % RUN PATCH11782 if box_test(3)==11783 rho_patch1=str2num(get(handles.rho_patch1,'String'));1784 if isempty(rho_patch1)1785 rho_patch1='1000';1786 set(handles.rho_patch1,'String','1')1787 else1788 rho_patch1=num2str(1000*rho_patch1);1789 end1790 nx_patch1=get(handles.nx_patch1,'String');1791 if isequal(str2num(nx_patch1),[])1792 nx_patch1='50' ;%default1793 set(handles.nx_patch1,'String','50');1794 end1795 ny_patch1=get(handles.ny_patch1,'String');1796 if isequal(str2num(ny_patch1),[])1797 ny_patch1='50' ;%default1798 set(handles.ny_patch1,'String','50');1799 end1800 subdomain_patch1=get(handles.subdomain_patch1,'String');1801 thresh_patch1=get(handles.thresh_patch1,'String');1802 test_interp=get(handles.test_interp,'Value');1803 icount=0;1804 for ifile=1:nbfield1805 for j=1:nbslice1806 icount=icount+1;1807 barlength=0.188*icount/(nbfield*nbslice);1808 set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength])1809 drawnow1810 if isequal(get(handles.test_stereo1,'Value'),0)1811 cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);1812 s=-1;1813 if sge1814 [s,w]=unix(['qrsh -q -fast.q ' cmd]);1815 end1816 if s~=01817 display(['!' cmd])1818 eval(['!' cmd]);1819 end1820 1821 %stereo case:1822 elseif isequal(get(handles.test_stereo1,'Value'),1)1823 if exist('stinterp_exe','var')%Prog Gauthier1824 cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},...1825 nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']);1826 display(['!' cmd])1827 eval(['!' cmd]);1828 else1829 RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},...1830 str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']);1831 end1832 end1833 if compare==3 && isequal(get(handles.test_stereo1,'Value'),0)1834 cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);1835 s=-1;1836 if sge1837 [s,w]=unix(['qrsh -q -fast.q ' cmd]);1838 end1839 if s~=01840 display(['!' cmd])1841 eval(['!' cmd]);1842 end1843 end1844 end1845 end1846 end1847 1848 % CIV21849 if box_test(4)==11850 RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,...1851 num_a_civ2,num_b_civ2,nom_type_nc)1852 end1853 1854 % FIX21855 if box_test(5)==11856 %names of the civ2 fields1857 field2.vel_type='civ2';1858 field2.nb='nb_vectors2';1859 field2.X='vec2_X';1860 field2.Y='vec2_Y';1861 field2.U='vec2_U';1862 field2.V='vec2_V';1863 field2.fixflag='vec2_FixFlag';1864 flagindex(1)=get(handles.vec_Fmin2_2, 'Value');1865 flagindex(2)=get(handles.vec_F3_2, 'Value');1866 flagindex(3)=get(handles.vec_F4, 'Value');1867 thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C1868 thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus1869 inf_sup=get(handles.inf_sup2,'Value');1870 menu=get(handles.field_ref2,'String');1871 index=get(handles.field_ref2,'Value');1872 if isempty(menu)1873 fieldchoice='';1874 else1875 fieldchoice=menu{index};1876 end1877 h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar1878 test_mask=get(handles.get_mask_fix2,'Value');1879 if test_mask1880 maskdispl=get(handles.mask_fix2,'String');1881 if exist(maskdispl,'file')1882 test_mask=2;1883 maskname=maskdispl;1884 else1885 maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name1886 end1887 end1888 for ifile=1:nbfield1889 waitbar(ifile/nbfield); %update the waitbar1890 for j=1:nbslice1891 if test_mask==01892 maskname='noFile use default';1893 maskflag=0;1894 elseif test_mask==11895 nbslice_mask=str2num(maskdispl(1:end-4)); %1896 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;1897 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');1898 maskflag= exist(maskname,'file')==2;1899 if ~maskflag;1900 maskname='noFile use default';1901 end1902 end1903 if ~isempty(file_ref_fix2)1904 file_ref=file_ref_fix2{ifile,j};1905 else1906 file_ref='';1907 end1908 error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,...1909 thresh_vel2,inf_sup,file_ref,fieldchoice);1910 if ~isempty(error)1911 msgbox_uvmat('ERROR',error)1912 return1913 end1914 if compare==31915 if test_mask==01916 maskname='noFile use default';1917 maskflag=0;1918 else1919 maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name1920 nbslice_mask=str2num(maskdispl(1:end-4)); %1921 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;1922 maskname=name_generator(maskbase,num1_mask,1,'.png','_i');1923 maskflag= exist(maskname,'file')==2;1924 if ~maskflag;1925 maskname='noFile use default';1926 end1927 end1928 error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,...1929 thresh_vel2,inf_sup,file_ref,fieldchoice);1930 if ~isempty(error)1931 msgbox_uvmat('ERROR',error)1932 return1933 end1934 end1935 end1936 end1937 close(h)1938 end1939 1940 %PATCH 21941 if box_test(6)==11942 rho_patch2=str2num(get(handles.rho_patch2,'String'));1943 if isempty(rho_patch2)1944 rho_patch2='1000';1945 set(handles.rho_patch2,'String','1')1946 else1947 rho_patch2=num2str(1000*rho_patch2);1948 end1949 nx_patch2=get(handles.nx_patch2,'String');1950 ny_patch2=get(handles.ny_patch2,'String');1951 thresh_patch2=get(handles.thresh_patch2,'String');1952 if isequal(str2num(nx_patch2),[])1953 nx_patch2='50' ;%default1954 set(handles.nx_patch2,'String','50');1955 end1956 if isequal(str2num(ny_patch2),[])1957 ny_patch2='50' ;%default1958 set(handles.ny_patch2,'String','50');1959 end1960 subdomain_patch2=get(handles.subdomain_patch2,'String');1961 icount=0;1962 for ifile=1:nbfield1963 for j=1:nbslice1964 icount=icount+1;1965 barlength=0.188*icount/(nbfield*nbslice);1966 set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength])1967 drawnow1968 if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0)1969 cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);1970 s=-1;1971 if sge1972 [s,w]=unix(['qrsh -q -fast.q ' cmd]);1973 end1974 if s~=01975 display(['!' cmd])1976 eval(['!' cmd]);1977 end1978 elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1)1979 if exist('stinterp_exe','var')%Prog Gauthier1980 cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},...1981 nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']);1982 display(['!' cmd])1983 eval(['!' cmd])1984 else1985 RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...1986 str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])1987 end1988 end1989 if compare==3 && isequal(get(handles.test_stereo2,'Value'),0)1990 cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0);1991 s=-1;1992 if sge1993 [s,w]=unix(['qrsh -q -fast.q ' cmd]);1994 end1995 if s~=01996 display(['!' cmd])1997 eval(['!' cmd]);1998 end1999 end2000 end2001 end2002 end2003 2004 set(handles.RUN, 'Enable','On')2005 set(handles.RUN,'BackgroundColor',[1 0 0])2006 2007 %save the current interface setting as figure namefig, append .0 to the name if it already exists2008 if isfield(filecell,'st')2009 fileresu=filecell.st{1,1};2010 elseif isfield(filecell,'nc')2011 if isfield(filecell.nc,'civ2')2012 fileresu=filecell.nc.civ2{1,1};2013 else2014 fileresu=filecell.nc.civ1{1,1};2015 end2016 end2017 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu);2018 namedoc=fullfile(RootPath,subdir,RootFile);2019 detect=1;2020 while detect==12021 namefigfull=[namedoc '.fig'];2022 hh=dir(namefigfull);2023 if ~isempty(hh)2024 detect=1;2025 namedoc=[namedoc '.0'];2026 else2027 detect=0;2028 end2029 end2030 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml)2031 2032 %------------------------------------------------------------------------2033 % --- Executes on button press in BATCH: remote processing2034 function BATCH_Callback(hObject, eventdata, handles)2035 %------------------------------------------------------------------------2036 global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe2037 compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)2038 2039 %check the list of operations:2040 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};2041 run_flag=1;2042 box_test(1)=get(handles.CIV1,'Value');2043 box_test(2)=get(handles.FIX1,'Value');2044 box_test(3)=get(handles.PATCH1,'Value');2045 box_test(4)=get(handles.CIV2,'Value');2046 box_test(5)=get(handles.FIX2,'Value');2047 box_test(6)=get(handles.PATCH2,'Value');2048 index=find(box_test==1);2049 if isempty(index)2050 msgbox_uvmat('ERROR','no selected operation')2051 return2052 end2053 index_first=min(index);2054 index_last=max(index);2055 box_used=box_test([index_first : index_last]);2056 [box_missing,ind_missing]=min(box_used);2057 if isequal(box_missing,0)2058 msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]);2059 return2060 end2061 2062 %root name2063 filebase=get(handles.displ_filebase,'String');2064 if isempty(filebase)||isequal(filebase,'')2065 msgbox_uvmat('ERROR','no input files')2066 return2067 end2068 2084 2069 2085 %check mask if selecetd … … 2099 2115 if exist(xmlfile,'file') 2100 2116 t=xmltree(xmlfile); 2101 s param=convert(t);2117 s=convert(t); 2102 2118 end 2103 2119 % else … … 2108 2124 % end 2109 2125 % end 2110 sge=0; 2111 if isfield(sparam,'Civ_exe') 2112 Civ_exe=sparam.Civ_exe; 2113 end 2114 if isfield(sparam,'Civ1_exe') 2115 civ1_exe=sparam.Civ1_exe; 2116 end 2117 if isfield(sparam,'Civ2_exe') 2118 civ2_exe=sparam.Civ2_exe; 2119 end 2120 if isfield(sparam,'Patch_exe') 2121 patch_exe=sparam.Patch_exe; 2122 end 2123 if isfield(sparam,'PatchNew_exe') 2124 patch_new_exe=sparam.PatchNew_exe; 2126 % batch=0; 2127 if batch 2128 if isfield(s,'BatchParam') 2129 sparam=s.BatchParam; 2130 if ~ismember(sparam.BatchMode,{'sge'}) 2131 msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) 2132 end 2133 else 2134 msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') 2135 return 2136 end 2137 else 2138 if isfield(s,'RunParam') 2139 sparam=s.RunParam; 2140 else 2141 msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') 2142 return 2143 end 2144 end 2145 if isfield(sparam,'CivBin') 2146 CivBin=sparam.CivBin; 2147 end 2148 if isfield(sparam,'Civ1Bin') 2149 civ1Bin=sparam.Civ1Bin; 2150 end 2151 if isfield(sparam,'Civ2Bin') 2152 civ2Bin=sparam.Civ2Bin; 2153 end 2154 if isfield(sparam,'PatchBin') 2155 patchBin=sparam.PatchBin; 2156 end 2157 if isfield(sparam,'PatchNewBin') 2158 patch_newBin=sparam.PatchNewBin; 2125 2159 end 2126 if isfield(sparam,'Fix _exe')2127 fix _exe=sparam.Fix_exe;2160 if isfield(sparam,'FixBin') 2161 fixBin=sparam.FixBin; 2128 2162 end 2129 if isfield(sparam,'Todo_path') 2130 todo_path=sparam.Todo_path; 2131 end 2132 if isfield(sparam,'SGE') 2133 sge=str2num(sparam.SGE); 2134 end 2163 % if isfield(sparam,'Todo_path') 2164 % todo_path=sparam.Todo_path; 2165 % end 2166 if batch 2167 if isfield(sparam,'BatchMode') 2168 batch_mode=sparam.BatchMode; 2169 end 2170 else 2171 MaxCivProcesses=50; 2172 if isfield(sparam,'MaxCivProcesses') 2173 MaxCivProcesses=str2double(sparam.MaxCivProcesses); 2174 end 2175 end 2176 2177 %initialize the waitbars 2178 set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) 2179 set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) 2180 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) 2181 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) 2182 set(handles.BATCH, 'Enable','Off') 2183 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) 2184 drawnow 2185 %get the filename root, nomenclature and numbers 2186 2187 % for Windows system find the UBC path name if needed 2188 if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') 2189 cur_dir=pwd; 2190 if ~isequal(cur_dir(2:3),':\') 2191 cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: 2192 end 2193 [ss,ww]=dos(['net use ' filebase(1:2)]); 2194 if isequal(ss,0) 2195 rankpath=findstr(ww,'\\'); 2196 if ~isempty(rankpath) 2197 wwrest=ww(rankpath:end); 2198 rankend=min(find(double(wwrest)==10))-1; 2199 filebase=[wwrest(1:rankend) filebase(3:end)]; 2200 set(handles.displ_filebase,'String',filebase); 2201 end 2202 else 2203 msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); 2204 set(handles.BATCH, 'Enable','On') 2205 set(handles.BATCH,'BackgroundColor',[1 0 0]) 2206 return 2207 end 2208 end 2209 2210 % set the list of files and check them 2211 display('checking the files...') 2212 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... 2213 set_civ_filenames(handles,compare,box_test); 2135 2214 2136 2215 %choice of batch priority 2137 2216 ind_answer=2; 2138 if sge2217 if batch 2139 2218 [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) 2140 2219 if isequal(s,0) … … 2152 2231 return 2153 2232 end 2154 end 2155 2156 %initialize the waitbars 2157 set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) 2158 set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) 2159 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) 2160 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) 2161 set(handles.BATCH, 'Enable','Off') 2162 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) 2163 drawnow 2164 %get the filename root, nomenclature and numbers 2165 2166 % for Windows system find the UBC path name if needed 2167 if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') 2168 cur_dir=pwd; 2169 if ~isequal(cur_dir(2:3),':\') 2170 cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: 2171 end 2172 [ss,ww]=dos(['net use ' filebase(1:2)]); 2173 if isequal(ss,0) 2174 rankpath=findstr(ww,'\\'); 2175 if ~isempty(rankpath) 2176 wwrest=ww(rankpath:end); 2177 rankend=min(find(double(wwrest)==10))-1; 2178 filebase=[wwrest(1:rankend) filebase(3:end)]; 2179 set(handles.displ_filebase,'String',filebase); 2180 end 2181 else 2182 msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); 2183 set(handles.BATCH, 'Enable','On') 2184 set(handles.BATCH,'BackgroundColor',[1 0 0]) 2185 return 2186 end 2187 end 2188 2189 % set the list of files and check them 2190 display('checking the files...') 2191 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... 2192 set_civ_filenames(handles,compare,box_test); 2233 else 2234 if isunix 2235 [s,w]=unix('ps faux |grep civ|wc -l'); 2236 w(end)=[]; 2237 if str2num(w)+numel(filecell)> MaxCivProcesses 2238 msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) 2239 return 2240 end 2241 end 2242 end 2193 2243 2194 2244 display('files OK, processing...') … … 2227 2277 2228 2278 %get patch1 parameters 2229 2279 if box_test(3)==1 2230 2280 rho_patch1=str2num(get(handles.rho_patch1,'String')); 2231 2281 if isempty(rho_patch1) … … 2296 2346 end 2297 2347 2298 if ~sge2299 2300 %OPEN THE WAIT LIST FOR BATCH PROCESSES2301 name_lock=fullfile(todo_path,'lock'); %lock file2302 iwait=0;2303 while(exist(name_lock) & iwait<15)2304 pause(1); %wait 1 second2305 iwait=iwait+1;2306 end2307 if iwait==152308 msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ])2309 set(handles.BATCH, 'Enable','On')2310 set(handles.BATCH,'BackgroundColor',[1 0 0])2311 return2312 end2313 p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere2314 name_todo=fullfile(todo_path,'TODO.txt');2315 p1=fopen(name_todo,'a');2316 if (p1<0)2317 msgbox_uvmat('ERROR',['error in opening ' name_todo])2318 set(handles.BATCH, 'Enable','On')2319 set(handles.BATCH,'BackgroundColor',[1 0 0])2320 return;2321 end2322 end2348 % if ~sge 2349 % 2350 % %OPEN THE WAIT LIST FOR BATCH PROCESSES 2351 % name_lock=fullfile(todo_path,'lock'); %lock file 2352 % iwait=0; 2353 % while(exist(name_lock) & iwait<15) 2354 % pause(1); %wait 1 second 2355 % iwait=iwait+1; 2356 % end 2357 % if iwait==15 2358 % msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) 2359 % set(handles.BATCH, 'Enable','On') 2360 % set(handles.BATCH,'BackgroundColor',[1 0 0]) 2361 % return 2362 % end 2363 % p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere 2364 % name_todo=fullfile(todo_path,'TODO.txt'); 2365 % p1=fopen(name_todo,'a'); 2366 % if (p1<0) 2367 % msgbox_uvmat('ERROR',['error in opening ' name_todo]) 2368 % set(handles.BATCH, 'Enable','On') 2369 % set(handles.BATCH,'BackgroundColor',[1 0 0]) 2370 % return; 2371 % end 2372 % end 2323 2373 2324 2374 %MAIN LOOP … … 2331 2381 i_cmd=0; 2332 2382 cmd=''; 2333 if sge2383 if batch 2334 2384 %fid=fopen([filename '.cmx'],'w') 2335 2385 cmd='#!/bin/bash'; … … 2407 2457 i_cmd=i_cmd+1; 2408 2458 if isequal(civAll,0) 2409 cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles )];2459 cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam)]; 2410 2460 else 2411 2461 civAllCmd=[civAllCmd ' civ1 ']; … … 2436 2486 end 2437 2487 if isequal(civAll,0) 2438 cmd_FIX=[fix _exe' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ...2488 cmd_FIX=[fixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... 2439 2489 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... 2440 2490 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; … … 2573 2623 %endTESTgrid 2574 2624 i_cmd=i_cmd+1; 2575 cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2 );2625 cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2,sparam); 2576 2626 if isequal(civAll,0) 2577 2627 if(isunix) … … 2582 2632 else 2583 2633 civAllCmd=[civAllCmd ' civ2 ']; 2584 str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2 );2634 str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2,sparam); 2585 2635 fieldnames=fields(str); 2586 2636 [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); … … 2608 2658 end 2609 2659 if isequal(civAll,0) 2610 cmd_FIX=[fix _exe' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ...2660 cmd_FIX=[fixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... 2611 2661 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2612 2662 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; … … 2681 2731 if isequal(civAll,1) 2682 2732 save(civAllxml,[filename_cmx([1:end-4]) '.xml']); 2683 cmd=char({cmd;[Civ _exe' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});2733 cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); 2684 2734 end 2685 2735 % create the .bat file: 2686 if sge2736 if batch 2687 2737 [Rootbat,Filebat,extbat]=fileparts(filename_cmx); 2688 2738 filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); … … 2695 2745 fclose(fid); 2696 2746 %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat 2697 if sge 2698 pvalue=num2str((1-ind_answer)*500); 2699 namelog=[filename_bat '.patch.log']; 2700 ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; 2701 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); 2747 if batch 2748 switch batch_mode 2749 case 'sge' 2750 pvalue=num2str((1-ind_answer)*500); 2751 namelog=[filename_bat '.patch.log']; 2752 ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; 2753 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); 2754 end 2755 2756 2757 2702 2758 else 2759 %% to lauch the jobs locally : 2703 2760 if(isunix) 2704 cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat];2761 eval(['!. ' filename_bat ' &']); 2705 2762 else 2706 cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat';2763 eval(['!' filename_bat ' &']); 2707 2764 end 2708 count= fprintf(p1,'%s\n', cmdtodo); 2765 % if(isunix) 2766 % cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; 2767 % else 2768 % cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; 2769 % end 2770 % count= fprintf(p1,'%s\n', cmdtodo); 2709 2771 end 2710 2772 end 2711 2773 end 2712 if ~sge2713 fclose(p1);2714 fclose(p0);2715 delete(name_lock);2716 end2774 % if ~sge 2775 % fclose(p1); 2776 % fclose(p0); 2777 % delete(name_lock); 2778 % end 2717 2779 2718 2780 set(handles.BATCH, 'Enable','On') … … 3403 3465 %------------------------------------------------------------------------ 3404 3466 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 3405 global civ1 _exesge%name of the executable for civ1 calculation3467 global civ1Bin sge%name of the executable for civ1 calculation 3406 3468 3407 3469 %get civ parameters … … 3598 3660 3599 3661 s=-1; 3600 display(['!' civ1 _exe' -f ' filename_cmx ' > ' namelog ])3601 eval(['!' civ1 _exe' -f ' filename_cmx ' > ' namelog ]);3662 display(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]) 3663 eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]); 3602 3664 % if sge%dispatch computation on the cluster using interactive queue 3603 % % [s,w] = unix(['qrsh -q fast.q ' civ1 _exe' -f ' filename_cmx ' > ' namelog ' 2>&1' ]);3665 % % [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); 3604 3666 % end 3605 3667 % if s~=0 3606 % % ['!' civ1 _exe' -f ' filename_cmx ' > ' namelog]3607 % % eval(['!' civ1 _exe' -f ' filename_cmx ' > ' namelog]);3668 % % ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog] 3669 % % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]); 3608 3670 % end 3609 3671 end 3610 3672 end 3611 3673 3612 % ------------------------------------------------------------------------3613 % RUN CIV2 CIV2 CIV2 CIV23614 function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc)3615 % ------------------------------------------------------------------------3616 % filecell_2: names of first image3617 % filecell_3: names of second images3618 global civ2_exesge3619 3620 % names of the civ2 fields3621 field.vel_type='civ2';3622 field.nb='nb_vectors2';3623 field.X='vec2_X';3624 field.Y='vec2_Y';3625 field.U='vec2_U';3626 field.V='vec2_V';3627 3628 % get civ parameters3629 ibx=get(handles.ibx_civ2,'String');3630 iby=get(handles.iby_civ2,'String');3631 rho=get(handles.rho_civ2,'String');3632 decimal=int2str(get(handles.decimal,'Value'));3633 deformation=int2str(get(handles.deformation,'Value'));3634 dx=get(handles.dx_civ2,'String');3635 dy=get(handles.dy_civ2,'String');3636 if isequal(str2num(dx),[])3637 dx='20';%default3638 end3639 if isequal(str2num(dy),[])3640 dy='20';%default3641 end3642 pxcmx='1';%velocity fields are expressed in pixel displacement3643 pxcmy='1';3644 A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size3645 sizim=size(A);3646 npx=num2str(sizim(2));3647 npy=num2str(sizim(1));3648 time=get(handles.displ_filebase,'UserData'); %get the set of times3649 filebase=get(handles.displ_filebase,'String');3650 % grid3651 gridname='';%default ='noFile use default'3652 gridflag='n';%default3653 test_grid=get(handles.browse_gridciv2,'Value');3654 nbslice_grid=[];3655 if test_grid3656 gridname=get(handles.grid_civ2,'String');3657 if numel(gridname)>4 && isequal(gridname(end-3:end),'grid')3658 nbslice_grid=str2num(gridname(1:end-4)); %3659 if ~isempty(nbslice_grid)3660 gridflag='y';3661 end3662 elseif exist(gridname,'file')3663 gridflag='y';3664 else3665 msgbox_uvmat('ERROR',['input grid file ' gridname ' not found'])3666 return3667 end3668 end3669 sizcell=size(filecell_2);3670 nbfield=sizcell(1);3671 nbslice=sizcell(2);3672 3673 % main loop3674 icount=0;3675 for ifile=1:nbfield3676 for j=1:nbslice3677 icount=icount+1;3678 barlength=0.188*icount/(nbfield*nbslice);3679 set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength])3680 drawnow3681 filename_ima_2=cell2mat(filecell_2(ifile,j));3682 filename_ima_2([end-3:end])=[];%remove .png extension3683 filename_ima_3=cell2mat(filecell_3(ifile,j));3684 filename_ima_3([end-3:end])=[];%remove .png extension3685 filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file3686 filename_cmx([end-1:end])=[ 'cm'];%name of cmx file3687 filename_cmx=[filename_cmx 'x'];3688 namelog=[filename_cmx([1:end-3]) 'log'];3689 if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j)3690 Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j)));3691 if isequal(Dt,'0')3692 Dt='1' ;%case of 'displacement' mode3693 end3694 T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);3695 else3696 Dt='1';3697 T0='0';3698 end3699 term_a=num2stra(num_a(j),nom_type_nc);3700 term_b=num2stra(num_b(j),nom_type_nc);3701 filename_nc1=cell2mat(filecell_nc1(ifile,j));3702 filename_nc1([end-2:end])=[]; % remove '.nc'3703 if test_grid && ~isempty(nbslice_grid)3704 num1_grid=mod(num1(ifile)-1,nbslice_grid)+1;3705 gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];3706 if ~exist(gridname,'file')3707 msgbox_uvmat('ERROR',['missing grid file ' gridname])3708 return3709 end3710 end3711 test_mask=get(handles.get_mask_civ2,'Value');3712 if test_mask==03713 maskname='noFile use default';3714 maskflag='n';3715 else3716 maskdispl=get(handles.mask_civ2,'String');3717 maskbase=[filebase '_' maskdispl]; %3718 nbslice_mask=str2num(maskdispl(1:end-4)); %3719 num1_mask=mod(num1(ifile)-1,nbslice_mask)+1;3720 maskname =name_generator(maskbase,num1_mask,1,'.png','_i');3721 if ~exist(maskname,'file')3722 maskflag='y';3723 else3724 maskname='noFile use default';3725 maskflag='n';3726 end3727 end3728 3729 textcmx={'############## CMX file';...3730 ['FirstImage ' filename_ima_2];...3731 ['LastImage ' filename_ima_3];...3732 'XX' ;...3733 ['Mask ' maskflag];...3734 ['MaskName ' maskname];...3735 ['ImageSize ' npx ' ' npy];...3736 ['CorrelationBoxesSize ' ibx ' ' iby];...3737 ['SearchBoxeSize ' ibx ' ' iby];...3738 ['RO ' rho];...3739 ['GridSpacing ' dx ' ' dy];...3740 'XX 1.0';...3741 ['Dt_TO ' Dt ' ' T0];...3742 ['PixCmXY ' pxcmx ' ' pxcmy];...3743 'XX 1';...3744 ['ShiftXY 0 0'];...3745 ['Grid ' gridflag];...3746 ['GridName ' gridname];...3747 'XX 85';...3748 'XX 1.0';...3749 'XX 1.0';...3750 'Hart 1';...3751 ['DecimalShift ' decimal];...3752 ['Deformation ' deformation];...3753 'CorrelationMin 0';...3754 'IntensityMin 0';...3755 'SeuilImage n';...3756 'SeuilImageValues 0 4096';...3757 ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ?3758 ['ImageUsedBefore ' filename_nc1]};3759 textout=char(textcmx);3760 dlmwrite(filename_cmx,textout,'');3761 s=-1;3762 display(['!' civ2_exe' -f ' filename_cmx ' > ' namelog ])3763 eval(['!' civ2_exe' -f ' filename_cmx ' > ' namelog ]);3764 3765 % if sge%dispatch computation on the cluster using interactive queue3766 % [s,w] = unix(['qrsh -q fast.q ' civ2_exe' -f ' filename_cmx ' > ' namelog ' 2>&1']);3767 % end3768 % if s~=03769 % eval(['!' civ2_exe' -f ' filename_cmx ' > ' namelog]);3770 % ['!' civ2_exe' -f ' filename_cmx ' > ' namelog]3771 % end3772 end3773 end3774 % close(h)3674 % %------------------------------------------------------------------------ 3675 % % RUN CIV2 CIV2 CIV2 CIV2 3676 % function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) 3677 % %------------------------------------------------------------------------ 3678 % %filecell_2: names of first image 3679 % %filecell_3: names of second images 3680 % global civ2Bin sge 3681 % 3682 % %names of the civ2 fields 3683 % field.vel_type='civ2'; 3684 % field.nb='nb_vectors2'; 3685 % field.X='vec2_X'; 3686 % field.Y='vec2_Y'; 3687 % field.U='vec2_U'; 3688 % field.V='vec2_V'; 3689 % 3690 % %get civ parameters 3691 % ibx=get(handles.ibx_civ2,'String'); 3692 % iby=get(handles.iby_civ2,'String'); 3693 % rho=get(handles.rho_civ2,'String'); 3694 % decimal=int2str(get(handles.decimal,'Value')); 3695 % deformation=int2str(get(handles.deformation,'Value')); 3696 % dx=get(handles.dx_civ2,'String'); 3697 % dy=get(handles.dy_civ2,'String'); 3698 % if isequal(str2num(dx),[]) 3699 % dx='20';%default 3700 % end 3701 % if isequal(str2num(dy),[]) 3702 % dy='20';%default 3703 % end 3704 % pxcmx='1';%velocity fields are expressed in pixel displacement 3705 % pxcmy='1'; 3706 % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size 3707 % sizim=size(A); 3708 % npx=num2str(sizim(2)); 3709 % npy=num2str(sizim(1)); 3710 % time=get(handles.displ_filebase,'UserData'); %get the set of times 3711 % filebase=get(handles.displ_filebase,'String'); 3712 % %grid 3713 % gridname='';%default ='noFile use default' 3714 % gridflag='n';%default 3715 % test_grid=get(handles.browse_gridciv2,'Value'); 3716 % nbslice_grid=[]; 3717 % if test_grid 3718 % gridname=get(handles.grid_civ2,'String'); 3719 % if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') 3720 % nbslice_grid=str2num(gridname(1:end-4)); % 3721 % if ~isempty(nbslice_grid) 3722 % gridflag='y'; 3723 % end 3724 % elseif exist(gridname,'file') 3725 % gridflag='y'; 3726 % else 3727 % msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) 3728 % return 3729 % end 3730 % end 3731 % sizcell=size(filecell_2); 3732 % nbfield=sizcell(1); 3733 % nbslice=sizcell(2); 3734 % 3735 % %main loop 3736 % icount=0; 3737 % for ifile=1:nbfield 3738 % for j=1:nbslice 3739 % icount=icount+1; 3740 % barlength=0.188*icount/(nbfield*nbslice); 3741 % set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) 3742 % drawnow 3743 % filename_ima_2=cell2mat(filecell_2(ifile,j)); 3744 % filename_ima_2([end-3:end])=[];%remove .png extension 3745 % filename_ima_3=cell2mat(filecell_3(ifile,j)); 3746 % filename_ima_3([end-3:end])=[];%remove .png extension 3747 % filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file 3748 % filename_cmx([end-1:end])=[ 'cm'];%name of cmx file 3749 % filename_cmx=[filename_cmx 'x']; 3750 % namelog=[filename_cmx([1:end-3]) 'log']; 3751 % if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) 3752 % Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); 3753 % if isequal(Dt,'0') 3754 % Dt='1' ;%case of 'displacement' mode 3755 % end 3756 % T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); 3757 % else 3758 % Dt='1'; 3759 % T0='0'; 3760 % end 3761 % term_a=num2stra(num_a(j),nom_type_nc); 3762 % term_b=num2stra(num_b(j),nom_type_nc); 3763 % filename_nc1=cell2mat(filecell_nc1(ifile,j)); 3764 % filename_nc1([end-2:end])=[]; % remove '.nc' 3765 % if test_grid && ~isempty(nbslice_grid) 3766 % num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; 3767 % gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 3768 % if ~exist(gridname,'file') 3769 % msgbox_uvmat('ERROR',['missing grid file ' gridname]) 3770 % return 3771 % end 3772 % end 3773 % test_mask=get(handles.get_mask_civ2,'Value'); 3774 % if test_mask==0 3775 % maskname='noFile use default'; 3776 % maskflag='n'; 3777 % else 3778 % maskdispl=get(handles.mask_civ2,'String'); 3779 % maskbase=[filebase '_' maskdispl]; % 3780 % nbslice_mask=str2num(maskdispl(1:end-4)); % 3781 % num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; 3782 % maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); 3783 % if ~exist(maskname,'file') 3784 % maskflag='y'; 3785 % else 3786 % maskname='noFile use default'; 3787 % maskflag='n'; 3788 % end 3789 % end 3790 % 3791 % textcmx={'############## CMX file';... 3792 % ['FirstImage ' filename_ima_2];... 3793 % ['LastImage ' filename_ima_3];... 3794 % 'XX' ;... 3795 % ['Mask ' maskflag];... 3796 % ['MaskName ' maskname];... 3797 % ['ImageSize ' npx ' ' npy];... 3798 % ['CorrelationBoxesSize ' ibx ' ' iby];... 3799 % ['SearchBoxeSize ' ibx ' ' iby];... 3800 % ['RO ' rho];... 3801 % ['GridSpacing ' dx ' ' dy];... 3802 % 'XX 1.0';... 3803 % ['Dt_TO ' Dt ' ' T0];... 3804 % ['PixCmXY ' pxcmx ' ' pxcmy];... 3805 % 'XX 1';... 3806 % ['ShiftXY 0 0'];... 3807 % ['Grid ' gridflag];... 3808 % ['GridName ' gridname];... 3809 % 'XX 85';... 3810 % 'XX 1.0';... 3811 % 'XX 1.0';... 3812 % 'Hart 1';... 3813 % ['DecimalShift ' decimal];... 3814 % ['Deformation ' deformation];... 3815 % 'CorrelationMin 0';... 3816 % 'IntensityMin 0';... 3817 % 'SeuilImage n';... 3818 % 'SeuilImageValues 0 4096';... 3819 % ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? 3820 % ['ImageUsedBefore ' filename_nc1]}; 3821 % textout=char(textcmx); 3822 % dlmwrite(filename_cmx,textout,''); 3823 % s=-1; 3824 % display(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]) 3825 % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]); 3826 % 3827 % % if sge%dispatch computation on the cluster using interactive queue 3828 % % [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']); 3829 % % end 3830 % % if s~=0 3831 % % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]); 3832 % % ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog] 3833 % % end 3834 % end 3835 % end 3836 % % close(h) 3775 3837 3776 3838 %------------------------------------------------------------------------ … … 3778 3840 function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) 3779 3841 %------------------------------------------------------------------------ 3780 global patch _exe patch_new_exe3842 global patchBin patch_newBin 3781 3843 namelog=[filename_nc([1:end-3]) '_patch.log']; 3782 3844 if test_interp==0 3783 cmd_PATCH=[patch _exe' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ...3845 cmd_PATCH=[patchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... 3784 3846 ' > ' namelog ' 2>&1']; % redirect standard output to the log file 3785 3847 else %nouveau programme patch 3786 cmd_PATCH=[patch_new _exe' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ...3848 cmd_PATCH=[patch_newBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... 3787 3849 ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file 3788 3850 end … … 3790 3852 %------------------------------------------------------------------------ 3791 3853 % --- STEREO Interp 3792 function cmd=RUN_STINTERP(stinterp _exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)3854 function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) 3793 3855 %------------------------------------------------------------------------ 3794 3856 namelog=[filename_nc([1:end-3]) '_stinterp.log']; 3795 cmd=[stinterp _exe' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ...3857 cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... 3796 3858 ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file 3797 3859 … … 4473 4535 function enable_patch1(handles) 4474 4536 %------------------------------------------------------------------------ 4475 global patch_new _exe4537 global patch_newBin 4476 4538 set(handles.frame_patch1,'BackgroundColor',[1 1 0]) 4477 4539 set(handles.rho_patch1,'Visible','on') … … 4485 4547 set(handles.nx_patch1_title,'Visible','on') 4486 4548 set(handles.ny_patch1_title,'Visible','on') 4487 if (~isequal(patch_new _exe,[]) & ~isequal(patch_new_exe,[]))4549 if (~isequal(patch_newBin,[]) & ~isequal(patch_newBin,[])) 4488 4550 set(handles.test_interp,'Visible','on'); 4489 4551 end … … 4777 4839 %------------------------------------------------------------------------ 4778 4840 % --- CIV1 CIV1 CIV1 CIV1 4779 function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles )4841 function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles,sparam) 4780 4842 %------------------------------------------------------------------------ 4781 4843 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4782 global civ1_exe Civ_exe sge%name of the executable for civ1 calculation4783 4844 4784 4845 %changes : filename_cmx -> filename ( no extension ) … … 4854 4915 fclose(fid); 4855 4916 4856 if sge4857 cmd_CIV1=[ civ1_exe' -f ' filename '.cmx' ]; % redirect standard output to the log file4858 else4859 cmd_CIV1=[civ1_exe' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file4860 end4917 % if sge 4918 cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx' ]; % redirect standard output to the log file 4919 % else 4920 % cmd_CIV1=[civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file 4921 % end 4861 4922 if(isunix) 4862 4923 [Rootbat,Filebat,extbat]=fileparts(namelog); 4863 4924 ncName=fullfile(Rootbat,[ Filebat '.nc']); 4864 cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog'.civ1.log' '\n' 'chmod g+w ' ncName];4865 else 4866 cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog'.civ1.log'];4925 cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName]; 4926 else 4927 cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log']; 4867 4928 end 4868 4929 … … 4872 4933 %------------------------------------------------------------------------ 4873 4934 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4874 global civ1 _exe Civ_exe%name of the executable for civ1 calculation4935 global civ1Bin CivBin%name of the executable for civ1 calculation 4875 4936 4876 4937 civ1.image1=par.filename_ima_a; … … 4911 4972 %------------------------------------------------------------------------ 4912 4973 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4913 global civ2 _exe Civ_exe%name of the executable for civ1 calculation4974 global civ2Bin CivBin%name of the executable for civ1 calculation 4914 4975 4915 4976 civ2.image1=par.filename_ima_a; … … 4960 5021 %------------------------------------------------------------------------ 4961 5022 % --- CIV2 CIV2 CIV2 CIV2 4962 function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par )5023 function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par,sparam) 4963 5024 %------------------------------------------------------------------------ 4964 5025 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4965 global civ2_exesge%name of the executable for civ1 calculation5026 % global civ2Bin sge%name of the executable for civ1 calculation 4966 5027 if isequal(par.Dt,'0') 4967 5028 par.Dt='1' ;%case of 'displacement' mode … … 5001 5062 fprintf(fid,textout); 5002 5063 fclose(fid) 5003 if sge5004 cmd_CIV2=[ civ2_exe' -f ' filename_cmx ]; % redirect standard output to the log file5005 else5006 cmd_CIV2=[civ2_exe' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file5007 end5064 % if sge 5065 cmd_CIV2=[sparam.Civ2Bin ' -f ' filename_cmx ]; % redirect standard output to the log file 5066 % else 5067 % cmd_CIV2=[civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file 5068 % end 5008 5069 5009 5070 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.