Changeset 363
- Timestamp:
- Jan 10, 2012, 9:13:31 AM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r362 r363 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 0 8-Jan-2012 11:00:1325 % Last Modified by GUIDE v2.5 09-Jan-2012 20:42:45 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 619 619 ValueCiv1=1; 620 620 end 621 set(handles. txt_SubdirCiv1,'String',listdir{ValueCiv1})621 set(handles.SubdirCiv1,'String',listdir{ValueCiv1}) 622 622 ValueCiv2=get(handles.ListSubdirCiv2,'Value'); 623 623 if ValueCiv2>numel(listdir) 624 624 ValueCiv2=1; 625 625 end 626 set(handles. txt_SubdirCiv2,'String',listdir{ValueCiv2})626 set(handles.SubdirCiv2,'String',listdir{ValueCiv2}) 627 627 else 628 628 ValueCiv1=Value; 629 629 ValueCiv2=Value; 630 set(handles. txt_SubdirCiv1,'String',listdir{Value})631 set(handles. txt_SubdirCiv2,'String',listdir{Value})630 set(handles.SubdirCiv1,'String',listdir{Value}) 631 set(handles.SubdirCiv2,'String',listdir{Value}) 632 632 end 633 633 set(handles.ListSubdirCiv1,'Value',ValueCiv1) … … 636 636 set(handles.ListSubdirCiv2,'String',[listdir;'new...']) 637 637 if isempty(listdir) 638 set(handles. txt_SubdirCiv1,'String','CIV')639 set(handles. txt_SubdirCiv2,'String','CIV')638 set(handles.SubdirCiv1,'String','CIV') 639 set(handles.SubdirCiv2,'String','CIV') 640 640 end 641 641 … … 664 664 %------------------------------------------------------------------------ 665 665 % --- Executes on carriage return on the subdir checkciv1 edit window 666 function txt_SubdirCiv1_Callback(hObject, eventdata, handles)667 %------------------------------------------------------------------------ 668 SubDir=get(handles. txt_SubdirCiv1,'String');666 function SubdirCiv1_Callback(hObject, eventdata, handles) 667 %------------------------------------------------------------------------ 668 SubDir=get(handles.SubdirCiv1,'String'); 669 669 menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update 670 670 ichoice=find(strcmp(SubDir,menu_str),1); … … 676 676 set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu 677 677 if get(handles.CheckCiv1,'Value')% if Civ1 is performed 678 set(handles. txt_SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1678 set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 679 679 set(handles.ListSubdirCiv2,'Value',ilist) 680 680 else % if Civ1 data already exist … … 687 687 %------------------------------------------------------------------------ 688 688 % --- Executes on carriage return on the SubDir checkciv1 edit window 689 function txt_SubdirCiv2_Callback(hObject, eventdata, handles)690 %------------------------------------------------------------------------ 691 SubDir=get(handles. txt_SubdirCiv1,'String');689 function SubdirCiv2_Callback(hObject, eventdata, handles) 690 %------------------------------------------------------------------------ 691 SubDir=get(handles.SubdirCiv1,'String'); 692 692 menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update 693 693 ichoice=find(strcmp(SubDir,menu_str),1); … … 762 762 end 763 763 set(handles.PairIndices,'Visible','on') 764 set(handles. txt_SubdirCiv1,'Visible','on')764 set(handles.SubdirCiv1,'Visible','on') 765 765 set(handles.ListSubdirCiv1,'Visible','on') 766 766 if ~opening … … 773 773 set(handles.TitlePairCiv2,'Visible','on') 774 774 set(handles.TitleSubdirCiv2,'Visible','on') 775 set(handles. txt_SubdirCiv2,'Visible','on')775 set(handles.SubdirCiv2,'Visible','on') 776 776 set(handles.ListSubdirCiv2,'Visible','on') 777 777 set(handles.ListPairCiv2,'Visible','on') … … 784 784 else 785 785 set(handles.TitleSubdirCiv2,'Visible','off') 786 set(handles. txt_SubdirCiv2,'Visible','off')786 set(handles.SubdirCiv2,'Visible','off') 787 787 set(handles.ListSubdirCiv2,'Visible','off') 788 788 set(handles.ListPairCiv2,'Visible','off') … … 1692 1692 end 1693 1693 end 1694 Param=rmfield(Param,'status'); 1695 Param=rmfield(Param,'xml'); 1694 1696 t=struct2xml(Param); 1697 t=set(t,1,'Name','CivDoc');% set the head label 1695 1698 save(t,[namedoc '.xml']); %save GUI parameters as xml file 1696 1699 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) … … 1934 1937 1935 1938 %check dir 1936 subdir_civ1=get(handles. txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data1937 subdir_civ2=get(handles. txt_SubdirCiv2,'String');1939 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data 1940 subdir_civ2=get(handles.SubdirCiv2,'String'); 1938 1941 if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir 1939 1942 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir … … 1985 1988 end 1986 1989 1987 %create the new txt_SubdirCiv11990 %create the new SubdirCiv1 1988 1991 if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') 1989 1992 % cd(Path_ima); … … 2028 2031 end 2029 2032 end 2030 %create the new txt_SubdirCiv12033 %create the new SubdirCiv1 2031 2034 if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') 2032 2035 % cd(Path_ima); … … 2210 2213 end 2211 2214 subdir_civ2=subdir_civ2_new; 2212 %create the new txt_SubdirCiv12215 %create the new SubdirCiv1 2213 2216 if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') 2214 2217 [xx,m2]=mkdir(subdir_civ2_new); … … 2384 2387 end 2385 2388 end 2386 set(handles. txt_SubdirCiv1,'String',subdir_civ1);%update the edit box2387 set(handles. txt_SubdirCiv2,'String',subdir_civ2);%update the edit box2389 set(handles.SubdirCiv1,'String',subdir_civ1);%update the edit box 2390 set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box 2388 2391 browse.nom_type_nc=nom_type_nc; 2389 2392 set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat … … 2962 2965 2963 2966 %% reads .nc subdirectoy and image numbers from the interface 2964 subdir_civ1=get(handles. txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data2965 subdir_civ2=get(handles. txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data2967 subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 2968 subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 2966 2969 ref_i=str2double(get(handles.ref_i,'String')); 2967 2970 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') … … 3193 3196 % 3194 3197 % %reads .nc subdirectory and image numbers from the interface 3195 % subdir_civ1=get(handles. txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data3196 % subdir_civ2=get(handles. txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data3198 % subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data 3199 % subdir_civ2=get(handles.SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data 3197 3200 % ref_i=str2double(get(handles.ref_i,'String')); 3198 3201 % if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') … … 3611 3614 nbslice=1; 3612 3615 3613 % subdir=get(handles. txt_SubdirCiv1,'String');3616 % subdir=get(handles.SubdirCiv1,'String'); 3614 3617 [Path,Name]=fileparts(filebase); 3615 3618 if ~isdir(Path) … … 3707 3710 end 3708 3711 end 3709 set(handles. txt_SubdirCiv1,'String',SubDir);3712 set(handles.SubdirCiv1,'String',SubDir); 3710 3713 errormsg=find_netcpair_civ(handles,1); 3711 3714 if ~isempty(errormsg) … … 3728 3731 end 3729 3732 end 3730 set(handles. txt_SubdirCiv2,'String',SubDir);3733 set(handles.SubdirCiv2,'String',SubDir); 3731 3734 3732 3735 %------------------------------------------------------------------------ -
trunk/src/civ_matlab.m
r356 r363 77 77 for ilist=1:length(list_param) 78 78 Civ1_param{ilist}=['Civ1_' list_param{ilist}]; 79 % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])80 79 Data.(['Civ1_' list_param{ilist}])=Param.Civ1.(list_param{ilist}); 81 80 end 82 81 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];% {'Civ1_Time','Civ1_Dt'}]; 83 % if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)84 82 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record 85 83 Data.VarDimName={'NbVec1','NbVec1','NbVec1','NbVec1','NbVec1','NbVec1'}; … … 103 101 CivFile=Param.Patch1.CivFile; 104 102 end 105 Data=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0') %look for the constant 'absolut_time_T0' to detect old civx data format103 Data=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 106 104 if isfield(Data,'Txt') 107 105 errormsg=Data.Txt; … … 112 110 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 113 111 else 114 if isfield(Param,'Fix1') 115 Data=nc2struct(CivFile,ListVarCiv1);%read civ1 data in the existing netcdf file 116 else 117 Data=nc2struct(CivFile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file 118 end 112 Data=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 113 % if isfield(Param,'Fix1') 114 % Data=nc2struct(CivFile,ListVarCiv1);%read civ1 data in the existing netcdf file 115 % else 116 % Data=nc2struct(CivFile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file 117 % end 119 118 end 120 119 end … … 153 152 end 154 153 check_patch1=1; 155 Param.Patch1156 154 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}]; 157 155 Data.Patch1_Rho=Param.Patch1.SmoothingParam; … … 168 166 if isfield(Data,'Civ1_FF') 169 167 ind_good=find(Data.Civ1_FF==0); 170 else 171 168 else 172 169 ind_good=1:numel(Data.Civ1_X); 173 170 end … … 183 180 if isfield (Param,'Civ2') 184 181 par_civ2=Param.Civ2; 185 if ~check_civ1 || ~strcmp(par_civ1.filename_ima_a,par_civ2.filename_ima_a) 186 par_civ2.ImageA=imread(par_civ2.filename_ima_a);%read first image if not already done for civ1 187 end 188 if ~check_civ1|| ~strcmp(par_civ1.filename_ima_b,par_civ2.filename_ima_b) 189 par_civ2.ImageB=imread(par_civ2.filename_ima_b);%read second image if not already done for civ1 190 end 191 % stepx=str2double(par_civ2.dx); 192 % stepy=str2double(par_civ2.dy); 193 ibx2=ceil(str2double(par_civ2.ibx)/2); 194 iby2=ceil(str2double(par_civ2.iby)/2); 182 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA) 183 par_civ2.ImageA=imread(par_civ2.ImageA);%read first image if not already done for civ1 184 else 185 par_civ2.ImageA=Param.Civ1.ImageA; 186 end 187 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB) 188 par_civ2.ImageB=imread(par_civ2.ImageB);%read second image if not already done for civ1 189 else 190 par_civ2.ImageB=Param.Civ1.ImageB; 191 end 192 ibx2=ceil(par_civ2.Bx/2); 193 iby2=ceil(par_civ2.By/2); 195 194 isx2=ibx2+2; 196 195 isy2=iby2+2; 197 198 199 % Data.Civ1_U_Diff=zeros(size(Data.Civ1_X)); 200 % Data.Civ1_V_Diff=zeros(size(Data.Civ1_X)); 201 % if isfield(Data,'Civ1_FF') 202 % ind_good=find(Data.Civ1_FF==0); 203 % else 204 % ind_good=1:numel(Data.Civ1_X); 205 % end 206 % [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=... 207 % patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain); 208 % end 209 % shiftx=str2num(par_civ1.shiftx); 210 % shifty=str2num(par_civ1.shifty); 211 % TO GET shift from par_civ2.filename_nc1 212 % shiftx=velocity interpolated at position 213 miniy=max(1+isy2+shifty,1+iby2); 214 minix=max(1+isx2-shiftx,1+ibx2); 215 maxiy=min(size(par_civ2.ImageA,1)-isy2+shifty,size(par_civ2.ImageA,1)-iby2); 216 maxix=min(size(par_civ2.ImageA,2)-isx2-shiftx,size(par_civ2.ImageA,2)-ibx2); 196 % shift from par_civ2.filename_nc1 197 % shiftx=velocity interpolated at position 198 miniy=max(1+isy2,1+iby2); 199 minix=max(1+isx2,1+ibx2); 200 maxiy=min(size(par_civ2.ImageA,1)-isy2,size(par_civ2.ImageA,1)-iby2); 201 maxix=min(size(par_civ2.ImageA,2)-isx2,size(par_civ2.ImageA,2)-ibx2); 217 202 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 218 PointCoord(:,1)=reshape(GridX,[],1); 219 PointCoord(:,2)=reshape(GridY,[],1); 220 221 Guess = tps_eval(PointCoord,[Data.Civ1_X_tps Data.Civ1_Y_tps]) 222 Shiftx=Guess*Data.Civ1_U_tps; 223 Shifty=Guess*Data.Civ1_V_tps; 224 225 if ~isempty(par_civ2.maskname)&& ~strcmp(maskname,par_civ2.maskname)% mask exist, not already read in civ1 203 GridX=reshape(GridX,[],1); 204 GridY=reshape(GridY,[],1); 205 Shiftx=zeros(size(GridX));% shift expected from civ1 data 206 Shifty=zeros(size(GridX)); 207 nbval=zeros(size(GridX)); 208 if par_civ2.CheckDeformation 209 DUDX=zeros(size(GridX)); 210 DUDY=zeros(size(GridX)); 211 DVDX=zeros(size(GridX)); 212 DVDY=zeros(size(GridX)); 213 end 214 [NbSubDomain,xx]=size(Data.Civ1_X_SubRange); 215 % get the guess from patch1 216 for isub=1:NbSubDomain 217 nbvec_sub=Data.Civ1_NbSites(isub); 218 ind_sel=find(GridX>=Data.Civ1_X_SubRange(isub,1) & GridX<=Data.Civ1_X_SubRange(isub,2) & GridY>=Data.Civ1_Y_SubRange(isub,1) & GridY<=Data.Civ1_Y_SubRange(isub,2)); 219 epoints = [GridX(ind_sel) GridY(ind_sel)];% coordinates of interpolation sites 220 ctrs=[Data.Civ1_X_tps(1:nbvec_sub,isub) Data.Civ1_Y_tps(1:nbvec_sub,isub)];%(=initial points) ctrs 221 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap) 222 EM = tps_eval(epoints,ctrs); 223 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*Data.Civ1_U_tps(1:nbvec_sub+3,isub); 224 Shifty(ind_sel)=Shifty(ind_sel)+EM*Data.Civ1_V_tps(1:nbvec_sub+3,isub); 225 if par_civ2.CheckDeformation 226 [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs 227 DUDX(ind_sel)=DUDX(ind_sel)+EMDX*Data.Civ1_U_tps(1:nbvec_sub+3,isub); 228 DUDY(ind_sel)=DUDY(ind_sel)+EMDY*Data.Civ1_U_tps(1:nbvec_sub+3,isub); 229 DVDX(ind_sel)=DVDX(ind_sel)+EMDX*Data.Civ1_V_tps(1:nbvec_sub+3,isub); 230 DVDY(ind_sel)=DVDY(ind_sel)+EMDY*Data.Civ1_V_tps(1:nbvec_sub+3,isub); 231 end 232 end 233 mask=''; 234 if par_civ2.CheckMask&&~isempty(par_civ2.maskname)&& ~strcmp(maskname,par_civ2.maskname)% mask exist, not already read in civ1 226 235 mask=imread(par_civ2.maskname); 227 236 end 237 par_civ2.Searchx=2*isx2+1; 238 par_civ2.Searchy=2*isy2+1; 239 par_civ2.Shiftx=Shiftx./nbval; 240 par_civ2.Shifty=Shifty./nbval; 241 par_civ2.Grid=[GridX GridY]; 242 if par_civ2.CheckDeformation 243 DUDX=DUDX./nbval; 244 DUDY=DUDY./nbval; 245 DVDX=DVDX./nbval; 246 DVDY=DVDY./nbval; 247 end 228 248 % caluclate velocity data (y and v in indices, reverse to y component) 229 [xtable ytable utable vtable ctable F] = civ (par_civ2 .ImageA,par_civ1.ImageB,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask);230 list_param=(fieldnames( par_civ1))';249 [xtable ytable utable vtable ctable F] = civ (par_civ2); 250 list_param=(fieldnames(Param.Civ2))'; 231 251 list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'}; 232 index=zeros(size(list_param));233 252 for ilist=1:length(list_remove) 234 253 index=strcmp(list_remove{ilist},list_param); … … 238 257 end 239 258 for ilist=1:length(list_param) 240 Civ 1_param{ilist}=['Civ1_' list_param{ilist}];241 eval(['Data.Civ 1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])242 end 243 if isfield(Data,'Civ 1_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile')259 Civ2_param{ilist}=['Civ2_' list_param{ilist}]; 260 eval(['Data.Civ2_' list_param{ilist} '=Param.Civ2.' list_param{ilist} ';']) 261 end 262 if isfield(Data,'Civ2_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile') 244 263 Data.Civ1_gridname=''; 245 264 end 246 if isfield(Data,'Civ 1_maskname') && strcmp(Data.Civ1_maskname(1:6),'noFile')247 Data.Civ 1_maskname='';248 end 249 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ 1_param {'Civ1_Time','Civ1_Dt'}];250 Data.Civ 1_Time=str2double(par_civ1.T0);251 Data.Civ 1_Dt=str2double(par_civ1.Dt);252 Data.ListVarName= {'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record253 Data.VarDimName= {'NbVec1','NbVec1','NbVec1','NbVec1','NbVec1','NbVec1'};265 if isfield(Data,'Civ2_maskname') && strcmp(Data.Civ1_maskname(1:6),'noFile') 266 Data.Civ2_maskname=''; 267 end 268 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}]; 269 Data.Civ2_Time=str2double(par_civ2.Time); 270 Data.Civ2_Dt=str2double(par_civ2.Dt); 271 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_C','Civ2_F'}];% cell array containing the names of the fields to record 272 Data.VarDimName=[Data.VarDimName {'NbVec2','NbVec2','NbVec2','NbVec2','NbVec2','NbVec2'}]; 254 273 Data.VarAttribute{1}.Role='coord_x'; 255 274 Data.VarAttribute{2}.Role='coord_y'; … … 257 276 Data.VarAttribute{4}.Role='vector_y'; 258 277 Data.VarAttribute{5}.Role='warnflag'; 259 Data.Civ 1_X=reshape(xtable,[],1);260 Data.Civ 1_Y=reshape(size(par_civ2.ImageA,1)-ytable+1,[],1);261 Data.Civ 1_U=reshape(utable,[],1);262 Data.Civ 1_V=reshape(-vtable,[],1);263 Data.Civ 1_C=reshape(ctable,[],1);264 Data.Civ 1_F=reshape(F,[],1);278 Data.Civ2_X=reshape(xtable,[],1); 279 Data.Civ2_Y=reshape(size(par_civ2.ImageA,1)-ytable+1,[],1); 280 Data.Civ2_U=reshape(utable,[],1); 281 Data.Civ2_V=reshape(-vtable,[],1); 282 Data.Civ2_C=reshape(ctable,[],1); 283 Data.Civ2_F=reshape(F,[],1); 265 284 Data.CivStage=Data.CivStage+1; 266 285 end … … 361 380 if isfield(par_civ,'Grid') 362 381 if ischar(par_civ.Grid) 363 par_civ.Grid;364 382 par_civ.Grid=dlmread(par_civ.Grid); 365 383 par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) … … 370 388 isx2=ceil(par_civ.Searchx/2); 371 389 isy2=ceil(par_civ.Searchy/2); 372 shiftx=par_civ.Shiftx;373 shifty=-par_civ.Shifty;374 390 miniy=max(1+isy2+shifty,1+iby2); 375 391 minix=max(1+isx2-shiftx,1+ibx2); … … 380 396 par_civ.Grid(:,2)=reshape(GridY,[],1); 381 397 end 382 398 nbvec=size(par_civ.Grid,1); 399 if numel(shiftx)==1 400 shiftx=round(shiftx)*ones(nbvec,1); 401 shifty=round(shifty)*ones(nbvec,1); 402 end 383 403 %% Default output 384 nbvec=size(par_civ.Grid,1);385 404 xtable=par_civ.Grid(:,1); 386 405 ytable=par_civ.Grid(:,2); … … 462 481 % ytable(ivec)=jref;%default 463 482 if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask 464 if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth% we are outside the image 483 if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||... 484 jref+shifty(ivec)-isy2<1||jref+shifty(ivec)+isy2>par_civ.ImageHeight|| iref+shiftx(ivec)-isx2<1 || iref+shiftx(ivec)+isx2>par_civ.ImageWidth % we are outside the image 465 485 F(ivec)=3; 466 486 else 467 487 image1_crop=par_civ.ImageA(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);%extract a subimage (correlation box) from image A 468 image2_crop=par_civ.ImageB(jref+shifty -isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);%extract a larger subimage (search box) from image B488 image2_crop=par_civ.ImageB(jref+shifty(ivec)-isy2:jref+shifty(ivec)+isy2,iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2);%extract a larger subimage (search box) from image B 469 489 image1_mean=mean(mean(image1_crop)); 470 490 image2_mean=mean(mean(image2_crop)); … … 496 516 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 497 517 end 498 utable(ivec)=vector(1)+shiftx ;499 vtable(ivec)=vector(2)+shifty ;518 utable(ivec)=vector(1)+shiftx(ivec); 519 vtable(ivec)=vector(2)+shifty(ivec); 500 520 xtable(ivec)=iref+utable(ivec)/2;% convec flow (velocity taken at the point middle from imgae1 and 2) 501 521 ytable(ivec)=jref+vtable(ivec)/2; … … 509 529 ctable(ivec)=corrmax/sum_square;% correlation value 510 530 catch ME 511 % vector=[0 0]; %if something goes wrong with cross correlation.....512 531 F(ivec)=3; 513 532 end … … 619 638 function FF=fix(Param,F,C,U,V,X,Y) 620 639 FF=zeros(size(F));%default 621 Param622 640 623 641 %criterium on warn flags -
trunk/src/fill_GUI.m
r361 r363 17 17 else 18 18 hh=[]; 19 input_data=Param.(fields{ifield}); 19 20 if isfield(handles,fields{ifield}) 20 21 hh=handles.(fields{ifield}); 21 22 if strcmp(get(hh,'Type'),'uitable') 22 set(hh,'Data',input )23 set(hh,'Data',input_data) 23 24 break 24 25 end 25 elseif isnumeric(input ) && isfield(handles,['num_' fields{ifield}])26 elseif isnumeric(input_data) && isfield(handles,['num_' fields{ifield}]) 26 27 hh=handles.(['num_' fields{ifield}]); 27 28 end 28 29 if ~isempty(hh) 29 30 set(hh,'Visible','on') 31 get(hh,'style') 32 input_data 30 33 switch get(hh,'style') 31 case {'checkbox',' pushbutton','radiobutton','togglebutton'}32 if isnumeric(input )33 set(hh,'Value',input )34 case {'checkbox','radiobutton','togglebutton'} 35 if isnumeric(input_data) 36 set(hh,'Value',input_data) 34 37 end 35 38 case 'edit' 36 if isnumeric(input )37 input =num2str(input);39 if isnumeric(input_data) 40 input_data=num2str(input_data); 38 41 end 39 set(hh,'String',input )42 set(hh,'String',input_data) 40 43 case{'Listbox','popupmenu'} 41 if isnumeric(input )42 input =num2str(input);44 if isnumeric(input_data) 45 input_data=num2str(input_data); 43 46 end 44 47 menu=get(hh,'String'); 45 iline=find(strcmp(input ,menu));48 iline=find(strcmp(input_data,menu)); 46 49 if isempty(iline) 47 50 iline=numel(menu)+1; 48 set(hh,'String',[menu;{input }])51 set(hh,'String',[menu;{input_data}]) 49 52 end 50 53 set(hh,'Value',iline) -
trunk/src/get_field.m
r236 r363 1075 1075 Field=get(handles.get_field,'UserData'); 1076 1076 index=get(handles.variables,'Value');%index in the list 'variables' 1077 1078 %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected 1077 1079 if isequal(index,1) 1078 1080 set(handles.attributes_txt,'String','global attributes') 1079 % list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected1080 1081 if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) 1081 1082 for iline=1:length(Field.ListGlobalAttribute) … … 1092 1093 Tabchar=cell2tab(Tabcell,'='); 1093 1094 end 1095 %% list Attribute names and values associated to the Variable # index-1 1094 1096 else 1095 %list TimeAttribute names and values associated to the TimeVariable # injdex-11096 1097 list_var=get(handles.variables,'String'); 1097 1098 var_select=list_var{index}; … … 1122 1123 set(handles.attributes,'String',Tabchar); 1123 1124 1124 % update dimensions;1125 %% update dimensions; 1125 1126 if isfield(Field,'ListDimName') 1126 1127 Tabdim={};%default … … 1139 1140 dim_indices=[dim_indices dim_index]; 1140 1141 end 1141 %dim_indices=find(dim_list) %removes 0 values1142 1142 set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) 1143 1143 end -
trunk/src/read_GUI.m
r350 r363 16 16 check_input=1;%default 17 17 switch object_style 18 case {'checkbox',' pushbutton','radiobutton','togglebutton'}18 case {'checkbox','radiobutton','togglebutton'} 19 19 input=get(hchild(ichild),'Value'); 20 20 case 'edit' 21 separator=regexp(tag,' _');21 separator=regexp(tag,'^num_'); 22 22 if isempty(separator) 23 23 input=get(hchild(ichild),'String'); 24 24 else 25 switch(tag(1:separator)) 26 case 'num_' 27 input=str2double(get(hchild(ichild),'String')); 28 tag=tag(separator+1:end); 29 %deal with undefined input: retrieve the default value stored as UserData 30 if isnan(input) 31 input=get(hchild(ichild),'UserData'); 32 set(hchild(ichild),'String',num2str(input)) 33 end 34 case 'txt_' 35 input=get(hchild(ichild),'String'); 36 tag=tag(separator+1:end); 37 otherwise 38 input=get(hchild(ichild),'String'); 25 input=str2double(get(hchild(ichild),'String')); 26 tag=regexprep(tag,'^num_',''); 27 %deal with undefined input: retrieve the default value stored as UserData 28 if isnan(input) 29 input=get(hchild(ichild),'UserData'); 30 set(hchild(ichild),'String',num2str(input)) 39 31 end 40 end 41 42 % key=tag(7:end); 43 case{'Listbox','popupmenu'} 32 end 33 case{'listbox','popupmenu'} 44 34 listinput=get(hchild(ichild),'String'); 45 35 value=get(hchild(ichild),'Value'); 46 36 if ~isempty(listinput) 47 input=listinput(value); 37 input=listinput{value}; 38 else 39 check_input=0; 48 40 end 49 separator=regexp(tag,' _');50 if strcmp(tag(1:separator),'num_')41 separator=regexp(tag,'^num_'); 42 if ~isempty(separator) 51 43 input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_' 52 tag= tag(separator+1:end);44 tag=regexprep(tag,'^num_',''); 53 45 end 54 46 otherwise … … 57 49 if check_input 58 50 struct.(tag)=input; 59 % eval(['struct.' tag '=input;'])60 51 end 61 52 case 'uitable' 62 53 struct.(tag)=get(hchild(ichild),'Data'); 63 54 end 64 55 end
Note: See TracChangeset
for help on using the changeset viewer.