- Timestamp:
- Jan 9, 2011, 12:56:28 PM (14 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r178 r179 4623 4623 box_test(4)=get(handles.CIV2,'Value'); 4624 4624 box_test(5)=get(handles.FIX2,'Value'); 4625 box_test(6)=get(handles.PATCH2,'Value'); 4626 option=listtype{max(box_test(find(box_test)))}; 4625 box_test(6)=get(handles.PATCH2,'Value') 4626 find(box_test) 4627 option_civ=max(find(box_test)) 4627 4628 filecell=get(handles.civ,'UserData'); 4628 4629 if ~isfield(filecell,'nc') … … 4655 4656 for ifile=1:nbfiles 4656 4657 detect=exist(civ_files{ifile},'file'); % check the existence of the file 4658 option=0; 4657 4659 if detect==0 4658 lastfield='not created';4660 option_str='not created'; 4659 4661 else 4660 4662 datfile=dir(civ_files{ifile}); … … 4665 4667 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); 4666 4668 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 4667 lastfield='patch2'; 4669 option=6; 4670 option_str='patch2'; 4668 4671 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 4669 lastfield='fix2'; 4672 option=5; 4673 option_str='fix2'; 4670 4674 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 4671 lastfield='civ2'; 4675 option=4; 4676 option_str='civ2'; 4672 4677 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 4673 lastfield='patch1'; 4678 option=3; 4679 option_str='patch1'; 4674 4680 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 4675 lastfield='fix1'; 4681 option=2; 4682 option_str='fix1'; 4676 4683 else 4677 lastfield='civ1'; 4678 end 4679 end 4680 if strcmp(lastfield,option) 4684 option=1; 4685 option_str='civ1'; 4686 end 4687 end 4688 if option >= option_civ 4681 4689 count=count+1; 4682 4690 end 4683 4691 [rr,filename,ext]=fileparts(civ_files{ifile}); 4684 Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' lastfield];4692 Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; 4685 4693 end 4686 4694 if isempty(datnum) -
trunk/src/get_field.m
r150 r179 796 796 function RUN_Callback(hObject, eventdata, handles) 797 797 %--------------------------------------------------------- 798 figstring=get(handles.list_fig,'String'); 799 if isequal(figstring,{'uvmat'}) 798 figcell=get(handles.list_fig,'String'); 799 index=get(handles.list_fig,'value'); 800 figstring=figcell{index}; 801 if isequal(figstring,'uvmat') 800 802 huvmat=findobj(allchild(0),'tag','uvmat'); 801 803 hhuvmat=guidata(huvmat); 802 uvmat('run0_Callback',hObject,eventdata,hhuvmat); % file input with xml reading in uvmat, show the image in phys coordinates804 uvmat('run0_Callback',hObject,eventdata,hhuvmat); % display field in uvmat 803 805 else 806 huvmat=findobj(allchild(0),'tag','uvmat'); 807 delete(huvmat)% 804 808 index=get(handles.ACTION,'Value'); 805 809 list_func=get(handles.ACTION,'UserData'); -
trunk/src/plot_field.m
r156 r179 164 164 end 165 165 166 % check the cells of fields : 167 % testnbdim=1; 166 %% check the cells of fields : 168 167 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 169 168 169 %% plot if the input field is valid 170 170 if ~isempty(errormsg) 171 msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]) 172 display(['input of plot_field: ' errormsg]) 173 return 174 end 175 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot 176 [Data.NbDim]=max(NbDim); 177 end 178 errormsg=[]; 179 if isequal(Data.NbDim,0) 180 AxeData=plot_text(Data,htext); 181 PlotType='text'; 171 errormsg=['input of plot_field/find_field_indices: ' errormsg]; 172 else 173 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot 174 [Data.NbDim]=max(NbDim); 175 end 176 if isequal(Data.NbDim,0) 177 AxeData=plot_text(Data,htext); 178 PlotType='text'; 179 errormsg=[]; 180 elseif isequal(Data.NbDim,1) 181 [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 182 if testzoomaxes 183 [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam); 184 AxeData.ZoomAxes=zoomaxes; 185 end 186 PlotType='line'; 182 187 errormsg=[]; 183 elseif isequal(Data.NbDim,1) 184 [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 185 if testzoomaxes 186 [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam); 187 AxeData.ZoomAxes=zoomaxes; 188 end 189 PlotType='line'; 190 errormsg=[]; 191 elseif isequal(Data.NbDim,2) 192 ind_select=find(NbDim>=2); 193 if numel(ind_select)>2 194 errormsg='more than two fields to map'; 195 else 196 [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar); 197 if testzoomaxes && isempty(errormsg) 198 [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar); 199 Data.ZoomAxes=zoomaxes; 200 end 201 end 202 elseif isequal(Data.NbDim,3) 203 errormsg='volume plot not implemented yet'; 204 end 205 if ~isempty(errormsg) 206 msgbox_uvmat('ERROR','volume plot not implemented yet') 207 return 208 end 209 210 %display (or delete) error message 211 htext=findobj(haxes,'Tag','hTxt'); 212 if isfield(Data,'Txt') 213 if isempty(htext) 214 Xlim=get(haxes,'XLim'); 215 Ylim=get(haxes,'YLim'); 216 htext=text(Xlim(1),(Ylim(1)+Ylim(2))/2,Data.Txt,'Tag','hTxt','Color','r'); 217 set(htext,'Interpreter','none') 218 else 219 set(htext,'String',Data.Txt) 220 end 221 elseif ~isempty(htext) 222 delete(htext) 223 end 224 225 % % set graph aspect ratio 226 % if isfield(AxeData,'Mesh') 227 % Data.Mesh=AxeData.Mesh; 228 % end 229 230 %set(haxes,'UserData',AxeData) 231 set(haxes,'UserData',Data) 232 % if ~testnewfig 233 % %set(0,'Children',hstack);%put back the initial figure stack after plot creation 234 % 235 % end 188 elseif isequal(Data.NbDim,2) 189 ind_select=find(NbDim>=2); 190 if numel(ind_select)>2 191 errormsg='more than two fields to map'; 192 else 193 [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar); 194 if testzoomaxes && isempty(errormsg) 195 [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar); 196 Data.ZoomAxes=zoomaxes; 197 end 198 end 199 elseif isequal(Data.NbDim,3) 200 errormsg='volume plot not implemented yet'; 201 end 202 end 203 204 if isempty(errormsg) 205 set(haxes,'UserData',Data) 206 else 207 msgbox_uvmat('ERROR', errormsg) 208 end 236 209 237 210 -
trunk/src/proj_field.m
r174 r179 40 40 % Role = 'scalar': (default) represents a scalar field 41 41 % = 'coord': represents a set of unstructured coordinates, whose 42 % space dimension is given by the last array dimension (called ' nb_dim').42 % space dimension is given by the last array dimension (called 'NbDim'). 43 43 % = 'coord_x', 'coord_y', 'coord_z': represents a separate set of 44 44 % unstructured coordinate x, y or z 45 45 % = 'vector': represents a vector field whose number of components 46 % is given by the last dimension (called ' nb_dim')46 % is given by the last dimension (called 'NbDim') 47 47 % = 'vector_x', 'vector_y', 'vector_z' :represents the x, y or z component of a vector 48 48 % = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning … … 100 100 end 101 101 102 % OBSOLETE102 %% OBSOLETE 103 103 if isfield(ObjectData,'XMax') && ~isempty(ObjectData.XMax) 104 104 ObjectData.RangeX(1)=ObjectData.XMax; … … 120 120 end 121 121 %%%%%%%%%% 122 123 %% apply projection depending on the object style 122 124 switch ObjectData.Style 123 125 case 'points' … … 131 133 [ProjData,errormsg] = proj_line(FieldData,ObjectData); 132 134 end 133 %A FAIRE : GERER MASK134 135 case 'plane' 135 % if isfield(FieldData,'NbDim') & isequal(FieldData.NbDim,3)136 % ProjData= proj_plane3D(FieldData,ObjectData);%137 % else138 136 [ProjData,errormsg] = proj_plane(FieldData,ObjectData); 139 % end140 137 case 'volume' 141 138 [ProjData,errormsg] = proj_volume(FieldData,ObjectData); … … 300 297 %DimIndices(ind_1)=[]; %suppress singleton dimensions 301 298 % indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero) 302 % nb_dim=length(DimIndices)%number of space dimensions303 nb_dim=numel(VarType.coord);299 %NbDim=length(DimIndices)%number of space dimensions 300 NbDim=numel(VarType.coord); 304 301 Coord_z=[]; 305 302 Coord_y=[]; 306 303 Coord_x=[]; 307 for idim=1: nb_dim %loop on space dimensions304 for idim=1:NbDim %loop on space dimensions 308 305 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default 309 306 test_coord(idim)=0;%test for defined coordinates, =0 by default … … 1005 1002 %----------------------------------------------------------------- 1006 1003 idimvar=0; 1007 [CellVarIndex,NbDim ,VarTypeCell,errormsg]=find_field_indices(FieldData);1004 [CellVarIndex,NbDimVec,VarTypeCell,errormsg]=find_field_indices(FieldData); 1008 1005 if ~isempty(errormsg) 1009 1006 errormsg=['error in proj_field/proj_plane:' errormsg]; … … 1016 1013 icoord=0; 1017 1014 nbcoord=0;%number of added coordinate variables brought by projection 1015 nbvar=0; 1018 1016 for icell=1:length(CellVarIndex) 1019 if NbDim(icell)<2 1017 NbDim=NbDimVec(icell); 1018 if NbDim<2 1020 1019 continue 1021 1020 end … … 1129 1128 %ProjData.DimValue=[ProjData. 1130 1129 %length(coord_X)]; 1131 nbvar=0; 1130 1132 1131 for ivar=VarIndex %transfer variables to the projection plane 1133 1132 VarName=FieldData.ListVarName{ivar}; … … 1143 1142 ProjData.VarDimName=[ProjData.VarDimName DimCell]; 1144 1143 nbvar=nbvar+1; 1145 if isfield(FieldData,'VarAttribute') & length(FieldData.VarAttribute) >=ivar1144 if isfield(FieldData,'VarAttribute') && length(FieldData.VarAttribute) >=ivar 1146 1145 ProjData.VarAttribute{nbvar}=FieldData.VarAttribute{ivar}; 1147 1146 end … … 1215 1214 1216 1215 %% case of input fields defined on a structured grid 1217 else 1218 AYName=FieldData.ListVarName{VarType.coord(1)};%name of input x coordinate (name preserved on projection) 1219 AXName=FieldData.ListVarName{VarType.coord(2)};%name of input y coordinate (name preserved on projection) 1216 else 1217 VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions 1218 eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions 1219 DimValue(find(DimValue==1))=[];%remove singleton dimensions 1220 NbDim=numel(DimValue);%update number of space dimensions 1221 nbcolor=1; %default number of 'color' components: third matrix index without corresponding coordinate 1222 if NbDim>=3 1223 if NbDim>3 1224 errormsg='matrices with more than 3 dimensions not handled'; 1225 return 1226 else 1227 VarType.coord 1228 if numel(find(VarType.coord))==2% the third matrix dimension does not correspond to a space coordinate 1229 nbcolor=DimValue(3); 1230 DimValue(3)=[]; %number of 'color' components updated 1231 NbDim=2;% space dimension set to 2 1232 end 1233 end 1234 end 1235 AYName=FieldData.ListVarName{VarType.coord(NbDim-1)};%name of input x coordinate (name preserved on projection) 1236 AXName=FieldData.ListVarName{VarType.coord(NbDim)};%name of input y coordinate (name preserved on projection) 1220 1237 eval(['AX=FieldData.' AXName ';']) 1221 1238 eval(['AY=FieldData.' AYName ';']) 1222 VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions1223 eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions1224 1239 ListDimName=FieldData.VarDimName{VarIndex(1)}; 1225 ProjData.ListVarName=[{AYName} {AXName} ProjData.ListVarName]; %TODO: check if it already exists in Projdata (several cells) 1226 ProjData.VarDimName=[{AYName} {AXName} ProjData.VarDimName]; 1227 nbcolor=1; %default 1228 for idim=1:length(ListDimName) 1229 DimName=ListDimName{idim}; 1230 if strcmp(DimName,'rgb')||strcmp(DimName,'nb_coord')||strcmp(DimName,'nb_coord_i') 1231 nbcolor=DimValue(idim); 1232 DimValue(idim)=[]; 1233 end 1234 if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED 1235 DimValue(idim)=[]; 1236 end 1237 end 1238 ind_1=find(DimValue==1); 1240 ProjData.ListVarName=[ProjData.ListVarName {AYName} {AXName}]; %TODO: check if it already exists in Projdata (several cells) 1241 ProjData.VarDimName=[ProjData.VarDimName {AYName} {AXName}]; 1242 1243 % for idim=1:length(ListDimName) 1244 % DimName=ListDimName{idim}; 1245 % if strcmp(DimName,'rgb')||strcmp(DimName,'nb_coord')||strcmp(DimName,'nb_coord_i') 1246 % nbcolor=DimValue(idim); 1247 % DimValue(idim)=[]; 1248 % end 1249 % if isequal(DimName,'nb_coord_j')% NOTE: CASE OF TENSOR NOT TREATED 1250 % DimValue(idim)=[]; 1251 % end 1252 % end 1239 1253 Coord_z=[]; 1240 1254 Coord_y=[]; 1241 1255 Coord_x=[]; 1242 nb_dim=numel(DimValue); 1243 for idim=1: nb_dim %loop on space dimensions1256 1257 for idim=1:NbDim %loop on space dimensions 1244 1258 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default 1245 1259 ivar=VarType.coord(idim);% index of the variable corresponding to the current dimension … … 1268 1282 end 1269 1283 if DY==0 1270 DY=abs(DCoord_min( nb_dim-1));1271 end 1272 npY=1+round(abs(Coord{ nb_dim-1}(end)-Coord{nb_dim-1}(1))/DY);%nbre of points after interpol1284 DY=abs(DCoord_min(NbDim-1)); 1285 end 1286 npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol 1273 1287 if DX==0 1274 DX=abs(DCoord_min( nb_dim));1275 end 1276 npX=1+round(abs(Coord{ nb_dim}(end)-Coord{nb_dim}(1))/DX);%nbre of points after interpol1277 for idim=[1: nb_dim]1288 DX=abs(DCoord_min(NbDim)); 1289 end 1290 npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol 1291 for idim=[1:NbDim] 1278 1292 if test_interp(idim) 1279 1293 DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri 1280 1294 end 1281 1295 end 1282 Coord_y=linspace(Coord{nb_dim-1}(1),Coord{nb_dim-1}(end),npY); 1283 test_direct_y=test_direct(nb_dim-1); 1284 Coord_x=linspace(Coord{nb_dim}(1),Coord{nb_dim}(end),npX); 1285 test_direct_x=test_direct(nb_dim); 1286 DAX=DCoord_min(nb_dim); 1287 DAY=DCoord_min(nb_dim-1); 1288 if nb_dim==3 1289 DZ=abs(DCoord_min(1)); 1290 Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1)); 1291 test_direct_z=test_direct(1); 1292 end 1296 Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY); 1297 test_direct_y=test_direct(NbDim-1); 1298 Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX); 1299 test_direct_x=test_direct(NbDim); 1300 DAX=DCoord_min(NbDim); 1301 DAY=DCoord_min(NbDim-1); 1293 1302 minAX=min(Coord_x); 1294 1303 maxAX=max(Coord_x); … … 1311 1320 YMin=min(ycor_new); 1312 1321 end 1313 DXinit=(maxAX-minAX)/(DimValue( 2)-1);1314 DYinit=(maxAY-minAY)/(DimValue( 1)-1);1322 DXinit=(maxAX-minAX)/(DimValue(NbDim)-1); 1323 DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1); 1315 1324 if DX==0 1316 1325 DX=DXinit; … … 1318 1327 if DY==0 1319 1328 DY=DYinit; 1329 end 1330 if NbDim==3 1331 DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1); 1332 if ~test_direct(1) 1333 DZ=-DZ; 1334 end 1335 Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1)); 1336 test_direct_z=test_direct(1); 1320 1337 end 1321 1338 npX=floor((XMax-XMin)/DX+1); … … 1334 1351 % case with no rotation and interpolation 1335 1352 if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0) 1336 if ~testXMin && ~testXMax && ~testYMin && ~testYMax && nb_dim==21353 if ~testXMin && ~testXMax && ~testYMin && ~testYMax && NbDim==2 1337 1354 ProjData=FieldData; 1338 1355 else 1339 if test_direct(1) 1340 min_ind1=ceil((YMin-Coord{1}(1))/DYinit)+1; 1341 max_ind1=floor((YMax-Coord{1}(1))/DYinit)+1; 1342 Ybound(1)=Coord{1}(1)+DYinit*(min_ind1-1); 1343 Ybound(2)=Coord{1}(1)+DYinit*(max_ind1-1); 1356 indY=NbDim-1; 1357 if test_direct(indY) 1358 min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1; 1359 max_indy=floor((YMax-Coord{indY}(1))/DYinit)+1; 1360 Ybound(1)=Coord{indY}(1)+DYinit*(min_indy-1); 1361 Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1); 1344 1362 else 1345 min_ind 1=ceil((Coord{1}(1)-YMax)/DYinit)+1;1346 max_ind 1=floor((Coord{1}(1)-YMin)/DYinit)+1;1347 Ybound(2)=Coord{ 1}(1)-DYinit*(max_ind1-1);1348 Ybound(1)=Coord{ 1}(1)-DYinit*(min_ind1-1);1349 end 1350 if test_direct( 2)==11351 min_ind 2=ceil((XMin-Coord{2}(1))/DXinit)+1;1352 max_ind 2=floor((XMax-Coord{2}(1))/DXinit)+1;1353 Xbound(1)=Coord{ 2}(1)+DXinit*(min_ind2-1);1354 Xbound(2)=Coord{ 2}(1)+DXinit*(max_ind2-1);1363 min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1; 1364 max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1; 1365 Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1); 1366 Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1); 1367 end 1368 if test_direct(NbDim)==1 1369 min_indx=ceil((XMin-Coord{NbDim}(1))/DXinit)+1; 1370 max_indx=floor((XMax-Coord{NbDim}(1))/DXinit)+1; 1371 Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1); 1372 Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1); 1355 1373 else 1356 min_ind 2=ceil((Coord{2}(1)-XMax)/DXinit)+1;1357 max_ind 2=floor((Coord{2}(1)-XMin)/DXinit)+1;1358 Xbound(2)=Coord{ 2}(1)+DXinit*(max_ind2-1);1359 Xbound(1)=Coord{ 2}(1)+DXinit*(min_ind2-1);1374 min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1; 1375 max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1; 1376 Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1); 1377 Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1); 1360 1378 end 1361 if nb_dim==3 %TODO: to update 1362 min_ind3=ceil((Coord{1}(1)-ZMax)/DZinit)+1; 1363 max_ind2=floor((Coord{1}(2)-XMin)/DZinit)+1; 1364 Zbound(2)=Coord{1}(1)+DXinit*(max_ind2-1); 1365 Zbound(1)=Coord{1}(1)+DXinit*(min_ind2-1); 1379 iz_str=':'; %default 1380 if NbDim==3 1381 DimCell(1)=[]; %suppress z variable 1382 DimValue(1)=[]; 1383 %structured coordinates 1384 if test_direct(1) 1385 iz=ceil((ObjectData.Coord(1,3)-Coord{1}(1))/DZ)+1; 1386 else 1387 iz=ceil((Coord{1}(1)-ObjectData.Coord(1,3))/DZ)+1; 1388 end 1366 1389 end 1367 min_ind 1=max(min_ind1,1);% deals with margin (bound lower than the first index)1368 min_ind 2=max(min_ind2,1);1369 max_ind 1=min(max_ind1,DimValue(1));1370 max_ind 2=min(max_ind2,DimValue(2));1371 for ivar=VarIndex 1390 min_indy=max(min_indy,1);% deals with margin (bound lower than the first index) 1391 min_indx=max(min_indx,1); 1392 max_indy=min(max_indy,DimValue(1)); 1393 max_indx=min(max_indx,DimValue(2)); 1394 for ivar=VarIndex% loop on non coordinate variables 1372 1395 VarName=FieldData.ListVarName{ivar}; 1373 1396 ProjData.ListVarName=[ProjData.ListVarName VarName]; … … 1376 1399 ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; 1377 1400 end 1378 eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind1:max_ind1,min_ind2:max_ind2,:) ;']); 1401 if NbDim==3 1402 eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,min_indy:max_indy,min_indx:max_indx));']); 1403 else 1404 eval(['ProjData.' VarName '=FieldData.' VarName '(min_indy:max_indy,min_indx:max_indx,:);']); 1405 end 1379 1406 end 1380 1407 eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates … … 1382 1409 end 1383 1410 else % case with rotation and/or interpolation 1384 if isempty(Coord_z)%2D case1411 if NbDim==2 %2D case 1385 1412 [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1386 1413 XIMA=ObjectData.Coord(1,1)+(X)*cos(Phi)-Y*sin(Phi);%corresponding coordinates in the original image … … 1436 1463 else %3D case 1437 1464 if isequal(Theta,0) & isequal(Phi,0) 1465 % unstructured z coordinate 1438 1466 test_sup=(Coord{1}>=ObjectData.Coord(1,3)); 1439 1467 iz_sup=find(test_sup); … … 1448 1476 eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz 1449 1477 %TODO : do a vertical average for a thick plane 1450 if test_interp(2) | test_interp(3)1478 if test_interp(2) || test_interp(3) 1451 1479 eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');']) 1452 1480 end … … 1461 1489 end 1462 1490 end 1463 1491 1464 1492 %% projection of velocity components in the rotated coordinates 1465 1493 if ~isequal(Phi,0) && length(ivar_U)==1 … … 1523 1551 % test for 3D fields 1524 1552 test3D=0; 1525 if isfield(FieldData,' nb_dim')1526 test3D=isequal(FieldData. nb_dim,3);1553 if isfield(FieldData,'NbDim') 1554 test3D=isequal(FieldData.NbDim,3); 1527 1555 end 1528 1556 test3C=test3D; %default 3 vel components … … 1829 1857 DimIndices(ind_1)=[]; %suppress singleton dimensions 1830 1858 % indxy=find(DimVarIndex(DimIndices));%select dimension variables (DimIndices non zero) 1831 nb_dim=length(DimIndices);%number of space dimensions1859 NbDim=length(DimIndices);%number of space dimensions 1832 1860 Coord_z=[]; 1833 1861 Coord_y=[]; 1834 1862 Coord_x=[]; 1835 1863 1836 for idim=1: nb_dim %loop on space dimensions1864 for idim=1:NbDim %loop on space dimensions 1837 1865 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default 1838 1866 ivar=DimVarIndex(DimIndices(idim));% index of the variable corresponding to the current dimension … … 1856 1884 end 1857 1885 end 1858 if nb_dim==21886 if NbDim==2 1859 1887 if DY==0 1860 1888 DY=abs(DCoord_min(1)); … … 1873 1901 DAX=DCoord_min(2); 1874 1902 DAY=DCoord_min(1); 1875 elseif nb_dim==31903 elseif NbDim==3 1876 1904 DZ=abs(DCoord_min(1)); 1877 1905 npz=1+round(abs(Coord{1}(end)-Coord{1}(1))/DZ);%nbre of points after interpolation … … 1937 1965 if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0) 1938 1966 if test_direct(1) 1939 min_ind 1=ceil((YMin-Coord{1}(1))/DYinit)+1;1940 max_ind 1=floor((YMax-Coord{1}(1))/DYinit)+1;1941 Ybound(1)=Coord{1}(1)+DYinit*(min_ind 1-1);1942 Ybound(2)=Coord{1}(1)+DYinit*(max_ind 1-1);1967 min_indy=ceil((YMin-Coord{1}(1))/DYinit)+1; 1968 max_indy=floor((YMax-Coord{1}(1))/DYinit)+1; 1969 Ybound(1)=Coord{1}(1)+DYinit*(min_indy-1); 1970 Ybound(2)=Coord{1}(1)+DYinit*(max_indy-1); 1943 1971 else 1944 min_ind 1=ceil((Coord{1}(1)-YMax)/DYinit)+1;1945 max_ind 1=floor((Coord{1}(1)-YMin)/DYinit)+1;1946 Ybound(2)=Coord{1}(1)-DYinit*(max_ind 1-1);1947 Ybound(1)=Coord{1}(1)-DYinit*(min_ind 1-1);1972 min_indy=ceil((Coord{1}(1)-YMax)/DYinit)+1; 1973 max_indy=floor((Coord{1}(1)-YMin)/DYinit)+1; 1974 Ybound(2)=Coord{1}(1)-DYinit*(max_indy-1); 1975 Ybound(1)=Coord{1}(1)-DYinit*(min_indy-1); 1948 1976 end 1949 1977 if test_direct(2)==1 1950 min_ind 2=ceil((XMin-Coord{2}(1))/DXinit)+1;1951 max_ind 2=floor((XMax-Coord{2}(1))/DXinit)+1;1952 Xbound(1)=Coord{2}(1)+DXinit*(min_ind 2-1);1953 Xbound(2)=Coord{2}(1)+DXinit*(max_ind 2-1);1978 min_indx=ceil((XMin-Coord{2}(1))/DXinit)+1; 1979 max_indx=floor((XMax-Coord{2}(1))/DXinit)+1; 1980 Xbound(1)=Coord{2}(1)+DXinit*(min_indx-1); 1981 Xbound(2)=Coord{2}(1)+DXinit*(max_indx-1); 1954 1982 else 1955 min_ind 2=ceil((Coord{2}(1)-XMax)/DXinit)+1;1956 max_ind 2=floor((Coord{2}(1)-XMin)/DXinit)+1;1957 Xbound(2)=Coord{2}(1)+DXinit*(max_ind 2-1);1958 Xbound(1)=Coord{2}(1)+DXinit*(min_ind 2-1);1983 min_indx=ceil((Coord{2}(1)-XMax)/DXinit)+1; 1984 max_indx=floor((Coord{2}(1)-XMin)/DXinit)+1; 1985 Xbound(2)=Coord{2}(1)+DXinit*(max_indx-1); 1986 Xbound(1)=Coord{2}(1)+DXinit*(min_indx-1); 1959 1987 end 1960 min_ind 1=max(min_ind1,1);% deals with margin (bound lower than the first index)1961 min_ind 2=max(min_ind2,1);1962 max_ind 1=min(max_ind1,DimValue(1));1963 max_ind 2=min(max_ind2,DimValue(2));1988 min_indy=max(min_indy,1);% deals with margin (bound lower than the first index) 1989 min_indx=max(min_indx,1); 1990 max_indy=min(max_indy,DimValue(1)); 1991 max_indx=min(max_indx,DimValue(2)); 1964 1992 for ivar=VarIndex 1965 1993 VarName=FieldData.ListVarName{ivar}; 1966 1994 ProjData.ListVarName=[ProjData.ListVarName VarName]; 1967 %ProjData.VarDimIndex=[ProjData.VarDimIndex [ nb_dim-1 nb_dim]];1995 %ProjData.VarDimIndex=[ProjData.VarDimIndex [NbDim-1 NbDim]]; 1968 1996 if length(FieldData.VarAttribute)>=ivar 1969 1997 ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; 1970 1998 end 1971 eval(['ProjData.' VarName '=FieldData.' VarName '(min_ind 1:max_ind1,min_ind2:max_ind2) ;']);1999 eval(['ProjData.' VarName '=FieldData.' VarName '(min_indy:max_indy,min_indx:max_indx) ;']); 1972 2000 end 1973 2001 else -
trunk/src/read_civxdata.m
r159 r179 5 5 % 6 6 % OUTPUT: 7 % nb_coord,nb_dim, 8 % Civ: =0 or 1, indicates whether the data is civ (A SUPPRIMER ?) 9 % CivStage: =0, ??? A UTILISER POUR REMPLACER civ 10 % =1, civ1 has been performed only 11 % =2, fix1 has been performed 12 % =3, pacth1 has been performed 13 % =4, civ2 has been performed 14 % =5, fix2 has been performed 15 % =6, pacth2 has been performed 16 % time: absolute time 17 % Field 7 % Field: structure representing the selected field, containing 18 8 % .Txt: (char string) error message if any 19 % . NbDim: number of dimensions (=0 by default)20 % .NbCoord: number of vector components21 % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')22 % .dt: time interval for the corresponding image pair23 % .CivStage: =0,24 % =1, civ1 has been performed only25 % =2, fix1 has been performed26 % =3, pacth1 has been performed27 % =4, civ2 has been performed28 % =5, fix2 has been performed29 % =6, pacth2 has been performed30 % .X, .Y, .Z: set of vector coordinates31 % .U,.V,.W: corresponding set of vector components32 % .F: warning flags33 % .FF: error flag, =0 for good vectors34 % .C: scalar associated with velocity (used for vector colors)35 % .CoordType36 % .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX,37 % DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY38 % .A, .AX, .AY: additional scalar39 % dt:time interval of the image pair red from a single file, or vector with40 % pixcmx,pixcmy: scaling factors (from the first file)41 % vel_type_out: string representing the selected velocity type (civ1,civ2,filter1...)9 % .ListGlobalAttribute: list of global attributes containing: 10 % .NbCoord: number of vector components 11 % .NbDim: number of dimensions (=2 or 3) 12 % .dt: time interval for the corresponding image pair 13 % .Time: absolute time (average of the initial image pair) 14 % .CivStage: =0, 15 % =1, civ1 has been performed only 16 % =2, fix1 has been performed 17 % =3, pacth1 has been performed 18 % =4, civ2 has been performed 19 % =5, fix2 has been performed 20 % =6, pacth2 has been performed 21 % .CoordUnit: 'pixel' 22 % .ListVarName: {'X' 'Y' 'U' 'V' 'F' 'FF'} 23 % .X, .Y, .Z: set of vector coordinates 24 % .U,.V,.W: corresponding set of vector components 25 % .F: warning flags 26 % .FF: error flag, =0 for good vectors 27 % .C: scalar associated with velocity (used for vector colors) 28 % .DijU; matrix of spatial derivatives (DijU(1,1,:)=DUDX, 29 % DijU(1,2,:)=DUDY, Dij(2,1,:)=DVDX, DijU(2,2,:)=DVDY 30 % 31 % VelTypeOut: velocity type corresponding to the selected field: ='civ1','interp1','interp2','civ2'.... 42 32 % 43 33 % INPUT: … … 95 85 Field.VarAttribute(end-2:end)=[]; 96 86 end 87 88 %renaiming for standard conventions 89 Field.NbCoord=Field.nb_coord; 90 Field.NbDim=Field.nb_dim; 97 91 98 92 %determine the appropriate constant for time and dt for the PIV pair … … 125 119 end 126 120 127 %update list of global attributes 128 List=Field.ListGlobalAttribute; 129 ind_remove=[]; 130 for ilist=1:length(List) 131 switch(List{ilist}) 132 case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2'} 133 ind_remove=[ind_remove ilist]; 134 Field=rmfield(Field,List{ilist}); 135 end 136 end 137 List(ind_remove)=[]; 138 Field.ListGlobalAttribute=[List {'Time','CivStage','CoordUnit'}]; 139 140 % rescale to pixel coordiantes 121 %% rescale fields to pixel coordinates 141 122 if isfield(Field,'pixcmx') 142 123 Field.pixcmx=double(Field.pixcmx); … … 157 138 end 158 139 end 159 %Field.CoordType='px';% TODO: abandon, use COORdUnit instead ? (to adapt 'px' and 'phys') 140 141 %% update list of global attributes 142 List=Field.ListGlobalAttribute; 143 ind_remove=[]; 144 for ilist=1:length(List) 145 switch(List{ilist}) 146 case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2','nb_coord','nb_dim','pixcmx','pixcmy'} 147 ind_remove=[ind_remove ilist]; 148 Field=rmfield(Field,List{ilist}); 149 end 150 end 151 List(ind_remove)=[]; 152 Field.ListGlobalAttribute=[{'NbCoord'},{'NbDim'} List {'Time','CivStage','CoordUnit'}]; 160 153 Field.CoordUnit='pixel'; 161 154 -
trunk/src/read_get_field.m
r105 r179 179 179 else 180 180 dimname_y=Field.VarDimName{VarIndex}; 181 %check consistency of dimensions182 181 nbvar=nbvar+1; 183 182 ListVarName{nbvar}=Field.ListVarName{VarIndex}; … … 201 200 SubVarAttribute{nbvar}.Role='coord_y';%abcissa with unstructured coordinates 202 201 end 203 % if isequal(dimname_y,dimname_x)204 % errormsg='identical x and y coordinates selected in get_field';205 % return206 % end207 202 end 208 203 … … 214 209 VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName 215 210 if isempty(VarIndex)% default abscissa = matrix index 216 % coord_z_name=dimname_A{1};% name of the x coordinate = dimension of the plotted quantity 217 % empty_coord_z=1; 211 empty_coord_z=1; 218 212 else 219 213 dimname_z=Field.VarDimName{VarIndex}; 220 %check consistency of dimensions 221 if ~isequal(dimname_z,dimname_A) 222 for icoord=1:numel(dimname_A) 223 if strcmp(dimname_z,dimname_A{icoord})% a dimension variable 224 dim_z=icoord; 225 break 214 nbvar=nbvar+1; 215 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 216 VarDimName{nbvar}=dimname_y; 217 if numel(VarAttribute)>=VarIndex 218 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 219 end 220 %check consistency of dimensions 221 if ~isequal(dimname_y,dimname_A)% case of dimension variables 222 if iscell(dimname_y) 223 if numel(dimname_y)==1 224 dimname_y=dimname_y{1};%transform to char chain 225 else 226 errormsg='invalid y coordinate selection in get_field'; 227 return 226 228 end 227 229 end 228 if ~dim_z 229 errormsg='inconsistent dimensions for coordinate z'; 230 return 231 end 232 end 233 nbvar=nbvar+1; 234 ListVarName{nbvar}=Field.ListVarName{VarIndex}; 235 VarDimName{nbvar}=dimname_z; 236 if numel(VarAttribute)>=VarIndex 237 SubVarAttribute{nbvar}=VarAttribute{VarIndex}; 238 end 239 if dim_z 230 test_zdimvar=1; 240 231 SubVarAttribute{nbvar}.Role='dimvar';% dimension variable 241 232 else 242 SubVarAttribute{nbvar}.Role='coord_z';% z coordinatewith unstructured coordinates233 SubVarAttribute{nbvar}.Role='coord_z';%abcissa with unstructured coordinates 243 234 end 244 235 end … … 456 447 %permute indices if coord_y is not the first matrix index: scalar case 457 448 if test_scalar 458 VarNameA=Field.ListVarName{VarIndexA}; 459 DimCellA=Field.VarDimName{VarIndexA}; 460 eval(['npxy=size(SubField.' VarNameA ');']) 449 VarNameA=Field.ListVarName{VarIndexA};%name of the scalar variable 450 DimCellA=Field.VarDimName{VarIndexA}; %dimension names for the scalar variable 451 eval(['npxy=size(SubField.' VarNameA ');'])%zize of the scalar variable 461 452 SingleCellA={}; 462 453 if numel(npxy) < numel(DimCellA) … … 464 455 DimCellA=DimCellA(end-numel(npxy)+1:end); %suppress the first singletons) dimensions 465 456 end 466 ind_single=find(npxy==1); 467 if ~isempty(ind_single) 468 %SingleCellA=[SingleCellA DimCellA(ind_single)];TO CHECK 469 end 457 %ind_single=find(npxy==1); 470 458 ind_select=find(npxy~=1);%look for non singleton dimensions 471 DimCellA=DimCellA(ind_select); 459 DimCellA=DimCellA(ind_select);%dimension names for the scalar variable, after removing singletons 472 460 npxy=npxy(ind_select); 473 461 dimA=[]; 474 462 if test_zdimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 475 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 476 if strcmp(dimname_z,SingleCellA{icoord})% a singleton dimension 477 errormsg=['the singleton dimension ' dimname_z ' has been selected for z']; 478 return 479 end 480 end 481 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 482 if strcmp(dimname_z,DimCellA{icoord})% a dimension variable 483 dimA=[dimA icoord]; 484 break 485 end 486 end 463 ind_singleton=find(strcmp(dimname_z,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 464 if ~isempty(ind_singleton) 465 errormsg=['the singleton dimension ' dimname_z ' has been selected for z']; 466 return 467 end 468 icoord=find(strcmp(dimname_z,DimCellA),1);% a dimension variable 469 dimA=[dimA icoord]; 470 % for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 471 % if strcmp(dimname_z,DimCellA{icoord})% a dimension variable 472 % dimA=[dimA icoord]; 473 % break 474 % end 475 % end 487 476 end 488 477 if test_ydimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 489 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 490 if strcmp(dimname_y,SingleCellA{icoord})% a singleton dimension 491 errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate']; 492 return 493 end 494 end 495 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 496 if strcmp(dimname_y,DimCellA{icoord})% a dimension variable 497 dimA=[dimA icoord]; 498 break 499 end 500 end 501 end 502 if test_xdimvar%dim_x && dim_y && ~isempty(VarSubIndexA) 503 for icoord=1:numel(SingleCellA)% look for coincidence of dimension with one of the dimensions of the scalar 504 if strcmp(dimname_x,SingleCellA{icoord})% a singleton dimension 505 errormsg=['the singleton dimension ' dimname_x ' has been selected for abscissa']; 506 return 507 end 508 end 509 for icoord=1:numel(DimCellA)% look for coincidence of dimension with one of the dimensions of the scalar 510 if strcmp(dimname_x,DimCellA{icoord})% a dimension variable 511 dimA=[dimA icoord]; 512 break 513 end 514 end 478 ind_singleton=find(strcmp(dimname_y,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 479 if ~isempty(ind_singleton) 480 errormsg=['the singleton dimension ' dimname_y ' has been selected for ordinate']; 481 return 482 end 483 icoord=find(strcmp(dimname_y,DimCellA),1);% a dimension variable 484 dimA=[dimA icoord]; 485 end 486 if test_xdimvar 487 ind_singleton=find(strcmp(dimname_x,SingleCellA),1);% look for coincidence of dimension with one of the singleton dimensions 488 if ~isempty(ind_singleton) 489 errormsg=['the singleton dimension ' dimname_x ' has been selected for ordinate']; 490 return 491 end 492 icoord=find(strcmp(dimname_x,DimCellA),1);% a dimension variable 493 dimA=[dimA icoord]; 515 494 end 516 495 dimextra=(1:numel(DimCellA)); -
trunk/src/series.m
r158 r179 1694 1694 end 1695 1695 eval(['h_function=@' ACTION ';']); 1696 [fid,errormsg] =fopen([ACTION '.m']); 1697 InputText=textscan(fid,'%s',1,'delimiter','\n'); 1698 fclose(fid) 1696 1699 if ~isequal(path_series,PathName) 1697 1700 rmpath(PathName) 1698 1701 end 1699 1702 set(handles.ACTION,'ToolTipString',InputText{1}{1}) 1700 1703 varargout=h_function(); 1701 1704 Param_list={}; -
trunk/src/set_object.m
r159 r179 733 733 if isequal(get(hhuvmat.list_object_2,'Visible'),'on') 734 734 IndexObj_2=get(hhuvmat.list_object_2,'Value'); 735 List2=get(hhuvmat.list_object_2,'String') 736 if IndexObj_2==length(List2) 737 IndexObj_2=[];% '...' selected 738 end 735 739 else 736 740 IndexObj_2=[]; -
trunk/src/sub_field.m
r165 r179 1 %'sub_field': combines two input fields 1 %'sub_field': combines two input fields 2 % 3 % the two fields are subtstracted when of the same nature (scalar or 4 % vector), if the coordinates do not coincide, the second field is 5 % interpolated on the cooridintes of the first one 6 % 7 % when scalar and vectors are combined, the fields are just merged in a single matlab structure for common visualisation 2 8 %----------------------------------------------------------------------- 3 9 % function SubData=sub_field(Field,Field_1) … … 7 13 % 8 14 % INPUT: 9 % UvData: main structure UvData associated to the uvmat GUI as 'UserData' 10 % Field: cell of Matlab structures representing the input fields 11 % 12 % -- TODO: need to be rationalized -- 15 % Field: matlab structure representing the first field 16 % Field_1:matlab structure representing the second field 13 17 14 18 function [SubData,errormsg]=sub_field(Field,Field_1) … … 77 81 return 78 82 end 79 % VarIndex=CellVarIndex{iselect};80 % VarIndex_1=CellVarIndex_1{iselect_1};81 83 VarType=VarTypeCell{iselect}; 82 84 VarType_1=VarTypeCell_1{iselect_1}; … … 85 87 testU=~isempty(VarType.vector_x)&& ~isempty(VarType.vector_y);%vector field 86 88 testU_1=~isempty(VarType_1.vector_x)&& ~isempty(VarType_1.vector_y);%vector field 87 % testfalse=~isempty(VarType.errorflag);88 89 testfalse_1=~isempty(VarType_1.errorflag); 89 90 ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields … … 101 102 if (testU && testU_1) || (~testU && ~testU_1) 102 103 %check coincidence in positions 103 %unstructured coordinates 104 if testX 104 %unstructured coordinates for the first field 105 if testX 106 XName=Field.ListVarName{VarType.coord_x}; 107 YName=Field.ListVarName{VarType.coord_y}; 108 eval(['vec_X=Field.' XName ';']) 109 eval(['vec_Y=Field.' YName ';']) 110 nbpoints=numel(vec_X); 111 vec_X=reshape(vec_X,nbpoints,1); 112 vec_Y=reshape(vec_Y,nbpoints,1); 113 if testX_1 %unstructured coordinates for the second field 114 X_1_Name=Field_1.ListVarName{VarType_1.coord_x}; 115 Y_1_Name=Field_1.ListVarName{VarType_1.coord_y}; 116 eval(['vec_X_1=Field_1.' X_1_Name ';']) 117 eval(['vec_Y_1=Field_1.' Y_1_Name ';']) 118 119 else %structured coordinates for the second field 120 y_1_Name=Field_1.ListVarName{VarType_1.coord(1)}; 121 x_1_Name=Field_1.ListVarName{VarType_1.coord(2)}; 122 eval(['y_1=Field_1.' y_1_Name ';']) 123 eval(['x_1=Field_1.' x_1_Name ';']) 124 if isequal(numel(x_1),2) 125 x_1=linspace(x_1(1),x_1(2),nbpoints_x_1); 126 end 127 if isequal(numel(y_1),2) 128 y_1=linspace(y_1(1),y_1(2),nbpoints_y_1); 129 end 130 [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1); 131 end 132 vec_X_1=reshape(vec_X_1,[],1); 133 vec_Y_1=reshape(vec_Y_1,[],1); 134 if testfalse_1 135 FFName_1=Field_1.ListVarName{VarType_1.errorflag}; 136 eval(['vec_FF_1=Field_1.' FFName_1 ';']) 137 vec_FF_1=reshape(vec_FF_1,[],1); 138 indsel=find(~vec_FF_1); 139 vec_X_1=vec_X_1(indsel); 140 vec_Y_1=vec_Y_1(indsel); 141 end 105 142 if testU % vector fields 106 143 U_1_Name=Field_1.ListVarName{VarType_1.vector_x}; … … 126 163 end 127 164 end 128 XName=Field.ListVarName{VarType.coord_x}; 129 YName=Field.ListVarName{VarType.coord_y}; 130 eval(['vec_X=Field.' XName ';']) 131 eval(['vec_Y=Field.' YName ';']) 132 nbpoints=numel(vec_X); 133 vec_X=reshape(vec_X,nbpoints,1); 134 vec_Y=reshape(vec_Y,nbpoints,1); 135 if testX_1 %unstructured coordinates for the second field 136 X_1_Name=Field_1.ListVarName{VarType_1.coord_x}; 137 Y_1_Name=Field_1.ListVarName{VarType_1.coord_y}; 138 eval(['vec_X_1=Field_1.' X_1_Name ';']) 139 eval(['vec_Y_1=Field_1.' Y_1_Name ';']) 140 141 else %structured coordinates for the second field 142 y_1_Name=Field_1.ListVarName{VarType_1.coord(1)}; 143 x_1_Name=Field_1.ListVarName{VarType_1.coord(2)}; 144 eval(['y_1=Field_1.' y_1_Name ';']) 145 eval(['x_1=Field_1.' x_1_Name ';']) 146 if isequal(numel(x_1),2) 147 x_1=linspace(x_1(1),x_1(2),nbpoints_x_1); 148 end 149 if isequal(numel(y_1),2) 150 y_1=linspace(y_1(1),y_1(2),nbpoints_y_1); 151 end 152 [vec_X_1,vec_Y_1]=meshgrid(x_1,y_1); 153 end 154 vec_X_1=reshape(vec_X_1,nbpoints_x_1*nbpoints_y_1,1); 155 vec_Y_1=reshape(vec_Y_1,nbpoints_x_1*nbpoints_y_1,1); 156 if testfalse_1 157 FFName_1=Field_1.ListVarName{VarType_1.errorflag}; 158 eval(['vec_FF_1=Field_1.' FFName_1 ';']) 159 vec_FF_1=reshape(vec_FF_1,nbpoints_1,1); 160 indsel=find(~vec_FF_1); 161 vec_X_1=vec_X_1(indsel); 162 vec_Y_1=vec_Y_1(indsel); 163 end 165 164 166 if ~isequal(vec_X_1,vec_X) && ~isequal(vec_Y_1,vec_Y) % if the unstructured positions are not the same 165 167 if testU … … 228 230 if testU && ~testU_1 229 231 AName_1=Field_1.ListVarName{ivar_C_1}; 230 if isfield(Field_1,'VarAttribute') & &numel(Field_1.VarAttribute)>=ivar_C_1232 if isfield(Field_1,'VarAttribute') & numel(Field_1.VarAttribute)>=ivar_C_1 231 233 AAttr=Field_1.VarAttribute{ivar_C_1} ; 232 234 else … … 236 238 XName_1=Field_1.ListVarName{VarType_1.coord_x}; 237 239 YName_1=Field_1.ListVarName{VarType_1.coord_y}; 238 %SubData.ListVarName=[SubData.ListVarName {XName_1} {YName_1}];239 240 DimCell=Field_1.VarDimName([VarType_1.coord_x VarType_1.coord_y ]); 240 241 if isfield(Field_1,'VarAttribute') 241 242 if numel(Field_1.VarAttribute)>=VarType_1.coord_x 242 XAttr=Field_1.VarAttribute{VarType_1.coord_x} ;243 XAttr=Field_1.VarAttribute{VarType_1.coord_x}; 243 244 else 244 245 XAttr=[]; 245 246 end 246 247 if numel(Field_1.VarAttribute)>=VarType_1.coord_y 247 YAttr=Field_1.VarAttribute{VarType_1.coord_y} ;248 YAttr=Field_1.VarAttribute{VarType_1.coord_y}; 248 249 else 249 250 YAttr=[]; … … 361 362 eval(['SubData.' VName_1_1 '=Field_1.' VName_1 ';']) 362 363 end 363 364 364 -
trunk/src/update_obj.m
r159 r179 21 21 22 22 %% default input and output 23 % Object_out{IndexObj}=ObjectData;%default24 % if isfield(UvData,'Object')25 % Object_set=UvData.Object;26 % else27 % Object_set={};%create the object28 % end29 23 Object_out=UvData.Object; 30 24 31 %% plot the field projected on the object32 % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData33 % if ~isempty(ProjData)34 % plotaxes=[];%default35 % if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')36 % plotaxes=Object_set{IndexObj}.plotaxes;37 % [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot38 % plotfig=get(plotaxes,'parent');39 % ViewData=get(plotfig,'UserData');40 % eval(41 % else42 % hview_field=view_field(ProjData);%create a new field plot with view_field43 % hhview_field=guidata(hview_field);44 % plotaxes=hhview_field.axes3;45 % end46 % Object_out{IndexObj}.plotaxes=plotaxes;47 % end48 25 49 26 %% representation of the different objects in the plots uvmat and view_field 50 51 27 %plot uvmat 52 28 for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_1 53 29 hobject=[]; 54 30 if isfield(Object_out{iobj},'DisplayHandle_uvmat') && ~isempty(Object_out{iobj}.DisplayHandle_uvmat) && ishandle(Object_out{iobj}.DisplayHandle_uvmat) 55 hobject=Object_out{iobj}.DisplayHandle_uvmat; 31 hobject=Object_out{iobj}.DisplayHandle_uvmat;%graphic handle of object #iobj in the uvmat plot 56 32 end 57 33 Object_out{iobj}.DisplayHandle_uvmat=plot_object(Object_out{iobj},Object_out{IndexObj_1},hobject,'m');%update the object representation … … 62 38 hobject=[]; 63 39 if isfield(Object_out{iobj},'DisplayHandle_view_field') && ~isempty(Object_out{iobj}.DisplayHandle_view_field) && ishandle(Object_out{iobj}.DisplayHandle_view_field) 64 hobject=Object_out{iobj}.DisplayHandle_view_field; 65 % else 66 % hobject=plotaxes; 40 hobject=Object_out{iobj}.DisplayHandle_view_field;%graphic handle of object #iobj in the view_field plot 67 41 end 68 42 Object_out{iobj}.DisplayHandle_view_field=plot_object(Object_out{iobj},Object_out{IndexObj_2},hobject,'m');%update the object representation 69 43 end 70 44 end 71 % end72 73 % if isfield(Object_set{iobj},'plotaxes')74 % haxes=Object_set{iobj}.plotaxes;% axes for the field plot75 % if ishandle(haxes) && isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists76 % testupdate=0;77 % HandlesDisplay=[];%default78 % if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')79 % HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations80 % end81 % hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes82 % for ih=1:length(HandlesDisplay)83 % plot_detect=find(hplot_list==HandlesDisplay(ih));84 % if ~isempty(plot_detect)85 % Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iobj},HandlesDisplay(ih),'m');%update the the object representation86 % testupdate=1;87 % break88 % end89 % end90 % if ~testupdate% draw new object plot91 % hh=plot_object(ObjectData,Object_set{iobj},haxes,'m');%draw the object with the new object data92 % if isfield(Object_out,'HandlesDisplay')93 % Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];94 % else95 % Object_out.HandlesDisplay=hh;96 % end97 % PlotData=get(hh,'UserData');98 % PlotData.IndexObj=IndexObj;99 % set(hh,'UserData',PlotData); %record the object index in the graph100 % end101 % end102 % end103 % end104 45 105 46 106 47 107 48 49 -
trunk/src/uvmat.m
r178 r179 52 52 % .VelType_1: last velocity type (civ1, civ2...) for the second input series 53 53 % .FieldName_1: last field name(velocity, vorticity...) for the second input series 54 % .NbDim: number of space dimensions of the input field55 54 % .ZMin, .ZMax: range of the z coordinate 56 55 %..... to complement … … 1225 1224 nburst_1=1; 1226 1225 set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec 1227 time= [0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';1226 time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)'; 1228 1227 ColorType=imainfo.ImageType;%='truecolor' for color images 1229 1228 hhh=which('mmreader'); … … 1333 1332 else 1334 1333 UvData.GeometryCalib_1=GeometryCalib; 1335 if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0))|...1336 (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))1334 if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... 1335 (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) 1337 1336 set(handles.pxcm,'String','var') 1338 1337 set(handles.pycm,'String','var') … … 1591 1590 end 1592 1591 num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; 1593 MaskData.NomType1594 1592 MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType); 1595 1593 huvmat=get(handles.mask_test,'parent'); … … 2227 2225 if isfield(UvData.XmlData,'Npy') 2228 2226 Npz=size(A,1)/UvData.XmlData.Npy; 2229 A=reshape(A,Npz,UvData.XmlData.Npy,UvData.XmlData.Npx); 2227 A=reshape(A',UvData.XmlData.Npx,UvData.XmlData.Npy,Npz); 2228 A=permute(A,[3 2 1]); 2230 2229 end 2231 2230 case 'multimage' … … 2239 2238 Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers 2240 2239 Rangy=[npxy(1)-0.5 0.5]; % 2240 Field{1}.NbDim=2;%default 2241 2241 Field{1}.AName='image'; 2242 2242 Field{1}.ListVarName={'AY','AX','A'}; % … … 2247 2247 Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers 2248 2248 else 2249 Field{1}.NbDim=3; 2249 2250 Field{1}.ListVarName=['AZ' Field{1}.ListVarName]; 2250 2251 Field{1}.VarDimName={'AZ','AY','AX',{'AZ','AY','AX'}}; 2251 Field{1}.AZ=[ 0.5 npxy(1)-0.5];2252 Field{1}.AZ=[npxy(1)-0.5 0.5]; 2252 2253 Field{1}.AY=[npxy(2)-0.5 0.5]; 2253 2254 Field{1}.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers … … 2342 2343 end 2343 2344 CivStage=Field{1}.CivStage; 2344 UvData.NbDim=Field{1}.nb_dim;2345 %UvData.NbDim=Field{1}.NbDim; 2345 2346 end 2346 2347 end … … 2411 2412 end 2412 2413 %put W as background image by default if NbDim=2: 2413 if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3) 2414 if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W); 2414 if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); 2415 2415 set(handles.SubField,'Value',1); 2416 2416 %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w' … … 2430 2430 set(handles.Fields_1,'Visible','on'); 2431 2431 Field{1}.AName='w'; 2432 % testscal=1;2433 end2434 2432 end 2435 2433 2436 2434 %multislice case 2437 if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case 2438 isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord') 2439 siz=size(UvData.XmlData.GeometryCalib.SliceCoord); 2440 % if siz(1)>1 2441 % NbSlice=siz(1); 2442 % else 2443 % NbSlice=1; 2444 % end 2445 end 2435 % if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case 2436 % isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord') 2437 % siz=size(UvData.XmlData.GeometryCalib.SliceCoord); 2438 % end 2446 2439 2447 2440 %store the current open names, fields and vel types in uvmat interface … … 2493 2486 Field{2}=calc_field(InputField_1,Field{2}); 2494 2487 end 2495 % combine the two input fields (e.g. substract velocity fields) 2488 2489 %% combine the two input fields (e.g. substract velocity fields) 2496 2490 if numel(Field)==2 2497 UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT2491 UvData.Field=sub_field(Field{1},Field{2}); 2498 2492 else 2499 2493 UvData.Field=Field{1}; … … 2503 2497 test_x=0; 2504 2498 test_z=0;% test for unstructured z coordinate 2505 % UvData.ZMax=0;2506 % UvData.ZMin=0;%default2507 %UvData.Mesh=1; %default2508 2499 [UvData.Field,errormsg]=check_field_structure(UvData.Field); 2509 2500 if ~isempty(errormsg) … … 2513 2504 [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field); 2514 2505 [NbDim,imax]=max(NbDim); 2515 % if isempty(imax)2516 % % DimVarIndex=0;2517 % coord_x=[];2518 % else2519 % % VarIndex=CellVarIndex{imax};2520 % coord_x=VarType{imax}.coord_x;2521 % end2522 % if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)2523 % NbDim=UvData.NbDim;2524 % else2525 UvData.NbDim=NbDim;2526 % end2527 2506 if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates 2528 2507 XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; … … 2530 2509 eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors) 2531 2510 test_x=1;%test for unstructured coordinates 2532 elseif NbDim==2 2533 YName=UvData.Field.ListVarName{VarType{imax}.coord(1)}; %structured coordinates 2534 XName=UvData.Field.ListVarName{VarType{imax}.coord(2)}; 2535 elseif NbDim==3 2511 else %structured coordinate 2512 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2513 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2514 end 2515 if NbDim==3 2536 2516 ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D 2537 YName=UvData.Field.ListVarName{VarType{imax}.coord(2)};2538 XName=UvData.Field.ListVarName{VarType{imax}.coord(3)};2539 2517 eval(['ZMax=max(UvData.Field.' ZName ');']) 2540 2518 eval(['ZMin=min(UvData.Field.' ZName ');']) 2519 test_z=1; 2520 if isequal(ZMin,ZMax)%no z dependency 2521 NbDim=2; 2522 test_z=0; 2523 end 2541 2524 end 2542 2525 eval(['XMax=max(UvData.Field.' XName ');']) … … 2545 2528 eval(['YMin=min(UvData.Field.' YName ');']) 2546 2529 eval(['nbvec=length(UvData.Field.' XName ');']) 2547 if NbDim==3% 2548 if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z 2549 % ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; 2550 eval(['ZMax=max(UvData.Field.' ZName ');']) 2551 eval(['ZMin=min(UvData.Field.' ZName ');']) 2552 test_z=1; 2553 elseif isfield(UvData,'Z')% usual civ data 2554 ZMax=max(UvData.Z); 2555 ZMin=min(UvData.Z); 2556 test_z=1; 2557 end 2558 if isequal(ZMin,ZMax)%no z dependency 2559 NbDim=2; 2560 test_z=0; 2561 end 2562 end 2563 if test_x 2530 if test_x %unstructured coordinates 2564 2531 if test_z 2565 2532 UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector … … 2571 2538 VarIndex=CellVarIndex{imax}; % list of variable indices 2572 2539 DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable 2573 nbpoints_y=UvData.Field.DimValue(DimIndex(1)); 2574 nbpoints_x=UvData.Field.DimValue(DimIndex(2)); 2575 DX=(XMax-XMin)/nbpoints_x; 2576 DY=(YMax-YMin)/nbpoints_y; 2577 UvData.Field.Mesh=sqrt(DX*DY); 2578 end 2540 nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1)); 2541 nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim)); 2542 DX=(XMax-XMin)/(nbpoints_x-1); 2543 DY=(YMax-YMin)/(nbpoints_y-1); 2544 if NbDim==3 2545 nbpoints_z=UvData.Field.DimValue(DimIndex(1)); 2546 DZ=(ZMax-ZMin)/(nbpoints_z-1); 2547 UvData.Field.Mesh=sqrt(DX*DY*DZ); 2548 UvData.Field.ZMax=ZMax; 2549 UvData.Field.ZMin=ZMin; 2550 else 2551 UvData.Field.Mesh=sqrt(DX*DY); 2552 end 2553 end 2554 UvData.Field.NbDim=NbDim; 2579 2555 UvData.Field.XMax=XMax; 2580 2556 UvData.Field.XMin=XMin; 2581 UvData.Field.YMax=XMax; 2582 UvData.Field.YMin=XMin; 2583 if NbDim==3 2584 UvData.Field.ZMax=ZMax; 2585 UvData.Field.ZMin=ZMin; 2586 end 2587 2588 %case of structured coordinates 2589 2590 % if isempty(coord_x) && ~isempty(CellVarIndex) 2591 % VarIndex=CellVarIndex{imax}; % list of variable indices 2592 % DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable 2593 % if NbDim==3 2594 % nbpoints=UvData.Field.DimValue(DimIndex(1)); 2595 % if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable 2596 % ZName=UvData.Field.ListVarName{VarType{imax}.coord_3}; 2597 % eval(['UvData.ZMax=max(UvData.Field.' ZName ');']) 2598 % eval(['UvData.ZMin=min(UvData.Field.' ZName ');']) 2599 % else 2600 % testcoord_z=0; 2601 % if length(UvData.Field.VarAttribute)>=VarIndex(1) 2602 % if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid 2603 % Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1; 2604 % UvData.ZMax=max(Coord_z); 2605 % UvData.ZMin=min(Coord_z); 2606 % testcoord_z=1; 2607 % end 2608 % end 2609 % if ~testcoord_z 2610 % UvData.ZMin=1; 2611 % UvData.ZMax=UvData.Field.DimValue(DimIndex(1)); 2612 % end 2613 % end 2614 % Field.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1); 2615 % elseif NbDim==2 2616 % nbpoints_y=UvData.Field.DimValue(DimIndex(1)); 2617 % Yvar=VarType{imax}.coord_y; 2618 % if Yvar~=0 % x is a dimension variable 2619 % YName=UvData.Field.ListVarName{Yvar}; 2620 % eval(['UvData.YMax=max(UvData.Field.' YName ');']) 2621 % eval(['UvData.YMin=min(UvData.Field.' YName ');']) 2622 % else 2623 % testcoord_y=0; 2624 % if ~testcoord_y 2625 % UvData.YMin=1; 2626 % UvData.YMax=UvData.Field.DimValue(DimIndex(1)); 2627 % end 2628 % end 2629 % DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1); 2630 % nbpoints_x=UvData.Field.DimValue(DimIndex(2)); 2631 % Xvar=VarType{imax}.coord_x; 2632 % if Xvar~=0 % x is a dimension variable 2633 % XName=UvData.Field.ListVarName{Xvar}; 2634 % eval(['UvData.XMax=max(UvData.Field.' XName ');']) 2635 % eval(['UvData.XMin=min(UvData.Field.' XName ');']) 2636 % else 2637 % testcoord_x=0; 2638 % if ~testcoord_x 2639 % UvData.XMin=1; 2640 % UvData.XMax=UvData.Field.DimValue(DimIndex(2)); 2641 % end 2642 % end 2643 % DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1); 2644 % Field.Mesh= sqrt(DX*DY); 2645 % end 2646 % end 2647 2648 %create a default projection menuplane 2557 UvData.Field.YMax=YMax; 2558 UvData.Field.YMin=YMin; 2559 2560 %% create a default projection menuplane 2649 2561 UvData.Object{1}.Style='plane';%main plotting plane 2650 2562 UvData.Object{1}.ProjMode='projection';%main plotting plane 2563 UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat 2564 2565 2566 %% 3D case (menuvolume) 2567 if NbDim==3% && UvData.NewSeries 2568 test_set_object=1; 2569 hset_object=findobj(allchild(0),'tag','set_object'); 2570 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 2571 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 2572 if ~isempty(hset_object) 2573 hhset_object=guidata(hset_object); 2574 ZBounds_old(1)=get(hhset_object.z_slider,'Min'); 2575 ZBounds_old(2)=get(hhset_object.z_slider,'Max'); 2576 if isequal(ZBounds_old,ZBounds) 2577 test_set_object=0; 2578 else 2579 delete(test_set_object); 2580 end 2581 end 2582 if test_set_object% reinitiate set_object 2583 delete_object(1); 2584 UvData.Object{1}.Style='plane';%main plotting plane 2585 UvData.Object{1}.ProjMode='projection';%main plotting plane 2586 UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat 2587 UvData.Object{1}.NbDim=NbDim;%test for 3D objects 2588 UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane 2589 UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2590 UvData.Object{1}.Phi=0; 2591 UvData.Object{1}.Theta=0; 2592 UvData.Object{1}.Psi=0; 2593 UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 2594 PlotHandles=get_plot_handles(handles); 2595 UvData.Object{1}.Name='1-PLANE'; 2596 UvData.Object{1}.enable_plot=1; 2597 set_object(UvData.Object{1},PlotHandles,ZBounds); 2598 set(handles.list_object_1,'Value',1); 2599 end 2600 %multilevel case (single menuplane in a 3D space) 2601 elseif isfield(UvData,'Z') 2602 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') 2603 XmlData=UvData.XmlData; 2604 if isfield(XmlData,'PlanePos') 2605 UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); 2606 end 2607 if isfield(XmlData,'PlaneAngle') 2608 siz=size(XmlData.PlaneAngle); 2609 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) 2610 UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1); 2611 UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2); 2612 UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3); 2613 end 2614 elseif isfield(UvData,'ZIndex') 2615 UvData.Object{1}.ZObject=UvData.ZIndex; 2616 end 2617 end 2651 2618 if ~isfield(UvData.Object{1},'plotaxes') 2652 2619 UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis 2653 2620 set(handles.list_object_1,'Value',1); 2654 2621 set(handles.list_object_1,'String',{'1-PLANE'}); 2655 end2656 2657 %3D case (menuvolume)2658 if NbDim==3 && UvData.NewSeries2659 UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects2660 UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane2661 UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen2662 UvData.Object{1}.Phi=0;2663 UvData.Object{1}.Theta=0;2664 UvData.Object{1}.Psi=0;2665 UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR2666 PlotHandles=get_plot_handles(handles);2667 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider2668 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider2669 UvData.Object{1}.Name='1-PLANE';2670 UvData.Object{1}.enable_plot=1;2671 set_object(UvData.Object{1},PlotHandles,ZBounds);2672 set(handles.list_object_1,'Value',1);2673 %multilevel case (single menuplane in a 3D space)2674 elseif isfield(UvData,'Z')2675 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')2676 XmlData=UvData.XmlData;2677 if isfield(XmlData,'PlanePos')2678 UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);2679 end2680 if isfield(XmlData,'PlaneAngle')2681 siz=size(XmlData.PlaneAngle);2682 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)2683 UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);2684 UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);2685 UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);2686 end2687 elseif isfield(UvData,'ZIndex')2688 UvData.Object{1}.ZObject=UvData.ZIndex;2689 end2690 2622 end 2691 2623 … … 3569 3501 set(handles.uvmat,'UserData',UvData) 3570 3502 setfield(handles);% update the field structure ('civ1'....) 3571 if ~isfield(UvData,'NewSeries')| isequal(UvData.NewSeries,0)3503 if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0) 3572 3504 run0_Callback(hObject, eventdata, handles) 3573 3505 end … … 3830 3762 npx=size(UvData.Field.A,2); 3831 3763 npy=size(UvData.Field.A,1); 3832 xi= [0.5:npx-0.5];3833 yi= [0.5:npy-0.5];3764 xi=0.5:npx-0.5; 3765 yi=0.5:npy-0.5; 3834 3766 [Xi,Yi]=meshgrid(xi,yi); 3835 3767 if isfield(UvData,'Object') … … 3884 3816 RootPath=get(handles.RootPath,'String'); 3885 3817 RootFile=get(handles.RootFile,'String'); 3886 if ~isempty(RootFile)& (isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))3818 if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) 3887 3819 RootFile(1)=[]; 3888 3820 end … … 4184 4116 Amax=double(max(max(max(FieldHisto))));%max of image 4185 4117 if isequal(Amin,Amax) 4186 Histo.Txt=['uniform field =' num2str(Amin)];4118 msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]); 4187 4119 else 4188 Histo.ListVarName={FieldName,'histo'}; 4189 if numel(nxy)==2 4190 Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram 4191 else %color images 4192 Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram 4193 end 4194 %unit 4195 units=[]; %default 4196 for ivar=1:numel(Field.ListVarName) 4197 if strcmp(Field.ListVarName{ivar},FieldName) 4198 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') 4199 units=Field.VarAttribute{ivar}.units; 4200 break 4120 Histo.ListVarName={FieldName,'histo'}; 4121 if isequal(Field.NbDim,3) 4122 Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram 4123 else 4124 if numel(nxy)==2 4125 Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram 4126 else 4127 Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram 4201 4128 end 4202 4129 end 4203 end 4204 if ~isempty(units) 4205 Histo.VarAttribute{1}.units=units; 4206 end 4207 eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo 4208 for col=1:size(FieldHisto,3) 4209 B=FieldHisto(:,:,col); 4210 C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector 4211 eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram 4212 end 4213 set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect) 4214 set(haxes,'YLimMode','auto') 4215 plot_field(Histo,haxes); 4130 %unit 4131 units=[]; %default 4132 for ivar=1:numel(Field.ListVarName) 4133 if strcmp(Field.ListVarName{ivar},FieldName) 4134 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') 4135 units=Field.VarAttribute{ivar}.units; 4136 break 4137 end 4138 end 4139 end 4140 if ~isempty(units) 4141 Histo.VarAttribute{1}.units=units; 4142 end 4143 eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo 4144 if isequal(Field.NbDim,3) 4145 C=reshape(double(FieldHisto),1,[]);% reshape in a vector 4146 eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram 4147 else 4148 for col=1:size(FieldHisto,3) 4149 B=FieldHisto(:,:,col); 4150 C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector 4151 eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram 4152 end 4153 end 4154 set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect) 4155 set(haxes,'YLimMode','auto') 4156 plot_field(Histo,haxes); 4216 4157 end 4217 4158 end … … 4376 4317 % colcode.CName= list_code{index_code(1)}; % selected field used for vector color 4377 4318 colcode.FixedCbounds=1; 4378 vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)* [0.5:width-0.5]/width;%sample of vec_C values from min to max4319 vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max 4379 4320 [colorlist,col_vec]=set_col_vec(colcode,vec_C); 4380 4321 oneheight=ones(1,height); … … 4510 4451 hother=findobj('Tag','proj_object');%find all the proj objects 4511 4452 for iobj=1:length(hother) 4512 if isequal(get(hother(iobj),'Type'),'rectangle')| isequal(get(hother(iobj),'Type'),'patch')4453 if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') 4513 4454 set(hother(iobj),'EdgeColor','b') 4514 4455 if isequal(get(hother(iobj),'FaceColor'),'m') … … 4791 4732 end 4792 4733 end 4793 % flag=~flag;4734 4794 4735 %mask name 4795 4736 RootPath=get(handles.RootPath,'String'); 4796 4737 RootFile=get(handles.RootFile,'String'); 4797 if ~isempty(RootFile)& (isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))4738 if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) 4798 4739 RootFile(1)=[]; 4799 4740 end
Note: See TracChangeset
for help on using the changeset viewer.