Changeset 257
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r256 r257 22 22 function varargout = civ(varargin) 23 23 24 % Last Modified by GUIDE v2.5 11-Mar-2011 08:21:2124 % Last Modified by GUIDE v2.5 27-May-2011 17:55:50 25 25 % Begin initialization code - DO NOT EDIT 26 26 gui_Singleton = 1; … … 66 66 filebase=''; % root file name ('filebase'.civ) 67 67 ext=[]; 68 set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'})69 set(handles.subdomain_patch1,'String','1500')% default values70 set(handles.subdomain_patch2,'String','1500')71 delete(handles.grid_patch1)72 delete(handles.get_gridpatch1)73 delete(handles.grid_patch2)74 delete(handles.get_gridpatch2)75 68 76 69 %default input parameters: … … 344 337 if ~isempty(Data.CivStage)%test for civ files 345 338 ind_opening=Data.CivStage; 346 set(handles.Civ All,'Value',3)339 set(handles.CivMode,'Value',3) 347 340 end 348 341 if ~isempty(Data.absolut_time_T0)%test for civx files 349 set(handles.Civ All,'Value',1)342 set(handles.CivMode,'Value',1) 350 343 if isfield(Data,'fix') && isequal(Data.fix,1) 351 344 ind_opening=3; … … 1426 1419 display(errormsg) 1427 1420 msgbox_uvmat('ERROR',errormsg) 1428 elseif isfield(handles,'status') %&& ~isequal(get(handles.Civ All,'Value'),3)1421 elseif isfield(handles,'status') %&& ~isequal(get(handles.CivMode,'Value'),3) 1429 1422 set(handles.status,'Value',1);%suppress status display 1430 1423 status_Callback(hObject, eventdata, handles) … … 1524 1517 nbslice=numel(num_a_civ1); 1525 1518 1526 %% read names of the .exe files for PIV and patch1519 %% choose the batch or run mode 1527 1520 path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat 1528 1521 xmlfile='PARAM.xml'; … … 1535 1528 if isfield(s,'BatchParam') 1536 1529 sparam=s.BatchParam; 1537 1538 if ~ismember(sparam.BatchMode,{'sge','oar'}) 1539 errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT']; 1540 return 1530 if isfield(sparam,'BatchMode') 1531 batch_mode=sparam.BatchMode; 1532 if ~ismember(batch_mode,{'sge','oar'}) 1533 errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; 1534 return 1535 end 1541 1536 end 1542 1537 else … … 1544 1539 return 1545 1540 end 1546 if isfield(sparam,'BatchMode') 1547 batch_mode=sparam.BatchMode; 1548 end 1549 % choice of batch priority: 1550 ind_answer=2; 1551 [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) 1552 if isequal(s,0) 1553 w(end)=[]; 1554 str_displ={[w ' jobs in the waiting list'];... 1555 '***********************';... 1556 'JOBS PRIORITY POLICY';... 1557 '- urgent = less than 100 images pairs';... 1558 '- normal = during the experiments';... 1559 '- low = post processing';... 1560 '***********************';... 1561 'Select a priority:'}; 1562 ' ';... 1563 str={'urgent';'normal';'low'}; 1564 [ind_answer,v] = listdlg('PromptString',str_displ,... 1565 'SelectionMode','single',... 1566 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); 1567 if isequal(v,0) % to handle Cancel button and figure close, 1568 errormsg='job cancelled'; 1569 return % a better way should be create 1570 end 1571 else 1572 msgbox_uvmat('ERROR','sge batch system not available') 1573 return 1574 end 1575 else 1541 1542 switch batch_mode 1543 case 'sge' 1544 % choice of batch priority: 1545 ind_answer=2; 1546 [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) 1547 if isequal(s,0) 1548 w(end)=[]; 1549 str_displ={[w ' jobs in the waiting list'];... 1550 '***********************';... 1551 'JOBS PRIORITY POLICY';... 1552 '- urgent = less than 100 images pairs';... 1553 '- normal = during the experiments';... 1554 '- low = post processing';... 1555 '***********************';... 1556 'Select a priority:'}; 1557 ' ';... 1558 str={'urgent';'normal';'low'}; 1559 [ind_answer,v] = listdlg('PromptString',str_displ,... 1560 'SelectionMode','single',... 1561 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); 1562 if isequal(v,0) % to handle Cancel button and figure close, 1563 errormsg='job cancelled'; 1564 return % a better way should be create 1565 end 1566 else 1567 msgbox_uvmat('ERROR','sge batch system not available') 1568 return 1569 end 1570 end 1571 else % run 1576 1572 if isfield(s,'RunParam') 1577 1573 sparam=s.RunParam; … … 1583 1579 1584 1580 %% choose the civ program 1585 ProgList=get(handles.CivAll,'String'); 1586 index=get(handles.CivAll,'Value'); 1587 CivX=isequal(ProgList{index},'CivX'); 1588 CivAll=isequal(ProgList{index},'CivAll'); 1589 CivUvmat=isequal(ProgList{index},'CivUvmat'); 1590 %CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs 1591 if CivAll && isfield(sparam,'CivBin') 1592 CivBin=sparam.CivBin; 1593 if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat 1594 sparam.CivBin=fullfile(path_UVMAT,CivBin); 1595 if ~exist(sparam.CivBin,'file') 1596 msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) 1597 return 1598 end 1599 end 1600 end 1601 if isfield(sparam,'Civ1Bin') 1602 Civ1Bin=sparam.Civ1Bin; 1603 if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat 1604 sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); 1605 if ~exist(sparam.Civ1Bin,'file') 1606 msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) 1607 return 1608 end 1609 end 1610 end 1611 if isfield(sparam,'Civ2Bin') 1612 Civ2Bin=sparam.Civ2Bin; 1613 if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat 1614 sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); 1615 if ~exist(sparam.Civ2Bin,'file') 1616 msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) 1617 return 1618 end 1619 end 1620 end 1621 if isfield(sparam,'PatchBin') 1622 if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat 1623 sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); 1624 end 1625 end 1626 if isfield(sparam,'FixBin') 1627 if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat 1628 sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); 1629 end 1581 ProgList=get(handles.CivMode,'String'); 1582 index=get(handles.CivMode,'Value'); 1583 % CivX=isequal(ProgList{index},'CivX'); 1584 % CivAll=isequal(ProgList{index},'CivAll'); 1585 % CivUvmat=isequal(ProgList{index},'CivUvmat'); 1586 CivMode=ProgList{index}; 1587 %CivMode=isequal(get(handles.CivMode,'Value'),2); % Boolean for new civ programs 1588 1589 switch CivMode 1590 case 'CivAll' 1591 if isfield(sparam,'CivBin') 1592 CivBin=sparam.CivBin; 1593 if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat 1594 sparam.CivBin=fullfile(path_UVMAT,CivBin); 1595 if ~exist(sparam.CivBin,'file') 1596 msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) 1597 return 1598 end 1599 end 1600 end 1601 case 'CivX' 1602 if isfield(sparam,'Civ1Bin') 1603 Civ1Bin=sparam.Civ1Bin; 1604 if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat 1605 sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); 1606 if ~exist(sparam.Civ1Bin,'file') 1607 msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) 1608 return 1609 end 1610 end 1611 end 1612 if isfield(sparam,'Civ2Bin') 1613 Civ2Bin=sparam.Civ2Bin; 1614 if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat 1615 sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); 1616 if ~exist(sparam.Civ2Bin,'file') 1617 msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) 1618 return 1619 end 1620 end 1621 end 1622 if isfield(sparam,'PatchBin') 1623 if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat 1624 sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); 1625 end 1626 end 1627 if isfield(sparam,'FixBin') 1628 if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat 1629 sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); 1630 end 1631 end 1632 case 'Matlab' 1633 if batch 1634 %% vérifier Mtlab installé sur le cluster 1635 end 1630 1636 end 1631 1637 … … 1638 1644 end 1639 1645 1640 %% get fix1 parameters 1646 %% get fix1 parameters TODO : par_fix1=read_param_fix1(handles); 1641 1647 if box_test(2)==1 1642 1648 flagindex1(1)=get(handles.vec_Fmin2, 'Value'); … … 1727 1733 subdomain_patch2=get(handles.subdomain_patch2,'String'); 1728 1734 thresh_patch2=get(handles.thresh_patch2,'String'); 1729 % test_interp=get(handles.test_interp,'Value');1730 1735 end 1731 1736 … … 1736 1741 for ifile=1:nbfield 1737 1742 for j=1:nbslice 1743 % initiate system command 1738 1744 i_cmd=0; 1739 cmd=''; 1740 if isunix % check: necessaire aussi en RUN? 1741 cmd='#!/bin/bash \n'; 1742 cmd=[cmd '#$ -cwd \n']; 1743 cmd=[cmd 'hostname && date \n']; 1744 cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group 1745 end 1746 if CivAll 1747 CivAllxml=xmltree;% xml contents, all parameters 1748 CivAllCmd=''; 1749 CivAllxml=set(CivAllxml,1,'name','CivDoc'); 1745 switch CivMode 1746 case 'CivX' 1747 cmd=''; 1748 if isunix % check: necessaire aussi en RUN? 1749 cmd='#!/bin/bash \n'; 1750 cmd=[cmd '#$ -cwd \n']; 1751 cmd=[cmd 'hostname && date \n']; 1752 cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group 1753 end 1754 case 'CivAll' 1755 % if CivAll 1756 CivAllxml=xmltree;% xml contents, all parameters 1757 CivAllCmd=''; 1758 CivAllxml=set(CivAllxml,1,'name','CivDoc'); 1750 1759 end 1751 1760 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) … … 1753 1762 if batch 1754 1763 filename_bat=fullfile(Rootbat,['job_' Filebat]); 1755 1764 else 1756 1765 filename_bat=flname; 1757 1766 end … … 1788 1797 end 1789 1798 end 1790 1791 1799 test_grid=get(handles.browse_gridciv1,'Value'); 1792 1800 if test_grid … … 1811 1819 par_civ1.gridflag='n'; 1812 1820 end 1813 %1821 1814 1822 i_cmd=i_cmd+1; 1815 if isequal(CivAll,0) 1816 civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe 1817 % if(isunix) 1818 % cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n']; 1819 % else 1820 % flname=regexprep(flname,'\\','\\\\'); 1821 % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; 1822 % end 1823 cmd=[cmd civ1_exe '\n']; 1824 else 1825 CivAllCmd=[CivAllCmd ' civ1 ']; 1826 str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); 1827 fieldnames=fields(str); 1828 [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); 1829 for ilist=1:length(fieldnames) 1830 val=eval(['str.' fieldnames{ilist}]); 1831 if ischar(val) 1832 [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); 1833 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1823 switch CivMode 1824 case 'CivX' 1825 civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe 1826 cmd=[cmd civ1_exe '\n']; 1827 case 'CivAll' 1828 CivAllCmd=[CivAllCmd ' civ1 ']; 1829 str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); 1830 fieldnames=fields(str); 1831 [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); 1832 for ilist=1:length(fieldnames) 1833 val=eval(['str.' fieldnames{ilist}]); 1834 if ischar(val) 1835 [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); 1836 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1837 end 1834 1838 end 1835 end1836 1839 end 1837 1840 end … … 1849 1852 maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1850 1853 end 1851 if CivX 1852 if isunix %unix system 1853 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... 1854 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... 1855 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; 1856 else %windows system 1857 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... 1858 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... 1859 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; 1860 cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); 1861 end 1862 cmd=[cmd cmd_FIX '\n']; 1863 elseif CivAll 1864 fix1.inputFileName=filecell.nc.civ1{ifile,j} ; 1865 fix1.fi1=num2str(flagindex1(1)); 1866 fix1.fi2=num2str(flagindex1(2)); 1867 fix1.fi3=num2str(flagindex1(3)); 1868 fix1.threshC=num2str(thresh_vecC1); 1869 fix1.threshV=num2str(thresh_vel1); 1870 fieldnames=fields(fix1); 1871 [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); 1872 for ilist=1:length(fieldnames) 1873 val=eval(['fix1.' fieldnames{ilist}]); 1874 if ischar(val) 1875 [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); 1876 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1854 switch CivMode 1855 % if CivX 1856 case 'CivX' 1857 if isunix %unix system 1858 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... 1859 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... 1860 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; 1861 else %windows system 1862 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... 1863 ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... 1864 ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; 1865 cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); 1877 1866 end 1878 end 1879 CivAllCmd=[CivAllCmd ' fix1 ']; 1867 cmd=[cmd cmd_FIX '\n']; 1868 case 'CivAll' 1869 fix1.inputFileName=filecell.nc.civ1{ifile,j} ; 1870 fix1.fi1=num2str(flagindex1(1)); 1871 fix1.fi2=num2str(flagindex1(2)); 1872 fix1.fi3=num2str(flagindex1(3)); 1873 fix1.threshC=num2str(thresh_vecC1); 1874 fix1.threshV=num2str(thresh_vel1); 1875 fieldnames=fields(fix1); 1876 [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); 1877 for ilist=1:length(fieldnames) 1878 val=eval(['fix1.' fieldnames{ilist}]); 1879 if ischar(val) 1880 [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); 1881 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1882 end 1883 end 1884 CivAllCmd=[CivAllCmd ' fix1 ']; 1880 1885 end 1881 1886 end … … 1883 1888 %PATCH1 1884 1889 if box_test(3)==1 1885 if isequal(CivAll,0) 1886 cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); 1887 cmd=[cmd cmd_PATCH '\n']; 1888 else 1889 patch1.inputFileName=filecell.nc.civ1{ifile,j} ; 1890 patch1.nopt=subdomain_patch1; 1891 patch1.maxdiff=thresh_patch1; 1892 patch1.ro=rho_patch1; 1893 test_grid=get(handles.get_gridpatch1,'Value'); 1894 if test_grid 1895 patch1.gridflag='y'; 1896 gridname=get(handles.grid_patch1,'String'); 1897 if isequal(gridname(end-3:end),'grid') 1898 nbslice_grid=str2double(gridname(1:end-4)); % 1899 if ~isnan(nbslice_grid) 1900 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; 1901 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 1902 if ~exist(patch1.gridPatch,'file') 1890 switch CivMode 1891 case 'CivX' 1892 cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); 1893 cmd=[cmd cmd_PATCH '\n']; 1894 case 'CivAll' 1895 patch1.inputFileName=filecell.nc.civ1{ifile,j} ; 1896 patch1.nopt=subdomain_patch1; 1897 patch1.maxdiff=thresh_patch1; 1898 patch1.ro=rho_patch1; 1899 test_grid=get(handles.get_gridpatch1,'Value'); 1900 if test_grid 1901 patch1.gridflag='y'; 1902 gridname=get(handles.grid_patch1,'String'); 1903 if isequal(gridname(end-3:end),'grid') 1904 nbslice_grid=str2double(gridname(1:end-4)); % 1905 if ~isnan(nbslice_grid) 1906 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; 1907 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 1908 if ~exist(patch1.gridPatch,'file') 1909 msgbox_uvmat('ERROR','grid file absent for patch1') 1910 end 1911 elseif exist(gridname,'file') 1912 patch1.gridPatch=gridname; 1913 else 1903 1914 msgbox_uvmat('ERROR','grid file absent for patch1') 1904 1915 end 1905 elseif exist(gridname,'file') 1906 patch1.gridPatch=gridname; 1907 else 1908 msgbox_uvmat('ERROR','grid file absent for patch1') 1916 end 1917 else 1918 patch1.gridPatch='none'; 1919 patch1.gridflag='n'; 1920 patch1.m=nx_patch1; 1921 patch1.n=ny_patch1; 1922 end 1923 patch1.convectFlow='n'; 1924 fieldnames=fields(patch1); 1925 [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); 1926 for ilist=1:length(fieldnames) 1927 val=eval(['patch1.' fieldnames{ilist}]); 1928 if ischar(val) 1929 [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); 1930 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1909 1931 end 1910 1932 end 1911 else 1912 patch1.gridPatch='none'; 1913 patch1.gridflag='n'; 1914 patch1.m=nx_patch1; 1915 patch1.n=ny_patch1; 1916 end 1917 patch1.convectFlow='n'; 1918 fieldnames=fields(patch1); 1919 [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); 1920 for ilist=1:length(fieldnames) 1921 val=eval(['patch1.' fieldnames{ilist}]); 1922 if ischar(val) 1923 [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); 1924 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1925 end 1926 end 1927 CivAllCmd=[CivAllCmd ' patch1 ']; 1928 end 1929 end 1930 1933 CivAllCmd=[CivAllCmd ' patch1 ']; 1934 end 1935 end 1931 1936 if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 1932 1937 filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file 1933 1938 filename_cmx(end-1:end+1)='cmx';%name of cmx file 1934 1939 end 1935 1936 1940 if box_test(4)==1 1937 1941 par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; … … 1966 1970 end 1967 1971 end 1968 %TESTgrid1969 %test_grid=get(handles.browse_gridciv2,'Value');1970 1972 gridname=get(handles.grid_civ2,'String'); 1971 %gridflag='y';1972 1973 if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') 1973 1974 nbslice_grid=str2double(gridname(1:end-4)); % … … 1991 1992 i_cmd=i_cmd+1; 1992 1993 flname=fullfile(Rootbat,Filebat); 1993 1994 if isequal(CivAll,0) 1995 cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 1996 % if(isunix) 1997 cmd=[cmd cmd_CIV2 '\n']; 1998 % else 1999 % flname=regexprep(flname,'\\','\\\\'); 2000 % cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; 2001 % end 2002 else 2003 CivAllCmd=[CivAllCmd ' civ2 ']; 2004 str=CIV2_CMD_Unified(flname,'',par_civ2); 2005 fieldnames=fields(str); 2006 [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); 2007 for ilist=1:length(fieldnames) 2008 val=eval(['str.' fieldnames{ilist}]); 2009 if ischar(val) 2010 [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); 2011 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 1994 switch CivMode 1995 case 'CivX' 1996 cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 1997 cmd=[cmd cmd_CIV2 '\n']; 1998 case 'CivAll' 1999 CivAllCmd=[CivAllCmd ' civ2 ']; 2000 str=CIV2_CMD_Unified(flname,'',par_civ2); 2001 fieldnames=fields(str); 2002 [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); 2003 for ilist=1:length(fieldnames) 2004 val=eval(['str.' fieldnames{ilist}]); 2005 if ischar(val) 2006 [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); 2007 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2008 end 2012 2009 end 2013 end2014 2010 end 2015 2011 end … … 2027 2023 maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); 2028 2024 end 2029 if isequal(CivAll,0) 2030 if isunix 2031 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... 2032 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2033 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; 2034 else 2035 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... 2036 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2037 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; 2038 cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); 2039 end 2040 cmd=[cmd cmd_FIX '\n']; 2041 else 2042 fix2.inputFileName=filecell.nc.civ2{ifile,j} ; 2043 fix2.fi1=num2str(flagindex2(1)); 2044 fix2.fi2=num2str(flagindex2(2)); 2045 fix2.fi3=num2str(flagindex2(3)); 2046 fix2.threshC=num2str(thresh_vec2C); 2047 fix2.threshV=num2str(thresh_vel2); 2048 fieldnames=fields(fix2); 2049 [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); 2050 for ilist=1:length(fieldnames) 2051 val=eval(['fix2.' fieldnames{ilist}]); 2052 if ischar(val) 2053 [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); 2054 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2025 switch CivMode 2026 case 'CivX' 2027 if isunix 2028 cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... 2029 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2030 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; 2031 else 2032 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... 2033 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2034 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; 2035 cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); 2055 2036 end 2056 end 2057 CivAllCmd=[CivAllCmd ' fix2 ']; 2037 cmd=[cmd cmd_FIX '\n']; 2038 case 'CivAll' 2039 fix2.inputFileName=filecell.nc.civ2{ifile,j} ; 2040 fix2.fi1=num2str(flagindex2(1)); 2041 fix2.fi2=num2str(flagindex2(2)); 2042 fix2.fi3=num2str(flagindex2(3)); 2043 fix2.threshC=num2str(thresh_vec2C); 2044 fix2.threshV=num2str(thresh_vel2); 2045 fieldnames=fields(fix2); 2046 [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); 2047 for ilist=1:length(fieldnames) 2048 val=eval(['fix2.' fieldnames{ilist}]); 2049 if ischar(val) 2050 [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); 2051 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2052 end 2053 end 2054 CivAllCmd=[CivAllCmd ' fix2 ']; 2058 2055 end 2059 2056 end … … 2061 2058 %PATCH2 2062 2059 if box_test(6)==1 2063 if isequal(CivAll,0) 2064 cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); 2065 cmd=[cmd cmd_PATCH '\n']; 2066 else 2067 patch2.inputFileName=filecell.nc.civ1{ifile,j} ; 2068 patch2.nopt=subdomain_patch2; 2069 patch2.maxdiff=thresh_patch2; 2070 patch2.ro=rho_patch2; 2071 test_grid=get(handles.get_gridpatch2,'Value'); 2072 if test_grid 2073 patch2.gridflag='y'; 2074 gridname=get(handles.grid_patch2,'String'); 2075 if isequal(gridname(end-3:end),'grid') 2076 nbslice_grid=str2double(gridname(1:end-4)); % 2077 if ~isnan(nbslice_grid) 2078 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; 2079 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 2080 if ~exist(patch2.gridPatch,'file') 2060 switch CivMode 2061 case 'CivX' 2062 cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); 2063 cmd=[cmd cmd_PATCH '\n']; 2064 case 'CivAll' 2065 patch2.inputFileName=filecell.nc.civ1{ifile,j} ; 2066 patch2.nopt=subdomain_patch2; 2067 patch2.maxdiff=thresh_patch2; 2068 patch2.ro=rho_patch2; 2069 test_grid=get(handles.get_gridpatch2,'Value'); 2070 if test_grid 2071 patch2.gridflag='y'; 2072 gridname=get(handles.grid_patch2,'String'); 2073 if isequal(gridname(end-3:end),'grid') 2074 nbslice_grid=str2double(gridname(1:end-4)); % 2075 if ~isnan(nbslice_grid) 2076 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; 2077 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 2078 if ~exist(patch2.gridPatch,'file') 2079 msgbox_uvmat('ERROR','grid file absent for patch2') 2080 end 2081 elseif exist(gridname,'file') 2082 patch2.gridPatch=gridname; 2083 else 2081 2084 msgbox_uvmat('ERROR','grid file absent for patch2') 2082 2085 end 2083 elseif exist(gridname,'file') 2084 patch2.gridPatch=gridname; 2085 else 2086 msgbox_uvmat('ERROR','grid file absent for patch2') 2086 end 2087 else 2088 patch2.gridPatch='none'; 2089 patch2.gridflag='n'; 2090 patch2.m=nx_patch2; 2091 patch2.n=ny_patch2; 2092 end 2093 patch2.convectFlow='n'; 2094 fieldnames=fields(patch2); 2095 [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); 2096 for ilist=1:length(fieldnames) 2097 val=eval(['patch2.' fieldnames{ilist}]); 2098 if ischar(val) 2099 [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); 2100 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2087 2101 end 2088 2102 end 2103 CivAllCmd=[CivAllCmd ' patch2 ']; 2104 end 2105 end 2106 2107 switch CivMode 2108 case {'CivX','CivAll'} 2109 if isequal(CivMode,'CivAll') 2110 save(CivAllxml,[flname '.xml']); 2111 cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; 2112 end 2113 % create the .bat file: 2114 [fid,message]=fopen(filename_bat,'w'); 2115 if isequal(fid,-1) 2116 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) 2117 return 2118 end 2119 fprintf(fid,cmd); 2120 fclose(fid); 2121 if batch 2122 switch batch_mode 2123 case 'sge' 2124 pvalue=num2str((1-ind_answer)*500); 2125 display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2126 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2127 case 'oar' 2128 eval( ['!chmod +x ' filename_bat]); 2129 eval( ['!oarsub -l /nodes=1/cpu=1,walltime=00:10:00 ' filename_bat]); 2130 end 2089 2131 else 2090 patch2.gridPatch='none'; 2091 patch2.gridflag='n'; 2092 patch2.m=nx_patch2; 2093 patch2.n=ny_patch2; 2132 %% to lauch the jobs locally : 2133 if(isunix) 2134 cmd_str=['. ' filename_bat]; 2135 else %case of Windows 2136 cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; 2137 end 2138 super_cmd=[super_cmd cmd_str '\n']; 2139 disp(cmd_str); 2094 2140 end 2095 patch2.convectFlow='n'; 2096 fieldnames=fields(patch2); 2097 [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); 2098 for ilist=1:length(fieldnames) 2099 val=eval(['patch2.' fieldnames{ilist}]); 2100 if ischar(val) 2101 [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); 2102 [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); 2141 case 'Matlab' 2142 drawnow 2143 if box_test(1)==1 2144 Param.Civ1=par_civ1; 2145 end 2146 if box_test(2)==1 2147 fix1.WarnFlags=[]; 2148 if get(handles.vec_Fmin2,'Value') 2149 fix1.WarnFlags=[fix1.WarnFlags -2]; 2103 2150 end 2151 if get(handles.vec_F3,'Value') 2152 fix1.WarnFlags=[fix1.WarnFlags 3]; 2153 end 2154 fix1.LowerBoundCorr=thresh_vecC1; 2155 if get(handles.inf_sup1,'Value') 2156 fix1.UppperBoundVel=thresh_vel1; 2157 else 2158 fix1.LowerBoundVel=thresh_vel1; 2159 end 2160 if get(handles.get_mask_fix1,'Value') 2161 fix1.MaskName=maskname; 2162 end 2163 Param.Fix1=fix1; 2104 2164 end 2105 CivAllCmd=[CivAllCmd ' patch2 ']; 2106 end 2107 end 2108 if CivAll 2109 save(CivAllxml,[flname '.xml']); 2110 cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; 2111 end 2112 % create the .bat file: 2113 [fid,message]=fopen(filename_bat,'w'); 2114 if isequal(fid,-1) 2115 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) 2116 return 2117 end 2118 fprintf(fid,cmd); 2119 fclose(fid); 2120 if batch 2121 switch batch_mode 2122 case 'sge' 2123 pvalue=num2str((1-ind_answer)*500); 2124 display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2125 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2126 case 'oar' 2127 % pvalue=num2str((1-ind_answer)*500); 2128 % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2129 eval( ['!chmod +x ' filename_bat]); 2130 eval( ['!oarsub -l /nodes=1/cpu=1,walltime=00:10:00 ' filename_bat]); 2131 end 2132 elseif ~CivUvmat 2133 %% to lauch the jobs locally : 2134 if(isunix) 2135 cmd_str=['. ' filename_bat]; 2136 else %case of Windows 2137 cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; 2138 end 2139 super_cmd=[super_cmd cmd_str '\n']; 2140 disp(cmd_str); 2141 else %run PIVlab if selected 2142 drawnow 2143 if box_test(1)==1 2144 Param.Civ1=par_civ1; 2145 end 2146 if box_test(2)==1 2147 fix1.WarnFlags=[]; 2148 if get(handles.vec_Fmin2,'Value') 2149 fix1.WarnFlags=[fix1.WarnFlags -2]; 2165 if box_test(3)==1 2166 Param.Patch1.Rho=rho_patch1; 2167 Param.Patch1.Threshold=thresh_patch1; 2168 Param.Patch1.SubDomain=subdomain_patch1; 2150 2169 end 2151 if get(handles.vec_F3,'Value')2152 fix1.WarnFlags=[fix1.WarnFlags 3];2170 if box_test(4)==1 2171 Param.Civ2=par_civ2; 2153 2172 end 2154 fix1.LowerBoundCorr=thresh_vecC1; 2155 if get(handles.inf_sup1,'Value') 2156 fix1.UppperBoundVel=thresh_vel1; 2173 if box_test(5)==1 2174 fix2.WarnFlags=[]; 2175 if get(handles.vec_Fmin2_2,'Value') 2176 fix2.WarnFlags=[fix2.WarnFlags -2]; 2177 end 2178 if get(handles.vec_F4,'Value') 2179 fix2.WarnFlags=[fix2.WarnFlags 4]; 2180 end 2181 if get(handles.vec_F3_2,'Value') 2182 fix2.WarnFlags=[fix2.WarnFlags 3]; 2183 end 2184 fix2.LowerBoundCorr=thresh_vec2C; 2185 if get(handles.inf_sup2,'Value') 2186 fix2.UppperBoundVel=thresh_vel2; 2187 else 2188 fix2.LowerBoundVel=thresh_vel2; 2189 end 2190 if get(handles.get_mask_fix2,'Value') 2191 fix2.MaskName=maskname; 2192 end 2193 Param.Fix2=fix2; 2194 end 2195 [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); 2196 if isempty(errormsg) 2197 display([filecell.nc.civ1{ifile,j} ' written']) 2157 2198 else 2158 fix1.LowerBoundVel=thresh_vel1; 2159 end 2160 if get(handles.get_mask_fix1,'Value') 2161 fix1.MaskName=maskname; 2162 end 2163 Param.Fix1=fix1; 2164 end 2165 if box_test(3)==1 2166 Param.Patch1.Rho=rho_patch1; 2167 Param.Patch1.Threshold=thresh_patch1; 2168 Param.Patch1.SubDomain=subdomain_patch1; 2169 end 2170 if box_test(4)==1 2171 Param.Civ2=par_civ2; 2172 end 2173 if box_test(5)==1 2174 fix2.WarnFlags=[]; 2175 if get(handles.vec_Fmin2_2,'Value') 2176 fix2.WarnFlags=[fix2.WarnFlags -2]; 2199 msgbox_uvmat('ERROR',errormsg) 2177 2200 end 2178 if get(handles.vec_F4,'Value') 2179 fix2.WarnFlags=[fix2.WarnFlags 4]; 2180 end 2181 if get(handles.vec_F3_2,'Value') 2182 fix2.WarnFlags=[fix2.WarnFlags 3]; 2183 end 2184 fix2.LowerBoundCorr=thresh_vec2C; 2185 if get(handles.inf_sup2,'Value') 2186 fix2.UppperBoundVel=thresh_vel2; 2187 else 2188 fix2.LowerBoundVel=thresh_vel2; 2189 end 2190 if get(handles.get_mask_fix2,'Value') 2191 fix2.MaskName=maskname; 2192 end 2193 Param.Fix2=fix2; 2194 end 2195 [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); 2196 if isempty(errormsg) 2197 display([filecell.nc.civ1{ifile,j} ' written']) 2198 else 2199 msgbox_uvmat('ERROR',errormsg) 2200 end 2201 end 2202 end 2203 end 2204 2205 if ~batch && ~CivUvmat 2201 end 2202 end 2203 end 2204 2205 if ~batch && ~isequal(CivMode,'Matlab') 2206 2206 [Rootbat,Filebat,extbat]=fileparts(filename_bat); 2207 2207 filename_superbat=fullfile(Rootbat,'job_list.bat'); 2208 2208 fid=fopen(filename_superbat,'w'); 2209 if fid==-1 2210 msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 2211 return 2212 end 2209 2213 fprintf(fid,super_cmd'); 2210 2214 fclose(fid); 2211 2215 if(isunix) 2212 2216 system(['chmod +x ' filename_superbat]) 2213 2214 2217 end 2218 system([filename_superbat ' &'])% execute main commmand 2215 2219 end 2216 2220 … … 3746 3750 set(handles.rho_title,'Visible',state) 3747 3751 set(handles.TestCiv1,'Visible',state) 3748 %set(handles.Civ All,'Visible',state)3752 %set(handles.CivMode,'Visible',state) 3749 3753 3750 3754 %------------------------------------------------------------------------ … … 3783 3787 set(handles.rho_patch1,'Visible','on') 3784 3788 set(handles.rho_text1,'Visible','on') 3785 if get(handles.Civ All,'Value')==23789 if get(handles.CivMode,'Value')==2 3786 3790 set(handles.thresh_patch1,'Visible','on') 3787 3791 set(handles.thresh_text1,'Visible','on') … … 4951 4955 4952 4956 %------------------------------------------------------------------------ 4953 % --- Executes on button press in Civ All.4954 function Civ All_Callback(hObject, eventdata, handles)4955 %------------------------------------------------------------------------ 4956 Listprog=get(handles.Civ All,'String');4957 index=get(handles.Civ All,'Value');4957 % --- Executes on button press in CivMode. 4958 function CivMode_Callback(hObject, eventdata, handles) 4959 %------------------------------------------------------------------------ 4960 Listprog=get(handles.CivMode,'String'); 4961 index=get(handles.CivMode,'Value'); 4958 4962 prog=Listprog{index}; 4959 4963 switch prog … … 4988 4992 set(handles.BATCH,'Enable','off') 4989 4993 end 4990 -
trunk/src/civ_uvmat.m
r252 r257 32 32 PointCoord(:,1)=reshape(GridX,[],1); 33 33 PointCoord(:,2)=reshape(GridY,[],1); 34 if isfield(par_civ1,'maskname') && ~isempty(par_civ1.maskname) 34 if isfield(par_civ1,'maskname') && ~isempty(par_civ1.maskname) && ~isequal(par_civ1.maskname,'noFile use default') 35 35 maskname=par_civ1.maskname; 36 36 mask=imread(maskname);
Note: See TracChangeset
for help on using the changeset viewer.