Changeset 236
- Timestamp:
- Apr 12, 2011, 12:12:19 AM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field.m
r180 r236 34 34 % the scalar is calculated from other fields, as explicited below 35 35 36 %list_scal={title, type, civ1 var name,civ2 var name}37 36 list_field={'velocity';...%image correlation corresponding to a vel vector 38 37 'ima_cor';...%image correlation corresponding to a vel vector … … 54 53 end 55 54 if ischar(FieldName) 56 FieldName={FieldName}; 55 FieldName={FieldName};%convert a string input to a cell with one string element 57 56 end 58 57 if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X)) -
trunk/src/civ.m
r233 r236 819 819 else 820 820 mode_list=get(handles.mode,'String'); 821 if ischar(mode_list) 822 mode_list={mode_list}; 823 end 821 824 mode_value=get(handles.mode,'Value'); 822 825 mode=mode_list{mode_value}; … … 1426 1429 display(errormsg) 1427 1430 msgbox_uvmat('ERROR',errormsg) 1428 elseif isfield(handles,'status') && ~isequal(get(handles.CivAll,'Value'),3)1431 elseif isfield(handles,'status') %&& ~isequal(get(handles.CivAll,'Value'),3) 1429 1432 set(handles.status,'Value',1);%suppress status display 1430 1433 status_Callback(hObject, eventdata, handles) … … 4319 4322 PointCoord(:,1)=reshape(GridX,[],1); 4320 4323 PointCoord(:,2)=reshape(GridY,[],1); 4321 4322 4324 % caluclate velocity data (y and v in indices, reverse to y component) 4323 [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); 4324 Data.ListGlobalAttribute={'title','Time','Dt'}; 4325 Data.title='PIVlab'; 4325 [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); 4326 Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}]; 4327 Data.Conventions='uvmat/civdata'; 4328 Data.Program='civ_uvmat'; 4329 Data.CivStage=1; 4330 % list_param=fieldnames(Param.Civ1); 4331 % for ilist=1:length(list_param) 4332 % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';']) 4333 % end 4326 4334 Data.Time=str2double(par_civ1.T0); 4327 4335 Data.Dt=str2double(par_civ1.Dt); 4328 Data.ListVarName={' X','Y','U','V','C','FF'};% cell array containing the names of the fields to record4336 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record 4329 4337 Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; 4330 4338 Data.VarAttribute{1}.Role='coord_x'; … … 4332 4340 Data.VarAttribute{3}.Role='vector_x'; 4333 4341 Data.VarAttribute{4}.Role='vector_y'; 4334 Data.VarAttribute{5}.Role=' errorflag';4335 Data. X=reshape(xtable,[],1);4336 Data. Y=reshape(size(image1,1)-ytable+1,[],1);4337 Data. U=reshape(utable,[],1);4338 Data. V=reshape(-vtable,[],1);4339 Data.C =reshape(ctable,[],1);4340 Data. FF=reshape(~typevector,[],1);4342 Data.VarAttribute{5}.Role='warnflag'; 4343 Data.Civ1_X=reshape(xtable,[],1); 4344 Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1); 4345 Data.Civ1_U=reshape(utable,[],1); 4346 Data.Civ1_V=reshape(-vtable,[],1); 4347 Data.Civ1_C=reshape(ctable,[],1); 4348 Data.Civ1_F=reshape(F,[],1); 4341 4349 4342 4350 %------------------------------------------------------------------------ … … 4725 4733 ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field 4726 4734 ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field 4727 ViewData.axes3.X=Data. X; %keep the set of points in memeory4728 ViewData.axes3.Y=Data. Y;4735 ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory 4736 ViewData.axes3.Y=Data.Civ1_Y; 4729 4737 set(hview_field,'UserData',ViewData) 4730 4738 corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display -
trunk/src/find_field_indices.m
r187 r236 142 142 return 143 143 end 144 if numel(ivar_vector_x)>1 || numel(ivar_vector_y)>1 || numel(ivar_vector_z)>1 145 errormsg='multiply defined vector components in the same cell'; 146 return 147 end 144 % if ivar_vector_x>1 145 % ivar_vector_x=ivar_vector_x(1); 146 % end 147 % if ivar_vector_y>1 148 % ivar_vector_y=ivar_vector_y(1); 149 % end 150 % if ivar_vector_z>1 151 % ivar_vector_z=ivar_vector_z(1); 152 % end 148 153 if numel(ivar_errorflag)>1 149 154 errormsg='multiply defined error flag in the same cell'; -
trunk/src/get_field.m
r231 r236 240 240 set(handles.check_vector,'Value',1) 241 241 set(handles.check_scalar,'Value',0) 242 set(handles.vector_x,'Value',VarType{imax}.vector_x )243 set(handles.vector_y,'Value',VarType{imax}.vector_y )242 set(handles.vector_x,'Value',VarType{imax}.vector_x(1)) 243 set(handles.vector_y,'Value',VarType{imax}.vector_y(1)) 244 244 if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) 245 245 set(handles.coord_x_vectors,'Value',VarType{imax}.coord_x+1) -
trunk/src/griddata_uvmat.m
r147 r236 1 1 %'griddata_uvmat': function griddata_uvmat(vec2_X,vec2_Y,vec2_U,vec_X,vec_Y,'linear') 2 2 %adapt the input of the matlab function griddata to the appropriate version of Matlab 3 function ZI = griddata_uvmat(X,Y,Z,XI,YI) 4 txt=ver('MATLAB'); 5 Release=txt.Release; 6 relnumb=str2num(Release(3:4)); 7 if relnumb >= 20 8 ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'}); 9 elseif relnumb >=14 10 ZI=griddata(X,Y,Z,XI,YI,'linear',{'QJ'}); 11 else 12 ZI=griddata(X,Y,Z,XI,YI,'linear'); 3 function ZI = griddata_uvmat(X,Y,Z,XI,YI,rho) 4 if ~exist('rho','var')|| isequal(rho,0) 5 txt=ver('MATLAB'); 6 Release=txt.Release; 7 relnumb=str2num(Release(3:4)); 8 if relnumb >= 20 9 ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'}); 10 elseif relnumb >=14 11 ZI=griddata(X,Y,Z,XI,YI,'linear',{'QJ'}); 12 else 13 ZI=griddata(X,Y,Z,XI,YI,'linear'); 14 end 15 else %smooth with thin plate spline 16 [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho); 17 diff_norm=mean(Z_diff.*Z_diff) 18 ind_good=find(abs(Z_diff)<5*diff_norm); 19 nb_remove=numel(Z_diff)-numel(ind_good) 20 if nb_remove>0 21 X=X(ind_good); 22 Y=Y(ind_good); 23 Z=Z(ind_good); 24 [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho); 25 diff_norm_new=mean(Z_diff.*Z_diff) 26 end 13 27 end 14 -
trunk/src/nc2struct.m
r227 r236 107 107 end 108 108 try 109 if ischar(valuestr) & length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters109 if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters 110 110 % valuestr=regexprep(valuestr,{'\\','\/','\.','\-',' '},{'_','_','_','_','_'})%remove '\','.' or '-' if exists 111 111 eval(['Data.' keystr '=''' valuestr ''';']) -
trunk/src/pivlab.m
r233 r236 19 19 % mask: =[] for no mask 20 20 % roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[]; 21 function [xtable ytable utable vtable ctable typevectorresult_conv errormsg] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask)21 function [xtable ytable utable vtable ctable F result_conv errormsg] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask) 22 22 %this funtion performs the DCC PIV analysis. Recent window-deformation 23 23 %methods perform better and will maybe be implemented in the future. 24 errormsg='';25 warning off %MATLAB:log:logOfZero26 [npy_ima npx_ima]=size(image1);27 if ~isequal(size(image1),size(image2))28 errormsg='image pair with unequal size';29 return30 end31 xroi=0;32 yroi=0;33 image1_roi=double(image1);34 image2_roi=double(image2);35 if numel(mask)>036 cellmask=mask;37 mask=zeros(size(image1));38 for i=1:size(cellmask,1);39 masklayerx=cellmask{i,1};40 masklayery=cellmask{i,2};41 mask = mask + poly2mask(masklayerx-xroi,masklayery-yroi,npy_ima,npx_ima); %kleineres eingangsbild und maske geshiftet42 end43 else44 mask=zeros(size(image1));45 end46 mask(mask>1)=1;47 48 % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even49 % iby=2*iby2-1;50 % miniy=1+iby251 % minix=1+ibx252 % maxiy=step*(floor(size(image1_roi,1)/step))-(iby-1)+iby2 %statt size deltax von ROI nehmen53 % maxix=step*(floor(size(image1_roi,2)/step))-(ibx-1)+ibx254 % numelementsy=floor((maxiy-miniy)/step+1);55 % numelementsx=floor((maxix-minix)/step+1);56 %57 % LAy=miniy;58 % LAx=minix;59 % LUy=size(image1_roi,1)-maxiy;60 % LUx=size(image1_roi,2)-maxix;61 % shift4centery=round((LUy-LAy)/2);62 % shift4centerx=round((LUx-LAx)/2);63 % if shift4centery<0 %shift4center will be negative if in the unshifted case the left border is bigger than the right border. the vectormatrix is hence not centered on the image. the matrix cannot be shifted more towards the left border because then image2_crop would have a negative index. The only way to center the matrix would be to remove a column of vectors on the right side. but then we weould have less data....64 % shift4centery=0;65 % end66 % if shift4centerx<0 %shift4center will be negative if in the unshifted case the left border is bigger than the right border. the vectormatrix is hence not centered on the image. the matrix cannot be shifted more towards the left border because then image2_crop would have a negative index. The only way to center the matrix would be to remove a column of vectors on the right side. but then we weould have less data....67 % shift4centerx=0;68 % end69 % miniy=miniy+shift4centery;70 % minix=minix+shift4centerx;71 % maxix=maxix+shift4centerx;72 % maxiy=maxiy+shift4centery;73 74 image1_roi=padarray(image1_roi,[iby2 ibx2], min(min(image1_roi)));%add a border around the image with minimum image value75 image2_roi=padarray(image2_roi,[iby2 ibx2], min(min(image1_roi)));76 mask=padarray(mask,[iby2 ibx2],0);77 %SubPixOffset=0.5;%odd values chosen for ibx and iby78 79 24 nbvec=size(GridIndices,1); 80 25 xtable=zeros(nbvec,1); … … 82 27 utable=xtable; 83 28 vtable=xtable; 84 u2table=xtable; 85 v2table=xtable; 86 s2n=xtable; 87 typevector=ones(size(xtable)); 29 ctable=xtable; 30 F=xtable; 31 result_conv=[]; 32 errormsg=''; 33 %warning off %MATLAB:log:logOfZero 34 [npy_ima npx_ima]=size(image1); 35 if ~isequal(size(image2),[npy_ima npx_ima]) 36 errormsg='image pair with unequal size'; 37 return 38 end 88 39 89 nrx=0; 90 nrxreal=0; 91 nry=0; 92 increments=0; 40 %% mask 41 testmask=0; 42 if exist('mask','var') && ~isempty(mask) 43 testmask=1; 44 if ~isequal(size(mask),[npy_ima npx_ima]) 45 errormsg='mask must be an image with the same size as the images'; 46 return 47 end 48 % Convention for mask 49 % mask >200 : velocity calculated 50 % 200 >=mask>150;velocity not calculated, interpolation allowed (bad spots) 51 % 150>=mask >100: velocity not calculated, nor interpolated 52 % 100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries) 53 % 20>=mask: velocity=0 54 test_noflux=(mask<=100) ; 55 test_undefined=(mask<=200 & mask>100 ); 56 image1(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined area 57 image2(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined area 58 end 59 image1=double(image1); 60 image2=double(image2); 93 61 94 %% MAINLOOP 62 %% calculate correlations: MAINLOOP 63 corrmax=0; 64 sum_square=1;% default 95 65 for ivec=1:nbvec 96 66 iref=GridIndices(ivec,1); 97 67 jref=GridIndices(ivec,2); 98 %jref=npy_ima-PointCoord(ivec,2)+1; 99 image1_crop=image1_roi(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2); 100 image2_crop=image2_roi(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2); 101 image1_crop=image1_crop-mean(mean(image1_crop)); 102 image2_crop=image2_crop-mean(mean(image2_crop)); 103 if mask(jref,iref)==0 104 %reference: Oliver Pust, PIV: Direct Cross-Correlation 105 % image2_crop: sub image with the size of the search area in image 2 106 % image1_crop: sub image of the correlation box in image 1 107 % %image2_crop is bigger than image1_crop. Zeropading is therefore not 108 result_conv= conv2(image2_crop,rot90(image1_crop,2),'valid'); 109 %necessary. 'Valid' makes sure that no zero padded content is returned. 110 corrmax= max(max(result_conv)); 111 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 112 % result_conv=flipdim(result_conv,2);%reverse x direction 113 %Find the 255 peak 114 [y,x] = find(result_conv==255); 115 if isnan(y)==0 & isnan(x)==0 116 try 117 if subpixfinder==1 118 [vector] = SUBPIXGAUSS (result_conv,x,y); 119 elseif subpixfinder==2 120 [vector] = SUBPIX2DGAUSS (result_conv,x,y); 121 end 122 catch ME 123 errormsg=ME.message 124 vector=[0 0]; %if something goes wrong with cross correlation..... 68 testmask_ij=0; 69 test0=0; 70 if testmask 71 if mask(jref,iref)<=20 72 vector=[0 0]; 73 test0=1; 74 else 75 mask_crop1=mask(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2); 76 mask_crop2=mask(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2); 77 if ~isempty(find(mask_crop1<=200 & mask_crop1>100,1)) || ~isempty(find(mask_crop2<=200 & mask_crop2>100,1)); 78 testmask_ij=1; 79 end 80 end 81 end 82 if ~test0 83 image1_crop=image1(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2); 84 image2_crop=image2(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2); 85 image1_crop=image1_crop-mean(mean(image1_crop)); 86 image2_crop=image2_crop-mean(mean(image2_crop)); 87 %reference: Oliver Pust, PIV: Direct Cross-Correlation 88 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 89 corrmax= max(max(result_conv)); 90 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 91 %Find the correlation max, at 255 92 [y,x] = find(result_conv==255); 93 if ~isnan(y) & ~isnan(x) 94 try 95 if subpixfinder==1 96 [vector] = SUBPIXGAUSS (result_conv,x,y); 97 elseif subpixfinder==2 98 [vector] = SUBPIX2DGAUSS (result_conv,x,y); 125 99 end 126 else 100 sum_square=sum(sum(image1_crop.*image1_crop)); 101 ctable(ivec)=corrmax/sum_square;% correlation value 102 if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder 103 F(ivec)=-2;%vector reaches the border of the search zone 104 end 105 catch ME 127 106 vector=[0 0]; %if something goes wrong with cross correlation..... 107 F(ivec)=3; 128 108 end 129 else %if mask was not 0 then130 vector=[0 0]; 131 typevector(ivec)=0;109 else 110 vector=[0 0]; %if something goes wrong with cross correlation..... 111 F(ivec)=3; 132 112 end 133 134 %Create the vector matrix x, y, u, v 135 xtable(ivec)=GridIndices(ivec,1); 136 ytable(ivec)=GridIndices(ivec,2); 137 utable(ivec)=vector(1); 138 vtable(ivec)=vector(2); 139 sum_square=sum(sum(image1_crop.*image1_crop)); 140 ctable(ivec)=corrmax/sum_square; 113 if testmask_ij 114 F(ivec)=3; 115 end 116 end 117 118 %Create the vector matrix x, y, u, v 119 xtable(ivec)=iref+vector(1)/2;% convec flow (velocity taken at the point middle from imgae1 and 2) 120 ytable(ivec)=jref+vector(2)/2; 121 utable(ivec)=vector(1); 122 vtable(ivec)=vector(2); 141 123 end 142 result_conv=result_conv /255;124 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output 143 125 144 126 -
trunk/src/proj_field.m
r231 r236 1189 1189 end 1190 1190 elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid 1191 if isequal(ObjectData.ProjMode,'filter') 1192 rho=1000;%smoothing parameter, (small for strong smoothing) 1193 else 1194 rho=0; 1195 end 1191 1196 coord_x_proj=XMin:DX:XMax; 1192 1197 coord_y_proj=YMin:DY:YMax; … … 1225 1230 eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);']) 1226 1231 end 1227 eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'' );'])1232 eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'',rho);']) 1228 1233 eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));']) 1229 1234 FFlag= isnan(varline); %detect undefined values NaN … … 1394 1399 ProjData=FieldData;% no change by projection 1395 1400 else 1396 test_direct 1397 indY=NbDim-1 1401 indY=NbDim-1; 1398 1402 if test_direct(indY) 1399 1403 min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1; … … 1402 1406 Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1); 1403 1407 else 1404 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1 1405 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1 1406 Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1) 1407 Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1) 1408 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1; 1409 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1; 1410 Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1); 1411 Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1); 1408 1412 end 1409 1413 if test_direct(NbDim)==1 … … 1423 1427 if test90y 1424 1428 ind_new=[3 2 1]; 1425 DimCell={AYProjName,AXProjName} 1429 DimCell={AYProjName,AXProjName}; 1426 1430 % DimValue=DimValue(ind_new); 1427 1431 iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1; … … 1568 1572 ProjData 1569 1573 ProjData.VarDimName{3} 1574 1570 1575 %----------------------------------------------------------------- 1571 1576 %projection in a volume -
trunk/src/read_civxdata.m
r221 r236 47 47 % 'nc2struct': reads a netcdf file 48 48 49 function [Field,VelTypeOut]=read_civxdata(filename,FieldNames,VelType) 49 function [Field,VelTypeOut,errormsg]=read_civxdata(filename,FieldNames,VelType) 50 errormsg=''; 51 DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions'); 52 if isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format 53 [Field,VelTypeOut]=read_civdata(filename,FieldNames,VelType); 54 return 55 end 56 50 57 %% default input 51 58 if ~exist('VelType','var') … … 64 71 [Field,vardetect,ichoice]=nc2struct(filename,var);%read the variables in the netcdf file 65 72 if isfield(Field,'Txt') 73 errormsg=Field.Txt; 66 74 return 67 75 end 68 76 if vardetect(1)==0 69 Field.Txt=[ 'requested field not available in ' filename '/' VelType];77 errormsg=[ 'requested field not available in ' filename '/' VelType]; 70 78 return 71 79 end … … 117 125 Field.dt=double(Field.dt); 118 126 else 119 Field.Txt='the input file is not civx';127 errormsg='the input file is not civx'; 120 128 Field.CivStage=0; 121 129 Field.dt=0; … … 125 133 Field.dt=double(Field.dt2); 126 134 else 127 Field.Txt='the input file is not civx';135 errormsg='the input file is not civx'; 128 136 Field.CivStage=0; 129 137 Field.dt=0; -
trunk/src/read_field.m
r233 r236 36 36 if strcmp(FileType,'netcdf') %read the first nc field 37 37 ParamOut.FieldName=ParamIn.FieldName; 38 GUIName='get_field'; %default name of the GUI get ç_field38 GUIName='get_field'; %default name of the GUI get_field 39 39 if isfield(ParamIn,'GUIName') 40 40 GUIName=ParamIn.GUIName; … … 44 44 FieldList=calc_field;%list of possible fields for Civx data 45 45 ParamOut.ColorVar='';%default 46 field_index=strcmp(ParamOut.FieldName,FieldList);%look for ParamOut.FieldName in the list 47 if isempty(find(field_index,1))% ParamOut.FieldName is not in the list, check whether Civx data exist 48 Data=nc2struct(ObjectName,'ListGlobalAttribute','absolut_time_T0','civ'); 49 if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 46 field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 47 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 48 Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); 49 if isequal(Data.Conventions,'uvmat/civdata') 50 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 51 ParamOut.ColorVar='ima_cor'; 52 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 53 [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType); 54 test_civx=Field.CivStage; 55 elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 50 56 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 51 57 ParamOut.ColorVar='ima_cor'; … … 67 73 InputField=[InputField {ParamOut.ColorVar}]; 68 74 end 69 [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 75 [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 76 if ~isempty(errormsg) 77 return 78 end 70 79 test_civx=Field.CivStage; 71 80 ParamOut.CivStage=Field.CivStage; -
trunk/src/update_menu.m
r19 r236 13 13 menu_str=get(handle,'String'); 14 14 nbmenu=length(menu_str); 15 ichoice=0;%default 16 for imenu=1:nbmenu 17 if isequal(menu_str{imenu},strinput) 18 ichoice=imenu; 19 end 20 end 21 if ichoice==0%the input string does not exist in the menu 15 ichoice=find(strcmp(strinput,menu_str),1); 16 if isempty(ichoice)%the input string does not exist in the menu 22 17 menu_str{nbmenu+1}=menu_str{nbmenu};%shift the last item ('more...') 23 18 menu_str{nbmenu}=strinput; -
trunk/src/uvmat.m
r235 r236 50 50 % .MovieObject_1: idem for a second input series (_1) 51 51 % .filename_1 : last second input file name (to deal with a constant second input without reading again the file) 52 % .VelType_1: last velocity type ( civ1, civ2...) for the second input series52 % .VelType_1: last velocity type (VelType, civ2...) for the second input series 53 53 % .FieldName_1: last field name(velocity, vorticity...) for the second input series 54 54 % .ZMin, .ZMax: range of the z coordinate … … 387 387 end 388 388 end 389 389 390 set_vec_col_bar(handles) %update the display of color code for vectors 390 391 … … 518 519 return 519 520 end 520 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput); 521 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);%extract information from the file name 521 522 ext_test=''; %default 522 if ~isempty(ext) 523 if ~isempty(ext) % if a file extension is detected 523 524 form=imformats(ext(2:end));%test valid Matlab image formats 524 525 if ~isempty(form) … … 533 534 [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file 534 535 end 535 elseif isequal(lower(ext),'.avi') 536 elseif isequal(lower(ext),'.avi')%case of avi movie file 536 537 ext_test='.image'; 537 538 i1='1'; % set the frame counter to 1 by default … … 663 664 UvData.TestInputFile=1; 664 665 set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window 665 666 set(handles.FixVelType,'Value',0); %desactivate fixed veltype 666 667 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles); 667 668 if ~exist(FileName,'file') … … 873 874 if ~testima 874 875 testcivx=0; 875 % hget_field=findobj('Name','get_field');876 % if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')877 876 if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) 878 877 set(handles.Fields,'Value',1) … … 880 879 UvData=rmfield(UvData,'FieldsString'); 881 880 else 882 %if isempty(hget_field) 883 Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ'); 884 if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx 881 Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); 882 if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx 885 883 FieldList=calc_field; 886 884 set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data … … 890 888 testcivx=1; 891 889 end 892 % else893 % hhget_field=guidata(hget_field);894 % if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input895 % delete(hget_field)896 % end897 % end898 890 if ~testcivx 899 891 set(handles.Fields,'Value',1) % set menu to 'get_field... … … 902 894 end 903 895 set(handles.col_vec,'String',col_vec) 904 % else905 % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])906 % return907 % end908 896 end 909 897 end … … 1001 989 '*.dat','.dat text files ';... 1002 990 '*.*', 'All Files (*.*)'}, ... 1003 'Pick a file',RootPath);991 'Pick a second file for comparison',RootPath); 1004 992 fileinput_1=[PathName FileName];%complete file name 1005 % testblank=findstr(fileinput_1,' ');%look for blanks1006 % if ~isempty(testblank)1007 % msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])1008 % return1009 % end1010 993 sizf=size(fileinput_1); 1011 994 if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end … … 1181 1164 1182 1165 % % default choice of fields 1183 % if isequal(ext_test,'.image') 1184 % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'}) 1185 % % set(handles.Fields_1,'Value',2) % set menu to 'image' 1186 % elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf') 1187 % Data=nc2struct(fileinput_1,[]); 1188 % % if isfield(Data,'absolut_time_T0') 1189 % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'}) 1190 % % set(handles.Fields_1,'Value',4) % set menu to 'velocity' 1191 % % else 1192 % % set(handles.Fields_1,'Value',2) % set menu to 'get_field...' 1193 % % set(handles.Fields_1,'String',{'';'get_field...'}); 1194 % % end 1195 % end 1196 set(handles.SubField,'Visible','on') 1166 %set(handles.SubField,'Visible','on') 1197 1167 set(handles.SubField,'Value',1) 1198 1168 RootPath_1_Callback(hObject,eventdata,handles); … … 1230 1200 msgbox_uvmat('ERROR',['input file ' FileName ' not found']); 1231 1201 end 1202 set(handles.FixVelType,'Value',0); %desactivate fixed veltype 1232 1203 nbfield_1=[];%default 1233 1204 nburst_1=[];%default … … 2134 2105 FieldName= list_fields{index_fields}; % selected field 2135 2106 if ~strcmp(FieldName,'get_field...') 2136 VelType=setfield(handles);% read the velocity type. 2107 TestVelType=get(handles.FixVelType,'Value'); 2108 if TestVelType 2109 VelType=setfield(handles);% read the velocity type. 2110 end 2137 2111 end 2138 2112 if strcmp(FieldName,'velocity') … … 2177 2151 return 2178 2152 end 2153 2179 2154 if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') 2180 2155 set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface … … 2189 2164 end 2190 2165 2191 %% choose a second field if Subfield option is 'on', and if the field has changed2166 %% choose a second field filename_1 if defined 2192 2167 VelType_1=[];%default 2193 2168 FieldName_1=[]; … … 2201 2176 FieldName_1=[];%default 2202 2177 VelType_1=[];%default 2203 Ext_1=get(handles.FileExt_1,'String'); 2178 if strcmp(get(handles.FileExt_1,'Visible'),'on') 2179 Ext_1=get(handles.FileExt_1,'String'); 2180 else 2181 Ext_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file) 2182 end 2204 2183 NomType_1=get(handles.FileIndex_1,'UserData'); 2205 2184 if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf') … … 2220 2199 end 2221 2200 else 2201 if length(Ext_1)>=2 2222 2202 form=imformats(Ext_1(2:end)); 2223 2203 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab … … 2228 2208 end 2229 2209 end 2210 end 2230 2211 end 2231 2212 if strcmp(FileType_1,'netcdf') … … 2234 2215 FieldName_1= list_fields{index_fields}; % selected field 2235 2216 if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field... 2236 VelType_1=setfield_1(handles); 2217 VelType_1=''; 2218 if get(handles.FixVelType,'Value') 2219 VelTypeList=get(handles.VelType_1,'String'); 2220 index=get(handles.VelType_1,'Value'); 2221 VelType_1=VelTypeList{index}; 2222 end 2237 2223 end 2238 2224 if strcmp(VelType_1,'*')% free veltype choice … … 2269 2255 [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1); 2270 2256 if ~isempty(errormsg) 2271 errormsg=['error in reading ' filename_1 ': ' errormsg];2257 errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg]; 2272 2258 return 2273 2259 end … … 2286 2272 end 2287 2273 2288 %% update the display buttons for the first velocity type (first menuline) 2289 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 2274 %% update the display menu for the first velocity type (first menuline) 2275 % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 2276 % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') 2277 % set(veltype_handles,'Visible','off') 2278 % else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...') 2279 % set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field 2280 % if isempty(ParamOut.VelType) 2281 % reset_vel_type(veltype_handles) 2282 % else 2283 % handle1=eval(['handles.' ParamOut.VelType]); 2284 % reset_vel_type(veltype_handles,handle1) 2285 % end 2286 % end 2287 test_veltype=0; 2290 2288 if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') 2291 % reset_vel_type(veltype_handles) 2292 set(veltype_handles,'Visible','off') 2293 else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...') 2294 set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field 2295 if isempty(ParamOut.VelType) 2296 reset_vel_type(veltype_handles) 2297 else 2298 handle1=eval(['handles.' ParamOut.VelType]); 2299 reset_vel_type(veltype_handles,handle1) 2300 end 2289 set(handles.VelType,'Visible','off') 2290 else 2291 test_veltype=1; 2292 set(handles.VelType,'Visible','on') 2293 set(handles.VelType_1,'Visible','on') 2294 set(handles.FixVelType,'Visible','on') 2295 menu=set_veltype_display(ParamOut.CivStage); 2296 index_menu=strcmp(ParamOut.VelType,menu); 2297 set(handles.VelType,'Value',find(index_menu,1)) 2298 set(handles.VelType,'String',menu) 2299 % set(handles.VelType_1,'Value',1) 2300 % set(handles.VelType_1,'String',[{''};menu]) 2301 2301 end 2302 2302 field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); … … 2304 2304 set(handles.Fields,'Value',find(field_index,1)) 2305 2305 2306 %% update the display buttons for the second velocity type (second menuline) 2307 if ~isempty(filename_1) 2308 veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]; 2306 %% update the display menu for the second velocity type (second menuline) 2307 % if ~isempty(filename_1) 2308 % veltype_handles_1=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]; 2309 % if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...') 2310 % set(veltype_handles_1,'Visible','off') 2311 % %reset_vel_type(veltype_handles_1) 2312 % else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...') 2313 % set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field 2314 % if isempty(ParamOut_1.VelType) 2315 % reset_vel_type(veltype_handles_1) 2316 % else 2317 % handle1=eval(['handles.' ParamOut_1.VelType '_1']); 2318 % reset_vel_type(veltype_handles_1,handle1) 2319 % end 2320 % end 2321 % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2322 % set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu 2323 % set(handles.Fields_1,'Value',find(field_index,1)) 2324 % end 2325 test_veltype_1=0; 2326 if isempty(filename_1) 2327 set(handles.Fields_1,'Value',1); %update the field menu 2328 set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu 2329 else 2309 2330 if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...') 2310 set(veltype_handles_1,'Visible','off') 2311 %reset_vel_type(veltype_handles_1) 2312 else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...') 2313 set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field 2314 if isempty(ParamOut_1.VelType) 2315 reset_vel_type(veltype_handles_1) 2316 else 2317 handle1=eval(['handles.' ParamOut_1.VelType '_1']); 2318 reset_vel_type(veltype_handles_1,handle1) 2319 end 2320 end 2321 field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2322 set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu 2323 set(handles.Fields_1,'Value',find(field_index,1)) 2324 end 2325 2331 set(handles.VelType_1,'Visible','off') 2332 else 2333 test_veltype_1=1; 2334 set(handles.VelType_1,'Visible','on') 2335 if ~get(handles.FixVelType,'Value') 2336 menu=set_veltype_display(ParamOut_1.CivStage); 2337 index_menu=strcmp(ParamOut_1.VelType,menu); 2338 set(handles.VelType_1,'Value',1+find(index_menu,1)) 2339 set(handles.VelType_1,'String',[{''};menu]) 2340 end 2341 end 2342 end 2343 if test_veltype||test_veltype_1 2344 set(handles.FixVelType,'Visible','on') 2345 else 2346 set(handles.FixVelType,'Visible','off') 2347 end 2348 2326 2349 %% introduce w as background image by default for a new series (only for nbdim=2) 2327 2350 if ~isfield(UvData,'NewSeries') … … 2432 2455 NbDim=2; 2433 2456 end 2434 elseif VarType{imax}.coord(NbDim)>0 %structured coordinate2457 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate 2435 2458 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2436 2459 if NbDim>1 2437 2460 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2438 2461 end 2462 else 2463 errormsg='input field coordinates not defined'; 2464 return 2439 2465 end 2440 2466 if NbDim==3 … … 2568 2594 2569 2595 % main projection object (uvmat display) 2596 list_object=get(handles.list_object_1,'String'); 2597 if isequal(list_object,{''})%refresh list of objects if the menu is empty 2598 UvData.Object={[]}; 2599 set(handles.list_object_1,'Value',1) 2600 set(handles.list_object_2,'Value',1) 2601 set(handles.list_object_2,'String',{''}) 2602 set(handles.list_object_2,'Visible','off') 2603 end 2570 2604 IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view 2571 2605 if IndexObj(1)> numel(UvData.Object) … … 2874 2908 end 2875 2909 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 2876 test_civ1=isequal(get(handles. civ1,'BackgroundColor'),[1 1 0]);2910 test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); 2877 2911 if ~test_civ2 && ~test_civ1 2878 2912 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') … … 2925 2959 %determines the fields to read from the interface 2926 2960 %------------------------------------------------------------------ 2927 function [VelType,civ]=setfield(handles) 2928 2929 VelType=[]; %default 2930 if (get(handles.civ1,'Value') == 1); 2931 VelType='civ1'; 2932 % interp1 2933 elseif (get(handles.interp1,'Value') == 1); 2934 VelType='interp1'; 2935 % filter1 2936 elseif (get(handles.filter1,'Value') == 1); 2937 VelType='filter1'; 2938 % CIV2 2939 elseif (get(handles.civ2,'Value') == 1); 2940 VelType='civ2'; 2941 % interp2 2942 elseif (get(handles.interp2,'Value') == 1); 2943 VelType='interp2'; 2944 % filter2 2945 elseif (get(handles.filter2,'Value') == 1); 2946 VelType='filter2'; 2947 end 2948 2949 if isequal(get(handles.filter2,'Visible'),'on'); 2950 civ=6; 2951 % interp1 2952 elseif isequal(get(handles.interp2,'Visible'),'on'); 2953 civ=5; 2954 % filter1 2955 elseif isequal(get(handles.civ2,'Visible'),'on'); 2956 civ=4; 2957 % CIV2 2958 elseif isequal(get(handles.filter1,'Visible'),'on'); 2959 civ=3; 2960 % interp2 2961 elseif isequal(get(handles.interp1,'Visible'),'on'); 2962 civ=2; 2963 % filter2 2964 elseif isequal(get(handles.civ1,'Visible'),'on'); 2965 civ=1; 2966 else 2967 civ=0; 2968 end 2961 function VelType=setfield(handles) 2962 VelTypeList=get(handles.VelType,'String'); 2963 index=get(handles.VelType,'Value'); 2964 VelType=VelTypeList{index}; 2965 2966 % VelType=[]; %default 2967 % if (get(handles.VelType,'Value') == 1); 2968 % VelType='civ1'; 2969 % % interp1 2970 % elseif (get(handles.interp1,'Value') == 1); 2971 % VelType='interp1'; 2972 % % filter1 2973 % elseif (get(handles.filter1,'Value') == 1); 2974 % VelType='filter1'; 2975 % % CIV2 2976 % elseif (get(handles.civ2,'Value') == 1); 2977 % VelType='civ2'; 2978 % % interp2 2979 % elseif (get(handles.interp2,'Value') == 1); 2980 % VelType='interp2'; 2981 % % filter2 2982 % elseif (get(handles.filter2,'Value') == 1); 2983 % VelType='filter2'; 2984 % end 2985 % 2986 % if isequal(get(handles.filter2,'Visible'),'on'); 2987 % civ=6; 2988 % % interp1 2989 % elseif isequal(get(handles.interp2,'Visible'),'on'); 2990 % civ=5; 2991 % % filter1 2992 % elseif isequal(get(handles.civ2,'Visible'),'on'); 2993 % civ=4; 2994 % % CIV2 2995 % elseif isequal(get(handles.filter1,'Visible'),'on'); 2996 % civ=3; 2997 % % interp2 2998 % elseif isequal(get(handles.interp1,'Visible'),'on'); 2999 % civ=2; 3000 % % filter2 3001 % elseif isequal(get(handles.VelType,'Visible'),'on'); 3002 % civ=1; 3003 % else 3004 % civ=0; 3005 % end 2969 3006 2970 3007 %------------------------------------------------------------------- … … 2972 3009 %------------------------------------------------------------------ 2973 3010 function VelType=setfield_1(handles) 2974 2975 VelType=[]; %default 2976 if (get(handles.civ1_1,'Value') == 1); 2977 VelType='civ1'; 2978 % interp1 2979 elseif (get(handles.interp1_1,'Value') == 1); 2980 VelType='interp1'; 2981 % filter1 2982 elseif (get(handles.filter1_1,'Value') == 1); 2983 VelType='filter1'; 2984 % CIV2 2985 elseif (get(handles.civ2_1,'Value') == 1); 2986 VelType='civ2'; 2987 % interp2 2988 elseif (get(handles.interp2_1,'Value') == 1); 2989 VelType='interp2'; 2990 % filter2 2991 elseif (get(handles.filter2_1,'Value') == 1); 2992 VelType='filter2'; 2993 end 3011 VelTypeList=get(handles.VelType_1,'String'); 3012 index=get(handles.VelType_1,'Value'); 3013 VelType=VelTypeList{index}; 3014 % VelType=[]; %default 3015 % if (get(handles.VelType_1,'Value') == 1); 3016 % VelType='civ1'; 3017 % % interp1 3018 % elseif (get(handles.interp1_1,'Value') == 1); 3019 % VelType='interp1'; 3020 % % filter1 3021 % elseif (get(handles.filter1_1,'Value') == 1); 3022 % VelType='filter1'; 3023 % % CIV2 3024 % elseif (get(handles.civ2_1,'Value') == 1); 3025 % VelType='civ2'; 3026 % % interp2 3027 % elseif (get(handles.interp2_1,'Value') == 1); 3028 % VelType='interp2'; 3029 % % filter2 3030 % elseif (get(handles.filter2_1,'Value') == 1); 3031 % VelType='filter2'; 3032 % end 2994 3033 2995 3034 … … 2997 3036 % --- Executes on button press in SubField 2998 3037 function SubField_Callback(hObject, eventdata, handles) 2999 huvmat=get(handles.run0,'parent');3000 UvData=get(h uvmat,'UserData');3038 % huvmat=get(handles.run0,'parent'); 3039 UvData=get(handles.uvmat,'UserData'); 3001 3040 if get(handles.SubField,'Value')==0% if the subfield button is desactivated 3002 3041 set(handles.RootPath_1,'String','') … … 3011 3050 set(handles.FileExt_1,'Visible','off'); 3012 3051 set(handles.Fields_1,'Value',1);%set to blank state 3013 set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ... 3014 handles.civ2_1 handles.interp2_1 handles.filter2_1],0) 3052 set(handles.VelType_1,'Value',1);%set to blank state 3053 if ~strcmp(get(handles.VelType,'Visible'),'on') 3054 set(handles.VelType_1,'Visible','off') 3055 end 3056 % set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ... 3057 % handles.civ2_1 handles.interp2_1 handles.filter2_1],0) 3015 3058 if isfield(UvData,'XmlData_1') 3016 3059 UvData=rmfield(UvData,'XmlData_1'); 3017 3060 end 3018 set(h uvmat,'UserData',UvData);3061 set(handles.uvmat,'UserData',UvData); 3019 3062 run0_Callback(hObject, eventdata, handles); %run 3020 3063 else … … 3094 3137 field= list_fields{index_fields(1)}; % selected string 3095 3138 if isequal(field,'get_field...') 3096 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 3097 set_veltype_display(veltype_handles,0) % unvisible civ buttons 3139 set(handles.FixVelType,'visible','off') 3140 set(handles.VelType,'visible','off') 3141 set(handles.VelType_1,'visible','off') 3142 % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 3143 % set_veltype_display(veltype_handles,0) % unvisible civ buttons 3098 3144 filename=read_file_boxes(handles); 3099 3145 hget_field=findobj(allchild(0),'name','get_field'); … … 3152 3198 return 3153 3199 % end 3154 % veltype_handles=[handles. civ1handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];3200 % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 3155 3201 % set_veltype_display(veltype_handles,0) % unvisible civ buttons 3156 3202 else … … 3168 3214 % MenuBrowse_Callback(hObject, eventdata, handles) 3169 3215 end 3170 if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')3171 set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey3172 set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])3173 set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])3174 set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])3175 elseif isequal(field,'more...');3176 set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey3177 set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])3178 str=calc_field;%get the list of available scalars by the function calc_scal3179 [ind_answer] = listdlg('PromptString','Select a file:',...3180 'SelectionMode','single',...3181 'ListString',str);3182 % edit the choice in the field and action menu3183 scalar=cell2mat(str(ind_answer));3184 menu=update_menu(handles.Fields,scalar);3185 menu=[{''};menu];3186 set(handles.Fields_1,'String',menu);% store the selected scalar type3187 end3216 % if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain') 3217 % % set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey 3218 % % set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702]) 3219 % % set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702]) 3220 % % set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702]) 3221 % elseif isequal(field,'more...'); 3222 % set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey 3223 % set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702]) 3224 % str=calc_field;%get the list of available scalars by the function calc_scal 3225 % [ind_answer] = listdlg('PromptString','Select a file:',... 3226 % 'SelectionMode','single',... 3227 % 'ListString',str); 3228 % % edit the choice in the field and action menu 3229 % scalar=cell2mat(str(ind_answer)); 3230 % menu=update_menu(handles.Fields,scalar); 3231 % menu=[{''};menu]; 3232 % set(handles.Fields_1,'String',menu);% store the selected scalar type 3233 % end 3188 3234 end 3189 3235 indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),''); … … 3258 3304 3259 3305 if isequal(field_1,'get_field...') 3260 veltype_handles=[handles. civ1handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];3306 veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 3261 3307 set_veltype_display(veltype_handles,0) % unvisible civ buttons 3262 3308 filename=read_file_boxes_1(handles); … … 3276 3322 if isequal(field_1,'image') 3277 3323 % transform netc type to the corresponding image type 3278 % set(handles.FileExt_1,'String','.png');3279 3324 if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2') 3280 UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory 3281 % set(handles.SubDir_1,'String','') 3282 % set(handles.FileExt_1,'String','.png'); 3325 UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory 3283 3326 if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2') 3284 3327 NomTypeNew='_i_j'; … … 3305 3348 display_file_name_1(hObject, eventdata, handles,imagename)%display the image 3306 3349 return 3307 % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];3308 % set_veltype_display(veltype_handles,0) % unvisible civ buttons3309 3350 else 3310 3351 set(handles.SubDir_1,'Visible','on') 3311 3352 if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file 3312 veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];3313 set_veltype_display(veltype_handles,6); % make all civ buttons visible3353 % veltype_handles=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]; 3354 % set_veltype_display(veltype_handles,6); % make all civ buttons visible 3314 3355 RootPath_1=get(handles.RootPath_1,'String'); 3315 3356 RootFile_1=get(handles.RootFile_1,'String'); 3316 if isempty(RootPath_1)| isequal(RootPath_1,'')3357 if isempty(RootPath_1)||isequal(RootPath_1,'') 3317 3358 set(handles.RootPath_1,'String','"') 3318 3359 end 3319 if isempty(RootFile_1) | isequal(RootFile_1,'')3360 if isempty(RootFile_1) || isequal(RootFile_1,'') 3320 3361 set(handles.RootFile_1,'String','"') 3321 3362 end 3322 if ~isempty(RootFile_1)& (isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))3363 if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\')) 3323 3364 RootFile_1(1)=[]; 3324 3365 end … … 3357 3398 set(handles.SubDir_1,'String',SubDir_1); 3358 3399 end 3359 if isequal(field,'vort') | isequal(field,'div')| isequal(field,'strain')3360 set(handles. civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey3400 if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain') 3401 set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey 3361 3402 set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702]) 3362 3403 set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702]) 3363 3404 set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702]) 3364 3405 elseif isequal(field_1,'more...'); %add new item to the menu 3365 set(handles. civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey3406 set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey 3366 3407 set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702]) 3367 3408 str=calc_field;%get the list of available scalars by the function calc_scal … … 3384 3425 3385 3426 %common to Fields_Callback 3386 if isequal(field,'image')| isequal(field_1,'image')3427 if isequal(field,'image')||isequal(field_1,'image') 3387 3428 set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons 3388 3429 set(handles.npy_title,'Visible','on') … … 3397 3438 % set(handles.fix_pair,'Value',1) 3398 3439 end 3399 if isequal(field,'velocity')| isequal(field_1,'velocity');3440 if isequal(field,'velocity')||isequal(field_1,'velocity'); 3400 3441 state_vect='on'; 3401 3442 else 3402 3443 state_vect='off'; 3403 3444 end 3404 if ~isequal(field,'velocity')| (~isequal(field_1,'velocity')&~isequal(field_1,''));3445 if ~isequal(field,'velocity')||(~isequal(field_1,'velocity')&~isequal(field_1,'')); 3405 3446 state_scal='on'; 3406 3447 else … … 3415 3456 %------------------------------------------------------------------------ 3416 3457 % --- set the visibility of relevant velocity type menus: 3417 function set_veltype_display(handles,Civ) 3418 %------------------------------------------------------------------------ 3419 %Civ=0; all states 'off' 3420 %Civ=6; all states 'on' 3458 function menu=set_veltype_display(Civ) 3459 %------------------------------------------------------------------------ 3421 3460 if isequal(Civ,0) 3422 3461 imax=0; 3423 % set(handles(1),'Visible','on') % unvisible civ buttons3424 % else3425 % set(handles(1),'String','civ1')3426 % end3427 3462 elseif isequal(Civ,1) || isequal(Civ,2) 3428 3463 imax=1; … … 3434 3469 imax=6; 3435 3470 end 3436 for ibutton=1:imax; 3437 set(handles(ibutton),'Visible','on') % unvisible civ buttons 3438 end 3439 % for ibutton=max(imax+1,2):6; 3440 for ibutton=imax+1:6; 3441 set(handles(ibutton),'Visible','off') % unvisible civ buttons 3442 set(handles(ibutton),'Value',0)%unactivate unvisible buttons 3443 end 3444 3445 %------------------------------------------------------------------- 3446 % --- Executes on button press in civ1. 3447 function civ1_Callback(hObject, eventdata, handles) 3448 %------------------------------------------------------------------- 3449 if get(handles.civ1,'Value')==1 3450 reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1) 3451 else 3452 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2]) 3453 end 3471 menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; 3472 menu=menu(1:imax); 3473 % for ibutton=1:imax; 3474 % set(handles(ibutton),'Visible','on') % unvisible civ buttons 3475 % end 3476 % % for ibutton=max(imax+1,2):6; 3477 % for ibutton=imax+1:6; 3478 % set(handles(ibutton),'Visible','off') % unvisible civ buttons 3479 % set(handles(ibutton),'Value',0)%unactivate unvisible buttons 3480 % end 3481 3482 %------------------------------------------------------------------- 3483 % --- Executes on button press in VelType. 3484 function VelType_Callback(hObject, eventdata, handles) 3485 %------------------------------------------------------------------- 3486 % if get(handles.VelType,'Value')==1 3487 % reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.VelType) 3488 % else 3489 % reset_vel_type([handles.VelType handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2]) 3490 % end 3491 set(handles.FixVelType,'Value',1) 3454 3492 run0_Callback(hObject, eventdata, handles) 3455 3493 3456 %-------------------------------------------------------------------3457 % --- Executes on button press in interp1.3458 function interp1_Callback(hObject, eventdata, handles)3459 %-------------------------------------------------------------------3460 if get(handles.interp1,'Value')==13461 reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)3462 else3463 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])3464 end3465 run0_Callback(hObject, eventdata, handles)3466 3467 %-------------------------------------------------------------------3468 % --- Executes on button press in filter1.3469 function filter1_Callback(hObject, eventdata, handles)3470 %-------------------------------------------------------------------3471 if get(handles.filter1,'Value')==13472 reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)3473 else3474 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])3475 end3476 run0_Callback(hObject, eventdata, handles)3477 3478 %-------------------------------------------------------------------3479 % --- Executes on button press in civ2.3480 function civ2_Callback(hObject, eventdata, handles)3481 %-------------------------------------------------------------------3482 if get(handles.civ2,'Value')==13483 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)3484 else3485 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])3486 end3487 run0_Callback(hObject, eventdata, handles)3488 3489 %-----------------------------------------3490 % --- Executes on button press in interp2.3491 %-------------------------------------------3492 function interp2_Callback(hObject, eventdata, handles)3493 if get(handles.interp2,'Value')==13494 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)3495 else3496 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])3497 end3498 run0_Callback(hObject, eventdata, handles)3499 3494 %--------------------------------------------- 3500 % --- Executes on button press in filter2. 3501 %------------------------------------------- 3502 function filter2_Callback(hObject, eventdata, handles) 3503 if get(handles.filter2,'Value')==1 3504 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2) 3505 else 3506 reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2]) 3507 end 3508 run0_Callback(hObject, eventdata, handles) 3509 3495 function VelType_1_Callback(hObject, eventdata, handles) 3510 3496 %--------------------------------------------- 3511 function civ1_1_Callback(hObject, eventdata, handles) 3512 %--------------------------------------------- 3513 if get(handles.civ1_1,'Value')==1 3514 reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1) 3515 else 3516 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3517 end 3518 run0_Callback(hObject, eventdata, handles) 3519 3520 %-------------------------------------------- 3521 function interp1_1_Callback(hObject, eventdata, handles) 3522 %-------------------------------------------- 3523 if get(handles.interp1_1,'Value')==1 3524 reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1) 3525 else 3526 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3527 end 3528 run0_Callback(hObject, eventdata, handles) 3529 3530 %-------------------------------------------- 3531 function filter1_1_Callback(hObject, eventdata, handles) 3532 %-------------------------------------------- 3533 if get(handles.filter1_1,'Value')==1 3534 reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1) 3535 else 3536 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3537 end 3538 run0_Callback(hObject, eventdata, handles) 3539 3540 %-------------------------------------------- 3541 function civ2_1_Callback(hObject, eventdata, handles) 3542 %-------------------------------------------- 3543 if get(handles.civ2_1,'Value')==1 3544 reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1) 3545 else 3546 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3547 end 3548 run0_Callback(hObject, eventdata, handles) 3549 3550 %-------------------------------------------- 3551 function interp2_1_Callback(hObject, eventdata, handles) 3552 %-------------------------------------------- 3553 if get(handles.interp2_1,'Value')==1 3554 reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1) 3555 else 3556 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3557 end 3558 run0_Callback(hObject, eventdata, handles) 3559 3560 %-------------------------------------------- 3561 function filter2_1_Callback(hObject, eventdata, handles) 3562 %-------------------------------------------- 3563 if get(handles.filter2_1,'Value')==1 3564 reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1) 3565 else 3566 reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]) 3567 end 3568 run0_Callback(hObject, eventdata, handles) 3497 3498 set(handles.FixVelType,'Value',1) 3499 %refresh field with a second filename=first fiel name 3500 set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow 3501 drawnow 3502 filename=read_file_boxes(handles); 3503 if get(handles.SubField,'Value') 3504 filename_1=read_file_boxes_1(handles); 3505 else 3506 index=get(handles.VelType_1,'Value'); 3507 if index==1 3508 filename_1='';% we plot the current field without the second field 3509 else 3510 filename_1=filename; 3511 end 3512 end 3513 num_i1=stra2num(get(handles.i1,'String')); 3514 num_i2=stra2num(get(handles.i2,'String')); 3515 num_j1=stra2num(get(handles.j1,'String')); 3516 num_j2=stra2num(get(handles.j2,'String')); 3517 3518 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2); 3519 3520 if ~isempty(errormsg) 3521 msgbox_uvmat('ERROR',errormsg); 3522 else 3523 set(handles.i1,'BackgroundColor',[1 1 1]) 3524 set(handles.i2,'BackgroundColor',[1 1 1]) 3525 set(handles.j1,'BackgroundColor',[1 1 1]) 3526 set(handles.j2,'BackgroundColor',[1 1 1]) 3527 set(handles.FileIndex,'BackgroundColor',[1 1 1]) 3528 set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 3529 end 3530 set(handles.run0,'BackgroundColor',[1 0 0]) 3569 3531 3570 3532 %----------------------------------------------- … … 3641 3603 if isequal(get(handles.edit_vect,'Value'),1) 3642 3604 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 3643 test_civ1=isequal(get(handles. civ1,'BackgroundColor'),[1 1 0]);3605 test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); 3644 3606 if ~test_civ2 && ~test_civ1 3645 3607 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') … … 4776 4738 param.index_fields_1=param.index_fields_1-1; 4777 4739 end 4778 param.civ1=get(handles. civ1,'Value');4740 param.civ1=get(handles.VelType,'Value'); 4779 4741 param.civ2=get(handles.civ2,'Value'); 4780 4742 param.interp1=get(handles.interp1,'Value'); … … 5073 5035 end 5074 5036 5075 5037 % --- Executes on button press in FixVelType. 5038 function FixVelType_Callback(hObject, eventdata, handles) 5039 val=get(handles.FixVelType,'Value'); 5040 if ~val 5041 run0_Callback(hObject, eventdata, handles) 5042 end 5043 5044
Note: See TracChangeset
for help on using the changeset viewer.