Changeset 127 for trunk/src/civ.m
- Timestamp:
- Nov 19, 2010, 10:44:24 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r122 r127 453 453 filebase=get(handles.RootName,'String'); 454 454 ext=get(handles.ImaDoc,'String'); 455 browse=get(handles.browse_root,'UserData') ;%default455 browse=get(handles.browse_root,'UserData')%default 456 456 if isfield(browse,'nom_type_ima') 457 457 nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name … … 548 548 nbfield=size(time,1); 549 549 nbfield2=size(time,2); 550 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index550 %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml 551 551 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')) 553 553 time=time'; 554 554 nbfield=nbfield2; … … 2059 2059 %check the list of operations: 2060 2060 operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; 2061 run_flag=1;2061 % run_flag=1; 2062 2062 box_test(1)=get(handles.CIV1,'Value'); 2063 2063 box_test(2)=get(handles.FIX1,'Value'); … … 2121 2121 s=convert(t); 2122 2122 end 2123 2124 2123 test_interp=0; 2124 if batch 2125 2125 if isfield(s,'BatchParam') 2126 2126 sparam=s.BatchParam; … … 2167 2167 % end 2168 2168 if isfield(sparam,'FixBin') 2169 % fixBin=sparam.FixBin;2170 2169 if ~exist(sparam.FixBin,'file') 2171 2170 sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); … … 2218 2217 else 2219 2218 if isunix 2220 [ s,w]=unix('ps faux |grep civ|wc -l');2219 [xx,w]=unix('ps faux |grep civ|wc -l'); 2221 2220 w(end)=[]; 2222 if str2 num(w)+numel(num1_civ1)> MaxCivProcesses2221 if str2double(w)+numel(num1_civ1)> MaxCivProcesses 2223 2222 msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) 2224 2223 return … … 2241 2240 flagindex1(2)=get(handles.vec_F3, 'Value'); 2242 2241 flagindex1(3)=get(handles.vec_F2, 'Value'); 2243 thresh_vecC1=str2 num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C2244 thresh_vel1=str2 num(get(handles.thresh_vel,'String'));%threshold on velocity modulus2242 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 2245 2244 test_mask=get(handles.get_mask_fix1,'Value'); 2246 2245 nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) … … 2262 2261 %get patch1 parameters 2263 2262 if box_test(3)==1 2264 rho_patch1=str2 num(get(handles.rho_patch1,'String'));2265 if is empty(rho_patch1)2263 rho_patch1=str2double(get(handles.rho_patch1,'String')); 2264 if isnan(rho_patch1) 2266 2265 rho_patch1='1000'; 2267 2266 set(handles.rho_patch1,'String','1') … … 2271 2270 nx_patch1=get(handles.nx_patch1,'String'); 2272 2271 ny_patch1=get(handles.ny_patch1,'String'); 2273 if is equal(str2num(nx_patch1),[])2272 if isnan(str2double(nx_patch1)) 2274 2273 nx_patch1='50' ;%default 2275 2274 set(handles.nx_patch1,'String','50'); 2276 2275 end 2277 if is equal(str2num(ny_patch1),[])2276 if isnan(str2double(ny_patch1)) 2278 2277 ny_patch1='50' ;%default 2279 2278 set(handles.ny_patch1,'String','50'); … … 2293 2292 flagindex2(2)=get(handles.vec_F3_2, 'Value'); 2294 2293 flagindex2(3)=get(handles.vec_F4, 'Value'); 2295 thresh_vec2C=str2 num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C2296 thresh_vel2=str2 num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus2294 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 2297 2296 test_mask=get(handles.get_mask_fix2,'Value'); 2298 2297 nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) … … 2306 2305 %get patch2 parameters 2307 2306 if box_test(6)==1 2308 rho_patch2=str2 num(get(handles.rho_patch2,'String'));2309 if is empty(rho_patch2)2307 rho_patch2=str2double(get(handles.rho_patch2,'String')); 2308 if isnan(rho_patch2) 2310 2309 rho_patch2='1000'; 2311 2310 set(handles.rho_patch2,'String','1') … … 2315 2314 nx_patch2=get(handles.nx_patch2,'String'); 2316 2315 ny_patch2=get(handles.ny_patch2,'String'); 2317 if is equal(str2num(nx_patch2),[])2316 if isnan(str2double(nx_patch2)) 2318 2317 nx_patch2='50' ;%default 2319 2318 set(handles.nx_patch2,'String','50'); 2320 2319 end 2321 if is equal(str2num(ny_patch2),[])2320 if isnan(str2double(ny_patch2)) 2322 2321 ny_patch2='50' ;%default 2323 2322 set(handles.ny_patch2,'String','50'); … … 2330 2329 %MAIN LOOP 2331 2330 % for ifile=1:nbfield 2332 p1text=[];%initiate command text2331 % p1text=[];%initiate command text 2333 2332 time=get(handles.RootName,'UserData'); %get the set of times 2334 2333 civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method … … 2350 2349 end 2351 2350 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 2354 2352 2355 2353 %CIV1 … … 2513 2511 end 2514 2512 2515 if box_test(4)==1 | box_test(5)==1| box_test(6)==12513 if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 2516 2514 filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file 2517 filename_cmx([end-1:end ])=[ 'cm'];%name of cmx file2518 filename_cmx=[filename_cmx 'x'];2515 filename_cmx([end-1:end+1])=[ 'cmx'];%name of cmx file 2516 % filename_cmx=[filename_cmx 'x']; 2519 2517 end 2520 2518 … … 2798 2796 filebase_B=filebase;% root name of the second field series for stereo 2799 2797 if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') 2800 test_disp=1;2798 % test_disp=1; 2801 2799 nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series 2802 2800 [Path2,Name2]=fileparts(filebase_B); … … 2812 2810 filebase_AB=fullfile(Path2,[Name2 '-' Name1]); 2813 2811 else 2814 test_disp=0;2812 % test_disp=0; 2815 2813 filebase_A=filebase; 2816 2814 nom_type_ima1=nom_type_ima2; … … 2841 2839 last_j=str2num(get(handles.last_j,'String')); 2842 2840 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; 2845 2843 if isequal(mode,'displacement') 2846 2844 num_i1=num_i_ref; … … 2889 2887 ref=get(handles.ref_fix2,'UserData'); 2890 2888 if ~isempty(ref) 2891 first_i=str2 num(get(handles.first_i,'String'));2892 last_i=str2 num(get(handles.last_i,'String'));2893 incr_i=str2 num(get(handles.incr_i,'String'));2894 first_j=str2 num(get(handles.first_j,'String'));2895 last_j=str2 num(get(handles.last_j,'String'));2896 incr_j=str2 num(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')); 2897 2895 num_i_ref=[first_i:incr_i:last_i]; 2898 2896 num_j_ref=[first_j:incr_j:last_j]; … … 2951 2949 dircur=pwd; %current working directory 2952 2950 m2=''; 2953 [ erread,message]=fileattrib(Path_ima);2951 [xx,message]=fileattrib(Path_ima); 2954 2952 if ~isempty(message) && ~isequal(message.UserWrite,1) 2955 2953 msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) … … 2963 2961 if box_test(1)==1; 2964 2962 detect=1; 2963 vers=0; 2964 subdir_civ1_new=subdir_civ1; 2965 2965 while detect==1 %create a new subdir if the netcdf files already exist 2966 vers=0;2967 subdir_civ1_new=subdir_civ1;2968 2966 for ifile=1:nbfield 2969 2967 for j=1:nbslice … … 2971 2969 detect=exist(filename,'file')==2; 2972 2970 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 2975 2979 subdir_civ2=subdir_civ1; 2976 2980 break … … 2982 2986 end 2983 2987 end 2984 subdir_civ1=subdir_civ1_new;2985 2988 %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); 2988 2991 if ~isequal(m2,'') 2989 2992 msgbox_uvmat('ERROR', m2)%error message for directory creation … … 2994 2997 end 2995 2998 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; 2998 3001 for ifile=1:nbfield 2999 3002 for j=1:nbslice … … 3001 3004 detect=exist(filename,'file')==2; 3002 3005 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 3007 3016 end 3008 3017 filecell.ncA.civ1(ifile,j)={filename}; … … 3012 3021 end 3013 3022 end 3014 subdir_civ1=subdir_civ1_new;3023 % subdir_civ1=subdir_civ1_new; 3015 3024 %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); 3018 3027 if ~isequal(m2,'') 3019 3028 msgbox_uvmat('ERROR', m2) … … 3025 3034 end 3026 3035 end 3036 subdir_civ1=subdir_civ1_new; 3027 3037 % get image names 3028 3038 for ifile=1:nbfield … … 3114 3124 testdiff=0; 3115 3125 if (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)) 3117 3127 testdiff=1; 3118 3128 detect=1; 3129 vers=0; 3130 subdir_civ2_new=subdir_civ2; 3119 3131 while detect==1 %create a new subdir if the netcdf files already exist 3120 3132 for ifile=1:nbfield 3121 3133 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);% 3123 3135 detect=exist(filename,'file')==2; 3124 3136 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 3126 3145 break 3127 3146 end … … 3134 3153 %create the new subdir_civ2 3135 3154 if ~exist(fullfile(Path_ima,subdir_civ2),'dir') 3136 [ m1,m2,m3]=mkdir(subdir_civ2);3155 [xx,m2]=mkdir(subdir_civ2); 3137 3156 if ~isequal(m2,'') 3138 3157 msgbox_uvmat('ERROR', m2) … … 3143 3162 end 3144 3163 if strcmp(compare,'stereo PIV')%check second nc series 3145 vers=0;3146 subdir_civ2_new=subdir_civ2;3147 3164 for ifile=1:nbfield 3148 3165 for j=1:nbslice … … 3151 3168 detect=exist(filename,'file')==2; 3152 3169 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 3155 3178 break 3156 3179 end … … 3163 3186 subdir_civ2=subdir_civ2_new; 3164 3187 %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); 3167 3190 if ~isequal(m2,'') 3168 3191 msgbox_uvmat('ERROR', m2)%error message for directory creation … … 3174 3197 end 3175 3198 end 3199 subdir_civ2=subdir_civ2_new; 3176 3200 end 3177 3201 cd(currentdir);%come back to the current working directory … … 3303 3327 %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% 3304 3328 if 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) 3306 3330 for ifile=1:nbfield 3307 3331 for j=1:nbslice … … 3312 3336 end 3313 3337 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) 3315 3339 for ifile=1:nbfield 3316 3340 for j=1:nbslice … … 3434 3458 end 3435 3459 3436 %------------------------------------------------------------------------3437 %CIV1 CIV1 CIV1 CIV1 NOT USED: replaced by RUN_BATCH3438 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 uvmat3441 global civ1Bin sge%name of the executable for civ1 calculation3442 3443 %get civ parameters3444 ibx_val=str2num(get(handles.ibx,'String'));3445 if isempty(ibx_val)3446 ibx='21'; set(handles.ibx,'String','21')3447 else3448 ibx=num2str(ibx_val);3449 end3450 iby_val=str2num(get(handles.iby,'String'));3451 if isempty(iby_val)3452 iby='21'; set(handles.iby,'String','21')3453 else3454 iby=num2str(iby_val);3455 end3456 isx=get(handles.isx,'String');3457 if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default3458 if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end3459 isy=get(handles.isy,'String');3460 if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default3461 if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end3462 shiftx=get(handles.shiftx,'String');3463 if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default3464 shifty=get(handles.shifty,'String');3465 if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default3466 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%default3469 dy=get(handles.dy_civ1,'String');3470 if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default3471 if isequal(str2num(dy),[]), dy='20'; end%default3472 pxcmx='1'; %velocity fields are expressed in pixel displacement3473 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 return3480 end3481 A=imread(cell2mat(filecell(1,1)));%read the first image to get the size3482 sizim=size(A);3483 npx=num2str(sizim(2));3484 npy=num2str(sizim(1));3485 time=get(handles.RootName,'UserData'); %get the set of times3486 gridname='';%default ='noFile use default'3487 gridflag='n';%default3488 test_grid=get(handles.browse_gridciv1,'Value');3489 nbslice_grid=[];3490 if test_grid3491 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 end3497 elseif exist(gridname,'file')3498 gridflag='y';3499 else3500 msgbox_uvmat('ERROR',['input grid file ' gridname ' not found'])3501 return3502 end3503 end3504 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 else3509 threshflag='n';3510 min_ima='0';3511 max_ima='4096';3512 end3513 %main loop3514 filebase=get(handles.RootName,'String');3515 sizcell=size(filecell);3516 nbfield=sizcell(1);3517 nbslice=sizcell(2);3518 icount=0;3519 for ifile=1:nbfield3520 for j=1:nbslice3521 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 drawnow3525 filename_ima=cell2mat(filecell(ifile,j));3526 filename_ima([end-3:end])=[];%remove .png extension3527 filename_ima_1=cell2mat(filecell_1(ifile,j));3528 filename_ima_1([end-3:end])=[];%remove .png extension3529 filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file3530 filename_cmx([end-1:end])=[ 'cm'];%name of cmx file3531 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' mode3537 end3538 T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);3539 else3540 Dt='1';3541 T0='0';3542 end3543 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 return3551 end3552 end3553 test_mask=get(handles.get_mask_civ1,'Value');3554 if test_mask==03555 maskname='noFile use default';3556 maskflag='n';3557 else3558 maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box3559 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 else3566 maskname='noFile use default';3567 maskflag='n';3568 end3569 end3570 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 queue3639 % % [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]);3640 % end3641 % if s~=03642 % % ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]3643 % % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]);3644 % end3645 end3646 end3647 3648 % %------------------------------------------------------------------------3649 % % RUN CIV2 CIV2 CIV2 CIV23650 % 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 image3653 % %filecell_3: names of second images3654 % global civ2Bin sge3655 %3656 % %names of the civ2 fields3657 % 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 parameters3665 % 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';%default3674 % end3675 % if isequal(str2num(dy),[])3676 % dy='20';%default3677 % end3678 % pxcmx='1';%velocity fields are expressed in pixel displacement3679 % pxcmy='1';3680 % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size3681 % sizim=size(A);3682 % npx=num2str(sizim(2));3683 % npy=num2str(sizim(1));3684 % time=get(handles.RootName,'UserData'); %get the set of times3685 % filebase=get(handles.RootName,'String');3686 % %grid3687 % gridname='';%default ='noFile use default'3688 % gridflag='n';%default3689 % test_grid=get(handles.browse_gridciv2,'Value');3690 % nbslice_grid=[];3691 % if test_grid3692 % 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 % end3698 % elseif exist(gridname,'file')3699 % gridflag='y';3700 % else3701 % msgbox_uvmat('ERROR',['input grid file ' gridname ' not found'])3702 % return3703 % end3704 % end3705 % sizcell=size(filecell_2);3706 % nbfield=sizcell(1);3707 % nbslice=sizcell(2);3708 %3709 % %main loop3710 % icount=0;3711 % for ifile=1:nbfield3712 % for j=1:nbslice3713 % 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 % drawnow3717 % filename_ima_2=cell2mat(filecell_2(ifile,j));3718 % filename_ima_2([end-3:end])=[];%remove .png extension3719 % filename_ima_3=cell2mat(filecell_3(ifile,j));3720 % filename_ima_3([end-3:end])=[];%remove .png extension3721 % filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file3722 % filename_cmx([end-1:end])=[ 'cm'];%name of cmx file3723 % 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' mode3729 % end3730 % T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2);3731 % else3732 % Dt='1';3733 % T0='0';3734 % end3735 % 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 % return3745 % end3746 % end3747 % test_mask=get(handles.get_mask_civ2,'Value');3748 % if test_mask==03749 % maskname='noFile use default';3750 % maskflag='n';3751 % else3752 % 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 % else3760 % maskname='noFile use default';3761 % maskflag='n';3762 % end3763 % end3764 %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 queue3802 % % [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']);3803 % % end3804 % % if s~=03805 % % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]);3806 % % ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]3807 % % end3808 % end3809 % end3810 % % close(h)3811 3460 3812 3461 %------------------------------------------------------------------------ … … 4721 4370 function par=read_param_civ1(handles,file_ima) 4722 4371 %------------------------------------------------------------------------ 4723 ibx_val=str2 num(get(handles.ibx,'String'));4372 ibx_val=str2double(get(handles.ibx,'String')); 4724 4373 par.ibx=num2str(ibx_val); 4725 iby_val=str2 num(get(handles.iby,'String'));4374 iby_val=str2double(get(handles.iby,'String')); 4726 4375 par.iby=num2str(iby_val); 4727 4376 isx=get(handles.isx,'String'); 4728 if is empty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default4729 if str2 num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end4377 if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default 4378 if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end 4730 4379 isy=get(handles.isy,'String'); 4731 if is empty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default4732 if str2 num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end4380 if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default 4381 if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end 4733 4382 par.isx=get(handles.isx,'String'); 4734 4383 par.isy=get(handles.isy,'String'); 4735 4384 par.shiftx=get(handles.shiftx,'String'); 4736 4385 par.shifty=get(handles.shifty,'String'); 4737 if is empty(str2num(par.isx))4386 if isnan(str2double(par.isx)) 4738 4387 par.isx='41';%default 4739 4388 set(handles.isx,'String','41'); 4740 4389 end 4741 if is empty(str2num(par.isy))4390 if isnan(str2double(par.isy)) 4742 4391 par.isy='41'; %default 4743 4392 set(handles.isy,'String','41'); 4744 4393 end 4745 if is empty(str2num(par.shiftx))4394 if isnan(str2double(par.shiftx)) 4746 4395 par.shiftx='0';%default 4747 4396 set(handles.shiftx,'String','0'); 4748 4397 end 4749 if is empty(str2num(par.shifty))4398 if isnan(str2double(par.shifty)) 4750 4399 par.shifty='0'; %default 4751 4400 set(handles.shifty,'String','0'); … … 4754 4403 par.dx=get(handles.dx_civ1,'String'); 4755 4404 par.dy=get(handles.dy_civ1,'String'); 4756 if is equal(str2num(par.dx),[])4405 if isnan(str2double(par.dx)) 4757 4406 if isempty(get(handles.grid_civ1,'String')); 4758 4407 par.dx='0'; %just read by civ program, not used … … 4762 4411 end 4763 4412 end 4764 if is equal(str2num(par.dy),[])4413 if isnan(str2double(par.dy)) 4765 4414 if isempty(get(handles.grid_civ1,'String')); 4766 4415 par.dy='0';%just read by civ program, not used … … 4777 4426 par.npx=num2str(sizim(2)); 4778 4427 par.npy=num2str(sizim(1)); 4779 time=get(handles.RootName,'UserData'); %get the set of times4428 %time=get(handles.RootName,'UserData'); %get the set of times 4780 4429 par.gridname=get(handles.grid_civ1,'String'); 4781 4430 par.gridflag='y'; 4782 if isequal(par.gridname,'')| isempty(par.gridname)4431 if strcmp(par.gridname,'')|| isempty(par.gridname) 4783 4432 par.gridname='nogrid'; 4784 4433 par.gridflag='n'; … … 4795 4444 par.dx=get(handles.dx_civ2,'String'); 4796 4445 par.dy=get(handles.dy_civ2,'String'); 4797 if is equal(str2num(par.dx),[])4446 if isnan(str2double(par.dx)) 4798 4447 if isempty(get(handles.grid_civ2,'String')); 4799 4448 par.dx='0'; %just read by civ program, not used … … 4803 4452 end 4804 4453 end 4805 if is equal(str2num(par.dy),[])4454 if isnan(str2double(par.dy)) 4806 4455 if isempty(get(handles.grid_civ2,'String')); 4807 4456 par.dy='0';%just read by civ program, not used … … 4817 4466 par.npx=num2str(sizim(2)); 4818 4467 par.npy=num2str(sizim(1)); 4819 time=get(handles.RootName,'UserData'); %get the set of times4468 %time=get(handles.RootName,'UserData'); %get the set of times 4820 4469 par.gridname=get(handles.grid_civ2,'String'); 4821 4470 par.gridflag='y'; 4822 if isequal(par.gridname,'')| isempty(par.gridname)4471 if strcmp(par.gridname,'')|| isempty(par.gridname) 4823 4472 par.gridname='nogrid'; 4824 4473 par.gridflag='n';
Note: See TracChangeset
for help on using the changeset viewer.