- Timestamp:
- Nov 17, 2011, 5:44:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r270 r272 1453 1453 %----------------------------------------------------------------------- 1454 1454 errormsg='';%default 1455 1456 1455 1457 %% check the selected list of operations: 1456 1458 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; … … 1474 1476 end 1475 1477 1476 %% check mask if selecetd 1478 %% check mask if selecetd 1479 %could be included in get_mask callback ? 1477 1480 if isequal(get(handles.get_mask_civ1,'Value'),1) 1478 1481 maskname=get(handles.mask_civ1,'String'); … … 1522 1525 nbslice=numel(num_a_civ1); 1523 1526 1524 %% choose the batch or run mode1527 %% read the PARAM.xml file to get the binaries (and batch_mode if batch) 1525 1528 path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat 1526 1529 xmlfile='PARAM.xml'; … … 1528 1531 t=xmltree(xmlfile); 1529 1532 s=convert(t); 1530 end 1531 test_interp=0; 1533 else 1534 errormsg=['no file ' xmlfile]; 1535 return 1536 end 1537 1538 test_interp=0; %eviter les variables test_ (LG) 1539 1532 1540 if batch 1533 1541 if isfield(s,'BatchParam') 1534 sparam=s.BatchParam;1535 if isfield( sparam,'BatchMode')1536 batch_mode= sparam.BatchMode;1542 param.global=s.BatchParam; 1543 if isfield(param.global,'BatchMode') 1544 batch_mode=param.global.BatchMode; 1537 1545 if ~ismember(batch_mode,{'sge','oar'}) 1538 1546 errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; … … 1544 1552 return 1545 1553 end 1546 1547 switch batch_mode1548 case 'sge'1549 % choice of batch priority:1550 [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix)1551 if isequal(s,0)1552 w(end)=[];1553 str_displ={[w ' jobs in the waiting list'];...1554 '***********************';...1555 'JOBS PRIORITY POLICY';...1556 '- urgent = less than 100 images pairs';...1557 '- normal = during the experiments';...1558 '- low = post processing';...1559 '***********************';...1560 'Select a priority:'};1561 ' ';...1562 str={'urgent';'normal';'low'};1563 [ind_answer,v] = listdlg('PromptString',str_displ,...1564 'SelectionMode','single',...1565 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3);1566 pvalue=num2str((1-ind_answer)*500); %1567 if isequal(v,0) % to handle Cancel button and figure close,1568 errormsg='job cancelled';1569 return % a better way should be create1570 end1571 else1572 msgbox_uvmat('ERROR','sge batch system not available')1573 return1574 end1575 case 'oar'1576 [s,w]=unix('oarstat'); %check the waiting list (command unix)1577 if ~isequal(s,0)1578 msgbox_uvmat('ERROR','oar batch system not available')1579 return1580 end1581 end1582 1554 else % run 1583 1555 if isfield(s,'RunParam') 1584 sparam=s.RunParam;1556 param.global=s.RunParam; 1585 1557 else 1586 1558 msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') … … 1589 1561 end 1590 1562 1591 %% choose the civ program 1563 %% check batch mode supported 1564 if batch 1565 switch batch_mode 1566 case 'sge' 1567 test_command='qstat'; 1568 case 'oar' 1569 test_command='oartat'; 1570 end 1571 [s,w]=system(test_command); 1572 if ~isequal(s,0) 1573 msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) 1574 return 1575 end 1576 end 1577 1578 %% check if the binaries exist 1592 1579 ProgList=get(handles.CivMode,'String'); 1593 index=get(handles.CivMode,'Value'); 1594 % CivX=isequal(ProgList{index},'CivX'); 1595 % CivAll=isequal(ProgList{index},'CivAll'); 1596 % CivUvmat=isequal(ProgList{index},'CivUvmat'); 1597 CivMode=ProgList{index}; 1598 %CivMode=isequal(get(handles.CivMode,'Value'),2); % Boolean for new civ programs 1580 CivMode=ProgList{get(handles.CivMode,'Value')}; 1599 1581 1600 1582 switch CivMode 1601 case 'CivAll' 1602 if isfield(sparam,'CivBin') 1603 CivBin=sparam.CivBin; 1604 if ~exist(CivBin,'file') || isempty(which(CivBin))% if path defined as relative to uvmat 1605 sparam.CivBin=fullfile(path_UVMAT,CivBin); 1606 if ~exist(sparam.CivBin,'file') 1607 msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) 1608 return 1583 case {'CivX','CivAll'} 1584 1585 for bin_name={'Civ1Bin','Civ2Bin','PatchBin','FixBin','CivBin'} 1586 if isfield(param.global,bin_name{1}) 1587 param.global.(bin_name{1}) 1588 exist(param.global.(bin_name{1})) 1589 if ~exist(param.global.(bin_name{1})) 1590 param.global.(bin_name{1})=fullfile(path_UVMAT,param.global.(bin_name{1})); 1591 if ~exist(param.global.(bin_name{1})) 1592 msgbox_uvmat('ERROR',['Binary ' param.global.(bin_name{1}) ' defined in PARAM.xm does not exist']) 1593 return 1594 end 1609 1595 end 1610 end 1611 end 1612 case 'CivX' 1613 if isfield(sparam,'Civ1Bin') 1614 Civ1Bin=sparam.Civ1Bin; 1615 if ~exist(Civ1Bin,'file')&&~isempty(which(Civ1Bin))% if path defined as relative to uvmat 1616 sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); 1617 if ~exist(sparam.Civ1Bin,'file') 1618 msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) 1619 return 1620 end 1621 end 1622 end 1623 if isfield(sparam,'Civ2Bin') 1624 Civ2Bin=sparam.Civ2Bin; 1625 if ~exist(Civ2Bin,'file')&&~isempty(which(Civ2Bin))% if path defined as relative to uvmat 1626 sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); 1627 if ~exist(sparam.Civ2Bin,'file') 1628 msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) 1629 return 1630 end 1631 end 1632 end 1633 if isfield(sparam,'PatchBin') 1634 if ~exist(sparam.PatchBin,'file')&&~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat 1635 sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); 1636 end 1637 end 1638 if isfield(sparam,'FixBin') 1639 if ~exist(sparam.FixBin,'file')&&~isempty(which(sparam.FixBin))% if path defined as relative to uvmat 1640 sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); 1596 [path,name,ext]=fileparts(param.global.(bin_name{1})) 1597 currentdir=pwd; 1598 cd(path); 1599 param.global.(bin_name{1})=which([name ext]); 1600 display(param.global.(bin_name{1})); 1601 cd(currentdir); 1641 1602 end 1642 1603 end 1643 1604 case 'Matlab' 1644 1605 if batch 1645 %% vï¿œrifier Mtlab installï¿œ sur le cluster 1606 % vérifier Matlab installé sur le cluster 1607 % difficile a faire a priori 1646 1608 end 1647 1609 end 1648 1610 1649 1650 1651 %% get civ1 parameters:1652 1611 display('files OK, processing...') 1653 if box_test(1)==1 1654 par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); 1655 end 1656 1657 %% get fix1 parameters TODO : par_fix1=read_param_fix1(handles); 1658 if box_test(2)==1 1659 flagindex1(1)=get(handles.vec_Fmin2, 'Value'); 1660 flagindex1(2)=get(handles.vec_F3, 'Value'); 1661 flagindex1(3)=get(handles.vec_F2, 'Value'); 1662 thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C 1663 thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus 1664 test_mask=get(handles.get_mask_fix1,'Value'); 1665 nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) 1666 %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX 1667 % inf_sup=get(handles.inf_sup1,'Value');80 1668 % fileref=get(handles.ref_fix1,'String'); 1669 % refpath=get(handles.ref_fix1,'UserData'); 1670 % fileref=fullfile(refpath,fileref); 1671 menu=get(handles.field_ref1,'String'); 1672 index=get(handles.field_ref1,'Value'); 1673 if isempty(menu) 1674 fieldchoice=''; 1675 else 1676 fieldchoice=menu{index}; 1677 msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') 1678 end 1679 end 1680 1681 %% get patch1 parameters 1682 if box_test(3)==1 1683 rho_patch1=str2double(get(handles.rho_patch1,'String')); 1684 if isnan(rho_patch1) 1685 rho_patch1='1000'; 1686 set(handles.rho_patch1,'String','1') 1687 else 1688 rho_patch1=num2str(1000*rho_patch1); 1689 end 1690 nx_patch1=get(handles.nx_patch1,'String'); 1691 ny_patch1=get(handles.ny_patch1,'String'); 1692 if isnan(str2double(nx_patch1)) 1693 nx_patch1='50' ;%default 1694 set(handles.nx_patch1,'String','50'); 1695 end 1696 if isnan(str2double(ny_patch1)) 1697 ny_patch1='50' ;%default 1698 set(handles.ny_patch1,'String','50'); 1699 end 1700 subdomain_patch1=get(handles.subdomain_patch1,'String'); 1701 thresh_patch1=get(handles.thresh_patch1,'String'); 1612 1613 %% get civ1 parameters 1614 if box_test(1) 1615 param.civ1=read_param_civ1(handles,filecell); 1616 end 1617 1618 %% get fix1 parameters 1619 if box_test(2) 1620 param.fix1=read_param_fix1(handles,filecell) 1621 end 1622 1623 %% get patch1 parameters TODO read_param_patch1 1624 if box_test(3) 1625 param.patch1=read_param_patch1(handles) 1702 1626 end 1703 1627 1704 1628 %% get civ2 parameters: 1705 if box_test(4) ==11706 par _civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1)));1629 if box_test(4) 1630 param.civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); 1707 1631 end 1708 1632 1709 1633 %% get fix2 parameters 1710 if box_test(5) ==11634 if box_test(5) 1711 1635 flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); 1712 1636 flagindex2(2)=get(handles.vec_F3_2, 'Value'); … … 1746 1670 end 1747 1671 1672 %% 1673 1674 1748 1675 %% MAIN LOOP 1749 1676 time=get(handles.RootName,'UserData'); %get the set of times … … 1755 1682 for j=1:nbslice 1756 1683 % initiate system command 1757 i_cmd=0;1758 1684 switch CivMode 1759 1685 case 'CivX' 1760 cmd='';1761 1686 if isunix % check: necessaire aussi en RUN? 1762 cmd='#!/bin/bash \n'; 1763 cmd=[cmd '#$ -cwd \n']; 1764 cmd=[cmd 'hostname && date \n']; 1765 cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group 1687 cmd=['#!/bin/bash \n '... 1688 '#$ -cwd \n '... 1689 'hostname && date \n '... 1690 'umask 002 \n'];%allow writting access to created files for user group 1691 else 1692 cmd=[]; 1766 1693 end 1767 1694 case 'CivAll' … … 1771 1698 CivAllxml=set(CivAllxml,1,'name','CivDoc'); 1772 1699 end 1773 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extension) 1774 1775 filename_bat=[fullfile(Rootbat,Filebat) '.bat']; 1700 1701 1702 % define output file name 1703 if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 1704 OutputFile=filecell.nc.civ2{ifile,j}; 1705 else 1706 OutputFile=filecell.nc.civ1{ifile,j}; 1707 end 1708 OutputFile=regexprep(OutputFile,'.nc',''); 1709 1776 1710 1777 1711 %CIV1 1778 if box_test(1)==1 1779 par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; 1780 par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; 1781 par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); 1782 par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); 1783 par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? 1784 par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% 1785 test_mask=get(handles.get_mask_civ1,'Value'); 1786 if test_mask==0 1787 par_civ1.maskname='noFile use default'; 1788 par_civ1.maskflag='n'; 1789 else 1712 if box_test(1) 1713 % read image-dependent parameters 1714 param.civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; 1715 param.civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; 1716 param.civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); 1717 param.civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); 1718 param.civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? 1719 param.civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% 1720 1721 % read mask parameters 1722 if get(handles.get_mask_civ1,'Value') 1790 1723 maskdispl=get(handles.mask_civ1,'String'); 1791 1724 if exist(maskdispl,'file') 1792 par _civ1.maskname=maskdispl;1793 par _civ1.maskflag='y';1725 param.civ1.maskname=maskdispl; 1726 param.civ1.maskflag='y'; 1794 1727 else 1795 1728 maskbase=[filecell.filebase '_' maskdispl]; % 1796 1729 nbslice_mask=str2double(maskdispl(1:end-4)); % 1797 1730 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; 1798 par _civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');1799 if exist(par _civ1.maskname,'file')1800 par _civ1.maskflag='y';1731 param.civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1732 if exist(param.civ1.maskname,'file') 1733 param.civ1.maskflag='y'; 1801 1734 else 1802 par _civ1.maskname='noFile use default';1803 par _civ1.maskflag='n';1735 param.civ1.maskname='noFile use default'; 1736 param.civ1.maskflag='n'; 1804 1737 end 1805 1738 end 1806 end 1807 test_grid=get(handles.browse_gridciv1,'Value'); 1808 if test_grid 1809 par_civ1.gridflag='y'; 1739 else 1740 param.civ1.maskname='noFile use default'; 1741 param.civ1.maskflag='n'; 1742 end 1743 1744 % read grid parameters 1745 if get(handles.browse_gridciv1,'Value') 1746 param.civ1.gridflag='y'; 1810 1747 gridname=get(handles.grid_civ1,'String'); 1811 1748 if isequal(gridname(end-3:end),'grid') … … 1813 1750 if ~isnan(nbslice_grid) 1814 1751 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; 1815 par _civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];1816 if ~exist(par _civ1.gridname,'file')1752 param.civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 1753 if ~exist(param.civ1.gridname,'file') 1817 1754 msgbox_uvmat('ERROR','grid file absent for civ1') 1818 1755 end 1819 1756 elseif exist(gridname,'file') 1820 par _civ1.gridname=gridname;1757 param.civ1.gridname=gridname; 1821 1758 else 1822 1759 msgbox_uvmat('ERROR','grid file absent for civ1') … … 1824 1761 end 1825 1762 else 1826 par _civ1.gridname='noFile use default';1827 par _civ1.gridflag='n';1763 param.civ1.gridname='noFile use default'; 1764 param.civ1.gridflag='n'; 1828 1765 end 1829 1766 1830 i_cmd=i_cmd+1;1831 1767 switch CivMode 1832 1768 case 'CivX' 1833 civ1_exe=CIV1_CMD(f ullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe1769 civ1_exe=CIV1_CMD(filecell.nc.civ1{ifile,j},param);%create the parameter file .civ1.cmx and set the execution string civ1_exe 1834 1770 cmd=[cmd civ1_exe '\n']; 1835 1771 case 'CivAll' 1836 1772 CivAllCmd=[CivAllCmd ' civ1 ']; 1837 str=CIV1_CMD_Unified(f ullfile(Rootbat,Filebat),'',par_civ1);1773 str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',param.civ1); 1838 1774 fieldnames=fields(str); 1839 1775 [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); … … 1849 1785 1850 1786 % FIX1 1851 if box_test(2)==1 1852 test_mask=get(handles.get_mask_fix1,'Value'); 1853 if test_mask==0 1854 maskname=''; 1855 else 1856 maskdispl=get(handles.mask_fix1,'String'); 1857 nbslice_mask=str2double(maskdispl(1:end-4)); % 1858 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; 1859 maskbase=[filecell.filebase '_' maskdispl]; 1860 maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1861 end 1862 switch CivMode 1863 % if CivX 1787 if box_test(2) 1788 switch CivMode 1864 1789 case 'CivX' 1865 1790 if isunix %unix system 1866 cmd_FIX=[ sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ...1867 ' -fi2 ' num2str( flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ...1868 ' -threshC ' num2str( thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName 'maskname];1791 cmd_FIX=[param.global.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(param.fix1.flagindex1(1)) ... 1792 ' -fi2 ' num2str(param.fix1.flagindex1(2)) ' -fi3 ' num2str(param.fix1.flagindex1(3)) ... 1793 ' -threshC ' num2str(param.fix1.thresh_vecC1) ' -threshV ' num2str(param.fix1.thresh_vel1) ' -maskName ' param.fix1.maskname]; 1869 1794 else %windows system 1870 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ...1871 ' -fi2 ' num2str( flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ...1872 ' -threshC ' num2str( thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "'maskname '"'];1795 cmd_FIX=['"' param.global.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(param.fix1.flagindex1(1)) ... 1796 ' -fi2 ' num2str(param.fix1.flagindex1(2)) ' -fi3 ' num2str(param.fix1.flagindex1(3)) ... 1797 ' -threshC ' num2str(param.fix1.thresh_vecC1) ' -threshV ' num2str(param.fix1.thresh_vel1) ' -maskName "' param.fix1.maskname '"']; 1873 1798 cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); 1874 1799 end … … 1876 1801 case 'CivAll' 1877 1802 fix1.inputFileName=filecell.nc.civ1{ifile,j} ; 1878 fix1.fi1=num2str( flagindex1(1));1879 fix1.fi2=num2str( flagindex1(2));1880 fix1.fi3=num2str( flagindex1(3));1881 fix1.threshC=num2str( thresh_vecC1);1882 fix1.threshV=num2str( thresh_vel1);1803 fix1.fi1=num2str(param.fix1.flagindex1(1)); 1804 fix1.fi2=num2str(param.fix1.flagindex1(2)); 1805 fix1.fi3=num2str(param.fix1.flagindex1(3)); 1806 fix1.threshC=num2str(param.fix1.thresh_vecC1); 1807 fix1.threshV=num2str(param.fix1.thresh_vel1); 1883 1808 fieldnames=fields(fix1); 1884 1809 [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); … … 1898 1823 switch CivMode 1899 1824 case 'CivX' 1900 cmd_PATCH= PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin);1825 cmd_PATCH=cmd_patch(filecell.nc.civ1{ifile,j},param); 1901 1826 cmd=[cmd cmd_PATCH '\n']; 1902 1827 case 'CivAll' … … 1942 1867 end 1943 1868 end 1944 if box_test(4)==1 || box_test(5)==1 || box_test(6)==11945 % pvalue=num2str((1-ind_answer)*500);1946 filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file1947 filename_cmx(end-1:end+1)='cmx';%name of cmx file1948 end1949 1869 if box_test(4)==1 1950 par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; 1951 par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; 1952 [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) 1953 par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); 1954 par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); 1955 par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); 1956 par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); 1957 par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; 1958 par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' 1870 param.civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; 1871 param.civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; 1872 param.civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); 1873 param.civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); 1874 param.civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); 1875 param.civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); 1876 param.civ2.filename_nc1=filecell.nc.civ1{ifile,j}; 1877 param.civ2.filename_nc1(end-2:end)=[]; % remove '.nc' 1959 1878 test_mask=get(handles.get_mask_civ2,'Value'); 1960 1879 if test_mask==0 1961 par _civ2.maskname='noFile use default';1962 par _civ2.maskflag='n';1880 param.civ2.maskname='noFile use default'; 1881 param.civ2.maskflag='n'; 1963 1882 else 1964 1883 maskdispl=get(handles.mask_civ2,'String'); 1965 1884 if exist(maskdispl,'file') 1966 par _civ2.maskname=maskdispl;1967 par _civ2.maskflag='y';1885 param.civ2.maskname=maskdispl; 1886 param.civ2.maskflag='y'; 1968 1887 else 1969 1888 maskbase=[filecell.filebase '_' maskdispl]; % 1970 1889 nbslice_mask=str2double(maskdispl(1:end-4)); % 1971 1890 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; 1972 par _civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');1973 if exist(par _civ2.maskname,'file')1974 par _civ2.maskflag='y';1891 param.civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 1892 if exist(param.civ2.maskname,'file') 1893 param.civ2.maskflag='y'; 1975 1894 else 1976 par _civ2.maskname='noFile use default';1977 par _civ2.maskflag='n';1895 param.civ2.maskname='noFile use default'; 1896 param.civ2.maskflag='n'; 1978 1897 end 1979 1898 end … … 1983 1902 nbslice_grid=str2double(gridname(1:end-4)); % 1984 1903 if ~isnan(nbslice_grid) 1985 par _civ2.gridflag='y';1904 param.civ2.gridflag='y'; 1986 1905 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; 1987 par _civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];1988 if exist(par _civ2.gridname,'file')1989 par _civ2.gridflag='y';1906 param.civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; 1907 if exist(param.civ2.gridname,'file') 1908 param.civ2.gridflag='y'; 1990 1909 else 1991 par _civ2.gridname='noFile use default';1992 par _civ2.gridflag='n';1910 param.civ2.gridname='noFile use default'; 1911 param.civ2.gridflag='n'; 1993 1912 end 1994 1913 elseif exist(gridname,'file') 1995 par _civ2.gridflag='y';1914 param.civ2.gridflag='y'; 1996 1915 else 1997 par _civ2.gridname='noFile use default';1998 par _civ2.gridflag='n';1916 param.civ2.gridname='noFile use default'; 1917 param.civ2.gridflag='n'; 1999 1918 end 2000 1919 end 2001 i_cmd=i_cmd+1;2002 flname=fullfile(Rootbat,Filebat);2003 1920 switch CivMode 2004 1921 case 'CivX' 2005 cmd_CIV2=CIV2_CMD(f lname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]1922 cmd_CIV2=CIV2_CMD(filecell.nc.civ2{ifile,j},[],param);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 2006 1923 cmd=[cmd cmd_CIV2 '\n']; 2007 1924 case 'CivAll' 2008 1925 CivAllCmd=[CivAllCmd ' civ2 ']; 2009 str=CIV2_CMD_Unified(f lname,'',par_civ2);1926 str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',param.civ2); 2010 1927 fieldnames=fields(str); 2011 1928 [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); … … 2035 1952 case 'CivX' 2036 1953 if isunix 2037 cmd_FIX=[ sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ...1954 cmd_FIX=[param.global.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... 2038 1955 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2039 1956 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; 2040 1957 else 2041 cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ...1958 cmd_FIX=['"' param.global.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... 2042 1959 ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... 2043 1960 ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; … … 2069 1986 switch CivMode 2070 1987 case 'CivX' 2071 cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp, sparam.PatchBin);1988 cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,param.global.PatchBin); 2072 1989 cmd=[cmd cmd_PATCH '\n']; 2073 1990 case 'CivAll' … … 2117 2034 case {'CivX','CivAll'} 2118 2035 if isequal(CivMode,'CivAll') 2119 save(CivAllxml,[ flname '.xml']);2120 cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n'];2036 save(CivAllxml,[OutputFile '.xml']); 2037 cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; 2121 2038 end 2122 % create the .bat file: 2039 2040 % create the .bat file used in run or batch 2041 filename_bat=[OutputFile '.bat']; 2123 2042 [fid,message]=fopen(filename_bat,'w'); 2124 2043 if isequal(fid,-1) … … 2158 2077 drawnow 2159 2078 if box_test(1)==1 2160 Param.Civ1=par _civ1;2079 Param.Civ1=param.civ1; 2161 2080 end 2162 2081 if box_test(2)==1 … … 2193 2112 end 2194 2113 if box_test(4)==1 2195 Param.Civ2=par _civ2;2114 Param.Civ2=param.civ2; 2196 2115 end 2197 2116 if box_test(5)==1 … … 2250 2169 display(cmd);eval(cmd); 2251 2170 end 2171 case 'sge' 2172 [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) 2173 w(end)=[]; 2174 str_displ={[w ' jobs in the waiting list'];... 2175 '***********************';... 2176 'JOBS PRIORITY POLICY';... 2177 '- urgent = less than 100 images pairs';... 2178 '- normal = during the experiments';... 2179 '- low = post processing';... 2180 '***********************';... 2181 'Select a priority:'}; 2182 str={'urgent';'normal';'low'}; 2183 [ind_answer,v] = listdlg('PromptString',str_displ,... 2184 'SelectionMode','single',... 2185 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); 2186 pvalue=num2str((1-ind_answer)*500); % 2187 if isequal(v,0) % to handle Cancel button and figure close 2188 errormsg='job submission cancelled'; 2189 return 2190 end 2252 2191 case 'oar' 2253 2192 for p=0:floor(length(batch_file_list)/6); … … 3196 3135 %------------------------------------------------------------------------ 3197 3136 % --- PATCH 3198 function cmd _PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin)3137 function cmd=cmd_patch(filename_nc,param) 3199 3138 %------------------------------------------------------------------------ 3200 3139 namelog=[filename_nc(1:end-3) '_patch.log']; 3201 if test_interp==03140 % if test_interp==0 3202 3141 if isunix 3203 cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... 3142 cmd=[param.global.PatchBin... 3143 ' -f ' filename_nc ' -m ' param.patch1.nx_patch... 3144 ' -n ' param.patch1.ny_patch ' -ro ' param.patch1.rho_patch... 3145 ' -nopt ' param.patch1.subdomain_patch ... 3204 3146 ' > ' namelog ' 2>&1']; % redirect standard output to the log file 3205 3147 else 3206 cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... 3148 cmd=['"' param.global.PatchBin... 3149 '" -f "' filename_nc '" -m ' param.patch1.nx_patch... 3150 ' -n ' param.patch1.ny_patch ' -ro ' param.patch1.rho_patch... 3151 ' -nopt ' param.patch1.subdomain_patch ... 3207 3152 ' > "' namelog '" 2>&1']; % redirect standard output to the log file 3208 3153 end 3209 else %nouveau programme patch3210 cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ...3211 ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file3212 end3213 cmd _PATCH=regexprep(cmd_PATCH,'\\','\\\\');3154 % else %nouveau programme patch 3155 % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... 3156 % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file 3157 % end 3158 cmd=regexprep(cmd,'\\','\\\\'); 3214 3159 %------------------------------------------------------------------------ 3215 3160 % --- STEREO Interp … … 3562 3507 return 3563 3508 end 3564 currentdir=pwd;3565 cd(Path);%move in the dir of the root name filebase3566 maskfiles=dir( [Name '_*mask_*.png']);%look for mask files3567 cd(currentdir);%come back to the current working directory3509 % currentdir=pwd; 3510 % cd(Path);%move in the dir of the root name filebase 3511 maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files 3512 % cd(currentdir);%come back to the current working directory 3568 3513 if ~isempty(maskfiles) 3569 3514 % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') … … 4090 4035 %------------------------------------------------------------------------ 4091 4036 % --- Read the parameters for civ1 on the interface 4092 function par=read_param_civ1(handles,file _ima)4037 function par=read_param_civ1(handles,filecell) 4093 4038 %------------------------------------------------------------------------ 4094 4039 ibx_val=str2double(get(handles.ibx,'String')); … … 4147 4092 par.pxcmx='1'; %velocities are expressed in pixel dispalcement 4148 4093 par.pxcmy='1'; 4149 if exist('file_ima','var')4150 A=imread(file _ima);%read the first image to get the size4094 % if exist('file_ima','var') 4095 A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size 4151 4096 sizim=size(A); 4152 4097 par.npx=num2str(sizim(2)); 4153 4098 par.npy=num2str(sizim(1)); 4154 end 4099 %TODO : civ should not need npx and npy 4100 4101 4102 % end 4155 4103 %time=get(handles.RootName,'UserData'); %get the set of times 4156 4104 par.gridname=get(handles.grid_civ1,'String'); … … 4161 4109 end 4162 4110 4111 %------------------------------------------------------------------------ 4112 function par=read_param_fix1(handles,filecell) 4113 %------------------------------------------------------------------------ 4114 par.flagindex1(1)=get(handles.vec_Fmin2, 'Value'); 4115 par.flagindex1(2)=get(handles.vec_F3, 'Value'); 4116 par.flagindex1(3)=get(handles.vec_F2, 'Value'); 4117 par.thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C 4118 par.thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus 4119 par.test_mask=get(handles.get_mask_fix1,'Value'); 4120 par.nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) 4121 %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX 4122 % inf_sup=get(handles.inf_sup1,'Value');80 4123 % fileref=get(handles.ref_fix1,'String'); 4124 % refpath=get(handles.ref_fix1,'UserData'); 4125 % fileref=fullfile(refpath,fileref); 4126 par.menu=get(handles.field_ref1,'String'); 4127 par.index=get(handles.field_ref1,'Value'); 4128 if isempty(par.menu) 4129 par.fieldchoice=''; 4130 else 4131 par.fieldchoice=menu{index}; 4132 msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') 4133 end 4134 if par.test_mask==0 4135 par.maskname=''; 4136 else 4137 maskdispl=get(handles.mask_fix1,'String'); 4138 nbslice_mask=str2double(maskdispl(1:end-4)); % 4139 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; 4140 maskbase=[filecell.filebase '_' maskdispl]; 4141 par.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); 4142 end 4143 4144 %------------------------------------------------------------------------ 4145 function par=read_param_patch1(handles) 4146 %------------------------------------------------------------------------ 4147 4148 par.rho_patch=str2double(get(handles.rho_patch1,'String')); 4149 if isnan(par.rho_patch) 4150 par.rho_patch='1000'; 4151 set(handles.rho_patch1,'String','1') 4152 else 4153 par.rho_patch=num2str(1000*par.rho_patch); 4154 end 4155 par.nx_patch=get(handles.nx_patch1,'String'); 4156 par.ny_patch=get(handles.ny_patch1,'String'); 4157 if isnan(str2double(par.nx_patch)) 4158 par.nx_patch='50' ;%default 4159 set(handles.nx_patch1,'String','50'); 4160 end 4161 if isnan(str2double(par.ny_patch)) 4162 par.ny_patch='50' ;%default 4163 set(handles.ny_patch1,'String','50'); 4164 end 4165 par.subdomain_patch=get(handles.subdomain_patch1,'String'); 4166 par.thresh_patch=get(handles.thresh_patch1,'String'); 4167 4168 4163 4169 %------------------------------------------------------------------------ 4164 4170 function par=read_param_civ2(handles,file_ima) … … 4201 4207 end 4202 4208 4203 %------------------------------------------------------------------------ 4204 % --- CIV1 CIV1 CIV1 CIV1 4205 function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) 4209 function cmd_CIV1=CIV1_CMD(filename,param) 4210 %TODO : include filename in par_civ1 4206 4211 %------------------------------------------------------------------------ 4207 4212 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4208 4213 4209 4214 %changes : filename_cmx -> filename ( no extension ) 4210 % input namelog not used 4211 if isequal(par.Dt,'0') 4212 par.Dt='1' ;%case of 'displacement' mode 4213 end 4214 par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); 4215 par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); 4215 4216 filename=regexprep(filename,'.nc','') 4217 4218 if isequal(param.civ1.Dt,'0') 4219 param.civ1.Dt='1' ;%case of 'displacement' mode 4220 end 4221 param.civ1.filename_ima_a=regexprep(param.civ1.filename_ima_a,'.png',''); 4222 param.civ1.filename_ima_b=regexprep(param.civ1.filename_ima_b,'.png',''); 4216 4223 fid=fopen([filename '.civ1.cmx'],'w'); 4217 4224 fprintf(fid,['############## CMX file' '\n' ]); 4218 fprintf(fid, ['FirstImage ' regexprep(par .filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility4219 fprintf(fid, ['LastImage ' regexprep(par .filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility4225 fprintf(fid, ['FirstImage ' regexprep(param.civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility 4226 fprintf(fid, ['LastImage ' regexprep(param.civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility 4220 4227 fprintf(fid, ['XX' '\n' ]); 4221 fprintf(fid, ['Mask ' par .maskflag '\n' ]);4222 fprintf(fid, ['MaskName ' regexprep(par .maskname,'\\','\\\\') '\n' ]);4223 fprintf(fid, ['ImageSize ' par .npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ?4224 fprintf(fid, ['CorrelationBoxesSize ' par .ibx ' ' par.iby '\n' ]);4225 fprintf(fid, ['SearchBoxeSize ' par .isx ' ' par.isy '\n' ]);4226 fprintf(fid, ['RO ' par .rho '\n' ]);4227 fprintf(fid, ['GridSpacing ' par .dx ' ' par.dy '\n' ]);4228 fprintf(fid, ['Mask ' param.civ1.maskflag '\n' ]); 4229 fprintf(fid, ['MaskName ' regexprep(param.civ1.maskname,'\\','\\\\') '\n' ]); 4230 fprintf(fid, ['ImageSize ' param.civ1.npx ' ' param.civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? 4231 fprintf(fid, ['CorrelationBoxesSize ' param.civ1.ibx ' ' param.civ1.iby '\n' ]); 4232 fprintf(fid, ['SearchBoxeSize ' param.civ1.isx ' ' param.civ1.isy '\n' ]); 4233 fprintf(fid, ['RO ' param.civ1.rho '\n' ]); 4234 fprintf(fid, ['GridSpacing ' param.civ1.dx ' ' param.civ1.dy '\n' ]); 4228 4235 fprintf(fid, ['XX 1.0' '\n' ]); 4229 fprintf(fid, ['Dt_TO ' par .Dt ' ' par.T0 '\n' ]);4230 fprintf(fid, ['PixCmXY ' par .pxcmx ' ' par.pxcmy '\n' ]);4236 fprintf(fid, ['Dt_TO ' param.civ1.Dt ' ' param.civ1.T0 '\n' ]); 4237 fprintf(fid, ['PixCmXY ' param.civ1.pxcmx ' ' param.civ1.pxcmy '\n' ]); 4231 4238 fprintf(fid, ['XX 1' '\n' ]); 4232 fprintf(fid, ['ShiftXY ' par .shiftx ' ' par.shifty '\n' ]);4233 fprintf(fid, ['Grid ' par .gridflag '\n' ]);4234 fprintf(fid, ['GridName ' regexprep(par .gridname,'\\','\\\\') '\n' ]);4239 fprintf(fid, ['ShiftXY ' param.civ1.shiftx ' ' param.civ1.shifty '\n' ]); 4240 fprintf(fid, ['Grid ' param.civ1.gridflag '\n' ]); 4241 fprintf(fid, ['GridName ' regexprep(param.civ1.gridname,'\\','\\\\') '\n' ]); 4235 4242 fprintf(fid, ['XX 85' '\n' ]); 4236 4243 fprintf(fid, ['XX 1.0' '\n' ]); … … 4243 4250 fprintf(fid, ['SeuilImage n' '\n' ]); 4244 4251 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4245 fprintf(fid, ['ImageToUse ' par .term_a ' ' par.term_b '\n' ]); % VERIFIER ?4252 fprintf(fid, ['ImageToUse ' param.civ1.term_a ' ' param.civ1.term_b '\n' ]); % VERIFIER ? 4246 4253 fprintf(fid, ['ImageUsedBefore null null' '\n' ]); 4247 4254 fclose(fid); … … 4251 4258 % namelog=regexprep(namelog,'\\','\\\\'); 4252 4259 if(isunix) 4253 cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; 4254 cmd_CIV1=[cmd_CIV1 sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 4260 cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; 4261 cmd_CIV1=[cmd_CIV1 '\n'... 4262 param.global.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 4255 4263 cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting 4256 4264 % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx … … 4259 4267 % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; 4260 4268 % filename=regexprep(filename,'\\','\\\\'); 4261 cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx" \n'];% copy the .civ1.cmx parameter file to .cmx4262 cmd_CIV1=[ '"' sparam.Civ1Bin'" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file4263 cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\');4264 namelog=regexprep(namelog,'\\','\\\\');4265 cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log 4266 % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"'];4269 cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx 4270 cmd_CIV1=[cmd_CIV1 '\n "' regexprep(param.global.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file 4271 % namelog=regexprep(namelog,'\\','\\\\'); 4272 cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log 4273 4274 % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; 4267 4275 end 4268 4276 … … 4312 4320 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4313 4321 %global CivBin%name of the executable for civ1 calculation 4322 filename=regexprep(filename,'.nc',''); 4314 4323 4315 4324 civ2.image1=par.filename_ima_a; … … 4360 4369 %------------------------------------------------------------------------ 4361 4370 % --- CIV2 CIV2 CIV2 CIV2 4362 function cmd_CIV2=CIV2_CMD(filename, namelog,par,sparam)4371 function cmd_CIV2=CIV2_CMD(filename,param) 4363 4372 %------------------------------------------------------------------------ 4364 4373 %pixels per cm and matrix of the image times, read from the .civ file by uvmat 4365 4374 % global civ2Bin sge%name of the executable for civ1 calculation 4366 4375 if isequal(par.Dt,'0') 4367 par .Dt='1' ;%case of 'displacement' mode4368 end 4369 par .filename_ima_a=regexprep(par.filename_ima_a,'.png','');4370 par .filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ?4376 param.civ2.Dt='1' ;%case of 'displacement' mode 4377 end 4378 param.civ2.filename_ima_a=regexprep(param.civ2.filename_ima_a,'.png',''); 4379 param.civ2.filename_ima_b=regexprep(param.civ2.filename_ima_b,'.png','');% bug : .png appears two times ? 4371 4380 [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); 4372 4381 if isequal(fid,-1) … … 4376 4385 end 4377 4386 fprintf(fid,['############## CMX file' '\n' ]); 4378 fprintf(fid, ['FirstImage ' regexprep(par .filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility4379 fprintf(fid, ['LastImage ' regexprep(par .filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility4387 fprintf(fid, ['FirstImage ' regexprep(param.civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility 4388 fprintf(fid, ['LastImage ' regexprep(param.civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility 4380 4389 fprintf(fid, ['XX' '\n' ]); 4381 fprintf(fid, ['Mask ' par .maskflag '\n' ]);4382 fprintf(fid, ['MaskName ' regexprep(par .maskname,'\\','\\\\') '\n' ]);% for windows compatibility4383 fprintf(fid, ['ImageSize ' par .npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ?4384 fprintf(fid, ['CorrelationBoxesSize ' par .ibx ' ' par.iby '\n' ]);4385 fprintf(fid, ['SearchBoxeSize ' par .ibx ' ' par.iby '\n']);4386 fprintf(fid, ['RO ' par .rho '\n']);4387 fprintf(fid, ['GridSpacing ' par .dx ' ' par.dy '\n']);4390 fprintf(fid, ['Mask ' param.civ2.maskflag '\n' ]); 4391 fprintf(fid, ['MaskName ' regexprep(param.civ2.maskname,'\\','\\\\') '\n' ]);% for windows compatibility 4392 fprintf(fid, ['ImageSize ' param.civ2.npx ' ' param.civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? 4393 fprintf(fid, ['CorrelationBoxesSize ' param.civ2.ibx ' ' param.civ2.iby '\n' ]); 4394 fprintf(fid, ['SearchBoxeSize ' param.civ2.ibx ' ' param.civ2.iby '\n']); 4395 fprintf(fid, ['RO ' param.civ2.rho '\n']); 4396 fprintf(fid, ['GridSpacing ' param.civ2.dx ' ' param.civ2.dy '\n']); 4388 4397 fprintf(fid, ['XX 1.0' '\n' ]); 4389 fprintf(fid, ['Dt_TO ' par .Dt ' ' par.T0 '\n' ]);4390 fprintf(fid, ['PixCmXY ' par .pxcmx ' ' par.pxcmy '\n' ]);4398 fprintf(fid, ['Dt_TO ' param.civ2.Dt ' ' param.civ2.T0 '\n' ]); 4399 fprintf(fid, ['PixCmXY ' param.civ2.pxcmx ' ' param.civ2.pxcmy '\n' ]); 4391 4400 fprintf(fid, ['XX 1' '\n' ]); 4392 4401 fprintf(fid, 'ShiftXY 0 0\n'); 4393 fprintf(fid, ['Grid ' par .gridflag '\n' ]);4394 fprintf(fid, ['GridName ' regexprep(par .gridname,'\\','\\\\') '\n']);4402 fprintf(fid, ['Grid ' param.civ2.gridflag '\n' ]); 4403 fprintf(fid, ['GridName ' regexprep(param.civ2.gridname,'\\','\\\\') '\n']); 4395 4404 fprintf(fid, ['XX 85' '\n' ]); 4396 4405 fprintf(fid, ['XX 1.0' '\n' ]); 4397 4406 fprintf(fid, ['XX 1.0' '\n' ]); 4398 4407 fprintf(fid, ['Hart 1' '\n' ]); 4399 fprintf(fid, ['DecimalShift ' par .decimal '\n']);4400 fprintf(fid, ['Deformation ' par .deformation '\n']);4408 fprintf(fid, ['DecimalShift ' param.civ2.decimal '\n']); 4409 fprintf(fid, ['Deformation ' param.civ2.deformation '\n']); 4401 4410 fprintf(fid, ['CorrelationMin 0' '\n' ]); 4402 4411 fprintf(fid, ['IntensityMin 0' '\n' ]); 4403 4412 fprintf(fid, ['SeuilImage n' '\n' ]); 4404 4413 fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); 4405 fprintf(fid, ['ImageToUse ' par .term_a ' ' par.term_b '\n' ]); % VERIFIER ?4406 fprintf(fid, ['ImageUsedBefore ' regexprep(par .filename_nc1,'\\','\\\\') '\n']);4414 fprintf(fid, ['ImageToUse ' param.civ2.term_a ' ' param.civ2.term_b '\n' ]); % VERIFIER ? 4415 fprintf(fid, ['ImageUsedBefore ' regexprep(param.civ2.filename_nc1,'\\','\\\\') '\n']); 4407 4416 fclose(fid); 4408 4417 4409 4418 if(isunix) 4410 4419 cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; 4411 cmd_CIV2=[cmd_CIV2 sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx4420 cmd_CIV2=[cmd_CIV2 param.global.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx 4412 4421 cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log 4413 4422 % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx … … 4415 4424 else 4416 4425 filename=regexprep(filename,'\\','\\\\'); 4417 cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"\n']; 4418 cmd_CIV2=[cmd_CIV2 '"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file 4419 cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); 4420 cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; 4426 cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; 4427 cmd_CIV2=[cmd_CIV2 '\n "' regexprep(param.global.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file 4428 cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; 4421 4429 % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; 4422 4430 end 4423 4431 4424 % %------------------------------------------------------------------------4425 % % --- civ using pivlab4426 % function Data=civ_uvmat(par_civ1)4427 % %------------------------------------------------------------------------4428 % image1=imread(par_civ1.filename_ima_a);4429 % image2=imread(par_civ1.filename_ima_b);4430 % stepx=str2num(par_civ1.dx);4431 % stepy=str2num(par_civ1.dy);4432 % ibx2=ceil(str2num(par_civ1.ibx)/2);4433 % iby2=ceil(str2num(par_civ1.iby)/2);4434 % isx2=ceil(str2num(par_civ1.isx)/2);4435 % isy2=ceil(str2num(par_civ1.isy)/2);4436 % shiftx=str2num(par_civ1.shiftx);4437 % shifty=str2num(par_civ1.shifty);4438 % miniy=max(1+isy2-shifty,1+iby2);4439 % minix=max(1+isx2-shiftx,1+ibx2);4440 % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);4441 % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);4442 % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);4443 % PointCoord(:,1)=reshape(GridX,[],1);4444 % PointCoord(:,2)=reshape(GridY,[],1);4445 % % caluclate velocity data (y and v in indices, reverse to y component)4446 % [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);4447 % Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}];4448 % Data.Conventions='uvmat/civdata';4449 % Data.Program='civ_uvmat';4450 % Data.CivStage=1;4451 % % list_param=fieldnames(Param.Civ1);4452 % % for ilist=1:length(list_param)4453 % % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])4454 % % end4455 % Data.Time=str2double(par_civ1.T0);4456 % Data.Dt=str2double(par_civ1.Dt);4457 % Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record4458 % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};4459 % Data.VarAttribute{1}.Role='coord_x';4460 % Data.VarAttribute{2}.Role='coord_y';4461 % Data.VarAttribute{3}.Role='vector_x';4462 % Data.VarAttribute{4}.Role='vector_y';4463 % Data.VarAttribute{5}.Role='warnflag';4464 % Data.Civ1_X=reshape(xtable,[],1);4465 % Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);4466 % Data.Civ1_U=reshape(utable,[],1);4467 % Data.Civ1_V=reshape(-vtable,[],1);4468 % Data.Civ1_C=reshape(ctable,[],1);4469 % Data.Civ1_F=reshape(F,[],1);4470 4432 4471 4433 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.