Changeset 272 for trunk/src/civ.m


Ignore:
Timestamp:
Nov 17, 2011, 5:44:16 PM (12 years ago)
Author:
gostiaux
Message:

functions read_param_... and cmd_... for civ1, civ2, fix1, fix2 generalized.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r270 r272  
    14531453%-----------------------------------------------------------------------
    14541454errormsg='';%default
     1455
     1456
    14551457%% check the selected list of operations:
    14561458operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
     
    14741476end
    14751477
    1476 %% check mask if selecetd
     1478%% check mask if selecetd
     1479%could be included in get_mask callback ?
    14771480if isequal(get(handles.get_mask_civ1,'Value'),1)
    14781481    maskname=get(handles.mask_civ1,'String');
     
    15221525nbslice=numel(num_a_civ1);
    15231526
    1524 %% choose the batch or run mode
     1527%% read the PARAM.xml file to get the binaries (and batch_mode if batch)
    15251528path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat
    15261529xmlfile='PARAM.xml';
     
    15281531    t=xmltree(xmlfile);
    15291532    s=convert(t);
    1530 end
    1531 test_interp=0;
     1533else
     1534    errormsg=['no file ' xmlfile];
     1535    return
     1536end
     1537
     1538test_interp=0; %eviter les variables test_ (LG)
     1539
    15321540if batch
    15331541    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;
    15371545            if ~ismember(batch_mode,{'sge','oar'})
    15381546                errormsg=['batch mode ' batch_mode ' not supported by UVMAT'];
     
    15441552        return
    15451553    end
    1546    
    1547     switch batch_mode
    1548         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 create
    1570                 end
    1571             else
    1572                 msgbox_uvmat('ERROR','sge batch system not available')
    1573                 return
    1574             end
    1575         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                 return
    1580             end
    1581     end
    15821554else % run
    15831555    if isfield(s,'RunParam')
    1584         sparam=s.RunParam;
     1556        param.global=s.RunParam;
    15851557    else
    15861558        msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml')
     
    15891561end
    15901562
    1591 %% choose the civ program
     1563%% check batch mode supported
     1564if 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
     1576end
     1577
     1578%% check if the binaries exist
    15921579ProgList=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
     1580CivMode=ProgList{get(handles.CivMode,'Value')};
    15991581
    16001582switch 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
    16091595                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);
    16411602            end
    16421603        end
    16431604    case 'Matlab'
    16441605        if batch
    1645             %% vï¿œrifier Mtlab installï¿œ sur le cluster
     1606            % vérifier Matlab installé sur le cluster
     1607            % difficile a faire a priori
    16461608        end         
    16471609end
    16481610
    1649 
    1650 
    1651 %% get civ1 parameters:
    16521611display('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
     1614if box_test(1)
     1615    param.civ1=read_param_civ1(handles,filecell);
     1616end
     1617
     1618%% get fix1 parameters
     1619if box_test(2)
     1620    param.fix1=read_param_fix1(handles,filecell)
     1621end
     1622
     1623%% get patch1 parameters TODO read_param_patch1
     1624if box_test(3)
     1625    param.patch1=read_param_patch1(handles)
    17021626end
    17031627
    17041628%% get civ2 parameters:
    1705 if box_test(4)==1
    1706     par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1)));
     1629if box_test(4)
     1630    param.civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1)));
    17071631end
    17081632
    17091633%% get fix2 parameters
    1710 if box_test(5)==1
     1634if box_test(5)
    17111635    flagindex2(1)=get(handles.vec_Fmin2_2, 'Value');
    17121636    flagindex2(2)=get(handles.vec_F3_2, 'Value');
     
    17461670end
    17471671
     1672%%
     1673
     1674
    17481675%% MAIN LOOP
    17491676time=get(handles.RootName,'UserData'); %get the set of times
     
    17551682    for j=1:nbslice
    17561683        % initiate system command
    1757         i_cmd=0;
    17581684        switch CivMode
    17591685            case 'CivX'
    1760                 cmd='';
    17611686                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=[];
    17661693                end
    17671694            case 'CivAll'
     
    17711698                CivAllxml=set(CivAllxml,1,'name','CivDoc');
    17721699        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
    17761710       
    17771711        %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')
    17901723                maskdispl=get(handles.mask_civ1,'String');
    17911724                if exist(maskdispl,'file')
    1792                     par_civ1.maskname=maskdispl;
    1793                     par_civ1.maskflag='y';
     1725                    param.civ1.maskname=maskdispl;
     1726                    param.civ1.maskflag='y';
    17941727                else
    17951728                    maskbase=[filecell.filebase '_' maskdispl]; %
    17961729                    nbslice_mask=str2double(maskdispl(1:end-4)); %
    17971730                    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';
    18011734                    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';
    18041737                    end
    18051738                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';
    18101747                gridname=get(handles.grid_civ1,'String');
    18111748                if isequal(gridname(end-3:end),'grid')
     
    18131750                    if ~isnan(nbslice_grid)
    18141751                        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')
    18171754                            msgbox_uvmat('ERROR','grid file absent for civ1')
    18181755                        end
    18191756                    elseif exist(gridname,'file')
    1820                         par_civ1.gridname=gridname;
     1757                        param.civ1.gridname=gridname;
    18211758                    else
    18221759                        msgbox_uvmat('ERROR','grid file absent for civ1')
     
    18241761                end
    18251762            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';
    18281765            end
    18291766           
    1830             i_cmd=i_cmd+1;
    18311767            switch CivMode
    18321768                case 'CivX'
    1833                     civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe
     1769                    civ1_exe=CIV1_CMD(filecell.nc.civ1{ifile,j},param);%create the parameter file .civ1.cmx and set the execution string civ1_exe
    18341770                    cmd=[cmd civ1_exe '\n'];
    18351771                case 'CivAll'
    18361772                    CivAllCmd=[CivAllCmd ' civ1 '];
    1837                     str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1);
     1773                    str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',param.civ1);
    18381774                    fieldnames=fields(str);
    18391775                    [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1');
     
    18491785       
    18501786        % 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
    18641789                case 'CivX'
    18651790                    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];
    18691794                    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 '"'];
    18731798                        cmd_FIX=regexprep(cmd_FIX,'\\','\\\\');
    18741799                    end
     
    18761801                case 'CivAll'
    18771802                    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);
    18831808                    fieldnames=fields(fix1);
    18841809                    [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1');
     
    18981823            switch CivMode
    18991824                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);
    19011826                    cmd=[cmd cmd_PATCH '\n'];
    19021827                case 'CivAll'
     
    19421867            end
    19431868        end
    1944         if box_test(4)==1 || box_test(5)==1 || box_test(6)==1
    1945  %                 pvalue=num2str((1-ind_answer)*500);
    1946            filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file
    1947             filename_cmx(end-1:end+1)='cmx';%name of cmx file
    1948         end
    19491869        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'
    19591878            test_mask=get(handles.get_mask_civ2,'Value');
    19601879            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';
    19631882            else
    19641883                maskdispl=get(handles.mask_civ2,'String');
    19651884                if exist(maskdispl,'file')
    1966                     par_civ2.maskname=maskdispl;
    1967                     par_civ2.maskflag='y';
     1885                    param.civ2.maskname=maskdispl;
     1886                    param.civ2.maskflag='y';
    19681887                else
    19691888                    maskbase=[filecell.filebase '_' maskdispl]; %
    19701889                    nbslice_mask=str2double(maskdispl(1:end-4)); %
    19711890                    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';
    19751894                    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';
    19781897                    end
    19791898                end
     
    19831902                nbslice_grid=str2double(gridname(1:end-4)); %
    19841903                if ~isnan(nbslice_grid)
    1985                     par_civ2.gridflag='y';
     1904                    param.civ2.gridflag='y';
    19861905                    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';
    19901909                    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';
    19931912                    end
    19941913                elseif exist(gridname,'file')
    1995                     par_civ2.gridflag='y';
     1914                    param.civ2.gridflag='y';
    19961915                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';
    19991918                end
    20001919            end
    2001             i_cmd=i_cmd+1;
    2002             flname=fullfile(Rootbat,Filebat);
    20031920            switch CivMode
    20041921                case 'CivX'
    2005                     cmd_CIV2=CIV2_CMD(flname,[],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]
    20061923                    cmd=[cmd cmd_CIV2 '\n'];
    20071924                case 'CivAll'
    20081925                    CivAllCmd=[CivAllCmd ' civ2 '];
    2009                     str=CIV2_CMD_Unified(flname,'',par_civ2);
     1926                    str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',param.civ2);
    20101927                    fieldnames=fields(str);
    20111928                    [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2');
     
    20351952                case 'CivX'
    20361953                    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)) ...
    20381955                            ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ...
    20391956                            ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname];
    20401957                    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)) ...
    20421959                            ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ...
    20431960                            ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"'];
     
    20691986            switch CivMode
    20701987                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);
    20721989                    cmd=[cmd cmd_PATCH '\n'];
    20731990                case 'CivAll'
     
    21172034            case {'CivX','CivAll'}
    21182035                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'];
    21212038                end
    2122                 % create the .bat file:
     2039               
     2040                % create the .bat file used in run or batch
     2041                filename_bat=[OutputFile '.bat'];
    21232042                [fid,message]=fopen(filename_bat,'w');
    21242043                if isequal(fid,-1)
     
    21582077                drawnow
    21592078                if box_test(1)==1
    2160                     Param.Civ1=par_civ1;
     2079                    Param.Civ1=param.civ1;
    21612080                end
    21622081                if box_test(2)==1
     
    21932112                end
    21942113                if box_test(4)==1
    2195                     Param.Civ2=par_civ2;
     2114                    Param.Civ2=param.civ2;
    21962115                end
    21972116                if box_test(5)==1
     
    22502169                display(cmd);eval(cmd);
    22512170            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
    22522191        case 'oar'
    22532192            for p=0:floor(length(batch_file_list)/6);               
     
    31963135%------------------------------------------------------------------------
    31973136% --- PATCH
    3198 function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin)
     3137function cmd=cmd_patch(filename_nc,param)
    31993138%------------------------------------------------------------------------
    32003139namelog=[filename_nc(1:end-3) '_patch.log'];
    3201 if test_interp==0
     3140% if test_interp==0
    32023141    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 ...
    32043146        '  > ' namelog ' 2>&1']; % redirect standard output to the log file
    32053147    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 ...
    32073152        '  > "' namelog '" 2>&1']; % redirect standard output to the log file
    32083153    end
    3209 else %nouveau programme patch
    3210     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 file
    3212 end
    3213 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
     3158cmd=regexprep(cmd,'\\','\\\\');
    32143159%------------------------------------------------------------------------
    32153160% --- STEREO Interp
     
    35623507    return
    35633508end
    3564 currentdir=pwd;
    3565 cd(Path);%move in the dir of the root name filebase
    3566 maskfiles=dir([Name '_*mask_*.png']);%look for mask files
    3567 cd(currentdir);%come back to the current working directory
     3509% currentdir=pwd;
     3510% cd(Path);%move in the dir of the root name filebase
     3511maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files
     3512% cd(currentdir);%come back to the current working directory
    35683513if ~isempty(maskfiles)
    35693514    %     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
     
    40904035%------------------------------------------------------------------------
    40914036% --- Read the parameters for civ1 on the interface
    4092 function par=read_param_civ1(handles,file_ima)
     4037function par=read_param_civ1(handles,filecell)
    40934038%------------------------------------------------------------------------
    40944039ibx_val=str2double(get(handles.ibx,'String'));
     
    41474092par.pxcmx='1'; %velocities are expressed in pixel dispalcement
    41484093par.pxcmy='1';
    4149 if exist('file_ima','var')
    4150 A=imread(file_ima);%read the first image to get the size
     4094% if exist('file_ima','var')
     4095A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size
    41514096sizim=size(A);
    41524097par.npx=num2str(sizim(2));
    41534098par.npy=num2str(sizim(1));
    4154 end
     4099%TODO : civ should not need npx and npy
     4100
     4101
     4102% end
    41554103%time=get(handles.RootName,'UserData'); %get the set of times
    41564104par.gridname=get(handles.grid_civ1,'String');
     
    41614109end
    41624110
     4111%------------------------------------------------------------------------
     4112function 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%------------------------------------------------------------------------
     4145function par=read_param_patch1(handles)
     4146%------------------------------------------------------------------------
     4147
     4148par.rho_patch=str2double(get(handles.rho_patch1,'String'));
     4149if isnan(par.rho_patch)
     4150    par.rho_patch='1000';
     4151    set(handles.rho_patch1,'String','1')
     4152else
     4153    par.rho_patch=num2str(1000*par.rho_patch);
     4154end
     4155par.nx_patch=get(handles.nx_patch1,'String');
     4156par.ny_patch=get(handles.ny_patch1,'String');
     4157if isnan(str2double(par.nx_patch))
     4158    par.nx_patch='50' ;%default
     4159    set(handles.nx_patch1,'String','50');
     4160end
     4161if isnan(str2double(par.ny_patch))
     4162    par.ny_patch='50' ;%default
     4163    set(handles.ny_patch1,'String','50');
     4164end
     4165par.subdomain_patch=get(handles.subdomain_patch1,'String');
     4166par.thresh_patch=get(handles.thresh_patch1,'String');
     4167
     4168           
    41634169%------------------------------------------------------------------------
    41644170function par=read_param_civ2(handles,file_ima)
     
    42014207end
    42024208
    4203 %------------------------------------------------------------------------
    4204 % --- CIV1  CIV1  CIV1 CIV1
    4205 function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam)
     4209function cmd_CIV1=CIV1_CMD(filename,param)
     4210%TODO : include filename in par_civ1
    42064211%------------------------------------------------------------------------
    42074212%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    42084213
    42094214%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
     4216filename=regexprep(filename,'.nc','')
     4217
     4218if isequal(param.civ1.Dt,'0')
     4219    param.civ1.Dt='1' ;%case of 'displacement' mode
     4220end
     4221param.civ1.filename_ima_a=regexprep(param.civ1.filename_ima_a,'.png','');
     4222param.civ1.filename_ima_b=regexprep(param.civ1.filename_ima_b,'.png','');
    42164223fid=fopen([filename '.civ1.cmx'],'w');
    42174224fprintf(fid,['##############   CMX file' '\n' ]);
    4218 fprintf(fid,   ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
    4219 fprintf(fid,   ['LastImage  ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
     4225fprintf(fid,   ['FirstImage ' regexprep(param.civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
     4226fprintf(fid,   ['LastImage  ' regexprep(param.civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
    42204227fprintf(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' ]);
     4228fprintf(fid,  ['Mask ' param.civ1.maskflag '\n' ]);
     4229fprintf(fid,  ['MaskName ' regexprep(param.civ1.maskname,'\\','\\\\') '\n' ]);
     4230fprintf(fid,   ['ImageSize ' param.civ1.npx ' ' param.civ1.npy '\n' ]);   %VERIFIER CAS GENERAL ?
     4231fprintf(fid,   ['CorrelationBoxesSize ' param.civ1.ibx ' ' param.civ1.iby '\n' ]);
     4232fprintf(fid,   ['SearchBoxeSize ' param.civ1.isx ' ' param.civ1.isy '\n' ]);
     4233fprintf(fid,   ['RO ' param.civ1.rho '\n' ]);
     4234fprintf(fid,   ['GridSpacing ' param.civ1.dx ' ' param.civ1.dy '\n' ]);
    42284235fprintf(fid,   ['XX 1.0' '\n' ]);
    4229 fprintf(fid,   ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]);
    4230 fprintf(fid,  ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
     4236fprintf(fid,   ['Dt_TO ' param.civ1.Dt ' ' param.civ1.T0 '\n' ]);
     4237fprintf(fid,  ['PixCmXY ' param.civ1.pxcmx ' ' param.civ1.pxcmy '\n' ]);
    42314238fprintf(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' ]);
     4239fprintf(fid,   ['ShiftXY ' param.civ1.shiftx ' '  param.civ1.shifty '\n' ]);
     4240fprintf(fid,  ['Grid ' param.civ1.gridflag '\n' ]);
     4241fprintf(fid,   ['GridName ' regexprep(param.civ1.gridname,'\\','\\\\') '\n' ]);
    42354242fprintf(fid,   ['XX 85' '\n' ]);
    42364243fprintf(fid,   ['XX 1.0' '\n' ]);
     
    42434250fprintf(fid,  ['SeuilImage n' '\n' ]);
    42444251fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
    4245 fprintf(fid,   ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ?
     4252fprintf(fid,   ['ImageToUse ' param.civ1.term_a ' ' param.civ1.term_b '\n' ]); % VERIFIER ?
    42464253fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
    42474254fclose(fid);
     
    42514258% namelog=regexprep(namelog,'\\','\\\\');
    42524259if(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
    42554263    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
    42564264   % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx
     
    42594267%                     cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n'];
    42604268%     filename=regexprep(filename,'\\','\\\\');
    4261     cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx
    4262     cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
    4263     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"'];
    42674275end
    42684276
     
    43124320%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    43134321%global CivBin%name of the executable for civ1 calculation
     4322filename=regexprep(filename,'.nc','');
    43144323
    43154324civ2.image1=par.filename_ima_a;
     
    43604369%------------------------------------------------------------------------
    43614370% --- CIV2  CIV2  CIV2 CIV2
    4362 function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam)
     4371function cmd_CIV2=CIV2_CMD(filename,param)
    43634372%------------------------------------------------------------------------
    43644373%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    43654374% global civ2Bin sge%name of the executable for civ1 calculation
    43664375if isequal(par.Dt,'0')
    4367     par.Dt='1' ;%case of 'displacement' mode
    4368 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
     4377end
     4378param.civ2.filename_ima_a=regexprep(param.civ2.filename_ima_a,'.png','');
     4379param.civ2.filename_ima_b=regexprep(param.civ2.filename_ima_b,'.png','');% bug : .png appears two times ?
    43714380[fid,errormsg]=fopen([filename '.civ2.cmx'],'w');
    43724381if isequal(fid,-1)
     
    43764385end
    43774386fprintf(fid,['##############   CMX file' '\n' ]);
    4378 fprintf(fid,   ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
    4379 fprintf(fid,   ['LastImage  ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
     4387fprintf(fid,   ['FirstImage ' regexprep(param.civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
     4388fprintf(fid,   ['LastImage  ' regexprep(param.civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility
    43804389fprintf(fid,  ['XX' '\n' ]);
    4381 fprintf(fid, ['Mask ' par.maskflag '\n' ]);
    4382 fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility
    4383 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']);
     4390fprintf(fid, ['Mask ' param.civ2.maskflag '\n' ]);
     4391fprintf(fid, ['MaskName ' regexprep(param.civ2.maskname,'\\','\\\\') '\n' ]);% for windows compatibility
     4392fprintf(fid, ['ImageSize ' param.civ2.npx ' ' param.civ2.npy '\n' ]);   %VERIFIER CAS GENERAL ?
     4393fprintf(fid, ['CorrelationBoxesSize ' param.civ2.ibx ' ' param.civ2.iby '\n' ]);
     4394fprintf(fid, ['SearchBoxeSize ' param.civ2.ibx ' ' param.civ2.iby '\n']);
     4395fprintf(fid, ['RO ' param.civ2.rho '\n']);
     4396fprintf(fid, ['GridSpacing ' param.civ2.dx ' ' param.civ2.dy '\n']);
    43884397fprintf(fid, ['XX 1.0' '\n' ]);
    4389 fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]);
    4390 fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
     4398fprintf(fid, ['Dt_TO ' param.civ2.Dt ' ' param.civ2.T0 '\n' ]);
     4399fprintf(fid, ['PixCmXY ' param.civ2.pxcmx ' ' param.civ2.pxcmy '\n' ]);
    43914400fprintf(fid, ['XX 1' '\n' ]);
    43924401fprintf(fid, 'ShiftXY 0 0\n');
    4393 fprintf(fid, ['Grid ' par.gridflag '\n' ]);
    4394 fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']);
     4402fprintf(fid, ['Grid ' param.civ2.gridflag '\n' ]);
     4403fprintf(fid, ['GridName ' regexprep(param.civ2.gridname,'\\','\\\\') '\n']);
    43954404fprintf(fid, ['XX 85' '\n' ]);
    43964405fprintf(fid, ['XX 1.0' '\n' ]);
    43974406fprintf(fid, ['XX 1.0' '\n' ]);
    43984407fprintf(fid, ['Hart 1' '\n' ]);
    4399 fprintf(fid, ['DecimalShift ' par.decimal '\n']);
    4400 fprintf(fid, ['Deformation ' par.deformation '\n']);
     4408fprintf(fid, ['DecimalShift ' param.civ2.decimal '\n']);
     4409fprintf(fid, ['Deformation ' param.civ2.deformation '\n']);
    44014410fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    44024411fprintf(fid,   ['IntensityMin 0' '\n' ]);
    44034412fprintf(fid,  ['SeuilImage n' '\n' ]);
    44044413fprintf(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']);
     4414fprintf(fid,   ['ImageToUse ' param.civ2.term_a ' ' param.civ2.term_b '\n' ]); % VERIFIER ?
     4415fprintf(fid, ['ImageUsedBefore ' regexprep(param.civ2.filename_nc1,'\\','\\\\') '\n']);
    44074416fclose(fid);
    44084417
    44094418if(isunix)
    44104419    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 CIVx
     4420    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
    44124421    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log
    44134422%    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
     
    44154424else
    44164425    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"'];
    44214429 %    cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"'];
    44224430end
    44234431
    4424 % %------------------------------------------------------------------------
    4425 % % --- civ using pivlab
    4426 % 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 % % end
    4455 % 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 record
    4458 % 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);
    44704432
    44714433%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.