Changeset 127 for trunk/src/civ.m


Ignore:
Timestamp:
Nov 19, 2010, 10:44:24 AM (14 years ago)
Author:
sommeria
Message:

merge_proj.m: cleaning
sub_field.m: ?
dataview.m: modifs not finished
name-generator: bug repair for new nom_type
nc2struct: cleaning
uvmat: cleaning
read_civxdata: transform all variables to double
civ: bug repair for new nom_type, not finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r122 r127  
    453453filebase=get(handles.RootName,'String');
    454454ext=get(handles.ImaDoc,'String');
    455 browse=get(handles.browse_root,'UserData');%default
     455browse=get(handles.browse_root,'UserData')%default
    456456if isfield(browse,'nom_type_ima')
    457457    nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
     
    548548        nbfield=size(time,1);
    549549        nbfield2=size(time,2);
    550         %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
     550        %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
    551551        if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector
    552             if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%'))
     552            if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D'))
    553553                time=time';
    554554                nbfield=nbfield2;
     
    20592059%check the list of operations:
    20602060operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'};
    2061 run_flag=1;
     2061% run_flag=1;
    20622062box_test(1)=get(handles.CIV1,'Value');
    20632063box_test(2)=get(handles.FIX1,'Value');
     
    21212121    s=convert(t);
    21222122end
    2123     test_interp=0;
    2124     if batch
     2123test_interp=0;
     2124if batch
    21252125    if isfield(s,'BatchParam')
    21262126        sparam=s.BatchParam;
     
    21672167    % end
    21682168    if isfield(sparam,'FixBin')
    2169         %     fixBin=sparam.FixBin;
    21702169        if ~exist(sparam.FixBin,'file')
    21712170            sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin);
     
    22182217else
    22192218    if isunix
    2220         [s,w]=unix('ps faux |grep civ|wc -l');
     2219        [xx,w]=unix('ps faux |grep civ|wc -l');
    22212220        w(end)=[];
    2222         if str2num(w)+numel(num1_civ1)> MaxCivProcesses
     2221        if str2double(w)+numel(num1_civ1)> MaxCivProcesses
    22232222            msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'})
    22242223            return
     
    22412240    flagindex1(2)=get(handles.vec_F3, 'Value');
    22422241    flagindex1(3)=get(handles.vec_F2, 'Value');
    2243     thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C
    2244     thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus
     2242    thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C
     2243    thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus
    22452244    test_mask=get(handles.get_mask_fix1,'Value');
    22462245    nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks)
     
    22622261%get patch1 parameters
    22632262if box_test(3)==1
    2264     rho_patch1=str2num(get(handles.rho_patch1,'String'));
    2265     if isempty(rho_patch1)
     2263    rho_patch1=str2double(get(handles.rho_patch1,'String'));
     2264    if isnan(rho_patch1)
    22662265        rho_patch1='1000';
    22672266        set(handles.rho_patch1,'String','1')
     
    22712270    nx_patch1=get(handles.nx_patch1,'String');
    22722271    ny_patch1=get(handles.ny_patch1,'String');
    2273     if isequal(str2num(nx_patch1),[])
     2272    if isnan(str2double(nx_patch1))
    22742273        nx_patch1='50' ;%default
    22752274        set(handles.nx_patch1,'String','50');
    22762275    end
    2277     if isequal(str2num(ny_patch1),[])
     2276    if isnan(str2double(ny_patch1))
    22782277        ny_patch1='50' ;%default
    22792278        set(handles.ny_patch1,'String','50');
     
    22932292    flagindex2(2)=get(handles.vec_F3_2, 'Value');
    22942293    flagindex2(3)=get(handles.vec_F4, 'Value');
    2295     thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C
    2296     thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus
     2294    thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C
     2295    thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus
    22972296    test_mask=get(handles.get_mask_fix2,'Value');
    22982297    nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks)
     
    23062305%get patch2 parameters
    23072306if box_test(6)==1
    2308     rho_patch2=str2num(get(handles.rho_patch2,'String'));
    2309     if isempty(rho_patch2)
     2307    rho_patch2=str2double(get(handles.rho_patch2,'String'));
     2308    if isnan(rho_patch2)
    23102309        rho_patch2='1000';
    23112310        set(handles.rho_patch2,'String','1')
     
    23152314    nx_patch2=get(handles.nx_patch2,'String');
    23162315    ny_patch2=get(handles.ny_patch2,'String');
    2317     if isequal(str2num(nx_patch2),[])
     2316    if isnan(str2double(nx_patch2))
    23182317        nx_patch2='50' ;%default
    23192318        set(handles.nx_patch2,'String','50');
    23202319    end
    2321     if isequal(str2num(ny_patch2),[])
     2320    if isnan(str2double(ny_patch2))
    23222321        ny_patch2='50' ;%default
    23232322        set(handles.ny_patch2,'String','50');
     
    23302329%MAIN LOOP
    23312330% for ifile=1:nbfield
    2332 p1text=[];%initiate command text
     2331% p1text=[];%initiate command text
    23332332time=get(handles.RootName,'UserData'); %get the set of times
    23342333civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method
     
    23502349        end
    23512350        filename_cmx=filecell.nc.civ1{ifile,j};%output netcdf file
    2352         filename_cmx(end-1:end)='cm';%name of cmx file
    2353         filename_cmx=[filename_cmx 'x'];
     2351        filename_cmx(end-1:end+1)='cmx';%name of cmx file
    23542352       
    23552353        %CIV1
     
    25132511        end
    25142512       
    2515         if box_test(4)==1 | box_test(5)==1 | box_test(6)==1
     2513        if box_test(4)==1 || box_test(5)==1 || box_test(6)==1
    25162514            filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file
    2517             filename_cmx([end-1:end])=[ 'cm'];%name of cmx file
    2518             filename_cmx=[filename_cmx 'x'];
     2515            filename_cmx([end-1:end+1])=[ 'cmx'];%name of cmx file
     2516%             filename_cmx=[filename_cmx 'x'];
    25192517        end
    25202518       
     
    27982796filebase_B=filebase;% root name of the second field series for stereo
    27992797if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV')
    2800     test_disp=1;
     2798%     test_disp=1;
    28012799    nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series
    28022800    [Path2,Name2]=fileparts(filebase_B);
     
    28122810    filebase_AB=fullfile(Path2,[Name2 '-' Name1]);
    28132811else
    2814     test_disp=0;
     2812%     test_disp=0;
    28152813    filebase_A=filebase;
    28162814    nom_type_ima1=nom_type_ima2;
     
    28412839        last_j=str2num(get(handles.last_j,'String'));
    28422840        incr_j=str2num(get(handles.incr_j,'String'));
    2843         num_i_ref=[first_i:incr_i:last_i];
    2844         num_j_ref=[first_j:incr_j:last_j];
     2841        num_i_ref=first_i:incr_i:last_i;
     2842        num_j_ref=first_j:incr_j:last_j;
    28452843        if isequal(mode,'displacement')
    28462844            num_i1=num_i_ref;
     
    28892887    ref=get(handles.ref_fix2,'UserData');
    28902888    if ~isempty(ref)
    2891         first_i=str2num(get(handles.first_i,'String'));
    2892         last_i=str2num(get(handles.last_i,'String'));
    2893         incr_i=str2num(get(handles.incr_i,'String'));
    2894         first_j=str2num(get(handles.first_j,'String'));
    2895         last_j=str2num(get(handles.last_j,'String'));
    2896         incr_j=str2num(get(handles.incr_j,'String'));
     2889        first_i=str2double(get(handles.first_i,'String'));
     2890        last_i=str2double(get(handles.last_i,'String'));
     2891        incr_i=str2double(get(handles.incr_i,'String'));
     2892        first_j=str2double(get(handles.first_j,'String'));
     2893        last_j=str2double(get(handles.last_j,'String'));
     2894        incr_j=str2double(get(handles.incr_j,'String'));
    28972895        num_i_ref=[first_i:incr_i:last_i];
    28982896        num_j_ref=[first_j:incr_j:last_j];
     
    29512949dircur=pwd; %current working directory
    29522950m2='';
    2953 [erread,message]=fileattrib(Path_ima);
     2951[xx,message]=fileattrib(Path_ima);
    29542952if ~isempty(message) && ~isequal(message.UserWrite,1)
    29552953    msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
     
    29632961if box_test(1)==1;
    29642962    detect=1;
     2963    vers=0;
     2964    subdir_civ1_new=subdir_civ1;
    29652965    while detect==1 %create a new subdir if the netcdf files already exist
    2966         vers=0;
    2967         subdir_civ1_new=subdir_civ1;
    29682966        for ifile=1:nbfield
    29692967            for j=1:nbslice
     
    29712969                detect=exist(filename,'file')==2;
    29722970                if detect% if a netcdf file already exists
    2973                     vers=vers+1;
    2974                     subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
     2971                    indstr=regexp(subdir_civ1,'\D');
     2972                    if indstr(end)<length(subdir_civ1) %subdir_civ1 ends by a number
     2973                        vers=str2double(subdir_civ1(indstr(end)+1:end))+1;
     2974                        subdir_civ1_new=[subdir_civ1(1:indstr(end)) num2str(vers)];
     2975                    else
     2976                        vers=vers+1;
     2977                        subdir_civ1_new=[subdir_civ1(1:indstr(end)) '_' num2str(vers)];       
     2978                    end
    29752979                    subdir_civ2=subdir_civ1;
    29762980                    break
     
    29822986            end
    29832987        end
    2984         subdir_civ1=subdir_civ1_new;
    29852988        %create the new subdir_civ1
    2986         if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
    2987             [m1,m2,m3]=mkdir(subdir_civ1);
     2989        if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
     2990            [xx,m2]=mkdir(subdir_civ1_new);
    29882991            if ~isequal(m2,'')
    29892992                msgbox_uvmat('ERROR', m2)%error message for directory creation
     
    29942997        end
    29952998        if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series
    2996             vers=0;
    2997             subdir_civ1_new=subdir_civ1;
     2999%             vers=0;
     3000%             subdir_civ1_new=subdir_civ1;
    29983001            for ifile=1:nbfield
    29993002                for j=1:nbslice
     
    30013004                    detect=exist(filename,'file')==2;
    30023005                    if detect% if a netcdf file already exists
    3003                         vers=vers+1;
    3004                         subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
    3005                         subdir_civ2=subdir_civ1;
    3006                         break
     3006                       indstr=regexp(subdir_civ1,'\D');
     3007                       if indstr(end)<length(subdir_civ1) %subdir_civ1 ends by a number
     3008                           vers=str2double(subdir_civ1(indstr(end)+1:end))+1;
     3009                           subdir_civ1_new=[subdir_civ1(1:indstr(end)) num2str(vers)];
     3010                       else
     3011                           vers=vers+1;
     3012                           subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
     3013                       end
     3014                       subdir_civ2=subdir_civ1;
     3015                       break
    30073016                    end
    30083017                    filecell.ncA.civ1(ifile,j)={filename};
     
    30123021                end
    30133022            end
    3014             subdir_civ1=subdir_civ1_new;
     3023%             subdir_civ1=subdir_civ1_new;
    30153024            %create the new subdir_civ1
    3016             if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
    3017                 [m1,m2,m3]=mkdir(subdir_civ1);
     3025            if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
     3026                [xx,m2]=mkdir(subdir_civ1_new);
    30183027                if ~isequal(m2,'')
    30193028                    msgbox_uvmat('ERROR', m2)
     
    30253034        end
    30263035    end
     3036    subdir_civ1=subdir_civ1_new;
    30273037    % get image names
    30283038    for ifile=1:nbfield
     
    31143124testdiff=0;
    31153125if (box_test(4)==1)&&...
    3116         ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1))
     3126        ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1))
    31173127    testdiff=1;
    31183128    detect=1;
     3129    vers=0;
     3130    subdir_civ2_new=subdir_civ2;
    31193131    while detect==1 %create a new subdir if the netcdf files already exist
    31203132        for ifile=1:nbfield
    31213133            for j=1:nbslice
    3122                 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
     3134                filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);%
    31233135                detect=exist(filename,'file')==2;
    31243136                if detect% if a netcdf file already exists
    3125                     subdir_civ2=[subdir_civ2 '.0'];
     3137                    indstr=regexp(subdir_civ2,'\D');
     3138                    if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number
     3139                        vers=str2double(subdir_civ2(indstr(end)+1:end))+1;
     3140                        subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)];
     3141                    else
     3142                        vers=vers+1;
     3143                        subdir_civ2_new=[subdir_civ1 '_' num2str(vers)];
     3144                    end
    31263145                    break
    31273146                end
     
    31343153        %create the new subdir_civ2
    31353154        if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
    3136             [m1,m2,m3]=mkdir(subdir_civ2);
     3155            [xx,m2]=mkdir(subdir_civ2);
    31373156            if ~isequal(m2,'')
    31383157                msgbox_uvmat('ERROR', m2)
     
    31433162        end
    31443163        if strcmp(compare,'stereo PIV')%check second nc series
    3145             vers=0;
    3146             subdir_civ2_new=subdir_civ2;
    31473164            for ifile=1:nbfield
    31483165                for j=1:nbslice
     
    31513168                    detect=exist(filename,'file')==2;
    31523169                    if detect% if a netcdf file already exists
    3153                         vers=vers+1;
    3154                         subdir_civ2_new=[subdir_civ2 '_' num2str(vers)];
     3170                        indstr=regexp(subdir_civ2,'\D');
     3171                        if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number
     3172                           vers=str2double(subdir_civ2(indstr(end)+1:end))+1;
     3173                           subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)];
     3174                        else
     3175                           vers=vers+1;
     3176                           subdir_civ2_new=[subdir_civ1 '_' num2str(vers)];
     3177                        end
    31553178                        break
    31563179                    end
     
    31633186            subdir_civ2=subdir_civ2_new;
    31643187            %create the new subdir_civ1
    3165             if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
    3166                 [m1,m2,m3]=mkdir(subdir_civ2);
     3188            if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
     3189                [xx,m2]=mkdir(subdir_civ2_new);
    31673190                if ~isequal(m2,'')
    31683191                    msgbox_uvmat('ERROR', m2)%error message for directory creation
     
    31743197        end
    31753198    end
     3199    subdir_civ2=subdir_civ2_new;
    31763200end
    31773201cd(currentdir);%come back to the current working directory
     
    33033327%%%%%%%%%%%%%  if stereo fields are calculated by PATCH %%%%%%%%%%%%%
    33043328if strcmp(compare,'stereo PIV')
    3305     if  box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1)
     3329    if  box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1)
    33063330        for ifile=1:nbfield
    33073331            for j=1:nbslice
     
    33123336        end
    33133337    end
    3314     if  box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1)
     3338    if  box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1)
    33153339        for ifile=1:nbfield
    33163340            for j=1:nbslice
     
    34343458end
    34353459
    3436 %------------------------------------------------------------------------
    3437 %CIV1  CIV1  CIV1 CIV1 NOT USED: replaced by RUN_BATCH
    3438 function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc)
    3439 %------------------------------------------------------------------------
    3440 %pixels per cm and matrix of the image times, read from the .civ file by uvmat
    3441 global civ1Bin sge%name of the executable for civ1 calculation
    3442 
    3443 %get civ parameters
    3444 ibx_val=str2num(get(handles.ibx,'String'));
    3445 if isempty(ibx_val)
    3446     ibx='21'; set(handles.ibx,'String','21')
    3447 else
    3448     ibx=num2str(ibx_val);
    3449 end
    3450 iby_val=str2num(get(handles.iby,'String'));
    3451 if isempty(iby_val)
    3452     iby='21'; set(handles.iby,'String','21')
    3453 else
    3454     iby=num2str(iby_val);
    3455 end
    3456 isx=get(handles.isx,'String');
    3457 if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default
    3458 if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end
    3459 isy=get(handles.isy,'String');
    3460 if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default
    3461 if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end
    3462 shiftx=get(handles.shiftx,'String');
    3463 if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default
    3464 shifty=get(handles.shifty,'String');
    3465 if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default
    3466 rho=get(handles.rho,'String');
    3467 dx=get(handles.dx_civ1,'String');
    3468 if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default
    3469 dy=get(handles.dy_civ1,'String');
    3470 if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default
    3471 if isequal(str2num(dy),[]), dy='20'; end%default
    3472 pxcmx='1'; %velocity fields are expressed in pixel displacement
    3473 pxcmy='1';
    3474 image_first=cell2mat(filecell(1,1));
    3475 if ~exist(image_first,'file')
    3476     msgbox_uvmat('ERROR',['image ' image_first 'not found'])
    3477     set(handles.RUN, 'Enable','On')
    3478     set(handles.RUN,'BackgroundColor',[1 0 0])
    3479     return
    3480 end
    3481 A=imread(cell2mat(filecell(1,1)));%read the first image to get the size
    3482 sizim=size(A);
    3483 npx=num2str(sizim(2));
    3484 npy=num2str(sizim(1));
    3485 time=get(handles.RootName,'UserData'); %get the set of times
    3486 gridname='';%default  ='noFile use default'
    3487 gridflag='n';%default
    3488 test_grid=get(handles.browse_gridciv1,'Value');
    3489 nbslice_grid=[];
    3490 if test_grid
    3491     gridname=get(handles.grid_civ1,'String');
    3492     if numel(gridname)>4 && isequal(gridname(end-3:end),'grid')
    3493         nbslice_grid=str2num(gridname(1:end-4)); %
    3494         if ~isempty(nbslice_grid)
    3495             gridflag='y';
    3496         end
    3497     elseif exist(gridname,'file')
    3498         gridflag='y';
    3499     else
    3500         msgbox_uvmat('ERROR',['input grid file ' gridname ' not found'])
    3501         return
    3502     end
    3503 end
    3504 if isequal(get(handles.ImaThreshold,'Value'),1)
    3505     threshflag='y';
    3506     min_ima=get(handles.MinIma,'String');
    3507     max_ima=get(handles.MaxIma,'String');
    3508 else
    3509     threshflag='n';
    3510     min_ima='0';
    3511     max_ima='4096';
    3512 end
    3513 %main loop
    3514 filebase=get(handles.RootName,'String');
    3515 sizcell=size(filecell);
    3516 nbfield=sizcell(1);
    3517 nbslice=sizcell(2);
    3518 icount=0;
    3519 for ifile=1:nbfield
    3520     for j=1:nbslice
    3521         icount=icount+1;
    3522         barlength=0.188*icount/(nbfield*nbslice);
    3523         set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength])
    3524         drawnow
    3525         filename_ima=cell2mat(filecell(ifile,j));
    3526         filename_ima([end-3:end])=[];%remove .png extension
    3527         filename_ima_1=cell2mat(filecell_1(ifile,j));
    3528         filename_ima_1([end-3:end])=[];%remove .png extension
    3529         filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file
    3530         filename_cmx([end-1:end])=[ 'cm'];%name of cmx file
    3531         filename_cmx=[filename_cmx 'x'];
    3532         namelog=[filename_cmx([1:end-3]) 'log'];
    3533         if size(time,1)>=num2(ifile) &  size(time,2)>=num_b(j)
    3534             Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j)));
    3535             if isequal(Dt,'0')
    3536                 Dt='1' ;%case of 'displacement' mode
    3537             end
    3538             T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);
    3539         else
    3540             Dt='1';
    3541             T0='0';
    3542         end
    3543         term_a=num2stra(num_a(j),nom_type_nc);%UTILITE?
    3544         term_b=num2stra(num_b(j),nom_type_nc);%
    3545         if test_grid && ~isempty(nbslice_grid)
    3546             num1_grid=mod(num1(ifile)-1,nbslice_grid)+1;
    3547             gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    3548             if ~exist(gridname,'file')
    3549                 msgbox_uvmat('ERROR',['missing grid file ' gridname])
    3550                 return
    3551             end
    3552         end
    3553         test_mask=get(handles.get_mask_civ1,'Value');
    3554         if test_mask==0
    3555             maskname='noFile use default';
    3556             maskflag='n';
    3557         else
    3558             maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box
    3559             maskbase=[filebase '_' maskdispl];%
    3560             nbslice=str2num(maskdispl(1:end-4)); %
    3561             num1_mask=mod(num1(ifile)-1,nbslice)+1;
    3562             maskname=name_generator(maskbase,num1_mask,1,'.png','_i');
    3563             if exist(maskname,'file')
    3564                 maskflag='y';
    3565             else
    3566                 maskname='noFile use default';
    3567                 maskflag='n';
    3568             end
    3569         end
    3570         textcmx={'##############   CMX file';...
    3571             ['FirstImage ' filename_ima];...
    3572             ['LastImage  ' filename_ima_1];...
    3573             'XX' ;...
    3574             ['Mask ' maskflag] ;...
    3575             ['MaskName ' maskname];...
    3576             ['ImageSize ' npx ' ' npy];...   %VERIFIER CAS GENERAL ?
    3577             ['CorrelationBoxesSize ' ibx ' ' iby];...
    3578             ['SearchBoxeSize ' isx ' ' isy];...
    3579             ['RO ' rho];...
    3580             ['GridSpacing ' dx ' ' dy];...
    3581             'XX 1.0';...
    3582             ['Dt_TO ' Dt ' ' T0];...
    3583             ['PixCmXY ' pxcmx ' ' pxcmy];...
    3584             'XX 1';...
    3585             ['ShiftXY ' shiftx ' ' shifty];...
    3586             ['Grid ' gridflag];...
    3587             ['GridName ' gridname] ;...
    3588             'XX 85';...
    3589             'XX 1.0';...
    3590             'XX 1.0';...
    3591             'Hart 1';...
    3592             'DecimalShift 0';...
    3593             'Deformation 0';...
    3594             'CorrelationMin 0';...
    3595             'IntensityMin 0';...
    3596             ['SeuilImage ' threshflag];...
    3597             ['SeuilImageValues ' min_ima ' ' max_ima];...
    3598             ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ?
    3599             'ImageUsedBefore null null'};
    3600         textout=char(textcmx);
    3601         %               dlmwrite(filename_cmx,textout,'');
    3602         fid=fopen([filename_cmx],'w');
    3603         fprintf(fid, ['##############   CMX file' '\n']);
    3604         fprintf(fid,   ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]);
    3605         fprintf(fid,   ['LastImage  ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]);
    3606         fprintf(fid,  ['XX' '\n' ]);
    3607         fprintf(fid,  ['Mask '  maskflag '\n' ]);
    3608         fprintf(fid,  ['MaskName '  maskname '\n' ]);
    3609         fprintf(fid,   ['ImageSize '  npx ' '  npy '\n' ]);   %VERIFIER CAS GENERAL ?
    3610         fprintf(fid,   ['CorrelationBoxesSize '  ibx ' '  iby '\n' ]);
    3611         fprintf(fid,   ['SearchBoxeSize '  isx ' '  isy '\n' ]);
    3612         fprintf(fid,   ['RO '  rho '\n' ]);
    3613         fprintf(fid,   ['GridSpacing '  dx ' '  dy '\n' ]);
    3614         fprintf(fid,   ['XX 1.0' '\n' ]);
    3615         fprintf(fid,   ['Dt_TO '  Dt ' '  T0 '\n' ]);
    3616         fprintf(fid,  ['PixCmXY '  pxcmx ' '  pxcmy '\n' ]);
    3617         fprintf(fid,  ['XX 1' '\n' ]);
    3618         fprintf(fid,   ['ShiftXY '  shiftx ' '   shifty '\n' ]);
    3619         fprintf(fid,  ['Grid '  gridflag '\n' ]);
    3620         fprintf(fid,   ['GridName '  gridname '\n' ]);
    3621         fprintf(fid,   ['XX 85' '\n' ]);
    3622         fprintf(fid,   ['XX 1.0' '\n' ]);
    3623         fprintf(fid,   ['XX 1.0' '\n' ]);
    3624         fprintf(fid,   ['Hart 1' '\n' ]);
    3625         fprintf(fid,  [ 'DecimalShift 0' '\n' ]);
    3626         fprintf(fid,   ['Deformation 0' '\n' ]);
    3627         fprintf(fid,  ['CorrelationMin 0' '\n' ]);
    3628         fprintf(fid,   ['IntensityMin 0' '\n' ]);
    3629         fprintf(fid,  ['SeuilImage n' '\n' ]);
    3630         fprintf(fid,   ['SeuilImageValues 0 4096' '\n' ]);
    3631         fprintf(fid,   ['ImageToUse '  term_a ' '  term_b '\n' ]); % VERIFIER ?
    3632         fprintf(fid,   ['ImageUsedBefore null null' '\n' ]);
    3633         fclose(fid);
    3634        
    3635         s=-1;
    3636         display(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ])
    3637         eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]);
    3638         %               if sge%dispatch computation on the cluster using interactive queue
    3639         %           %  [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]);
    3640         %        end
    3641         %         if s~=0
    3642         %            %  ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]
    3643         %            % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]);
    3644         %         end
    3645     end
    3646 end
    3647 
    3648 % %------------------------------------------------------------------------
    3649 % % RUN CIV2   CIV2    CIV2   CIV2
    3650 % function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc)
    3651 % %------------------------------------------------------------------------
    3652 % %filecell_2: names of first image
    3653 % %filecell_3: names of second images
    3654 % global civ2Bin sge
    3655 %
    3656 % %names of the civ2 fields
    3657 % field.vel_type='civ2';
    3658 % field.nb='nb_vectors2';
    3659 % field.X='vec2_X';
    3660 % field.Y='vec2_Y';
    3661 % field.U='vec2_U';
    3662 % field.V='vec2_V';
    3663 %
    3664 % %get civ parameters
    3665 % ibx=get(handles.ibx_civ2,'String');
    3666 % iby=get(handles.iby_civ2,'String');
    3667 % rho=get(handles.rho_civ2,'String');
    3668 % decimal=int2str(get(handles.decimal,'Value'));
    3669 % deformation=int2str(get(handles.deformation,'Value'));
    3670 % dx=get(handles.dx_civ2,'String');
    3671 % dy=get(handles.dy_civ2,'String');
    3672 % if isequal(str2num(dx),[])
    3673 %     dx='20';%default
    3674 % end
    3675 % if isequal(str2num(dy),[])
    3676 %     dy='20';%default
    3677 % end
    3678 %     pxcmx='1';%velocity fields are expressed in pixel displacement
    3679 %     pxcmy='1';
    3680 % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size
    3681 % sizim=size(A);
    3682 % npx=num2str(sizim(2));
    3683 % npy=num2str(sizim(1));
    3684 % time=get(handles.RootName,'UserData'); %get the set of times
    3685 % filebase=get(handles.RootName,'String');
    3686 % %grid
    3687 % gridname='';%default  ='noFile use default'
    3688 % gridflag='n';%default
    3689 % test_grid=get(handles.browse_gridciv2,'Value');
    3690 % nbslice_grid=[];
    3691 % if test_grid
    3692 %     gridname=get(handles.grid_civ2,'String');
    3693 %     if numel(gridname)>4 && isequal(gridname(end-3:end),'grid')
    3694 %         nbslice_grid=str2num(gridname(1:end-4)); %
    3695 %         if ~isempty(nbslice_grid)
    3696 %             gridflag='y';
    3697 %         end
    3698 %     elseif exist(gridname,'file')
    3699 %         gridflag='y';
    3700 %     else
    3701 %         msgbox_uvmat('ERROR',['input grid file ' gridname ' not found'])
    3702 %         return
    3703 %     end
    3704 % end
    3705 % sizcell=size(filecell_2);
    3706 % nbfield=sizcell(1);
    3707 % nbslice=sizcell(2);
    3708 %
    3709 % %main loop
    3710 % icount=0;
    3711 % for ifile=1:nbfield
    3712 %     for j=1:nbslice
    3713 %         icount=icount+1;
    3714 %         barlength=0.188*icount/(nbfield*nbslice);
    3715 %         set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength])
    3716 %         drawnow
    3717 %         filename_ima_2=cell2mat(filecell_2(ifile,j));
    3718 %         filename_ima_2([end-3:end])=[];%remove .png extension
    3719 %         filename_ima_3=cell2mat(filecell_3(ifile,j));
    3720 %         filename_ima_3([end-3:end])=[];%remove .png extension
    3721 %         filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file
    3722 %         filename_cmx([end-1:end])=[ 'cm'];%name of cmx file
    3723 %         filename_cmx=[filename_cmx 'x'];
    3724 %         namelog=[filename_cmx([1:end-3]) 'log'];
    3725 %         if size(time,1)>=num2(ifile) &  size(time,2)>=num_b(j)
    3726 %             Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j)));
    3727 %             if isequal(Dt,'0')
    3728 %                 Dt='1' ;%case of 'displacement' mode
    3729 %             end
    3730 %             T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);
    3731 %         else
    3732 %             Dt='1';
    3733 %             T0='0';
    3734 %         end
    3735 %         term_a=num2stra(num_a(j),nom_type_nc);
    3736 %         term_b=num2stra(num_b(j),nom_type_nc);
    3737 %         filename_nc1=cell2mat(filecell_nc1(ifile,j));
    3738 %         filename_nc1([end-2:end])=[]; % remove '.nc'
    3739 %         if test_grid && ~isempty(nbslice_grid)
    3740 %             num1_grid=mod(num1(ifile)-1,nbslice_grid)+1;
    3741 %             gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    3742 %             if ~exist(gridname,'file')
    3743 %                 msgbox_uvmat('ERROR',['missing grid file ' gridname])
    3744 %                 return
    3745 %             end
    3746 %         end
    3747 %         test_mask=get(handles.get_mask_civ2,'Value');
    3748 %         if test_mask==0
    3749 %             maskname='noFile use default';
    3750 %             maskflag='n';
    3751 %         else
    3752 %             maskdispl=get(handles.mask_civ2,'String');
    3753 %             maskbase=[filebase '_' maskdispl]; %
    3754 %             nbslice_mask=str2num(maskdispl(1:end-4)); %
    3755 %             num1_mask=mod(num1(ifile)-1,nbslice_mask)+1;
    3756 %             maskname =name_generator(maskbase,num1_mask,1,'.png','_i');
    3757 %             if ~exist(maskname,'file')
    3758 %                 maskflag='y';
    3759 %             else
    3760 %                 maskname='noFile use default';
    3761 %                 maskflag='n';
    3762 %             end
    3763 %         end
    3764 %
    3765 %               textcmx={'##############   CMX file';...
    3766 %               ['FirstImage ' filename_ima_2];...
    3767 %               ['LastImage  ' filename_ima_3];...
    3768 %               'XX' ;...
    3769 %               ['Mask ' maskflag];...
    3770 %               ['MaskName ' maskname];...
    3771 %               ['ImageSize ' npx ' ' npy];...
    3772 %               ['CorrelationBoxesSize ' ibx ' ' iby];...
    3773 %               ['SearchBoxeSize ' ibx ' ' iby];...
    3774 %               ['RO ' rho];...
    3775 %               ['GridSpacing ' dx ' ' dy];...
    3776 %               'XX 1.0';...
    3777 %               ['Dt_TO ' Dt ' ' T0];...
    3778 %               ['PixCmXY ' pxcmx ' ' pxcmy];...
    3779 %               'XX 1';...
    3780 %               ['ShiftXY 0 0'];...
    3781 %               ['Grid ' gridflag];...
    3782 %               ['GridName ' gridname];...
    3783 %               'XX 85';...
    3784 %               'XX 1.0';...
    3785 %               'XX 1.0';...
    3786 %               'Hart 1';...
    3787 %               ['DecimalShift ' decimal];...
    3788 %               ['Deformation ' deformation];...
    3789 %               'CorrelationMin 0';...
    3790 %               'IntensityMin 0';...
    3791 %               'SeuilImage n';...
    3792 %               'SeuilImageValues 0 4096';...
    3793 %               ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ?
    3794 %               ['ImageUsedBefore ' filename_nc1]};
    3795 %         textout=char(textcmx);
    3796 %         dlmwrite(filename_cmx,textout,'');
    3797 %         s=-1;
    3798 %         display(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ])
    3799 %         eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]);
    3800 %
    3801 % %             if sge%dispatch computation on the cluster using interactive queue
    3802 % %             [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']);
    3803 % %         end
    3804 % %         if s~=0
    3805 % %             eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]);
    3806 % %             ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]
    3807 % %         end
    3808 %     end
    3809 % end
    3810 % % close(h)
    38113460
    38123461%------------------------------------------------------------------------
     
    47214370function par=read_param_civ1(handles,file_ima)
    47224371%------------------------------------------------------------------------
    4723 ibx_val=str2num(get(handles.ibx,'String'));
     4372ibx_val=str2double(get(handles.ibx,'String'));
    47244373par.ibx=num2str(ibx_val);
    4725 iby_val=str2num(get(handles.iby,'String'));
     4374iby_val=str2double(get(handles.iby,'String'));
    47264375par.iby=num2str(iby_val);
    47274376isx=get(handles.isx,'String');
    4728 if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default
    4729 if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end
     4377if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default
     4378if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end
    47304379isy=get(handles.isy,'String');
    4731 if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default
    4732 if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end
     4380if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default
     4381if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end
    47334382par.isx=get(handles.isx,'String');
    47344383par.isy=get(handles.isy,'String');
    47354384par.shiftx=get(handles.shiftx,'String');
    47364385par.shifty=get(handles.shifty,'String');
    4737 if isempty(str2num(par.isx))
     4386if isnan(str2double(par.isx))
    47384387    par.isx='41';%default
    47394388    set(handles.isx,'String','41');
    47404389end
    4741 if isempty(str2num(par.isy))
     4390if isnan(str2double(par.isy))
    47424391    par.isy='41'; %default
    47434392    set(handles.isy,'String','41');
    47444393end
    4745 if isempty(str2num(par.shiftx))
     4394if isnan(str2double(par.shiftx))
    47464395    par.shiftx='0';%default
    47474396    set(handles.shiftx,'String','0');
    47484397end
    4749 if isempty(str2num(par.shifty))
     4398if isnan(str2double(par.shifty))
    47504399    par.shifty='0'; %default
    47514400    set(handles.shifty,'String','0');
     
    47544403par.dx=get(handles.dx_civ1,'String');
    47554404par.dy=get(handles.dy_civ1,'String');
    4756 if isequal(str2num(par.dx),[])
     4405if isnan(str2double(par.dx))
    47574406    if isempty(get(handles.grid_civ1,'String'));
    47584407        par.dx='0'; %just read by civ program, not used
     
    47624411    end
    47634412end
    4764 if isequal(str2num(par.dy),[])
     4413if isnan(str2double(par.dy))
    47654414    if isempty(get(handles.grid_civ1,'String'));
    47664415        par.dy='0';%just read by civ program, not used
     
    47774426par.npx=num2str(sizim(2));
    47784427par.npy=num2str(sizim(1));
    4779 time=get(handles.RootName,'UserData'); %get the set of times
     4428%time=get(handles.RootName,'UserData'); %get the set of times
    47804429par.gridname=get(handles.grid_civ1,'String');
    47814430par.gridflag='y';
    4782 if isequal(par.gridname,'')| isempty(par.gridname)
     4431if strcmp(par.gridname,'')|| isempty(par.gridname)
    47834432    par.gridname='nogrid';
    47844433    par.gridflag='n';
     
    47954444par.dx=get(handles.dx_civ2,'String');
    47964445par.dy=get(handles.dy_civ2,'String');
    4797 if isequal(str2num(par.dx),[])
     4446if isnan(str2double(par.dx))
    47984447    if isempty(get(handles.grid_civ2,'String'));
    47994448        par.dx='0'; %just read by civ program, not used
     
    48034452    end
    48044453end
    4805 if isequal(str2num(par.dy),[])
     4454if isnan(str2double(par.dy))
    48064455    if isempty(get(handles.grid_civ2,'String'));
    48074456        par.dy='0';%just read by civ program, not used
     
    48174466par.npx=num2str(sizim(2));
    48184467par.npy=num2str(sizim(1));
    4819 time=get(handles.RootName,'UserData'); %get the set of times
     4468%time=get(handles.RootName,'UserData'); %get the set of times
    48204469par.gridname=get(handles.grid_civ2,'String');
    48214470par.gridflag='y';
    4822 if isequal(par.gridname,'')| isempty(par.gridname)
     4471if strcmp(par.gridname,'')|| isempty(par.gridname)
    48234472    par.gridname='nogrid';
    48244473    par.gridflag='n';
Note: See TracChangeset for help on using the changeset viewer.