- Timestamp:
- Jun 30, 2013, 11:16:45 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r650 r654 1 %'calc_field_interp': defines fields (velocity, vort, div...) from civ data and calculate them 2 % for projection with linear interpolation 1 %'calc_field_interp': calculate fields (velocity, vort, div...) using linear interpolation if requested 3 2 %--------------------------------------------------------------------- 4 3 % [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) … … 10 9 % 11 10 % INPUT: 12 % Coord(nbpoints,2): matrix of x,y coordinates of the input data points11 % Coord(nbpoints,2): matrix of x,y coordinates of the input data points 13 12 % Data: inputfield structure 14 13 % FieldName: string representing the field to calculate, or cell array of fields (as displayed in uvmat/FieldName) 15 % XI, YI: set of x and y coordiantes where the fields need to be linearly interpolated 16 14 % XI, YI: set of x and y coordinates where the fields need to be linearly interpolated, 15 % if XI, YI are missing, there is no interpolation (case of colors in vector plots) 16 % 17 17 function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI) 18 18 … … 25 25 if ischar(FieldName),FieldName={FieldName};end 26 26 check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated 27 check_interp=ones(size(FieldName));% default, =1 to mark the variables which can be interpolated (not ancillary) 27 28 Operator=cell(size(FieldName)); 28 29 … … 35 36 if isempty(ivar) 36 37 check_skipped(ilist)=1; %variable not found 37 else 38 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 38 39 if isfield(Data.VarAttribute{ivar},'Role') &&... 39 40 (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag')) 40 check_skipped(ilist)=1; % ancillary variable, not interpolated 41 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 42 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 41 check_interp(ilist)=0; % ancillary variable, not interpolated 43 42 end 43 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 44 44 end 45 45 else … … 88 88 case 'vec' 89 89 if exist('XI','var') 90 if check_interp 90 91 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 91 92 VarVal{nbvar+2}=F.(VName{ilist})(XI,YI); 93 end 92 94 else 93 95 VarVal{nbvar+1}=Data.(UName{ilist}); … … 100 102 case 'norm' 101 103 if exist('XI','var') 104 if check_interp 102 105 U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI); 103 106 V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI); 107 end 104 108 else 105 109 U2=Data.(UName{ilist}).*Data.(UName{ilist}); … … 111 115 case {'curl','div','strain'} 112 116 if exist('XI','var') 117 if check_interp 113 118 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 119 end 114 120 else 115 121 VarVal{nbvar+1}=Data.(UName{ilist}); … … 120 126 if ~isempty(FieldName{ilist}) 121 127 if exist('XI','var') 128 if check_interp 122 129 VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI); 130 end 123 131 else 124 132 VarVal{nbvar+1}= Data.(FieldName{ilist}); -
trunk/src/check_files.m
r648 r654 54 54 'fill_GUI';...% fill a GUI with a set of parameters from a Matlab structure 55 55 'filter_tps';...% find the thin plate spline coefficients for interpolation-smoothing 56 'find_field_bounds': % find the boounds and typical meshs of coordinates 56 57 'find_field_cells';...% group the variables of a 'field object' into 'field cells' and specify their structure 57 58 'find_file_series';...% check the content of an input file and find the corresponding file series -
trunk/src/geometry_calib.m
r630 r654 50 50 % Edit the above text to modify the response to help geometry_calib 51 51 52 % Last Modified by GUIDE v2.5 29-Ju l-2012 08:46:0952 % Last Modified by GUIDE v2.5 29-Jun-2013 23:52:36 53 53 54 54 % Begin initialization code - DO NOT edit … … 208 208 set(handles.geometry_calib,'UserData',UserData) 209 209 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 210 MenuPlot_Callback(hObject, eventdata, handles)210 PLOT_Callback(hObject, eventdata, handles) 211 211 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake) 212 212 ListCoord_Callback(hObject, eventdata, handles) … … 748 748 set(handles.ListCoord,'Value',1)% refresh the display of coordinates 749 749 set(handles.ListCoord,'String',{'......'}) 750 MenuPlot_Callback(hObject, eventdata, handles) 750 PLOT_Callback(hObject, eventdata, handles) 751 751 752 752 753 %------------------------------------------------------------------------ … … 800 801 %update the plot 801 802 ListCoord_Callback(hObject, eventdata, handles) 802 MenuPlot_Callback(hObject, eventdata, handles)803 PLOT_Callback(hObject, eventdata, handles) 803 804 804 805 %------------------------------------------------------------------------ … … 917 918 plot_field(Data) 918 919 919 %------------------------------------------------------------------------920 function MenuPlot_Callback(hObject, eventdata, handles)921 %------------------------------------------------------------------------922 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle923 %UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface924 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat925 %hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat926 h_menu_coord=findobj(huvmat,'Tag','TransformName');927 menu=get(h_menu_coord,'String');928 choice=get(h_menu_coord,'Value');929 if iscell(menu)930 option=menu{choice};931 else932 option='px'; %default933 end934 Coord_cell=get(handles.ListCoord,'String');935 ObjectData=read_geometry_calib(Coord_cell);936 %ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object937 if ~isempty(ObjectData.Coord)938 if isequal(option,'phys')939 ObjectData.Coord=ObjectData.Coord(:,1:3);940 elseif isequal(option,'px')||isequal(option,'')941 ObjectData.Coord=ObjectData.Coord(:,4:5);942 else943 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ')944 end945 end946 947 set(0,'CurrentFigure',huvmat)948 set(huvmat,'CurrentAxes',hhuvmat.PlotAxes)949 hh=findobj('Tag','calib_points');950 if ~isempty(ObjectData.Coord) && isempty(hh)951 hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+');952 elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot953 delete(hh)954 else955 set(hh,'XData',ObjectData.Coord(:,1))956 set(hh,'YData',ObjectData.Coord(:,2))957 end958 pause(.1)959 figure(handles.geometry_calib)960 920 961 921 % -------------------------------------------------------------------- … … 969 929 web([helpfile '#geometry_calib']) 970 930 end 931 932 % -------------------------------------------------------------------- 933 function MenuSetScale_Callback(hObject, eventdata, handles) 934 % hObject handle to MenuSetScale (see GCBO) 935 % eventdata reserved - to be defined in a future version of MATLAB 936 % handles structure with handles and user data (see GUIDATA) 937 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','') 938 %create test points 939 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 940 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 941 Xima=0.8*[UvData.Field.XMin UvData.Field.XMax UvData.Field.XMax UvData.Field.XMin]'; 942 Yima=0.8*[UvData.Field.YMin UvData.Field.YMax UvData.Field.YMax UvData.Field.YMin]'; 943 x=Xima/str2num(answer); 944 y=Yima/str2num(answer); 945 for j=1:4 946 for i=1:5 947 Coord{j,1}=num2str(x);% 948 Coord{j,2}=num2str(y);% 949 Coord{j,3}='0';% 950 Coord{j,4}=num2str(Xima);% 951 Coord{j,5}=num2str(Yima);% 952 end 953 end 954 955 Tabchar=cell2tab(Coord,' | '); 956 Tabchar=[Tabchar ;{'......'}]; 957 set(handles.ListCoord,'String',Tabchar) 971 958 972 959 %------------------------------------------------------------------------ … … 1140 1127 set(handles.ListCoord,'Value',1) 1141 1128 set(handles.ListCoord,'String',Tabchar) 1142 MenuPlot_Callback(hObject, eventdata, handles)1129 PLOT_Callback(hObject, eventdata, handles) 1143 1130 1144 1131 %----------------------------------------------------------------------- … … 1233 1220 set(handles.ListCoord,'Value',1) 1234 1221 set(handles.ListCoord,'String',Tabchar) 1235 MenuPlot_Callback(handles.geometry_calib, [], handles)1222 PLOT_Callback(handles.geometry_calib, [], handles) 1236 1223 1237 1224 % ----------------------------------------------------------------------- … … 1280 1267 set(handles.ListCoord,'String',Coord_cell) 1281 1268 ListCoord_Callback(hObject, eventdata, handles) 1282 MenuPlot_Callback(hObject,eventdata,handles)1269 PLOT_Callback(hObject,eventdata,handles) 1283 1270 end 1284 1271 end … … 1357 1344 CoordCell=reshape(CoordCell,[],5); 1358 1345 Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1359 MenuPlot_Callback(handles.geometry_calib, [], handles)1346 PLOT_Callback(handles.geometry_calib, [], handles) 1360 1347 end 1361 1348 set(handles.calib_type,'Value',val_cal) … … 1405 1392 % Hint: delete(hObject) closes the figure 1406 1393 delete(hObject); 1394 1395 %------------------------------------------------------------------------ 1396 % --- Executes on button press in PLOT. 1397 %------------------------------------------------------------------------ 1398 function PLOT_Callback(hObject, eventdata, handles) 1399 1400 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 1401 %UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 1402 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat 1403 %hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat 1404 h_menu_coord=findobj(huvmat,'Tag','TransformName'); 1405 menu=get(h_menu_coord,'String'); 1406 choice=get(h_menu_coord,'Value'); 1407 if iscell(menu) 1408 option=menu{choice}; 1409 else 1410 option='px'; %default 1411 end 1412 Coord_cell=get(handles.ListCoord,'String'); 1413 ObjectData=read_geometry_calib(Coord_cell); 1414 %ObjectData=read_geometry_calib(handles);%read the interface input parameters defining the object 1415 if ~isempty(ObjectData.Coord) 1416 if isequal(option,'phys') 1417 ObjectData.Coord=ObjectData.Coord(:,1:3); 1418 elseif isequal(option,'px')||isequal(option,'') 1419 ObjectData.Coord=ObjectData.Coord(:,4:5); 1420 else 1421 msgbox_uvmat('ERROR','the choice in menu_coord of uvmat must be '''', px or phys ') 1422 end 1423 end 1424 1425 set(0,'CurrentFigure',huvmat) 1426 set(huvmat,'CurrentAxes',hhuvmat.PlotAxes) 1427 hh=findobj('Tag','calib_points'); 1428 if ~isempty(ObjectData.Coord) && isempty(hh) 1429 hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color','m','Tag','calib_points','LineStyle','.','Marker','+'); 1430 elseif isempty(ObjectData.Coord)%empty list of points, suppress the plot 1431 delete(hh) 1432 else 1433 set(hh,'XData',ObjectData.Coord(:,1)) 1434 set(hh,'YData',ObjectData.Coord(:,2)) 1435 end 1436 pause(.1) 1437 figure(handles.geometry_calib) 1438 1439 1440 -
trunk/src/get_field.m
r648 r654 140 140 set(handles.ordinate,'Value',1)% fill the menu of y vector components 141 141 set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components 142 if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') 143 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'}) 144 else 145 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) 146 end 142 147 if Field.MaxDim>=2 % case of 2D (or 3D) fields 143 148 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') … … 149 154 set(handles.FieldOption,'Value',2) 150 155 end 156 151 157 else % case of 1D fields 152 158 set(handles.FieldOption,'Value',1) … … 338 344 switch FieldOption 339 345 case '1D plot' 346 set(handles.Coordinates,'Visible','on') 340 347 set(handles.PanelOrdinate,'Visible','on') 341 348 pos=get(handles.PanelOrdinate,'Position'); … … 352 359 ordinate_Callback(hObject, eventdata, handles) 353 360 case 'scalar' 361 set(handles.Coordinates,'Visible','on') 354 362 set(handles.PanelOrdinate,'Visible','off') 355 363 set(handles.PanelScalar,'Visible','on') … … 364 372 scalar_Callback(hObject, eventdata, handles) 365 373 case 'vectors' 374 set(handles.Coordinates,'Visible','on') 366 375 set(handles.PanelOrdinate,'Visible','off') 367 376 set(handles.PanelScalar,'Visible','off') … … 375 384 set(handles.Y_title,'Visible','on') 376 385 vector_Callback(handles) 386 case 'civdata...' 387 set(handles.PanelOrdinate,'Visible','off') 388 set(handles.PanelScalar,'Visible','off') 389 set(handles.PanelVectors,'Visible','off') 390 set(handles.Coordinates,'Visible','off') 377 391 end 378 392 -
trunk/src/msgbox_uvmat.m
r599 r654 1 1 %'msgbox_uvmat': associated with GUI msgbox_uvmat.fig to display message boxes, for error, warning or input calls 2 % msgbox_uvmat(title,display) 2 % 3 % answer=msgbox_uvmat(title,display,default_answer,Position) 3 4 % 4 5 % OUTPUT: -
trunk/src/proj_field.m
r653 r654 893 893 norm_plane(3)=OmAxis(3)*coeff+cos_om; 894 894 end 895 testangle=~isequal(PlaneAngle,[0 0 0]) ;% && ~test90y && ~test90x;%=1 for slanted plane895 testangle=~isequal(PlaneAngle,[0 0 0])||~isequal(ObjectData.Coord(1:2),[0 0 ]) ;% && ~test90y && ~test90x;%=1 for slanted plane 896 896 897 897 %% mesh sizes DX and DY … … 984 984 %% group the variables (fields of 'FieldData') in cells of variables with the same dimensions 985 985 [CellInfo,NbDimArray,errormsg]=find_field_cells(FieldData); 986 986 987 if ~isempty(errormsg) 987 988 errormsg=['error in proj_field/proj_plane:' errormsg]; 988 989 return 989 990 end 990 991 %% projection modes 992 check_grid=0; 991 check_grid=zeros(size(CellInfo));% =1 if a grid is needed , =0 otherwise, for each field cell 992 993 993 ProjMode=cell(size(CellInfo)); 994 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates 995 ProjMode{icell}=ObjectData.ProjMode; 996 if isfield(CellInfo{icell},'ProjModeRequest') 997 switch CellInfo{icell}.ProjModeRequest 998 case 'interp_lin' 999 ProjMode{icell}='interp_lin'; 1000 case 'interp_tps' 1001 ProjMode{icell}='interp_tps'; 1002 end 1003 end 1004 if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps') 1005 check_grid=1; 1006 end 1007 end 1008 1009 %% define the new coordinates in case of interpolation on a grid 1010 if check_grid 1011 AYName='coord_y'; 1012 AXName='coord_x'; 1013 ProjData.ListVarName={'coord_y','coord_x'}; 1014 ProjData.VarDimName={'coord_y','coord_x'}; 1015 ProjData.VarAttribute={[],[]}; 994 for icell=1:numel(CellInfo) 995 ProjMode{icell}=ObjectData.ProjMode;% projection mode of the plane object 996 end 997 icell_grid=[];% field cell index which defines the grid 998 if ~strcmp(ObjectData.ProjMode,'projection') 999 %% define the new coordinates in case of interpolation on a imposed grid 1016 1000 if ~testYMin 1017 1001 errormsg='min Y value not defined for the projection grid';return … … 1026 1010 errormsg='max X value not defined for the projection grid';return 1027 1011 end 1028 ProjData.coord_y=[YMin YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1029 ProjData.coord_x=[XMin XMax]; 1030 coord_x_proj=XMin:DX:XMax; 1031 coord_y_proj=YMin:DY:YMax; 1032 [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1033 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1034 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1035 end 1036 1012 else 1013 %% case of a grid requested by the input field 1014 1015 for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates 1016 if isfield(CellInfo{icell},'ProjModeRequest') 1017 switch CellInfo{icell}.ProjModeRequest 1018 case 'interp_lin' 1019 ProjMode{icell}='interp_lin'; 1020 case 'interp_tps' 1021 ProjMode{icell}='interp_tps'; 1022 end 1023 end 1024 if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps') 1025 check_grid(icell)=1; 1026 end 1027 if strcmp(CellInfo{icell}.CoordType,'grid')&&NbDimArray(icell)>=2 1028 if ~testangle && isempty(icell_grid)% if the input gridded data is not modified, choose the first one in case of multiple gridded field cells 1029 icell_grid=icell; 1030 ProjMode{icell}='projection'; 1031 end 1032 check_grid(icell)=1; 1033 end 1034 end 1035 if ~isempty(find(check_grid))% if a grid is requested by the input field 1036 if isempty(icell_grid)% if the grid is not given by cell #icell_grid 1037 if ~isfield(FieldData,'XMax') 1038 FieldData=find_field_bounds(FieldData); 1039 % CellIndex=find(check_grid); 1040 % for igrid=1:numel(CellIndex) 1041 % icell=CellIndex(igrid);% TODO: recalculate coordinates here to get the bounds in the rotated coordinates 1042 % NbDim=NbDimArray(icell); 1043 % for idim=1:NbDim %loop on space dimensions 1044 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension 1045 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field 1046 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim 1047 % 1048 % 1049 % 1050 % else 1051 % Coord_i_str=['Coord_' num2str(idim)]; 1052 % DCoord_min(idim)=1;%default 1053 % Coord{idim}=[0.5 DimValue(idim)-0.5]; 1054 % test_direct(idim)=1; 1055 % end 1056 % % default bounds, case of gridded data 1057 % if strcmp(CellInfo{icell}.CoordType,'grid') 1058 % % find default mesh 1059 % for idim=1:NbDim %loop on space dimensions 1060 % test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default 1061 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension 1062 % DimValue=size(FieldData.(FieldData.ListVarName{ivar})); 1063 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim 1064 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field 1065 % if numel(Coord{idim})==2 %input array defined on a regular grid 1066 % DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim); 1067 % Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim)); 1068 % else 1069 % DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field 1070 % DCoord_min(idim)=min(DCoord); 1071 % DCoord_max=max(DCoord); 1072 % if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000) 1073 % msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m']) 1074 % return 1075 % end 1076 % test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity 1077 % end 1078 % test_direct(idim)=(DCoord_min(idim)>0); 1079 % else % no variable associated with the dimension #idim, the coordinate value is set equal to the matrix index by default 1080 % % Coord_i_str=['Coord_' num2str(idim)]; 1081 % % DCoord_min(idim)=1;%default 1082 % % Coord{idim}=[0.5 DimValue(idim)-0.5]; 1083 % % test_direct(idim)=1; 1084 % end 1085 % end 1086 % if isempty(DY) 1087 % DY=abs(DCoord_min(NbDim-1)); 1088 % end 1089 % npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol 1090 % if isempty(DX) 1091 % DX=abs(DCoord_min(NbDim)); 1092 % end 1093 % npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol 1094 % for idim=1:NbDim 1095 % if test_interp(idim) 1096 % 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 1097 % end 1098 % end 1099 % Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY); 1100 % test_direct_y=test_direct(NbDim-1); 1101 % Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX); 1102 % test_direct_x=test_direct(NbDim); 1103 % DAX=DCoord_min(NbDim); 1104 % DAY=DCoord_min(NbDim-1); 1105 % minAX=min(Coord_x); 1106 % maxAX=max(Coord_x); 1107 % minAY=min(Coord_y); 1108 % maxAY=max(Coord_y); 1109 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes 1110 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2); 1111 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame 1112 % ycor_new=-xcorner*sin_om+ycorner*cos_om; 1113 % if ~testXMax 1114 % XMax(igrid)=max(xcor_new); 1115 % end 1116 % if ~testXMin 1117 % XMin(igrid)=min(xcor_new); 1118 % end 1119 % if ~testYMax 1120 % YMax(igrid)=max(ycor_new); 1121 % end 1122 % if ~testYMin 1123 % YMin(igrid)=min(ycor_new); 1124 % end 1125 % DX(igrid)=(maxAX-minAX)/(DimValue(NbDim)-1); 1126 % DY(igrid)=(maxAY-minAY)/(DimValue(NbDim-1)-1); 1127 % if NbDim==3 1128 % DZ(igrid)=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1); 1129 % if ~test_direct(1) 1130 % DZ=-DZ; 1131 % end 1132 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1)); 1133 % test_direct_z=test_direct(1); 1134 % end 1135 % else 1136 % 1137 % end 1138 % YMax=max(YMax); 1139 % YMin=min(YMin); 1140 % XMax=max(XMax); 1141 % XMin=min(XMin); 1142 end 1143 end 1144 end 1145 end 1146 if ~isempty(find(check_grid))||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used 1147 if isempty(icell_grid)||~strcmp(ObjectData.ProjMode,'projection')%no existing gridded data used 1148 AYName='coord_y'; 1149 AXName='coord_x'; 1150 if ~strcmp(ObjectData.ProjMode,'projection') 1151 ProjData.coord_y=[ObjectData.RangeY(1) ObjectData.RangeY(2)];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1152 ProjData.coord_x=[ObjectData.RangeX(1) ObjectData.RangeX(2)]; 1153 coord_x_proj=ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2); 1154 coord_y_proj=ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2); 1155 else 1156 ProjData.coord_y=[FieldData.YMin FieldData.YMax];%note that if projection is done on a grid, the Min and Max along each direction must have been defined 1157 ProjData.coord_x=[FieldData.XMin FieldData.XMax]; 1158 coord_x_proj=FieldData.XMin:FieldData.CoordMesh:FieldData.XMax; 1159 coord_y_proj=FieldData.YMin:FieldData.CoordMesh:FieldData.YMax; 1160 end 1161 [X,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates 1162 XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system 1163 YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3)); 1164 else% we use the existing grid from field cell #icell_grid 1165 NbDim=NbDimArray(icell_grid); 1166 AYName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection) 1167 AXName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection) 1168 ProjData.(AYName)=FieldData.(AYName); % new (projected ) y coordinates 1169 ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates 1170 end 1171 ProjData.ListVarName={AYName,AXName}; 1172 ProjData.VarDimName={AYName,AXName}; 1173 ProjData.VarAttribute={[],[]}; 1174 end 1175 1037 1176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1038 % LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS1177 % LOOP ON FIELD CELLS, PROJECT VARIABLES 1039 1178 % CellVarIndex=cells of variable index arrays 1040 1179 %ivar_new=0; % index of the current variable in the projected field … … 1050 1189 end 1051 1190 VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list FieldData.ListVarName 1052 % ivar_U=[];ivar_V=[];ivar_W=[];1053 % if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')1054 % ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;1055 % ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;1056 % elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')1057 % ivar_U=CellInfo{icell}.VarIndex_vector_x;1058 % ivar_V=CellInfo{icell}.VarIndex_vector_y;1059 % end1060 % if isfield(CellInfo{icell},'VarIndex_vector_z')1061 % ivar_W=CellInfo{icell}.VarIndex_vector_z;1062 % end1191 % ivar_U=[];ivar_V=[];ivar_W=[]; 1192 % if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps') 1193 % ivar_U=CellInfo{icell}.VarIndex_vector_x_tps; 1194 % ivar_V=CellInfo{icell}.VarIndex_vector_y_tps; 1195 % elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') 1196 % ivar_U=CellInfo{icell}.VarIndex_vector_x; 1197 % ivar_V=CellInfo{icell}.VarIndex_vector_y; 1198 % end 1199 % if isfield(CellInfo{icell},'VarIndex_vector_z') 1200 % ivar_W=CellInfo{icell}.VarIndex_vector_z; 1201 % end 1063 1202 %dimensions 1064 1203 DimCell=FieldData.VarDimName{VarIndex(1)}; … … 1252 1391 Coord_x=[]; 1253 1392 1254 % find default mesh1255 for idim=1:NbDim %loop on space dimensions1256 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default1257 ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension1258 if ~isequal(ivar,0)% a variable corresponds to the dimension #idim1259 Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field1260 if numel(Coord{idim})==2 %input array defined on a regular grid1261 DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);1262 Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));1263 else1264 DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field1265 DCoord_min(idim)=min(DCoord);1266 DCoord_max=max(DCoord);1267 if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)1268 msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m'])1269 return1270 end1271 test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity1272 end1273 test_direct(idim)=(DCoord_min(idim)>0);1274 else % no variable associated with the dimension #idim, the coordinate value is set equal to the matrix index by default1275 Coord_i_str=['Coord_' num2str(idim)];1276 DCoord_min(idim)=1;%default1277 Coord{idim}=[0.5 DimValue(idim)-0.5];1278 test_direct(idim)=1;1279 end1280 end1281 if isempty(DY)1282 DY=abs(DCoord_min(NbDim-1));1283 end1284 npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol1285 if isempty(DX)1286 DX=abs(DCoord_min(NbDim));1287 end1288 npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol1289 for idim=1:NbDim1290 if test_interp(idim)1291 DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri1292 end1293 end1294 Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);1295 test_direct_y=test_direct(NbDim-1);1296 Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);1297 test_direct_x=test_direct(NbDim);1298 DAX=DCoord_min(NbDim);1299 DAY=DCoord_min(NbDim-1);1300 1393 1301 % default bounds 1302 minAX=min(Coord_x); 1303 maxAX=max(Coord_x); 1304 minAY=min(Coord_y); 1305 maxAY=max(Coord_y); 1306 xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes 1307 ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2); 1308 xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame 1309 ycor_new=-xcorner*sin_om+ycorner*cos_om; 1310 if ~testXMax 1311 XMax=max(xcor_new); 1312 end 1313 if ~testXMin 1314 XMin=min(xcor_new); 1315 end 1316 if ~testYMax 1317 YMax=max(ycor_new); 1318 end 1319 if ~testYMin 1320 YMin=min(ycor_new); 1321 end 1322 DXinit=(maxAX-minAX)/(DimValue(NbDim)-1); 1323 DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1); 1324 if DX==0 1325 DX=DXinit; 1326 end 1327 if DY==0 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); 1337 end 1394 1395 % % default bounds 1396 % minAX=min(Coord_x); 1397 % maxAX=max(Coord_x); 1398 % minAY=min(Coord_y); 1399 % maxAY=max(Coord_y); 1400 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes 1401 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2); 1402 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame 1403 % ycor_new=-xcorner*sin_om+ycorner*cos_om; 1404 % if ~testXMax 1405 % XMax=max(xcor_new); 1406 % end 1407 % if ~testXMin 1408 % XMin=min(xcor_new); 1409 % end 1410 % if ~testYMax 1411 % YMax=max(ycor_new); 1412 % end 1413 % if ~testYMin 1414 % YMin=min(ycor_new); 1415 % end 1416 % DXinit=(maxAX-minAX)/(DimValue(NbDim)-1); 1417 % DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1); 1418 % if DX==0 1419 % DX=DXinit; 1420 % end 1421 % if DY==0 1422 % DY=DYinit; 1423 % end 1424 % if NbDim==3 1425 % DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1); 1426 % if ~test_direct(1) 1427 % DZ=-DZ; 1428 % end 1429 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1)); 1430 % test_direct_z=test_direct(1); 1431 % end 1338 1432 %define new coordiantes if not already done by the definition of a projection grid 1339 1433 if ~check_grid 1340 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection) 1341 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection) 1342 ListVarName=[ListVarName {AYName} {AXName}];% update the list of projected variables 1343 VarDimName=[VarDimName {AYName} {AXName}];% update the corresponding list of dimensions 1344 VarAttribute=[VarAttribute {[]} {[]}];% update the list of attributes 1345 ProjData.(AYName)=[YMin YMax]; % new (projected ) y coordinates 1346 ProjData.(AXName)=[XMin XMax]; % new (projected ) y coordinates 1434 1435 1347 1436 end 1348 1437 … … 1370 1459 VarAttribute=[VarAttribute FieldData.VarAttribute(VarIndex)]; 1371 1460 end 1461 1372 1462 ProjData.(AYName)=FieldData.(AYName); 1373 1463 ProjData.(AXName)=FieldData.(AXName); … … 1540 1630 eval(['ProjData.' WName '=NormVec_X*ProjData.' UName '+ NormVec_Y*ProjData.' VName '+ NormVec_Z* ProjData.' WName ';']); 1541 1631 end 1542 % if ~isequal(Psi,0)1543 % eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']);1544 % eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']);1545 % end1632 % if ~isequal(Psi,0) 1633 % eval(['ProjData.' UName '=cos(Psi)* ProjData.' UName '- sin(Psi)*ProjData.' VName ';']); 1634 % eval(['ProjData.' VName '=sin(Psi)* ProjData.' UName '+ cos(Psi)*ProjData.' VName ';']); 1635 % end 1546 1636 end 1547 1637 end … … 1552 1642 % SubData.VarDimName={}; 1553 1643 % SubData.VarAttribute={}; 1554 % check_remove=zeros(size(ProjData.ListVarName)); 1644 % check_remove=zeros(size(ProjData.ListVarName)); 1555 1645 % for iproj=1:numel(ProjData.VarAttribute) 1556 1646 % if isfield(ProjData.VarAttribute{iproj},'CheckSub')&&isequal(ProjData.VarAttribute{iproj}.CheckSub,1) … … 1560 1650 % SubData.VarAttribute=[SubData.VarAttribute ProjData.VarAttribute{iproj}]; 1561 1651 % SubData.(VarName)=ProjData.(VarName); 1562 % check_remove(iproj)=1; 1652 % check_remove(iproj)=1; 1563 1653 % end 1564 1654 % end … … 1569 1659 % ProjData.VarAttribute(ind_remove)=[]; 1570 1660 % ProjData=sub_field(ProjData,[],SubData); 1571 % end 1661 % end 1572 1662 1573 1663 %----------------------------------------------------------------- 1574 %projection in a volume 1575 function [ProjData,errormsg] = proj_volume(FieldData, ObjectData) 1664 %projection in a volume 1665 function [ProjData,errormsg] = proj_volume(FieldData, ObjectData) 1666 1576 1667 %----------------------------------------------------------------- 1577 1668 ProjData=FieldData;%default output … … 1584 1675 end 1585 1676 1586 %% rotation angles 1587 VolumeAngle=[0 0 0]; 1677 %% rotation angles 1678 VolumeAngle=[0 0 0]; 1588 1679 norm_plane=[0 0 1]; 1589 1680 if isfield(ObjectData,'Angle')&& isequal(size(ObjectData.Angle),[1 3])&& ~isequal(ObjectData.Angle,[0 0 0]) -
trunk/src/read_civdata.m
r651 r654 73 73 switch FieldNames{ilist} 74 74 case{'U','V','norm(U,V)'} 75 if ~strcmp(FieldNames{1},'vec(U,V)')% if the scalar is not used as color of vectors 75 76 ProjModeRequest='interp_lin'; 77 end 76 78 case {'curl(U,V)','div(U,V)','strain(U,V)'} 77 79 ProjModeRequest='interp_tps'; -
trunk/src/read_field.m
r648 r654 49 49 end 50 50 end 51 check_colorvar=zeros(size(InputField)); 51 52 if isfield(ParamIn,'ColorVar') 52 53 InputField=[ParamIn.FieldName {ParamIn.ColorVar}]; 53 check_colorvar =1;54 check_colorvar(numel(InputField))=1; 54 55 end 55 56 end … … 70 71 for ilist=1:numel(InputField) 71 72 r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); 72 if isempty(r) 73 if isempty(r)% no operator used 73 74 ListVar=[ListVar InputField(ilist)]; 75 if check_colorvar(ilist) 76 Role{numel(ListVar)}='ancillary';% not projected with interpolation 77 ProjModeRequest{numel(ListVar)}=''; 78 else 74 79 Role{numel(ListVar)}='scalar'; 75 80 ProjModeRequest{numel(ListVar)}='interp_lin';%scalar field (requires interpolation for plot) 76 else 81 end 82 else % an operator 'vec' or 'norm' is used 77 83 ListVar=[ListVar {r.UName,r.VName}]; 78 84 Role{numel(ListVar)}='vector_y'; 79 85 Role{numel(ListVar)-1}='vector_x'; 80 switch r.Operator 81 case 'norm' 86 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm') 82 87 ProjModeRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot) 83 88 ProjModeRequest{numel(ListVar)}='interp_lin'; 84 otherwise89 else 85 90 ProjModeRequest{numel(ListVar)-1}=''; 86 91 ProjModeRequest{numel(ListVar)}=''; 87 92 end 88 93 end 89 end90 if check_colorvar91 Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)92 94 end 93 95 if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array -
trunk/src/series.m
r651 r654 120 120 121 121 %% list of builtin functions in the mebu ActionName 122 ActionList={'check_data_files';'aver_stat';'time_series';' merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback122 ActionList={'check_data_files';'aver_stat';'time_series';'civ_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback 123 123 NbBuiltinAction=numel(ActionList); 124 124 [path_series,name,ext]=fileparts(which('series'));% path to the GUI series -
trunk/src/set_col_vec.m
r517 r654 53 53 maxC=max(vec_C); 54 54 end 55 colcode_out.Min C=minC;56 colcode_out.Max C=maxC;55 colcode_out.MinVec=minC; 56 colcode_out.MaxVec=maxC; 57 57 if strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation 58 58 if isfield(colcode,'ColCode1') -
trunk/src/uvmat.m
r651 r654 2418 2418 % abstime_1=[]; 2419 2419 % end 2420 set(handles.TimeValue,'String',num2str(abstime)) 2420 2421 abstime_1=[]; 2421 2422 TimeName_1=get(handles.TimeName_1,'String'); … … 2480 2481 2481 2482 %% analyse input field 2482 [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2483 if ~isempty(errormsg) 2484 errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error 2485 return 2486 end 2487 2488 NbDim=max(NbDimArray);% spatial dimension of the input field 2489 imax=find(NbDimArray==NbDim);% indices of field cells to consider 2490 if isfield(UvData.Field,'NbDim') 2491 NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates 2492 end 2493 2494 %% get bounds and mesh (needed to propose default options for projection objects) 2495 if NbDim>1 2496 CoordMax=zeros(numel(imax),NbDim); 2497 CoordMin=zeros(numel(imax),NbDim); 2498 Mesh=zeros(1,numel(imax)); 2499 for ind=1:numel(imax) 2500 if strcmp(CellInfo{imax(ind)}.CoordType,'tps') 2501 CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable 2502 CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case) 2503 CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case) 2504 CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3); 2505 CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case) 2506 else 2507 XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; 2508 YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; 2509 CoordMax(ind,NbDim)=max(max(UvData.Field.(XName))); 2510 CoordMin(ind,NbDim)=min(min(UvData.Field.(XName))); 2511 CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName))); 2512 CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName))); 2513 % test_x=1;%test for unstructured coordinates 2514 if NbDim==3 2515 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; 2516 CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName))); 2517 CoordMin(ind,1)=min(min(UvData.Field.(ZName))); 2518 end 2519 end 2520 switch CellInfo{imax(ind)}.CoordType 2521 2522 case {'scattered','tps'} %unstructured coordinates 2523 NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points 2524 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) 2525 case 'grid'%structured coordinate 2526 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction 2527 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1)); 2528 end 2529 end 2530 UvData.Field.CoordMesh=min(Mesh); 2531 UvData.Field.XMax=max(CoordMax(:,end)); 2532 UvData.Field.XMin=min(CoordMin(:,end)); 2533 UvData.Field.YMax=max(CoordMax(:,end-1)); 2534 UvData.Field.YMin=min(CoordMin(:,end-1)); 2535 if NbDim==3 2536 UvData.Field.ZMax=max(CoordMax(ind,1)); 2537 UvData.Field.ZMin=max(CoordMin(ind,1)); 2538 end 2539 % adjust the mesh to a value 1, 2 , 5 *10^n 2540 ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude 2541 if UvData.Field.CoordMesh/ord>=5 2542 UvData.Field.CoordMesh=5*ord; 2543 elseif UvData.Field.CoordMesh/ord>=2 2544 UvData.Field.CoordMesh=2*ord; 2545 else 2546 UvData.Field.CoordMesh=ord; 2547 end 2483 % [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2484 % if ~isempty(errormsg) 2485 % errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error 2486 % return 2487 % end 2488 % 2489 % NbDim=max(NbDimArray);% spatial dimension of the input field 2490 % imax=find(NbDimArray==NbDim);% indices of field cells to consider 2491 % if isfield(UvData.Field,'NbDim') 2492 % NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates 2493 % end 2494 % 2495 % %% get bounds and mesh (needed to propose default options for projection objects) 2496 % if NbDim>1 2497 % CoordMax=zeros(numel(imax),NbDim); 2498 % CoordMin=zeros(numel(imax),NbDim); 2499 % Mesh=zeros(1,numel(imax)); 2500 % for ind=1:numel(imax) 2501 % if strcmp(CellInfo{imax(ind)}.CoordType,'tps') 2502 % CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable 2503 % CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case) 2504 % CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case) 2505 % CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3); 2506 % CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case) 2507 % else 2508 % XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; 2509 % YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; 2510 % CoordMax(ind,NbDim)=max(max(UvData.Field.(XName))); 2511 % CoordMin(ind,NbDim)=min(min(UvData.Field.(XName))); 2512 % CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName))); 2513 % CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName))); 2514 % % test_x=1;%test for unstructured coordinates 2515 % if NbDim==3 2516 % ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; 2517 % CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName))); 2518 % CoordMin(ind,1)=min(min(UvData.Field.(ZName))); 2519 % end 2520 % end 2521 % switch CellInfo{imax(ind)}.CoordType 2522 % 2523 % case {'scattered','tps'} %unstructured coordinates 2524 % NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points 2525 % Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) 2526 % case 'grid'%structured coordinate 2527 % NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction 2528 % Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1)); 2529 % end 2530 % end 2531 % UvData.Field.CoordMesh=min(Mesh); 2532 % UvData.Field.XMax=max(CoordMax(:,end)); 2533 % UvData.Field.XMin=min(CoordMin(:,end)); 2534 % UvData.Field.YMax=max(CoordMax(:,end-1)); 2535 % UvData.Field.YMin=min(CoordMin(:,end-1)); 2536 % if NbDim==3 2537 % UvData.Field.ZMax=max(CoordMax(ind,1)); 2538 % UvData.Field.ZMin=max(CoordMin(ind,1)); 2539 % end 2540 % % adjust the mesh to a value 1, 2 , 5 *10^n 2541 % ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude 2542 % if UvData.Field.CoordMesh/ord>=5 2543 % UvData.Field.CoordMesh=5*ord; 2544 % elseif UvData.Field.CoordMesh/ord>=2 2545 % UvData.Field.CoordMesh=2*ord; 2546 % else 2547 % UvData.Field.CoordMesh=ord; 2548 % end 2549 if UvData.Field.NbDim>1 2550 UvData.Field=find_field_bounds(UvData.Field); 2548 2551 % default projection plane 2549 2552 if isempty(UvData.ProjObject{1}) … … 2555 2558 end 2556 2559 %% 3D case (menuvolume) 2557 if NbDim==3% && UvData.NewSeries2560 if UvData.Field.NbDim==3% && UvData.NewSeries 2558 2561 test_set_object=1; 2559 2562 hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI … … 2607 2610 2608 2611 %% usual 1D (x,y) plots 2609 if NbDim<=12612 if UvData.Field.NbDim<=1 2610 2613 set(handles.Objects,'Visible','off') 2611 2614 set(handles.ListObject_1_title,'Visible','off') … … 2727 2730 view_field(ObjectData) 2728 2731 else 2732 % ObjectData.VarAttribute{5}.Role='scalar';TODO CORRECT 2729 2733 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); 2730 2734 if imap==1 … … 3155 3159 set(handles.FixVelType,'visible','off') 3156 3160 set(handles.VelType,'Visible','off') 3157 set(handles.VelType_1,'Visible','off')3161 %set(handles.VelType_1,'Visible','off') 3158 3162 3159 3163 %read selection from get_field … … 3163 3167 FieldList={}; 3164 3168 VecColorList={}; 3165 XName=GetFieldData.Coordinates.Coord_x;3166 3169 switch GetFieldData.FieldOption 3167 3170 case 'vectors' 3168 3171 UName=GetFieldData.PanelVectors.vector_x; 3169 3172 VName=GetFieldData.PanelVectors.vector_y; 3170 XName=GetFieldData.Coordinates.Coord_x;3171 3173 YName={GetFieldData.Coordinates.Coord_y}; 3172 3174 CName=GetFieldData.PanelVectors.vec_color; … … 3174 3176 case 'scalar' 3175 3177 AName=GetFieldData.PanelScalar.scalar; 3176 XName=GetFieldData.Coordinates.Coord_x;3177 3178 YName={GetFieldData.Coordinates.Coord_y}; 3178 3179 FieldList={AName}; 3179 3180 case '1D plot' 3180 3181 YName=GetFieldData.PanelOrdinate.ordinate; 3181 XName=GetFieldData.Coordinates.Coord_x; 3182 end 3182 case 'civdata...'%return to civdata from get_field 3183 % [FieldList,VecColorList]=set_field_list('U','V','C'); 3184 set(handles.FieldName,'Value',2) 3185 set(handles.FixVelType,'visible','on') 3186 set(handles.VelType,'Visible','on') 3187 end 3188 if ~strcmp(GetFieldData.FieldOption,'civdata...') 3189 XName=GetFieldData.Coordinates.Coord_x; 3183 3190 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 3184 3191 if strcmp(TimeNameStr,'file index') … … 3203 3210 UvData.FileType{1}='netcdf'; 3204 3211 set(handles.uvmat,'UserData',UvData) 3212 end 3205 3213 run0_Callback(hObject, eventdata, handles) 3206 3214 … … 4076 4084 function num_MinVec_Callback(hObject, eventdata, handles) 4077 4085 %------------------------------------------------------------------------ 4078 max_vec_Callback(hObject, eventdata, handles)4086 num_MaxVec_Callback(hObject, eventdata, handles) 4079 4087 4080 4088 %------------------------------------------------------------------------ … … 5202 5210 function MenuPIV_Callback(hObject, eventdata, handles) 5203 5211 Param=read_param(handles); 5204 Param.ActionName='civ_series'; 5205 series(Param) 5212 % Param.ActionName='civ_series'; 5213 hseries=series(Param); 5214 hhseries=guidata(hseries); 5215 ActionMenu=get(hhseries.ActionName,'String'); 5216 index_action=find(strcmp('civ_series',ActionMenu)); 5217 set(hhseries.ActionName,'Value',index_action); 5218 series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates 5219 5206 5220 5207 5221 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.