Changeset 12 for trunk/src/civ.m


Ignore:
Timestamp:
Feb 16, 2010, 3:19:38 PM (11 years ago)
Author:
gostiaux
Message:

The files from uvmat.2.2.beta that differed from the current version have been updated.
Now the /raid/soft/UVMAT/src should be operational

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r2 r12  
    2222function varargout = civ(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 29-Oct-2009 19:05:39
     24% Last Modified by GUIDE v2.5 10-Jan-2010 22:04:45
    2525% Begin initialization code - DO NOT EDIT
    2626gui_Singleton = 1;
     
    4242% End initialization code - DO NOT EDIT
    4343
    44 %--------------------------------------------------------------------------
     44%------------------------------------------------------------------------
    4545% --- Executes just before civ is made visible.
    46 %--------------------------------------------------------------------------
    4746function civ_OpeningFcn(hObject, eventdata, handles, varargin)
     47%------------------------------------------------------------------------
    4848% This function has no output args, see OutputFcn.
    4949% hObject    handle to figure
     
    106106set(handles.ImaDoc,'String',ext)
    107107
    108 
    109 % set(handles.ImaDoc,'String',ext)
    110  
    111108%read names of the .exe file to adjust the interface according to
    112109%available prog
     
    125122else
    126123    syst='WIN';
    127     %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names
    128124    xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
    129125    if exist(xmlfile,'file')
     
    150146test_batch=1;
    151147if ~sge
    152 if isequal(todo_path,'') || isequal(todo_path,[])
    153     display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst])
    154     test_batch=0;
    155 end
    156 if exist(name_todo,'file')~=2
    157     msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
    158   %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
    159 end
    160 end
    161 
    162 
     148    if isequal(todo_path,'') || isequal(todo_path,[])
     149        display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst])
     150        test_batch=0;
     151    end
     152    if exist(name_todo,'file')~=2
     153        msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
     154      %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
     155    end
     156end
    163157if test_batch==0
    164158    set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated)
    165159end
    166 
    167160set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working
    168161set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working
     
    215208
    216209% set the range of fields (1:1 by default) and selected pair
    217 if isempty(num2)|isequal(num2,num1)
     210if isempty(num2)||isequal(num2,num1)
    218211    num_ref_i=num1;
    219212else
     
    222215    browse.incr_pair(2)=0;
    223216end
    224 if isempty(num_b)|isequal(num_a,num_b)
     217if isempty(num_b)||isequal(num_a,num_b)
    225218    if isempty(num_a)
    226219        num_ref_j=1;
     
    248241set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001])
    249242
    250 
    251 %--------------------------------------------------------------
     243%------------------------------------------------------------------------
    252244% --- Outputs from this function are returned to the command line.
    253 %-----------------------------------------------------------------
    254245function varargout = civ_OutputFcn(hObject, eventdata, handles)
     246%------------------------------------------------------------------------
    255247% varargout  cell array for returning output args (see VARARGOUT);
    256248% hObject    handle to figure
     
    260252varargout{1} = handles.output;
    261253
    262 %------------------------------------------------------------------
     254%------------------------------------------------------------------------
    263255% --- Executes on button press in browse_root.
    264256function browse_root_Callback(hObject, eventdata, handles)
     257%------------------------------------------------------------------------
    265258%get the input file properties
    266259filebase=get(handles.displ_filebase,'String');
     
    321314   end
    322315end
    323 
    324316[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
    325317filebase=fullfile(RootPath,RootFile);
     
    441433displ_filebase_Callback(hObject, eventdata, handles);
    442434
    443 %------------------------------------------------
    444 
     435%------------------------------------------------------------------------
    445436function ImaDoc_Callback(hObject, eventdata, handles)
     437%------------------------------------------------------------------------
    446438displ_filebase_Callback(hObject, eventdata, handles)
    447439
    448 %--------------------------------------------------------------
     440%------------------------------------------------------------------------
    449441%function activated when a new filebase (image series) is introduced
    450 %------------------------------------------------------------
    451442function displ_filebase_Callback(hObject, eventdata, handles)
    452 
     443%------------------------------------------------------------------------
    453444global test_batch
    454 %set(gcf,'Pointer','watch')
    455445set(handles.compare,'Visible','on')
    456446ext_ima=get(handles.ext_ima,'String');
     
    471461if ~isempty(browse)
    472462    if isfield(browse,'nom_type_ima')
    473         nom_type_ima=browse.nom_type_ima;
     463        nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
    474464    end
    475465    if isfield(browse,'field_count')
    476         field_count=browse.field_count;
     466        field_count=browse.field_count;% get an image index type already determined by an input file
    477467    end
    478468end
     
    480470%default first_i and j and increments
    481471first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening
    482 if isempty(first_i)| first_i < 1
     472if isempty(first_i)|| first_i < 1
    483473    first_i=1; %default first_i
    484474end
    485475last_i=str2num(get(handles.last_i,'String'));
    486 if isempty(last_i)| last_i < first_i
     476if isempty(last_i)|| last_i < first_i
    487477    last_i=first_i;  %default last_i
    488478end
     
    511501
    512502 %look for an image documentation file
    513 ext
    514503if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI')
    515504    if exist([filebase '.xml'],'file')
     
    532521    drawnow
    533522    %read the image documentation file if found
    534 if isequal(ext,'.civxml') | isequal(ext,'.xml')| isequal(ext,'.civ')
     523if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ')
    535524    set(handles.ref_i,'Visible','On')%use a reference index
    536525    set(handles.ref_j,'Visible','On')
    537526    set(handles.dt,'Visible','Off')
    538     set(handles.dt_text,'String','ref. ind.')
    539 elseif isequal(ext,'.avi') | isequal(ext,'.AVI')
     527    set(handles.dt_text,'String','')
     528elseif isequal(ext,'.avi') || isequal(ext,'.AVI')
    540529    set(handles.ref_j,'Visible','Off')
    541530    set(handles.dt,'Visible','Off')
     
    547536    set(handles.dt_text,'String','dt(ms)=')
    548537end
     538testima_xml=0;
    549539if isequal(ext,'.civxml')%TO ABANDON
    550540    [nbfield,nburst,time]=read_civxml([filebase '.civxml']);
     
    562552    ext_ima_read=[];
    563553    nom_type_read=[];
    564     XmlData.Heading
    565     if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')
     554    if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
    566555        [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
     556        fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName) %full name (including path) of the first image defined by the xmle file,
     557        if exist(fullname,'file')
     558            testima_xml=1;
     559        else
     560            msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
     561        end
    567562    end
    568563    if isfield(XmlData,'Camera')
     
    606601elseif isequal(ext,'.civ')% case of .civ image documentation file
    607602        [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
    608         if error==2, warndlg(['no file ' filebase '.civ']);
    609         elseif error==1, warndlg('inconsistent number of fields in the .civ file');
     603        if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
     604        elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    610605        end
    611606%         ext_ima='.png';
     
    629624set(handles.ImaDoc,'BackgroundColor',[1 1 1])
    630625
     626%get the imabe nomenclature type if not defiend by the input file nor by the xml file
     627if isempty(nom_type_ima)
     628    %look for double image series '_i_j'
     629    dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']);
     630    if isempty(dirima)
     631       % look for images series  with sub marker '_'
     632       dirima=dir([filebase '_*' num2str(first_i) '.*']);
     633       if isempty(dirima)
     634          % look for other images series
     635          dirima=dir([filebase '*' num2str(first_i) '.*']);
     636          if ~isempty(dirima)
     637              [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
     638          end
     639       else
     640           [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
     641       end
     642    else
     643       [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
     644    end
     645end   
     646   
    631647% no image documentation file found: look for a series of existing images or .nc files
    632648if isempty(time) && ~isequal(ext,'.nc')
    633         subdir=get(handles.subdir_civ1,'String');
    634         incr_pair=[0 0];%default
    635         if isfield(browse,'incr_pair')
    636                 incr_pair=browse.incr_pair;
    637         end
    638         nbdetect=0;%test of detected images
    639         field_i=field_count;
    640         idetect=1;
    641         while idetect==1 %look for the maximum file number in the series
    642                 field_i=field_i+1;
     649    subdir=get(handles.subdir_civ1,'String');
     650    incr_pair=[0 0];%default
     651    if isfield(browse,'incr_pair')
     652            incr_pair=browse.incr_pair;
     653    end
     654    nbdetect=0;%test of detected images
     655    field_i=field_count;
     656    idetect=1;
     657    while idetect==1 %look for the maximum file number in the series
     658            field_i=field_i+1;
     659            imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
     660            if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'')
     661               idetect=0; %stop if the same image is repeated (if nom_type='none')
     662               nbdetect=1;
     663            else
     664                idetect=(exist(imagename,'file')==2);
     665            end
     666            %SEE CASE OF NETCDF FILES
     667            nbdetect=nbdetect+(exist(imagename,'file')==2);
     668    end
     669    nb_field=field_i;% last detected field number
     670    field_i=field_count;%look for the minimum file number in the series
     671    idetect=1;
     672    while idetect==1
     673                field_i=field_i-1;
    643674                imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
    644                 if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'')
    645                    idetect=0; %stop if the same image is repeated (if nom_type='none')
    646                    nbdetect=1;
     675                if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'')
     676                    idetect=0; %stop if the same image is repeated (if nom_type='none')
     677                    nbdetect=1;
    647678                else
    648679                    idetect=(exist(imagename,'file')==2);
    649680                end
    650                 %SEE CASE OF NETCDF FILES
    651                 nbdetect=nbdetect+(exist(imagename,'file')==2);
    652         end
    653         nb_field=field_i;% last detected field number
    654         field_i=field_count;%look for the minimum file number in the series
    655         idetect=1;
    656         while idetect==1
    657                     field_i=field_i-1;
    658                     imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima);
    659                     if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'')
    660                         idetect=0; %stop if the same image is repeted (if nom_type='none')
    661                         nbdetect=1;
    662                     else
    663                         idetect=(exist(imagename,'file')==2);
    664                     end
    665                     nbdetect=nbdetect+idetect;
    666         end
    667         first_i=max(field_i+1,1);
    668             %determine the set of times and possible intervals for CIV
    669         dt=(1/1000)*str2num(get(handles.dt,'String'));
    670         time=(dt*[0:nb_field-1])';
    671         set(handles.mode,'String',{'series(Di)'})
     681                nbdetect=nbdetect+idetect;
     682    end
     683    first_i=max(field_i+1,1);
     684        %determine the set of times and possible intervals for CIV
     685    dt=(1/1000)*str2num(get(handles.dt,'String'));
     686    time=(dt*[0:nb_field-1])';
     687    set(handles.mode,'String',{'series(Di)'})
    672688end
    673689if isequal(nom_type_ima,'none')% no file numbering used
     
    683699        set(handles.displ_filebase,'UserData',time); %store the set of times
    684700        if isempty(TimeUnit)
    685             set(handles.dt_unit,'String','e-03');
     701            set(handles.dt_unit,'String','dt in e-03');
    686702            set(handles.TimeUnit,'String','');
    687703        else
    688             set(handles.dt_unit,'String',['m' TimeUnit]);
     704            set(handles.dt_unit,'String',['dt in m' TimeUnit]);
    689705            set(handles.TimeUnit,'String',TimeUnit);
    690706        end
     
    780796set(gcf,'Pointer','arrow')
    781797
    782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%????????????
     798%------------------------------------------------------------------------
    783799% --- Executes on button press in mode.
    784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    785800function mode_Callback(hObject, eventdata, handles)
     801%------------------------------------------------------------------------
    786802browse=get(handles.browse_root,'UserData');
    787 
    788803compare_list=get(handles.compare,'String');
    789804val=get(handles.compare,'Value');
     
    813828    displ_dt=1;%default
    814829    nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10
    815 %     if nbfield2<2
    816 %         nbfield2=2,
    817 %     end
    818830    for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode
    819831        for numod_b=(numod_a+1):nbfield2
     
    938950find_netcpair_civ2(hObject, eventdata, handles)
    939951
    940 %--------------------------------------------------------------
     952%------------------------------------------------------------------------
    941953% determine the menu for civ1 pairs depending on existing netcdf file at the middle of
    942954% the field series set by first_i, incr, last_i
    943 %----------------------------------------------------------------
    944955function find_netcpair_civ1(hObject, eventdata, handles)
     956%------------------------------------------------------------------------
    945957set(gcf,'Pointer','watch')
    946958%nomenclature types
     
    971983end
    972984if isempty(nom_type_nc)
    973     'TESTciv'
    974     nom_type_ima
    975985     [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)'));
    976986end
     
    9931003else
    9941004    ref_j=str2num(get(handles.ref_j,'String'));
    995 end
    996 if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval
    997     ref_i=floor((first_i+last_i)/2);
    998     ref_j=1;
    9991005end
    10001006time=get(handles.displ_filebase,'UserData');%get the set of times
     
    11271133set(handles.list_pair_civ2,'String',displ_pair');
    11281134set(gcf,'Pointer','arrow')
    1129 %--------------------------------------------------------------
     1135
     1136%------------------------------------------------------------------------
    11301137% determine the menu for civ2 pairs depending on the existing netcdf file at the
    11311138%middle of the series set by first_i, incr, last_i
    1132 %--------------------------------------------------------------
    11331139function find_netcpair_civ2(hObject, eventdata, handles)
     1140%------------------------------------------------------------------------
    11341141set(gcf,'Pointer','watch')
    11351142%nomenclature types
     
    12651272          end
    12661273       end
    1267 %    else
    1268 %        for ipair=1:nbpair
    1269 %          if select(ipair)
    1270 %             displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)];
    1271 %          else
    1272 %             displ_pair{ipair}='...'; %pair not displayed in the menu
    1273 %          end
    1274 %        end
    1275 %     end
    12761274elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index
    12771275       for ipair=1:nbpair
     
    13101308end
    13111309set(handles.list_pair_civ2,'String',displ_pair');
    1312 
    1313 
    13141310set(gcf,'Pointer','arrow')
    1315 %----------------------------------------------------
     1311
     1312%------------------------------------------------------------------------
    13161313%  determine the list of index pairs of processing file
    1317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    13181314function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
    13191315    find_pair_indices(handles,mode)
     1316%------------------------------------------------------------------------
    13201317first_i=str2num(get(handles.first_i,'String'));
    13211318last_i=str2num(get(handles.last_i,'String'));
     
    14591456end
    14601457
    1461 
    1462 %-------------------------------------------------------------
     1458%------------------------------------------------------------------------
    14631459% --- Executes on selection change in list_pair_civ1.
    14641460function list_pair_civ1_Callback(hObject, eventdata, handles)
    1465 %------------------------------------------------------------
     1461%------------------------------------------------------------------------
    14661462%reproduce by default the chosen pair in the civ2 menu
    14671463list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
     
    15071503end
    15081504
    1509 %------------------------------------------------------------------
     1505%------------------------------------------------------------------------
    15101506% --- Executes on selection change in list_pair_civ2.
    15111507function list_pair_civ2_Callback(hObject, eventdata, handles)
    1512 
     1508%------------------------------------------------------------------------
    15131509index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu
    15141510
     
    15451541end
    15461542
    1547 %---------------------------------------------------
     1543%------------------------------------------------------------------------
    15481544% --- Executes on button press in RUN.
    1549 %------------------------------------------------------
    15501545function RUN_Callback(hObject, eventdata, handles)
     1546%------------------------------------------------------------------------
    15511547global civ1_exe civ2_exe patch_exe patch_new_exe sge
    15521548
     
    15831579%check mask if selecetd
    15841580if isequal(get(handles.get_mask_civ1,'Value'),1)
    1585      get_mask_civ1_Callback(hObject, eventdata, handles);
     1581    maskname=get(handles.mask_civ1,'String');
     1582    if ~exist(maskname,'file')
     1583        get_mask_civ1_Callback(hObject, eventdata, handles);
     1584    end
    15861585end
    15871586if isequal(get(handles.get_mask_fix1,'Value'),1)
     1587    maskname=get(handles.mask_fix1,'String');
     1588    if ~exist(maskname,'file')
    15881589     get_mask_fix1_Callback(hObject, eventdata, handles);
     1590    end
    15891591end
    15901592if isequal(get(handles.get_mask_civ2,'Value'),1)
     1593    maskname=get(handles.mask_civ2,'String');
     1594    if ~exist(maskname,'file')
    15911595     get_mask_civ2_Callback(hObject, eventdata, handles);
     1596    end
    15921597end
    15931598if isequal(get(handles.get_mask_fix2,'Value'),1)
     1599    maskname=get(handles.mask_fix2,'String');
     1600    if ~exist(maskname,'file')
    15941601     get_mask_fix2_Callback(hObject, eventdata, handles);
     1602    end
    15951603end
    15961604
     
    16511659[filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    16521660       set_civ_filenames(handles,compare,box_test);
     1661if isempty(filecell)
     1662   set(handles.RUN, 'Enable','On')
     1663    set(handles.RUN,'BackgroundColor',[1 0 0])
     1664    set(handles.BATCH, 'Enable','On')
     1665    set(handles.BATCH,'BackgroundColor',[1 0 0])
     1666   return
     1667end
    16531668display('files OK, processing...')   
    16541669nbfield=size(num1_civ1,2);
     
    16881703    end   
    16891704    h = waitbar(0,['removing velocity vectors, fix1']);% display a wait bar
    1690     test_mask=get(handles.get_mask_fix1,'Value');
    1691     maskdispl=get(handles.mask_fix1,'String');
    1692     maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
     1705    test_mask=get(handles.get_mask_fix1,'Value');   
     1706    if test_mask
     1707        maskdispl=get(handles.mask_fix1,'String');
     1708        if exist(maskdispl,'file')
     1709            test_mask=2;
     1710            maskname=maskdispl;
     1711        else
     1712            maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
     1713        end
     1714    end
    16931715    for ifile=1:nbfield
    16941716        waitbar(ifile/nbfield); %update the waitbar
     
    16971719                maskname='noFile use default';
    16981720                maskflag=0;
    1699             else
     1721            elseif test_mask==1
    17001722                nbslice_mask=str2num(maskdispl(1:end-4)); %
    17011723                num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
     
    18381860    h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar
    18391861    test_mask=get(handles.get_mask_fix2,'Value');
    1840     maskdispl=get(handles.mask_fix2,'String');
    1841     maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
     1862    if test_mask
     1863        maskdispl=get(handles.mask_fix2,'String');
     1864        if exist(maskdispl,'file')
     1865            test_mask=2;
     1866            maskname=maskdispl;
     1867        else
     1868            maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name
     1869        end
     1870    end
    18421871    for ifile=1:nbfield
    18431872        waitbar(ifile/nbfield); %update the waitbar
     
    18461875                maskname='noFile use default';
    18471876                maskflag=0;
    1848            else
     1877           elseif test_mask==1
    18491878                nbslice_mask=str2num(maskdispl(1:end-4)); %
    18501879                num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
     
    19842013saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    19852014
    1986 
    1987 %-----------------------------------------------------------
     2015%------------------------------------------------------------------------
    19882016% --- Executes on button press in BATCH: remote processing
    1989 %-----------------------------------------------------------
    19902017function BATCH_Callback(hObject, eventdata, handles)
     2018%------------------------------------------------------------------------
    19912019global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe
    19922020compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3)
     
    20242052%check mask if selecetd
    20252053if isequal(get(handles.get_mask_civ1,'Value'),1)
    2026      get_mask_civ1_Callback(hObject, eventdata, handles);
     2054    maskname=get(handles.mask_civ1,'String');
     2055    if ~exist(maskname,'file')
     2056        get_mask_civ1_Callback(hObject, eventdata, handles);
     2057    end
    20272058end
    20282059if isequal(get(handles.get_mask_fix1,'Value'),1)
    2029      get_mask_fix1_Callback(hObject, eventdata, handles);
     2060    maskname=get(handles.mask_fix1,'String');
     2061    if ~exist(maskname,'file')
     2062        get_mask_fix1_Callback(hObject, eventdata, handles);
     2063    end
    20302064end
    20312065if isequal(get(handles.get_mask_civ2,'Value'),1)
     2066    maskname=get(handles.mask_civ2,'String');
     2067    if ~exist(maskname,'file')
    20322068     get_mask_civ2_Callback(hObject, eventdata, handles);
     2069    end
    20332070end
    20342071if isequal(get(handles.get_mask_fix2,'Value'),1)
     2072    maskname=get(handles.mask_fix2,'String');
     2073    if ~exist(maskname,'file')
    20352074     get_mask_fix2_Callback(hObject, eventdata, handles);
     2075    end
    20362076end
    20372077
     
    22752315        cmd='';
    22762316        if sge
     2317           %fid=fopen([filename '.cmx'],'w')
    22772318           cmd='#!/bin/bash';
    2278            cmd=char({cmd;'#$ -cwd'});
    2279            cmd=char({cmd;'hostname && date'});
     2319           cmd=[cmd '\n' '#$ -cwd'];
     2320           cmd=[cmd '\n' 'hostname && date'];
    22802321        end
    22812322        if civAll
     
    23072348            else
    23082349                maskdispl=get(handles.mask_civ1,'String');
    2309                 maskbase=[filebase '_' maskdispl]; %
    2310                 nbslice_mask=str2num(maskdispl(1:end-4)); %
    2311                 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
    2312                 par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    2313                 if exist(par_civ1.maskname,'file')
    2314                     par_civ1.maskflag='y';
     2350                if exist(maskdispl,'file')
     2351                    par_civ1.maskname=maskdispl;
     2352                    par_civ1.maskflag='y';   
    23152353                else
    2316                     par_civ1.maskname='noFile use default';
    2317                     par_civ1.maskflag='n';
     2354                    maskbase=[filebase '_' maskdispl]; %
     2355                    nbslice_mask=str2num(maskdispl(1:end-4)); %
     2356                    num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
     2357                    par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
     2358                    if exist(par_civ1.maskname,'file')
     2359                        par_civ1.maskflag='y';
     2360                    else
     2361                        par_civ1.maskname='noFile use default';
     2362                        par_civ1.maskflag='n';
     2363                    end
    23182364                end
    23192365            end
     
    23462392            i_cmd=i_cmd+1;
    23472393            if isequal(civAll,0)
    2348                 cmd=char({cmd;BATCH_CIV1(filename_cmx([1:end-4]),namelog,par_civ1,handles)});
     2394                cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)];
    23492395            else
    23502396                 civAllCmd=[civAllCmd ' civ1 '];
     
    23782424                   ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ...
    23792425                   ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname];
    2380            cmd=char({cmd ;cmd_FIX});
     2426           cmd=[cmd '\n' cmd_FIX];
    23812427           else
    23822428                fix1.inputFileName=filecell.nc.civ1{ifile,j} ;
     
    24032449        if isequal(civAll,0)
    24042450            cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp);
    2405             cmd=char({cmd ;cmd_PATCH});
     2451            cmd=[cmd '\n' cmd_PATCH];
    24062452        else
    24072453            patch1.inputFileName=filecell.nc.civ1{ifile,j} ;
     
    24712517            else
    24722518                maskdispl=get(handles.mask_civ2,'String');
    2473                 maskbase=[filebase '_' maskdispl]; %
    2474                 nbslice_mask=str2num(maskdispl(1:end-4)); %
    2475                 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
    2476                 par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    2477                 if exist(par_civ2.maskname,'file')
    2478                     par_civ2.maskflag='y';
     2519                if exist(maskdispl,'file')
     2520                    par_civ2.maskname=maskdispl;
     2521                    par_civ2.maskflag='y';
    24792522                else
    2480                     par_civ2.maskname='noFile use default';
    2481                     par_civ2.maskflag='n';
     2523                    maskbase=[filebase '_' maskdispl]; %
     2524                    nbslice_mask=str2num(maskdispl(1:end-4)); %
     2525                    num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
     2526                    par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
     2527                    if exist(par_civ2.maskname,'file')
     2528                        par_civ2.maskflag='y';
     2529                    else
     2530                        par_civ2.maskname='noFile use default';
     2531                        par_civ2.maskflag='n';
     2532                    end
    24822533                end
    24832534            end
     
    25102561            if isequal(civAll,0)
    25112562                if(isunix)
    2512                     cmd=char({cmd ; ['cp -f ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
     2563                    cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2];
    25132564                else
    2514                     cmd=char({cmd ; ['copy /Y ' filename_cmx '2 ' filename_cmx]; cmd_CIV2});
     2565                    cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2];
    25152566                end
    25162567            else
     
    25302581     
    25312582     % FIX2
    2532        if box_test(5)==1
     2583     if box_test(5)==1
    25332584           test_mask=get(handles.get_mask_fix2,'Value');   
    25342585            if test_mask==0 
     
    25452596                   ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ...
    25462597                   ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname];
    2547                 cmd=char({cmd ;cmd_FIX});
     2598                cmd=[cmd '\n' cmd_FIX];
    25482599           else                     
    25492600                fix2.inputFileName=filecell.nc.civ2{ifile,j} ;
     
    25672618       
    25682619     %PATCH2
    2569     if box_test(6)==1
    2570         if isequal(civAll,0)
    2571             cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp);
    2572             cmd=char({cmd; cmd_PATCH});
     2620       if box_test(6)==1
     2621            if isequal(civAll,0)
     2622                cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp);
     2623                cmd=[cmd '\n' cmd_PATCH];
     2624            else
     2625                patch2.inputFileName=filecell.nc.civ1{ifile,j} ;
     2626                patch2.nopt=subdomain_patch1;
     2627                patch2.maxdiff=thresh_patch1;
     2628                patch2.ro=rho_patch1;
     2629                test_grid=get(handles.get_gridpatch2,'Value');
     2630                if test_grid
     2631                    patch2.gridflag='y';
     2632                    gridname=get(handles.grid_patch2,'String');
     2633                    if isequal(gridname(end-3:end),'grid')
     2634                        nbslice_grid=str2num(gridname(1:end-4)); %
     2635                        if ~isempty(nbslice_grid)
     2636                            num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
     2637                            patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
     2638                            if ~exist(patch2.gridPatch,'file')
     2639                               msgbox_uvmat('ERROR','grid file absent for patch2')
     2640                            end
     2641                        elseif exist(gridname,'file')
     2642                            patch2.gridPatch=gridname;
     2643                        else
     2644                            msgbox_uvmat('ERROR','grid file absent for patch2')
     2645                        end
     2646                    end
     2647                else
     2648                      patch2.gridPatch='n';
     2649                      patch2.gridflag='n';
     2650                      patch2.m=nx_patch2;
     2651                      patch2.n=ny_patch2;
     2652                end
     2653                patch2.convectFlow='n';
     2654                fieldnames=fields(patch2);
     2655                [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');
     2656                for ilist=1:length(fieldnames)
     2657                   val=eval(['patch2.' fieldnames{ilist}]);
     2658                   if ischar(val)
     2659                      [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});
     2660                      [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
     2661                   end
     2662                end             
     2663                civAllCmd=[civAllCmd ' patch2 '];
     2664            end     
     2665        end
     2666        if isequal(civAll,1)
     2667            save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
     2668            cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
     2669        end
     2670
     2671      % create the .bat file:
     2672        if sge
     2673                [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
     2674                filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
    25732675        else
    2574             patch2.inputFileName=filecell.nc.civ1{ifile,j} ;
    2575             patch2.nopt=subdomain_patch1;
    2576             patch2.maxdiff=thresh_patch1;
    2577             patch2.ro=rho_patch1;
    2578             test_grid=get(handles.get_gridpatch2,'Value');
    2579             if test_grid
    2580                  patch2.gridflag='y';
    2581                 gridname=get(handles.grid_patch2,'String');
    2582                 if isequal(gridname(end-3:end),'grid')
    2583                     nbslice_grid=str2num(gridname(1:end-4)); %
    2584                     if ~isempty(nbslice_grid)
    2585                         num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
    2586                         patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    2587                         if ~exist(patch2.gridPatch,'file')
    2588                            msgbox_uvmat('ERROR','grid file absent for patch2')
    2589                         end
    2590                     elseif exist(gridname,'file')
    2591                         patch2.gridPatch=gridname;
    2592                     else
    2593                         msgbox_uvmat('ERROR','grid file absent for patch2')
    2594                     end
    2595                 end
     2676            filename_bat=filename_cmx;
     2677        end
     2678        filename_bat(end-2:end)='bat';
     2679        fid=fopen(filename_bat,'w');
     2680        fprintf(fid,cmd)
     2681        fclose(fid)
     2682        %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
     2683        if sge
     2684            pvalue=num2str((1-ind_answer)*500);
     2685            namelog=[filename_bat '.patch.log'];
     2686            ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
     2687            eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
     2688        else
     2689            if(isunix)
     2690              cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ;
    25962691            else
    2597                   patch2.gridPatch='n';
    2598                   patch2.gridflag='n';
    2599                   patch2.m=nx_patch2;
    2600                   patch2.n=ny_patch2;
     2692               cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ;
    26012693            end
    2602             patch2.convectFlow='n';
    2603             fieldnames=fields(patch2);
    2604             [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2');
    2605             for ilist=1:length(fieldnames)
    2606                val=eval(['patch2.' fieldnames{ilist}]);
    2607                if ischar(val)
    2608                   [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist});
    2609                   [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val);
    2610                end
    2611             end             
    2612             civAllCmd=[civAllCmd ' patch2 '];
    2613         end     
    2614     end
    2615     if isequal(civAll,1)
    2616          civAllxml
    2617         save(civAllxml,[filename_cmx([1:end-4]) '.xml']);
    2618         cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]});
     2694            count= fprintf(p1,'%s\n', cmdtodo);
     2695        end
    26192696     end
    2620              
    2621   % create the .bat file:
    2622         if sge
    2623                 [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
    2624                 filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
    2625         else
    2626                 filename_bat=filename_cmx;
    2627         end
    2628   filename_bat(end-2:end)='bat';
    2629 
    2630     dlmwrite(filename_bat,cmd,'');%write commands in filename_bat
    2631     if sge
    2632         pvalue=num2str((1-ind_answer)*500);
    2633         namelog=[filename_bat '.patch.log'];
    2634         ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat];
    2635         eval(  ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]);
    2636     else
    2637         if(isunix)
    2638           cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ;
    2639         else
    2640            cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ;
    2641         end
    2642         count= fprintf(p1,'%s\n', cmdtodo);
    2643     end
    2644  end
    26452697end
    26462698if ~sge
     
    26762728saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    26772729
    2678 
    2679 %----------------------------------------------------------
     2730%------------------------------------------------------------------------
    26802731%OUTPUT:
    26812732% filecell: structure of input and output files
     
    26872738%         .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB)
    26882739%         .st{i,j};   set of nc files for the combined stereo fields
    2689 
    26902740function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    26912741    set_civ_filenames(handles,compare,box_test)
    2692 
     2742%------------------------------------------------------------------------
    26932743%get the filename root, nomenclature and numbers
    26942744filebase=get(handles.displ_filebase,'String');
     
    27952845                if ~exist(file_ref,'file')
    27962846                    msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1'])
    2797                     set(handles.RUN, 'Enable','On')
    2798                     set(handles.RUN,'BackgroundColor',[1 0 0])
    2799                     set(handles.BATCH, 'Enable','On')
    2800                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     2847                    filecell=[];
    28012848                    return
    28022849                end
     
    28492896                if ~exist(file_ref,'file')
    28502897                    msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2'])
    2851                     set(handles.RUN, 'Enable','On')
    2852                     set(handles.RUN,'BackgroundColor',[1 0 0])
    2853                     set(handles.BATCH, 'Enable','On')
    2854                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     2898                    filecell=[];
    28552899                    return
    28562900                end
     
    28682912[Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ)
    28692913if ~exist(Path_ima,'dir')
    2870     warndlg_uvmat(['path to images ' Path_ima ' not found'],'ERROR')
     2914    msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
     2915    filecell=[];
    28712916    return
    28722917end
     
    28772922if ~isempty(message) & ~isequal(message.UserWrite,1)
    28782923      msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
     2924      filecell=[];
    28792925      cd(currentdir);
    28802926      return
     
    29472993          if idetectmin==0,
    29482994                msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
    2949                 set(handles.RUN, 'Enable','On')
    2950                 set(handles.RUN,'BackgroundColor',[1 0 0])
    2951                 set(handles.BATCH, 'Enable','On')
    2952                 set(handles.BATCH,'BackgroundColor',[1 0 0])
    2953                 cd(currentdir)
     2995                filecell=[];
    29542996                return
    29552997          end
     
    29572999          if idetectmin==0,
    29583000                msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
    2959                 set(handles.RUN, 'Enable','On')
    2960                 set(handles.RUN,'BackgroundColor',[1 0 0])
    2961                 set(handles.BATCH, 'Enable','On')
    2962                 set(handles.BATCH,'BackgroundColor',[1 0 0])
     3001                filecell=[];
    29633002                cd(currentdir)
    29643003                return
     
    29783017              if idetectmin==0,
    29793018                    msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found'])
    2980                     set(handles.RUN, 'Enable','On')
    2981                     set(handles.RUN,'BackgroundColor',[1 0 0])
    2982                     set(handles.BATCH, 'Enable','On')
    2983                     set(handles.BATCH,'BackgroundColor',[1 0 0])
    2984                       cd(currentdir)
    2985                       return
     3019                    filecell=[];
     3020                    cd(currentdir)
     3021                    return
    29863022              end
    29873023               [idetectmin,indexj]=min(idetect_1);
    29883024               if idetectmin==0,
    2989                     msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
    2990                     set(handles.RUN, 'Enable','On')
    2991                     set(handles.RUN,'BackgroundColor',[1 0 0])
    2992                     set(handles.BATCH, 'Enable','On')
    2993                     set(handles.BATCH,'BackgroundColor',[1 0 0])
    2994                     cd(currentdir)
    2995                     return
     3025                   msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
     3026                  filecell=[];
     3027                  cd(currentdir)
     3028                  return
    29963029               end
    29973030         end
     
    30193052                        set(handles.BATCH, 'Enable','On')
    30203053                    set(handles.BATCH,'BackgroundColor',[1 0 0])
     3054                    filecell=[];
    30213055                        cd(currentdir)
    30223056                        return
     
    30963130                if ~exist(filename,'file')
    30973131                    msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    3098                     set(handles.RUN, 'Enable','On')
    3099                     set(handles.RUN,'BackgroundColor',[1 0 0])
    3100                      set(handles.BATCH, 'Enable','On')
    3101                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     3132                  filecell=[];
    31023133                    return
    31033134                end
     
    31073138                        if isempty(Data.civ2)||isequal(Data.civ2,0)
    31083139                            msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    3109                             set(handles.RUN, 'Enable','On')
    3110                             set(handles.RUN,'BackgroundColor',[1 0 0])
    3111                             set(handles.BATCH, 'Enable','On')
    3112                             set(handles.BATCH,'BackgroundColor',[1 0 0])
     3140                            filecell=[];
    31133141                            return
    31143142                        end 
     
    31173145                        if isempty(Data.patch)||isequal(Data.patch,0)
    31183146                            msgbox_uvmat('ERROR',['no patch data in ' filename])
    3119                             set(handles.RUN, 'Enable','On')
    3120                             set(handles.RUN,'BackgroundColor',[1 0 0])
    3121                             set(handles.BATCH, 'Enable','On')
    3122                             set(handles.BATCH,'BackgroundColor',[1 0 0])
     3147                            filecell=[];
    31233148                            return
    31243149                        end
     
    31703195            if idetectmin==0,
    31713196                    msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found'])
    3172                     set(handles.RUN, 'Enable','On')
    3173                     set(handles.RUN,'BackgroundColor',[1 0 0])
    3174                            set(handles.BATCH, 'Enable','On')
    3175                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     3197                    filecell=[];
    31763198                    return
    31773199            end
     
    31923214            if idetectmin==0,
    31933215                    msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found'])
    3194                     set(handles.RUN, 'Enable','On')
    3195                     set(handles.RUN,'BackgroundColor',[1 0 0])
    3196                            set(handles.BATCH, 'Enable','On')
    3197                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     3216                    filecell=[];
    31983217                    return
    31993218            end
     
    32123231                if ~exist(filename,'file')
    32133232                    msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    3214                     set(handles.RUN, 'Enable','On')
    3215                     set(handles.RUN,'BackgroundColor',[1 0 0])
    3216                     set(handles.BATCH, 'Enable','On')
    3217                     set(handles.BATCH,'BackgroundColor',[1 0 0])
     3233                    filecell=[];
    32183234                    return
    32193235                else
     
    32213237                    if isempty(Data.civ2)||isequal(Data.civ2,0)         
    32223238                        msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    3223                         set(handles.RUN, 'Enable','On')
    3224                         set(handles.RUN,'BackgroundColor',[1 0 0])
    3225                         set(handles.BATCH, 'Enable','On')
    3226                         set(handles.BATCH,'BackgroundColor',[1 0 0])
     3239                        filecell=[];
    32273240                        return
    32283241                    end
     
    33253338end
    33263339
    3327 %---------------------------------------------------------
     3340%------------------------------------------------------------------------
    33283341%CIV1  CIV1  CIV1 CIV1
    3329 %----------------------------------------------------------
    33303342function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc)
     3343%------------------------------------------------------------------------
    33313344%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    33323345global civ1_exe sge%name of the executable for civ1 calculation
     
    34903503                'ImageUsedBefore null null'};
    34913504                textout=char(textcmx);
    3492                 dlmwrite(filename_cmx,textout,'');
     3505%               dlmwrite(filename_cmx,textout,'');
     3506       
     3507       
     3508     fid=fopen([filename_cmx],'w');
     3509fprintf(fid, ['##############   CMX file' '\n']);
     3510 fprintf(fid,   ['FirstImage ' filename_ima '\n' ]);
     3511 fprintf(fid,   ['LastImage  ' filename_ima_1 '\n' ]);
     3512  fprintf(fid,  ['XX' '\n' ]);
     3513  fprintf(fid,  ['Mask '  maskflag '\n' ]);
     3514  fprintf(fid,  ['MaskName '  maskname '\n' ]);
     3515 fprintf(fid,   ['ImageSize '  npx ' '  npy '\n' ]);   %VERIFIER CAS GENERAL ?
     3516 fprintf(fid,   ['CorrelationBoxesSize '  ibx ' '  iby '\n' ]);
     3517 fprintf(fid,   ['SearchBoxeSize '  isx ' '  isy '\n' ]);
     3518 fprintf(fid,   ['RO '  rho '\n' ]);
     3519 fprintf(fid,   ['GridSpacing '  dx ' '  dy '\n' ]);
     3520 fprintf(fid,   ['XX 1.0' '\n' ]);
     3521 fprintf(fid,   ['Dt_TO '  Dt ' '  T0 '\n' ]);
     3522  fprintf(fid,  ['PixCmXY '  pxcmx ' '  pxcmy '\n' ]);
     3523  fprintf(fid,  ['XX 1' '\n' ]);
     3524 fprintf(fid,   ['ShiftXY '  shiftx ' '   shifty '\n' ]);
     3525  fprintf(fid,  ['Grid '  gridflag '\n' ]);
     3526 fprintf(fid,   ['GridName '  gridname '\n' ]);
     3527 fprintf(fid,   ['XX 85' '\n' ]);
     3528 fprintf(fid,   ['XX 1.0' '\n' ]);
     3529 fprintf(fid,   ['XX 1.0' '\n' ]);
     3530 fprintf(fid,   ['Hart 1' '\n' ]);
     3531 fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
     3532 fprintf(fid,   ['Deformation 0' '\n' ]);
     3533  fprintf(fid,  ['CorrelationMin 0' '\n' ]);
     3534 fprintf(fid,   ['IntensityMin 0' '\n' ]);
     3535  fprintf(fid,  ['SeuilImage n' '\n' ]);
     3536 fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
     3537 fprintf(fid,   ['ImageToUse '  term_a ' '  term_b '\n' ]); % VERIFIER ?
     3538 fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
     3539fclose(fid);
     3540       
    34933541                s=-1;
    34943542        display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog])
     
    35043552end
    35053553
    3506 %---------------------------------------------------------------
     3554%------------------------------------------------------------------------
    35073555% RUN CIV2   CIV2    CIV2   CIV2
    3508 %-----------------------------------------------------------
    35093556function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc)
     3557%------------------------------------------------------------------------
    35103558%filecell_2: names of first image
    35113559%filecell_3: names of second images
     
    36523700                ['ImageUsedBefore ' filename_nc1]};
    36533701        textout=char(textcmx);
    3654         dlmwrite(filename_cmx,textout,'');    
     3702        dlmwrite(filename_cmx,textout,'');
    36553703        s=-1; 
    36563704        display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog])
     
    36683716% close(h)
    36693717
    3670          
    3671 %----------------------------------------
    3672 %PATCH
    3673 %---------------------------------------
     3718%------------------------------------------------------------------------
     3719% --- PATCH
    36743720function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp)
     3721%------------------------------------------------------------------------
    36753722global patch_exe patch_new_exe
    36763723        namelog=[filename_nc([1:end-3]) '_patch.log'];
     
    36823729                ' -max ' thresh_value ' -nopt ' subdomain_patch  '  > ' namelog ' 2>&1']; % redirect standard output to the log file
    36833730        end
    3684              
    3685 %----------------------------------------
    3686 %STEREO Interp
    3687 %---------------------------------------
     3731
     3732%------------------------------------------------------------------------
     3733% --- STEREO Interp
    36883734function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB)
     3735%------------------------------------------------------------------------
    36893736namelog=[filename_nc([1:end-3]) '_stinterp.log'];
    36903737cmd=[stinterp_exe ' -f1 ' filename_A_nc  ' -f2 ' filename_B_nc ' -f  ' filename_nc ...
    36913738    ' -m ' nx_patch  ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB '  -xy  x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file
    3692  
    3693 %----------------------------------------------------
    3694 function first_j_Callback(hObject, eventdata, handles)
    3695 last_j_Callback(hObject, eventdata, handles)
    3696 
    3697 %---------------------------------------------------------
     3739
     3740%------------------------------------------------------------------------
    36983741% --- Executes on button press in CIV1.
    36993742function CIV1_Callback(hObject, eventdata, handles)
     3743%------------------------------------------------------------------------
    37003744val=get(handles.CIV1,'Value');
    37013745if isequal(val,1)
     
    37073751find_netcpair_civ1(hObject, eventdata, handles);
    37083752
    3709 %------------------------------------------------------
     3753%------------------------------------------------------------------------
    37103754% --- Executes on button press in FIX1.
    37113755function FIX1_Callback(hObject, eventdata, handles)
    3712 
     3756%------------------------------------------------------------------------
    37133757enable_fix1(handles,get(handles.FIX1,'Value'))
    37143758
    3715 
    3716 %----------------------------------------------------------------
     3759%------------------------------------------------------------------------
    37173760% --- Executes on button press in PATCH1.
    37183761function PATCH1_Callback(hObject, eventdata, handles)
    3719 
     3762%------------------------------------------------------------------------
    37203763if get(handles.PATCH1,'Value')==1
    3721 enable_patch1(handles)
    3722 else
    3723 desable_patch1(handles)
    3724 end
    3725 
    3726 %----------------------------------------------------------
     3764    enable_patch1(handles)
     3765else
     3766    desable_patch1(handles)
     3767end
     3768
     3769%------------------------------------------------------------------------
    37273770% --- Executes on button press in CIV2.
    37283771function CIV2_Callback(hObject, eventdata, handles)
     3772%------------------------------------------------------------------------
    37293773state=get(handles.CIV2,'Value');
    37303774enable_civ2(handles,state)
     
    37343778end
    37353779
    3736 %---------------------------------------------------
     3780%------------------------------------------------------------------------
    37373781% --- Executes on button press in FIX2.
    37383782function FIX2_Callback(hObject, eventdata, handles)
     3783%------------------------------------------------------------------------
    37393784if get(handles.FIX2,'Value')==1
    37403785    enable_fix2(handles)
     
    37463791end
    37473792
    3748 
    3749 %-------------------------------------------------------
     3793%------------------------------------------------------------------------
    37503794% --- Executes on button press in PATCH2.
    37513795function PATCH2_Callback(hObject, eventdata, handles)
    3752 %--------------------------------------------------------
     3796%------------------------------------------------------------------------
    37533797if get(handles.PATCH2,'Value')==1
    37543798    enable_patch2(handles)
     
    37603804end
    37613805
    3762 
    3763 
    3764 %-----------------------------------------------------------
     3806%------------------------------------------------------------------------
    37653807function first_i_Callback(hObject, eventdata, handles)
    3766 %------------------------------------------------------
    3767 last_i_Callback(hObject, eventdata, handles)
    3768 
    3769 %-----------------------------------------------------------
     3808%------------------------------------------------------------------------
     3809% last_i_Callback(hObject, eventdata, handles)
     3810first_i=str2num(get(handles.first_i,'String'));
     3811% last_i=str2num(get(handles.last_i,'String'));
     3812% ref_i=ceil((first_i+last_i)/2);
     3813set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index
     3814ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt)
     3815
     3816%------------------------------------------------------------------------
     3817function first_j_Callback(hObject, eventdata, handles)
     3818%------------------------------------------------------------------------
     3819first_j=str2num(get(handles.first_j,'String'));
     3820set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index
     3821ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt)
     3822
     3823%------------------------------------------------------------------------
    37703824% --- Executes on button press in calcul_search: determine the search range isx,isy
    3771 %--------------------------------------------------------
    37723825function calcul_search_Callback(hObject, eventdata, handles)
    3773 
     3826%------------------------------------------------------------------------
    37743827%determine pair numbers
    37753828list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs
     
    38203873set(handles.isy,'String',num2str(isy));
    38213874
    3822 
    3823 %---------------------------------------------------------
    3824 % Executes on carriage return on the subdir civ1 edit window
    3825 %--------------------------------------------------------
     3875%------------------------------------------------------------------------
     3876% --- Executes on carriage return on the subdir civ1 edit window
    38263877function subdir_civ1_Callback(hObject, eventdata, handles)
     3878%------------------------------------------------------------------------
    38273879subdir=get(handles.subdir_civ1,'String');
    38283880set(handles.subdir_civ2,'String',subdir);
     
    38313883end
    38323884
    3833 %---------------------------------------------------------
    3834 % Executes on carriage return on the subdir civ1 edit window
    3835 %---------------------------------------------------------
     3885%------------------------------------------------------------------------
     3886% --- Executes on carriage return on the subdir civ1 edit window
    38363887function subdir_civ2_Callback(hObject, eventdata, handles)
     3888%------------------------------------------------------------------------
    38373889%update the list of available pairs from netcdf files in the new directory
    38383890if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0
     
    38403892end
    38413893
    3842 %------------------------------------------------------
     3894%------------------------------------------------------------------------
    38433895% --- Executes on button press in get_mask_civ1.
    3844 %------------------------------------------------------
    38453896function get_mask_civ1_Callback(hObject, eventdata, handles)
     3897%------------------------------------------------------------------------
    38463898maskval=get(handles.get_mask_civ1,'Value');
    38473899if isequal(maskval,0)
     
    38573909            filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String'));
    38583910            [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3859             if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice_mask)
     3911            if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask)
    38603912                mask_displ='no mask';
    38613913            end
     3914    end
     3915    if isequal(mask_displ,'no mask')
     3916        [FileName, PathName, filterindex] = uigetfile( ...
     3917               {'*.png', ' (*.png)';
     3918                '*.png',  '.png files '; ...
     3919                '*.*', 'All Files (*.*)'}, ...
     3920                'Pick a mask file *.png',filebase);
     3921        mask_displ=fullfile(PathName,FileName); 
     3922        if ~exist(mask_displ,'file')
     3923            mask_displ='no mask';
     3924        end
    38623925    end
    38633926    if isequal(mask_displ,'no mask')
     
    38763939end
    38773940
    3878 %--------------------------------------------------------------
     3941%------------------------------------------------------------------------
    38793942% --- Executes on button press in get_mask_fix1.
    38803943function get_mask_fix1_Callback(hObject, eventdata, handles)
     3944%------------------------------------------------------------------------
    38813945maskval=get(handles.get_mask_fix1,'Value');
    38823946if isequal(maskval,0)
     
    38963960end
    38973961if isequal(mask_displ,'no mask')
     3962    [FileName, PathName, filterindex] = uigetfile( ...
     3963           {'*.png', ' (*.png)';
     3964            '*.png',  '.png files '; ...
     3965            '*.*', 'All Files (*.*)'}, ...
     3966            'Pick a mask file *.png',filebase);
     3967    mask_displ=fullfile(PathName,FileName); 
     3968    if ~exist(mask_displ,'file')
     3969        mask_displ='no mask';
     3970    end
     3971end
     3972if isequal(mask_displ,'no mask')
    38983973    set(handles.get_mask_fix1,'Value',0)
    38993974    set(handles.get_mask_civ2,'Value',0)
     
    39073982set(handles.mask_fix2,'String',mask_displ)
    39083983end
    3909 %-----------------------------------------
     3984
     3985%------------------------------------------------------------------------
    39103986% --- Executes on button press in get_mask_civ2.
    39113987function get_mask_civ2_Callback(hObject, eventdata, handles)
     3988%------------------------------------------------------------------------
    39123989maskval=get(handles.get_mask_civ2,'Value');
    39133990if isequal(maskval,0)
     
    39274004end
    39284005if isequal(mask_displ,'no mask')
     4006    [FileName, PathName, filterindex] = uigetfile( ...
     4007           {'*.png', ' (*.png)';
     4008            '*.png',  '.png files '; ...
     4009            '*.*', 'All Files (*.*)'}, ...
     4010            'Pick a mask file *.png',filebase);
     4011    mask_displ=fullfile(PathName,FileName);
     4012    if ~exist(mask_displ,'file')
     4013        mask_displ='no mask';
     4014    end
     4015end
     4016if isequal(mask_displ,'no mask')
    39294017    set(handles.get_mask_civ2,'Value',0)
    39304018    set(handles.get_mask_fix2,'Value',0)
     
    39354023set(handles.mask_fix2,'String',mask_displ)
    39364024end
    3937 %-------------------------------------
     4025
     4026%------------------------------------------------------------------------
    39384027% --- Executes on button press in get_mask_fix2.
    39394028function get_mask_fix2_Callback(hObject, eventdata, handles)
     4029%------------------------------------------------------------------------
    39404030maskval=get(handles.get_mask_fix2,'Value');
    39414031if isequal(maskval,0)
    39424032    set(handles.mask_fix2,'String','')
    39434033else
    3944 mask_displ='no mask'; %default
    3945 filebase=get(handles.displ_filebase,'String');
    3946 [nbslice, flag_mask]=get_mask(filebase,handles);
    3947 if isequal(flag_mask,1)
    3948       mask_displ=[num2str(nbslice) 'mask'];
    3949 elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    3950         filebase_a=get(handles.displ_filebase2,'String');
    3951         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    3952         if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
     4034    mask_displ='no mask'; %default
     4035    filebase=get(handles.displ_filebase,'String');
     4036    [nbslice, flag_mask]=get_mask(filebase,handles);
     4037    if isequal(flag_mask,1)
     4038          mask_displ=[num2str(nbslice) 'mask'];
     4039    elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
     4040            filebase_a=get(handles.displ_filebase2,'String');
     4041            [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
     4042            if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice)
     4043                mask_displ='no mask';
     4044            end
     4045    end
     4046    if isequal(mask_displ,'no mask')
     4047        [FileName, PathName, filterindex] = uigetfile( ...
     4048               {'*.png', ' (*.png)';
     4049                '*.png',  '.png files '; ...
     4050                '*.*', 'All Files (*.*)'}, ...
     4051                'Pick a mask file *.png',filebase);
     4052        mask_displ=fullfile(PathName,FileName); 
     4053        if ~exist(mask_displ,'file')
    39534054            mask_displ='no mask';
    39544055        end
    3955 end
    3956 if isequal(mask_displ,'no mask')
    3957     set(handles.get_mask_fix2,'Value',0)
    3958 end
    3959 set(handles.mask_fix2,'String',mask_displ)
    3960 end
    3961 
    3962 %---------------------------------------
     4056    end
     4057    if isequal(mask_displ,'no mask')
     4058        set(handles.get_mask_fix2,'Value',0)
     4059    end
     4060    set(handles.mask_fix2,'String',mask_displ)
     4061end
     4062
     4063%------------------------------------------------------------------------
     4064% --- function called to look for mask files
    39634065function [nbslice, flag_mask]=get_mask(filebase,handles)
     4066%------------------------------------------------------------------------
    39644067%detect mask files, images with appropriate file base
    39654068%[filebase '_' xx 'mask'], xx=nbslice
     
    39714074% subdir=get(handles.subdir_civ1,'String');
    39724075[Path,Name]=fileparts(filebase);
     4076if ~isdir(Path)
     4077    msgbox_uvmat('ERROR','no path for input files')
     4078    return
     4079end
    39734080currentdir=pwd;
    39744081cd(Path);%move in the dir of the root name filebase
    39754082maskfiles=dir([Name '_*mask_*.png']);%look for mask files
    39764083cd(currentdir);%come back to the current working directory
    3977 if isempty(maskfiles)
    3978     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
    3979 else
     4084if ~isempty(maskfiles)
     4085%     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
     4086% else
    39804087    flag_mask=1;
    39814088    maskname=maskfiles(1).name;% take the first mask file in the list
     
    39984105end   
    39994106
    4000 %---------------------------------------
     4107%------------------------------------------------------------------------
     4108% --- function called to look for grid files
    40014109function [nbslice, flag_mask]=get_grid(filebase,handles)
    4002 
     4110%------------------------------------------------------------------------
    40034111flag_mask=0;%default
    40044112nbslice=1;
     
    40274135          nbslice=1;
    40284136    end
    4029 end   
    4030 %------------------------------
    4031 
    4032 function grid_civ1_Callback(hObject, eventdata, handles)
    4033 % hObject    handle to grid_civ1 (see GCBO)
    4034 % eventdata  reserved - to be defined in a future version of MATLAB
    4035 % handles    structure with handles and user data (see GUIDATA)
    4036 
    4037 % Hints: get(hObject,'String') returns contents of grid_civ1 as text
    4038 %        str2double(get(hObject,'String')) returns contents of grid_civ1 as a double
    4039 
    4040 
    4041 %-----------------------------------------------------------
    4042 % transform numbers to letters
    4043 %--------------------------------------------
     4137end
     4138
     4139%------------------------------------------------------------------------
     4140% --- transform numbers to letters
    40444141function str=num2stra(num,nom_type);
     4142%------------------------------------------------------------------------
    40454143if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD')
    40464144    str=char(96+num);
     
    40514149    str=num2str(num);
    40524150end
    4053 %---------------------------------------------------
     4151
     4152%------------------------------------------------------------------------
    40544153function mask_civ1_Callback(hObject, eventdata, handles)
     4154%------------------------------------------------------------------------
    40554155set(handles.mask_civ1,'UserData',[])
    40564156set(handles.mask_civ1,'String','')
    4057 %----------------------------------------------------
     4157
     4158%------------------------------------------------------------------------
    40584159function mask_civ2_Callback(hObject, eventdata, handles)
     4160%------------------------------------------------------------------------
    40594161set(handles.mask_civ2,'UserData',[])
    40604162set(handles.mask_civ2,'String','')
    4061 %----------------------------------------------------
     4163
     4164%------------------------------------------------------------------------
    40624165function mask_fix1_Callback(hObject, eventdata, handles)
     4166%------------------------------------------------------------------------
    40634167set(handles.mask_fix1,'UserData',[])
    40644168set(handles.mask_fix1,'String','')
    4065 %----------------------------------------------------
     4169
     4170%------------------------------------------------------------------------
    40664171function mask_fix2_Callback(hObject, eventdata, handles)
     4172%------------------------------------------------------------------------
    40674173set(handles.mask_fix2,'UserData',[])
    40684174set(handles.mask_fix2,'String','')
    40694175
    4070 %--------------------------------------------------------------------------
     4176%------------------------------------------------------------------------
    40714177% --- Executes on button press in list_subdir_civ1.
    40724178function list_subdir_civ1_Callback(hObject, eventdata, handles)
     4179%------------------------------------------------------------------------
    40734180list_subdir_civ1=get(handles.list_subdir_civ1,'String');
    40744181val=get(handles.list_subdir_civ1,'Value');
     
    40794186end
    40804187
    4081 
    4082 %--------------------------------------------------------------------------
     4188%------------------------------------------------------------------------
    40834189% --- Executes on button press in list_subdir_civ2.
    40844190function list_subdir_civ2_Callback(hObject, eventdata, handles)
     4191%------------------------------------------------------------------------
    40854192list_subdir_civ2=get(handles.list_subdir_civ2,'String');
    40864193val=get(handles.list_subdir_civ2,'Value');
     
    40914198end
    40924199
    4093 
    4094 %----------------------------------------------
    4095 function last_i_Callback(hObject, eventdata, handles)
    4096 first_i=str2num(get(handles.first_i,'String'));
    4097 last_i=str2num(get(handles.last_i,'String'));
    4098 ref_i=ceil((first_i+last_i)/2);
    4099 set(handles.ref_i,'String', num2str(ref_i))
    4100 ref_i_Callback(hObject, eventdata, handles)
    4101 
    4102 %-------------------------------------------------------
    4103 function last_j_Callback(hObject, eventdata, handles)
    4104 first_j=str2num(get(handles.first_j,'String'));
    4105 last_j=str2num(get(handles.last_j,'String'));
    4106 ref_j=ceil((first_j+last_j)/2);
    4107 set(handles.ref_j,'String', num2str(ref_j))
    4108 ref_j_Callback(hObject, eventdata, handles)
    4109 
    4110 
    4111 %-----------------------------------------------------------
     4200%------------------------------------------------------------------------
    41124201% --- Executes on button press in browse_gridciv1.
    41134202function browse_gridciv1_Callback(hObject, eventdata, handles)
    4114 %-----------------------------------------------------------
     4203%------------------------------------------------------------------------
    41154204value=get(handles.browse_gridciv1,'Value');
    41164205testgrid=0;
     
    41604249end
    41614250
    4162 %-----------------------------------------------------------
     4251%------------------------------------------------------------------------
    41634252% --- Executes on button press in browse_gridciv1.
    41644253function browse_gridciv2_Callback(hObject, eventdata, handles)
    4165 %-----------------------------------------------------------
     4254%------------------------------------------------------------------------
    41664255value=get(handles.browse_gridciv2,'Value');
    41674256if value
     
    42314320% set(handles.grid_patch2,'string',filegrid
    42324321
    4233 %-----------------------------------------------------------------
     4322%------------------------------------------------------------------------
    42344323% --- Executes on button press in get_gridpatch2.
    42354324function get_gridpatch2_Callback(hObject, eventdata, handles)
    4236 
    4237 
    4238 %----------------------------------------------------------
     4325%------------------------------------------------------------------------
     4326
     4327%------------------------------------------------------------------------
    42394328function enable_civ1(handles,state)
     4329%------------------------------------------------------------------------
    42404330if isequal(state,0)
    42414331    state='off';
     
    42934383set(handles.rho_title,'Visible',state)
    42944384
    4295 %----------------------------------------------------------
     4385%------------------------------------------------------------------------
    42964386function enable_fix1(handles,state)
     4387%------------------------------------------------------------------------
    42974388if isequal(state,0)
    42984389    state='off';
     
    43214412set(handles.field_ref1,'Visible',state)
    43224413
    4323 
    4324 %--------------------------------------------------------------
     4414%------------------------------------------------------------------------
    43254415function enable_patch1(handles)
     4416%------------------------------------------------------------------------
    43264417global patch_new_exe
    43274418set(handles.frame_patch1,'BackgroundColor',[1 1 0])
     
    43434434set(handles.grid_patch1,'Visible','on')
    43444435
    4345 %--------------------------------------------------------------
     4436%------------------------------------------------------------------------
    43464437function desable_patch1(handles)
     4438%------------------------------------------------------------------------
    43474439set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784])
    43484440set(handles.rho_patch1,'Visible','off')
     
    43604452set(handles.grid_patch1,'Visible','off')
    43614453
    4362 %----------------------------------------------------------
     4454%------------------------------------------------------------------------
    43634455function enable_civ2(handles,state)
     4456%------------------------------------------------------------------------
    43644457if isequal(state,0)
    43654458    state='off';
     
    44154508end
    44164509
    4417 
    4418 %----------------------------------------------------------
     4510%------------------------------------------------------------------------
    44194511function enable_fix2(handles)
     4512%------------------------------------------------------------------------
    44204513set(handles.frame_fix2,'BackgroundColor',[1 1 0])
    44214514set(handles.REMOVE2,'Visible','on')
     
    44374530set(handles.field_ref2,'Visible','on')
    44384531
    4439 %----------------------------------------------------------
     4532%------------------------------------------------------------------------
    44404533function desable_fix2(handles)
     4534%------------------------------------------------------------------------
    44414535set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784])
    44424536set(handles.REMOVE2,'Visible','off')
     
    44604554end
    44614555
    4462 %--------------------------------------------------------------
     4556%------------------------------------------------------------------------
    44634557function enable_patch2(handles)
     4558%------------------------------------------------------------------------
    44644559set(handles.frame_patch2,'BackgroundColor',[1 1 0])
    44654560%set(handles.rho_patch2,'Visible','on')
     
    44794574set(handles.subdir_civ2_text,'Visible','on')
    44804575
    4481 %--------------------------------------------------------------
     4576%------------------------------------------------------------------------
    44824577function desable_patch2(handles)
     4578%------------------------------------------------------------------------
    44834579set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784])
    44844580set(handles.rho_patch2,'Visible','off')
     
    45004596end
    45014597
    4502 %--------------------------------------------------------------
     4598%------------------------------------------------------------------------
    45034599function enable_pair1(handles,state)
     4600%------------------------------------------------------------------------
    45044601set(handles.subdir_civ1,'Visible',state)
    45054602set(handles.list_subdir_civ1,'Visible',state)
     
    45084605set(handles.list_pair_civ1,'Visible',state)
    45094606set(handles.PAIR_txt,'Visible',state)
    4510 set(handles.dt_display_txt,'Visible',state)
     4607%set(handles.dt_display_txt,'Visible',state)
    45114608set(handles.dt_unit,'Visible',state)
    45124609set(handles.PAIR_frame,'Visible',state)
    45134610
    4514 % --- Executes on button press in test_interp.
    4515 function test_interp_Callback(hObject, eventdata, handles)
    4516 % hObject    handle to test_interp (see GCBO)
    4517 % eventdata  reserved - to be defined in a future version of MATLAB
    4518 % handles    structure with handles and user data (see GUIDATA)
    4519 
    4520 % Hint: get(hObject,'Value') returns toggle state of test_interp
    4521 
    4522 
    4523 
    4524 
    4525 
    4526 
    4527 %------------------------------------------------
    4528 %Read the parameters for civ1 on the interface
    4529 %--------------------------------------------------
     4611%------------------------------------------------------------------------
     4612% --- Read the parameters for civ1 on the interface
    45304613function par=read_param_civ1(handles,file_ima)
    4531 
     4614%------------------------------------------------------------------------
    45324615ibx_val=str2num(get(handles.ibx,'String'));
    45334616par.ibx=num2str(ibx_val);
     
    45514634         par.isy='41'; %default
    45524635         set(handles.isy,'String','41');
    4553 end;
     4636end
    45544637if isempty(str2num(par.shiftx))
    45554638         par.shiftx='0';%default
    45564639         set(handles.shiftx,'String','0');
    4557 end;
     4640end
    45584641if isempty(str2num(par.shifty))
    45594642         par.shifty='0'; %default
    45604643         set(handles.shifty,'String','0');
    4561 end;
    4562      par.rho=get(handles.rho,'String');
    4563      par.dx=get(handles.dx_civ1,'String');
    4564      par.dy=get(handles.dy_civ1,'String');
    4565      if isequal(str2num(par.dx),[])
    4566          if isempty(get(handles.grid_civ1,'String'));
    4567              par.dx='0'; %just read by civ program, not used
    4568          else
    4569             par.dx='20';%default
    4570             set(handles.dx_civ1,'String','20');
    4571          end
     4644end
     4645 par.rho=get(handles.rho,'String');
     4646 par.dx=get(handles.dx_civ1,'String');
     4647 par.dy=get(handles.dy_civ1,'String');
     4648 if isequal(str2num(par.dx),[])
     4649     if isempty(get(handles.grid_civ1,'String'));
     4650         par.dx='0'; %just read by civ program, not used
     4651     else
     4652        par.dx='20';%default
     4653        set(handles.dx_civ1,'String','20');
    45724654     end
    4573      if isequal(str2num(par.dy),[])
    4574          if isempty(get(handles.grid_civ1,'String'));
    4575              par.dy='0';%just read by civ program, not used
    4576          else
    4577             par.dy='20';%default
    4578             set(handles.dy_civ1_title,'String','20');
    4579          end
     4655 end
     4656 if isequal(str2num(par.dy),[])
     4657     if isempty(get(handles.grid_civ1,'String'));
     4658         par.dy='0';%just read by civ program, not used
     4659     else
     4660        par.dy='20';%default
     4661        set(handles.dy_civ1_title,'String','20');
    45804662     end
    4581         par.pxcmx='1'; %velocities are expressed in pixel dispalcement
    4582          par.pxcmy='1';
     4663 end
     4664    par.pxcmx='1'; %velocities are expressed in pixel dispalcement
     4665     par.pxcmy='1';
    45834666%      end
    4584      A=imread(file_ima);%read the first image to get the size
    4585      sizim=size(A);
    4586      par.npx=num2str(sizim(2));
    4587      par.npy=num2str(sizim(1));
    4588      time=get(handles.displ_filebase,'UserData'); %get the set of times
    4589      par.gridname=get(handles.grid_civ1,'String');
    4590      par.gridflag='y';
    4591      if isequal(par.gridname,'')| isempty(par.gridname)
    4592          par.gridname='nogrid';
    4593          par.gridflag='n';
     4667 A=imread(file_ima);%read the first image to get the size
     4668 sizim=size(A);
     4669 par.npx=num2str(sizim(2));
     4670 par.npy=num2str(sizim(1));
     4671 time=get(handles.displ_filebase,'UserData'); %get the set of times
     4672 par.gridname=get(handles.grid_civ1,'String');
     4673 par.gridflag='y';
     4674 if isequal(par.gridname,'')| isempty(par.gridname)
     4675     par.gridname='nogrid';
     4676     par.gridflag='n';
     4677 end
     4678
     4679%------------------------------------------------------------------------
     4680function par=read_param_civ2(handles,file_ima)
     4681%------------------------------------------------------------------------
     4682par.ibx=get(handles.ibx_civ2,'String');
     4683par.iby=get(handles.iby_civ2,'String');
     4684par.rho=get(handles.rho_civ2,'String');
     4685par.decimal=int2str(get(handles.decimal,'Value'));
     4686par.deformation=int2str(get(handles.deformation,'Value'));
     4687par.dx=get(handles.dx_civ2,'String');
     4688par.dy=get(handles.dy_civ2,'String');
     4689if isequal(str2num(par.dx),[])
     4690     if isempty(get(handles.grid_civ2,'String'));
     4691         par.dx='0'; %just read by civ program, not used
     4692     else
     4693        par.dx='20';%default
     4694        set(handles.dx_civ2,'String','20');
    45944695     end
    4595      
    4596 %----------------------------------------------------------------
    4597 function par=read_param_civ2(handles,file_ima)
    4598     par.ibx=get(handles.ibx_civ2,'String');
    4599     par.iby=get(handles.iby_civ2,'String');
    4600     par.rho=get(handles.rho_civ2,'String');
    4601     par.decimal=int2str(get(handles.decimal,'Value'));
    4602     par.deformation=int2str(get(handles.deformation,'Value'));
    4603     par.dx=get(handles.dx_civ2,'String');
    4604     par.dy=get(handles.dy_civ2,'String');
    4605     if isequal(str2num(par.dx),[])
    4606          if isempty(get(handles.grid_civ2,'String'));
    4607              par.dx='0'; %just read by civ program, not used
    4608          else
    4609             par.dx='20';%default
    4610             set(handles.dx_civ2,'String','20');
    4611          end
     4696 end
     4697 if isequal(str2num(par.dy),[])
     4698     if isempty(get(handles.grid_civ2,'String'));
     4699         par.dy='0';%just read by civ program, not used
     4700     else
     4701        par.dy='20';%default
     4702        set(handles.dy_civ2,'String','20');
    46124703     end
    4613      if isequal(str2num(par.dy),[])
    4614          if isempty(get(handles.grid_civ2,'String'));
    4615              par.dy='0';%just read by civ program, not used
    4616          else
    4617             par.dy='20';%default
    4618             set(handles.dy_civ2,'String','20');
    4619          end
    4620      end
    4621      par.pxcmx='1';
    4622      par.pxcmy='1';
    4623     A=imread(file_ima);%read the first image to get the size
    4624     sizim=size(A);
    4625     par.npx=num2str(sizim(2));
    4626     par.npy=num2str(sizim(1));
    4627     time=get(handles.displ_filebase,'UserData'); %get the set of times
    4628     par.gridname=get(handles.grid_civ2,'String');
    4629     par.gridflag='y';
    4630     if isequal(par.gridname,'')| isempty(par.gridname)
    4631         par.gridname='nogrid';
    4632         par.gridflag='n';
    4633     end
    4634 
    4635 
    4636 %---------------------------------------------------------
    4637 %CIV1  CIV1  CIV1 CIV1
    4638 %----------------------------------------------------------
     4704 end
     4705 par.pxcmx='1';
     4706 par.pxcmy='1';
     4707A=imread(file_ima);%read the first image to get the size
     4708sizim=size(A);
     4709par.npx=num2str(sizim(2));
     4710par.npy=num2str(sizim(1));
     4711time=get(handles.displ_filebase,'UserData'); %get the set of times
     4712par.gridname=get(handles.grid_civ2,'String');
     4713par.gridflag='y';
     4714if isequal(par.gridname,'')| isempty(par.gridname)
     4715    par.gridname='nogrid';
     4716    par.gridflag='n';
     4717end
     4718
     4719%------------------------------------------------------------------------
     4720% --- CIV1  CIV1  CIV1 CIV1
    46394721function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles)
     4722%------------------------------------------------------------------------
    46404723%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    46414724global civ1_exe Civ_exe sge%name of the executable for civ1 calculation
     
    46464729                par.Dt='1' ;%case of 'displacement' mode
    46474730            end         
    4648  
    4649     textcmx={'##############   CMX file';...
    4650     ['FirstImage ' par.filename_ima_a];...
    4651     ['LastImage  ' par.filename_ima_b];...
    4652     'XX' ;...
    4653     ['Mask ' par.maskflag] ;...
    4654     ['MaskName ' par.maskname];...
    4655     ['ImageSize ' par.npx ' ' par.npy];...   %VERIFIER CAS GENERAL ?
    4656     ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
    4657     ['SearchBoxeSize ' par.isx ' ' par.isy];...
    4658     ['RO ' par.rho];...
    4659     ['GridSpacing ' par.dx ' ' par.dy];...
    4660     'XX 1.0';...
    4661     ['Dt_TO ' par.Dt ' ' par.T0];...
    4662     ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
    4663     'XX 1';...
    4664     ['ShiftXY ' par.shiftx ' '  par.shifty];...
    4665     ['Grid ' par.gridflag];...
    4666     ['GridName ' par.gridname] ;...
    4667     'XX 85';...
    4668     'XX 1.0';...
    4669     'XX 1.0';...
    4670     'Hart 1';...
    4671     'DecimalShift 0';...
    4672     'Deformation 0';...
    4673     'CorrelationMin 0';...
    4674     'IntensityMin 0';...
    4675     'SeuilImage n';...
    4676     'SeuilImageValues 0 4096';...
    4677     ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
    4678     'ImageUsedBefore null null'};
    4679 
    4680             textout=char(textcmx);
    4681     %         timeL1=clock;
    4682             dlmwrite([filename '.cmx'],textout,'');
    4683     %             timeL2=clock;
    4684     %     timciv1=etime(timeL2,timeL1)
    4685           if sge 
    4686           cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file
    4687           else
    4688               cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
    4689           end
    4690     if(isunix)
    4691         [Rootbat,Filebat,extbat]=fileparts(namelog);
    4692         ncName=fullfile(Rootbat,[ Filebat '.nc']);
    4693             cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog  ' ' namelog '.civ1.log'];['chmod g+w ' ncName]});
    4694     else
    4695         cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']});
    4696     end
    4697 
    4698 %---------------------------------------------------------
    4699 %CIV1  Unified
    4700 %----------------------------------------------------------
     4731
     4732%     textcmx={'##############   CMX file';...
     4733%     ['FirstImage ' par.filename_ima_a];...
     4734%     ['LastImage  ' par.filename_ima_b];...
     4735%     'XX' ;...
     4736%     ['Mask ' par.maskflag] ;...
     4737%     ['MaskName ' par.maskname];...
     4738%     ['ImageSize ' par.npx ' ' par.npy];...   %VERIFIER CAS GENERAL ?
     4739%     ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
     4740%     ['SearchBoxeSize ' par.isx ' ' par.isy];...
     4741%     ['RO ' par.rho];...
     4742%     ['GridSpacing ' par.dx ' ' par.dy];...
     4743%     'XX 1.0';...
     4744%     ['Dt_TO ' par.Dt ' ' par.T0];...
     4745%     ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
     4746%     'XX 1';...
     4747%     ['ShiftXY ' par.shiftx ' '  par.shifty];...
     4748%     ['Grid ' par.gridflag];...
     4749%     ['GridName ' par.gridname] ;...
     4750%     'XX 85';...
     4751%     'XX 1.0';...
     4752%     'XX 1.0';...
     4753%     'Hart 1';...
     4754%     'DecimalShift 0';...
     4755%     'Deformation 0';...
     4756%     'CorrelationMin 0';...
     4757%     'IntensityMin 0';...
     4758%     'SeuilImage n';...
     4759%     'SeuilImageValues 0 4096';...
     4760%     ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
     4761%     'ImageUsedBefore null null'};
     4762%
     4763%             textout=char(textcmx);
     4764
     4765   fid=fopen([filename '.cmx'],'w');
     4766fprintf(fid,['##############   CMX file' '\n' ]);
     4767 fprintf(fid,   ['FirstImage ' par.filename_ima_a '\n' ]);
     4768 fprintf(fid,   ['LastImage  ' par.filename_ima_b '\n' ]);
     4769  fprintf(fid,  ['XX' '\n' ]);
     4770  fprintf(fid,  ['Mask ' par.maskflag '\n' ]);
     4771  fprintf(fid,  ['MaskName ' par.maskname '\n' ]);
     4772 fprintf(fid,   ['ImageSize ' par.npx ' ' par.npy '\n' ]);   %VERIFIER CAS GENERAL ?
     4773 fprintf(fid,   ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]);
     4774 fprintf(fid,   ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]);
     4775 fprintf(fid,   ['RO ' par.rho '\n' ]);
     4776 fprintf(fid,   ['GridSpacing ' par.dx ' ' par.dy '\n' ]);
     4777 fprintf(fid,   ['XX 1.0' '\n' ]);
     4778 fprintf(fid,   ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]);
     4779  fprintf(fid,  ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
     4780  fprintf(fid,  ['XX 1' '\n' ]);
     4781 fprintf(fid,   ['ShiftXY ' par.shiftx ' '  par.shifty '\n' ]);
     4782  fprintf(fid,  ['Grid ' par.gridflag '\n' ]);
     4783 fprintf(fid,   ['GridName ' par.gridname '\n' ]);
     4784 fprintf(fid,   ['XX 85' '\n' ]);
     4785 fprintf(fid,   ['XX 1.0' '\n' ]);
     4786 fprintf(fid,   ['XX 1.0' '\n' ]);
     4787 fprintf(fid,   ['Hart 1' '\n' ]);
     4788 fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
     4789 fprintf(fid,   ['Deformation 0' '\n' ]);
     4790  fprintf(fid,  ['CorrelationMin 0' '\n' ]);
     4791 fprintf(fid,   ['IntensityMin 0' '\n' ]);
     4792  fprintf(fid,  ['SeuilImage n' '\n' ]);
     4793 fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
     4794 fprintf(fid,   ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ?
     4795 fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
     4796fclose(fid);
     4797 
     4798if sge 
     4799    cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file
     4800else
     4801    cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
     4802end
     4803if(isunix)
     4804    [Rootbat,Filebat,extbat]=fileparts(namelog);
     4805    ncName=fullfile(Rootbat,[ Filebat '.nc']);
     4806    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog  ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName];
     4807else
     4808    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log'];
     4809end
     4810
     4811%------------------------------------------------------------------------
     4812% --- CIV1  Unified
    47014813function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par)
     4814%------------------------------------------------------------------------
    47024815%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    47034816global civ1_exe Civ_exe%name of the executable for civ1 calculation
     
    47344847 
    47354848    xml_civ1_parameters=civ1;
    4736    
    4737 %---------------------------------------------------------
    4738 %CIV2  Unified
    4739 %----------------------------------------------------------
     4849
     4850%------------------------------------------------------------------------
     4851% --- CIV2  Unified
    47404852function civ2=BATCH_CIV2_Unified(filename,namelog,par)
     4853%------------------------------------------------------------------------
    47414854%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    47424855global civ2_exe Civ_exe%name of the executable for civ1 calculation
     
    47874900civ2.convectFlow='n';
    47884901
    4789 %---------------------------------------------------------
    4790 %CIV2  CIV2  CIV2 CIV2
    4791 %----------------------------------------------------------
     4902%------------------------------------------------------------------------
     4903% --- CIV2  CIV2  CIV2 CIV2
    47924904function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par)
     4905%------------------------------------------------------------------------
    47934906%pixels per cm and matrix of the image times, read from the .civ file by uvmat
    47944907global civ2_exe sge%name of the executable for civ1 calculation
     
    47964909                par.Dt='1' ;%case of 'displacement' mode
    47974910  end
    4798 textcmx={'##############   CMX file';...
    4799 ['FirstImage ' par.filename_ima_a];...
    4800 ['LastImage  ' par.filename_ima_b];...
    4801 'XX' ;...
    4802 ['Mask ' par.maskflag];...
    4803 ['MaskName ' par.maskname];...
    4804 ['ImageSize ' par.npx ' ' par.npy];...   
    4805 ['CorrelationBoxesSize ' par.ibx ' ' par.iby];...
    4806 ['SearchBoxeSize ' par.ibx ' ' par.iby];...
    4807 ['RO ' par.rho];...
    4808 ['GridSpacing ' par.dx ' ' par.dy];...
    4809 'XX 1.0';...
    4810 ['Dt_TO ' par.Dt ' ' par.T0];...
    4811 ['PixCmXY ' par.pxcmx ' ' par.pxcmy];...
    4812 'XX 1';...
    4813 ['ShiftXY 0 0'];...
    4814 ['Grid ' par.gridflag];...
    4815 ['GridName ' par.gridname];...
    4816 'XX 85';...
    4817 'XX 1.0';...
    4818 'XX 1.0';...
    4819 'Hart 1';...
    4820 ['DecimalShift ' par.decimal];...
    4821 ['Deformation ' par.deformation];...
    4822 'CorrelationMin 0';...
    4823 'IntensityMin 0';...
    4824 'SeuilImage n';...
    4825 'SeuilImageValues 0 4096';...
    4826 ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ?
    4827 ['ImageUsedBefore ' par.filename_nc1]};
    4828         textout=char(textcmx);
    4829         dlmwrite([filename_cmx '2'] ,textout,'');
    4830         if sge
    4831         cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file
    4832         else
    4833           cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
    4834       end
    4835 
    4836 
     4911textcmx=['##############   CMX file'  '\n'...
     4912['FirstImage ' par.filename_ima_a]  '\n'...
     4913['LastImage  ' par.filename_ima_b]  '\n'...
     4914'XX'   '\n'...
     4915['Mask ' par.maskflag]  '\n'...
     4916['MaskName ' par.maskname]  '\n'...
     4917['ImageSize ' par.npx ' ' par.npy]  '\n'...   
     4918['CorrelationBoxesSize ' par.ibx ' ' par.iby]  '\n'...
     4919['SearchBoxeSize ' par.ibx ' ' par.iby]  '\n'...
     4920['RO ' par.rho]  '\n'...
     4921['GridSpacing ' par.dx ' ' par.dy]  '\n'...
     4922'XX 1.0'  '\n'...
     4923['Dt_TO ' par.Dt ' ' par.T0]  '\n'...
     4924['PixCmXY ' par.pxcmx ' ' par.pxcmy]  '\n'...
     4925'XX 1'  '\n'...
     4926['ShiftXY 0 0']  '\n'...
     4927['Grid ' par.gridflag]  '\n'...
     4928['GridName ' par.gridname]  '\n'...
     4929'XX 85'  '\n'...
     4930'XX 1.0'  '\n'...
     4931'XX 1.0'  '\n'...
     4932'Hart 1'  '\n'...
     4933['DecimalShift ' par.decimal]  '\n'...
     4934['Deformation ' par.deformation]  '\n'...
     4935'CorrelationMin 0'  '\n'...
     4936'IntensityMin 0'  '\n'...
     4937'SeuilImage n'  '\n'...
     4938'SeuilImageValues 0 4096'  '\n'...
     4939['ImageToUse ' par.term_a ' ' par.term_b]  '\n'... % VERIFIER ?
     4940['ImageUsedBefore ' par.filename_nc1]];
     4941textout=char(textcmx);
     4942fid=fopen([filename_cmx '2'],'w');
     4943fprintf(fid,textout);
     4944fclose(fid)
     4945if sge
     4946    cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file
     4947else
     4948    cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file
     4949end
     4950
     4951%------------------------------------------------------------------------
    48374952% --- Executes on button press in HELP.
    48384953function HELP_Callback(hObject, eventdata, handles)
     4954%------------------------------------------------------------------------
    48394955path_to_uvmat=which ('uvmat');% check the path of uvmat
    48404956pathelp=fileparts(path_to_uvmat);
     
    48454961end
    48464962
    4847 
    4848 %----------------------------------------------------------
     4963%------------------------------------------------------------------------
    48494964%--read images and convert them to the uint16 format used for PIV
    48504965function A=read_image(filename,nom_type,npx,npy,num);
     4966%------------------------------------------------------------------------
    48514967%npx, npy are the dimensions needed for the raw SMD images
    48524968%num is the view number needed for an avi movie
     
    48704986    A=uint16(A);
    48714987end
    4872        
    4873 %----------------------------------------------------------------
    4874 %Executes on carriage return on the time interval dt
    4875 %----------------------------------------------------------------
    4876 function dt_Callback(hObject, eventdata, handles)
    4877 %determine the set of times and possible intervals for CIV
    4878 %                 answer=inputdlg('time interval between images?');
    4879                 dt=(1/1000)*str2num(get(handles.dt,'String'));
    4880                 nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
    4881                 time=(dt*[0:nbfield-1])';
    4882 %                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
    4883                 set(handles.displ_filebase,'UserData',time); %store the set of times
    4884                 for index=1:min(nbfield-1,200)
    4885                     displ_num(1,index)=1;
    4886                     displ_num(2,index)=1;
    4887                     displ_num(3,index)=-floor(index/2);
    4888                     displ_num(4,index)=ceil(index/2);
    4889                 end
    4890 set(handles.list_pair_civ1,'Value',1);
    4891 set(handles.list_pair_civ1,'UserData',displ_num);
    4892 set(handles.list_pair_civ2,'Value',1);
    4893 %update the list of time intervals
    4894 find_netcpair_civ1(hObject, eventdata, handles)
    4895 find_netcpair_civ2(hObject, eventdata, handles)
    4896 
    4897 %-------------------------------------------------------
     4988
     4989% %----------------------------------------------------------------
     4990% %Executes on carriage return on the time interval dt
     4991% %----------------------------------------------------------------
     4992% function dt_Callback(hObject, eventdata, handles)
     4993% %determine the set of times and possible intervals for CIV
     4994% %                 answer=inputdlg('time interval between images?');
     4995%                 dt=(1/1000)*str2num(get(handles.dt,'String'));
     4996%                 nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
     4997%                 time=(dt*[0:nbfield-1])';
     4998% %                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
     4999%                 set(handles.displ_filebase,'UserData',time); %store the set of times
     5000%                 for index=1:min(nbfield-1,200)
     5001%                     displ_num(1,index)=1;
     5002%                     displ_num(2,index)=1;
     5003%                     displ_num(3,index)=-floor(index/2);
     5004%                     displ_num(4,index)=ceil(index/2);
     5005%                 end
     5006% set(handles.list_pair_civ1,'Value',1);
     5007% set(handles.list_pair_civ1,'UserData',displ_num);
     5008% set(handles.list_pair_civ2,'Value',1);
     5009% %update the list of time intervals
     5010% find_netcpair_civ1(hObject, eventdata, handles)
     5011% find_netcpair_civ2(hObject, eventdata, handles)
     5012
     5013%------------------------------------------------------------------------
    48985014function ref_i_Callback(hObject, eventdata, handles)
     5015%------------------------------------------------------------------------
    48995016mode_list=get(handles.mode,'String');
    49005017mode_value=get(handles.mode,'Value');
    49015018mode=mode_list{mode_value};
    4902 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)')
     5019%if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Di)')
    49035020    find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
    4904 end
    4905 if isequal(mode,'series(Di)') | ...% we do patch2 only
     5021%end
     5022if isequal(mode,'series(Di)') || ...% we do patch2 only
    49065023   (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
    49075024    find_netcpair_civ2(hObject, eventdata, handles);
    49085025end
    49095026
    4910 %----------------------------------------------------
     5027%------------------------------------------------------------------------
    49115028function ref_j_Callback(hObject, eventdata, handles)
     5029%------------------------------------------------------------------------
    49125030mode_list=get(handles.mode,'String');
    49135031mode_value=get(handles.mode,'Value');
     
    49205038    find_netcpair_civ2(hObject, eventdata, handles);
    49215039end
    4922 %----------------------------------------------------
     5040
     5041%------------------------------------------------------------------------
    49235042% --- Executes on button press in compare.
    49245043function compare_Callback(hObject, eventdata, handles)
     5044%------------------------------------------------------------------------
    49255045test=get(handles.compare,'Value');
    49265046if test==2 || test==3   
     
    49885108mode_Callback(hObject, eventdata, handles)
    49895109
    4990 %-----------------------------------------------------------
     5110%------------------------------------------------------------------------
    49915111% --- Executes on button press in get_ref_fix1.
    49925112function get_ref_fix1_Callback(hObject, eventdata, handles)
     5113%------------------------------------------------------------------------
    49935114filebase=get(handles.displ_filebase,'String');
    49945115[FileName, PathName, filterindex] = uigetfile( ...
     
    50015122sizf=size(fileinput);
    50025123if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    5003 %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    50045124[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    5005 %filebase=fullfile(RootPath,RootFile);
    5006 % [Pth,FileN]=fileparts(filebasesub);
    5007 % Pth=fileparts(Pth);
    50085125ref.filebase=fullfile(Path,File);
    50095126ref.num_a=stra2num(str_a);
     
    50165133    return
    50175134end
    5018 % [path,name]=fileparts(ref.filebase);
    50195135set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']);
    50205136set(handles.ref_fix1,'UserData',ref)
     
    50305146    menu_field{4}='filter2';
    50315147end
    5032 % [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
    5033 % if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
    5034 %          menu_field{2}='filter1';
    5035 % end
    5036 % if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
    5037 %          menu_field{3}='civ2';
    5038 % end
    5039 % if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
    5040 %          menu_field{4}='filter2';
    5041 % end
    50425148set(handles.field_ref1,'String',menu_field);
    50435149set(handles.field_ref1,'Value',length(menu_field));
     
    50455151set(handles.thresh_vel,'String','1');%default threshold
    50465152set(handles.ref_fix1,'Enable','on')
    5047  
    5048 %---------------------------------------------------------------
     5153
     5154%------------------------------------------------------------------------
    50495155% --- Executes on button press in get_ref_fix2.
    50505156function get_ref_fix2_Callback(hObject, eventdata, handles)
     5157%------------------------------------------------------------------------
    50515158if isequal(get(handles.get_ref_fix2,'Value'),1)
    50525159    filebase=get(handles.displ_filebase,'String');
     
    50595166    sizf=size(fileinput);
    50605167    if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    5061     %[filebasesub,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    50625168    [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    5063 %     [Pth,FileN]=fileparts(filebasesub);
    5064 %     Pth=fileparts(Pth);
    50655169    ref.filebase=fullfile(Path,File);
    50665170    ref.num_a=stra2num(str_a);
     
    50735177        return
    50745178    end
    5075 %     [path,name]=fileparts(ref.filebase);
    50765179    set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']);
    50775180    set(handles.ref_fix2,'UserData',ref)   
    50785181    menu_field{1}='civ1';
    5079 %     [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'});
    50805182    Data=nc2struct(fileinput,[]);
    50815183    if isfield(Data,'patch') & isequal(Data.patch,1)
     
    50885190        menu_field{4}='filter2';
    50895191    end
    5090 
    5091 %     if isequal(cte_detect(1),1) & isequal(cte_read(1),1)
    5092 %              menu_field{2}='filter1';
    5093 %     end
    5094 %     if isequal(cte_detect(2),1) & isequal(cte_read(2),1)
    5095 %              menu_field{3}='civ2';
    5096 %     end
    5097 %     if isequal(cte_detect(3),1) & isequal(cte_read(3),1)
    5098 %              menu_field{4}='filter2';
    5099 %     end
    51005192    set(handles.field_ref2,'String',menu_field);
    51015193    set(handles.field_ref2,'Value',length(menu_field));
     
    51095201    set(handles.field_ref2,'Visible','off')
    51105202end
    5111 %-------------------------------------------------------
    5112 
     5203
     5204%------------------------------------------------------------------------
    51135205function ref_fix1_Callback(hObject, eventdata, handles)
    5114     set(handles.inf_sup1,'Value',1);
    5115     set(handles.field_ref1,'Value',1)
    5116     set(handles.field_ref1,'String',{' '})
    5117     set(handles.ref_fix1,'UserData',[]);
    5118     set(handles.ref_fix1,'String','');
    5119     set(handles.thresh_vel1,'String','0');
     5206%------------------------------------------------------------------------
     5207set(handles.inf_sup1,'Value',1);
     5208set(handles.field_ref1,'Value',1)
     5209set(handles.field_ref1,'String',{' '})
     5210set(handles.ref_fix1,'UserData',[]);
     5211set(handles.ref_fix1,'String','');
     5212set(handles.thresh_vel1,'String','0');
    51205213 
    5121 
    5122 %------------------------------------------------------
    5123 
     5214%------------------------------------------------------------------------
    51245215function ref_fix2_Callback(hObject, eventdata, handles)
    5125     set(handles.inf_sup2,'Value',1);
    5126     set(handles.field_ref2,'Value',1)
    5127     set(handles.field_ref2,'String',{' '})
    5128     set(handles.ref_fix2,'UserData',[]);
    5129     set(handles.ref_fix2,'String','');
    5130     set(handles.thresh_vel2,'String','0');
    5131 
    5132 %--------------------------------------------------------
    5133 % --- Executes on selection change in inf_sup1.
    5134 function inf_sup1_Callback(hObject, eventdata, handles)
    5135 
    5136 %--------------------------------------------------------------------------
    5137 
    5138 
    5139 % --- Executes on selection change in field_ref.
    5140 function field_ref_Callback(hObject, eventdata, handles)
    5141 
    5142 %-------------------------------------------------------------------------
    5143 
    5144 % --- Executes on selection change in field_ref2.
    5145 function field_ref2_Callback(hObject, eventdata, handles)
    5146 
    5147 % -----------------------------------------------------------
     5216%------------------------------------------------------------------------
     5217set(handles.inf_sup2,'Value',1);
     5218set(handles.field_ref2,'Value',1)
     5219set(handles.field_ref2,'String',{' '})
     5220set(handles.ref_fix2,'UserData',[]);
     5221set(handles.ref_fix2,'String','');
     5222set(handles.thresh_vel2,'String','0');
     5223
     5224%------------------------------------------------------------------------
    51485225% transform letters to numbers
    5149 %--------------------------------------------
    51505226function numres=stra2num(str)
     5227%------------------------------------------------------------------------
    51515228numres=double(str)-96;
    51525229if double(str) >= 48 & double(str) <= 57 % = 1 for numbers
     
    51545231end
    51555232
    5156 
     5233%------------------------------------------------------------------------
    51575234% --- Executes on button press in test_stereo1.
    51585235function test_stereo1_Callback(hObject, eventdata, handles)
     5236%------------------------------------------------------------------------
    51595237if isequal(get(handles.test_stereo1,'Value'),0)
    51605238    set(handles.subdomain_patch1,'Visible','on')
     
    51655243end
    51665244
     5245%------------------------------------------------------------------------
    51675246% --- Executes on button press in test_stereo2.
    51685247function test_stereo2_Callback(hObject, eventdata, handles)
     5248%------------------------------------------------------------------------
    51695249if isequal(get(handles.test_stereo2,'Value'),0)
    51705250    set(handles.subdomain_patch2,'Visible','on')
     
    51755255end
    51765256
     5257%------------------------------------------------------------------------
    51775258% --- Executes on button press in ImaThreshold.
    51785259function ImaThreshold_Callback(hObject, eventdata, handles)
     5260%------------------------------------------------------------------------
    51795261if isequal(get(handles.ImaThreshold,'Value'),1)
    51805262    set(handles.MinIma,'Visible','on')
     
    51855267end
    51865268
    5187 
     5269%------------------------------------------------------------------------
    51885270% --- Executes on button press in ImaThreshold2.
    51895271function ImaThreshold2_Callback(hObject, eventdata, handles)
     5272%------------------------------------------------------------------------
    51905273if isequal(get(handles.ImaThreshold2,'Value'),1)
    51915274    set(handles.MinIma2,'Visible','on')
     
    51965279end
    51975280
    5198 
    5199 % --- Executes on button press in Experimental.
    5200 function Experimental_Callback(hObject, eventdata, handles)
    5201 
    5202 
    5203 
    5204 function ext_ima_1_Callback(hObject, eventdata, handles)
    5205 % hObject    handle to ext_ima_1 (see GCBO)
    5206 % eventdata  reserved - to be defined in a future version of MATLAB
    5207 % handles    structure with handles and user data (see GUIDATA)
    5208 
    5209 % Hints: get(hObject,'String') returns contents of ext_ima_1 as text
    5210 %        str2double(get(hObject,'String')) returns contents of ext_ima_1 as a double
    5211 
    5212 
    5213 % --- Executes during object creation, after setting all properties.
    5214 function ext_ima_1_CreateFcn(hObject, eventdata, handles)
    5215 % hObject    handle to ext_ima_1 (see GCBO)
    5216 % eventdata  reserved - to be defined in a future version of MATLAB
    5217 % handles    empty - handles not created until after all CreateFcns called
    5218 
    5219 % Hint: edit controls usually have a white background on Windows.
    5220 %       See ISPC and COMPUTER.
    5221 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    5222     set(hObject,'BackgroundColor','white');
    5223 end
    5224 
    5225 
    5226 
    5227 function ext_ima_Callback(hObject, eventdata, handles)
    5228 % hObject    handle to ext_ima (see GCBO)
    5229 % eventdata  reserved - to be defined in a future version of MATLAB
    5230 % handles    structure with handles and user data (see GUIDATA)
    5231 
    5232 % Hints: get(hObject,'String') returns contents of ext_ima as text
    5233 %        str2double(get(hObject,'String')) returns contents of ext_ima as a double
    5234 
    5235 
    5236 % --- Executes during object creation, after setting all properties.
    5237 function ext_ima_CreateFcn(hObject, eventdata, handles)
    5238 % hObject    handle to ext_ima (see GCBO)
    5239 % eventdata  reserved - to be defined in a future version of MATLAB
    5240 % handles    empty - handles not created until after all CreateFcns called
    5241 
    5242 % Hint: edit controls usually have a white background on Windows.
    5243 %       See ISPC and COMPUTER.
    5244 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    5245     set(hObject,'BackgroundColor','white');
    5246 end
    5247 
    5248 
Note: See TracChangeset for help on using the changeset viewer.