Changeset 89 for trunk/src/plot_field.m
- Timestamp:
- May 20, 2010, 1:48:25 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plot_field.m
r88 r89 31 31 % The only variable attribute used for plotting purpose is .Role which can take 32 32 % the values 33 34 35 36 37 38 39 40 41 42 43 33 % Role = 'scalar': (default) represents a scalar field 34 % = 'coord_x', 'coord_y', 'coord_z': represents a separate set of 35 % unstructured coordinate x, y or z 36 % = 'vector': represents a vector field whose number of components 37 % is given by the last dimension (called 'nb_dim') 38 % = 'vector_x', 'vector_y', 'vector_z' :represents the x, y or z component of a vector 39 % = 'warnflag' : provides a warning flag about the quality of data in a 'Field', default=0, no warning 40 % = 'errorflag': provides an error flag marking false data, 41 % default=0, no error. Different non zero values can represent different criteria of elimination. 42 % 43 % 44 44 % additional elements characterizing the projection object (should not be necessary)-- 45 45 % Data.Style : style of projection object … … 84 84 % PosColorbar: if not empty, display a colorbar for B&W images 85 85 % imposed position of the colorbar (ex [0.821 0.471 0.019 0.445]) 86 % 86 87 87 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 88 88 % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. … … 141 141 if testnewfig% create a new figure and axes if the plotting axes does not exist 142 142 hfig=figure; 143 if isfield(Data,'IndexObj') &isfield(Data,'Style')&isfield(Data,'ProjMode')143 if isfield(Data,'IndexObj') && isfield(Data,'Style') && isfield(Data,'ProjMode') 144 144 figname=[num2str(Data.IndexObj) '-' Data.Style]; 145 145 set(hfig,'Name',figname) 146 146 end 147 testhandle=0;148 if isfield(PlotParam,'text_display_1') & ishandle(PlotParam.text_display_1)147 % testhandle=0; 148 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1) 149 149 set(hfig,'UserData',PlotParam) 150 testhandle=1;150 % testhandle=1; 151 151 end 152 152 set(hfig,'Units','normalized') … … 160 160 hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab 161 161 end 162 if isfield(PlotParam,'text_display_1') & ishandle(PlotParam.text_display_1)162 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1) 163 163 PlotParam=read_plot_param(PlotParam); 164 164 end … … 171 171 172 172 % check the cells of fields : 173 testnbdim=1;173 % testnbdim=1; 174 174 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 175 175 … … 180 180 end 181 181 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot 182 [Data.NbDim ,imax]=max(NbDim);182 [Data.NbDim]=max(NbDim); 183 183 end 184 184 if isequal(Data.NbDim,0) … … 207 207 msgbox_uvmat('ERROR','volume plot not implemented yet') 208 208 return 209 else210 testnbdim=0;209 % else 210 % testnbdim=0; 211 211 end 212 212 … … 239 239 function hdisplay=plot_text(FieldData,hdisplay_in) 240 240 %------------------------------------------------------------------- 241 if exist('hdisplay_in','var') & ishandle(hdisplay_in)& isequal(get(hdisplay_in,'Type'),'uicontrol')241 if exist('hdisplay_in','var') && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol') 242 242 hdisplay=hdisplay_in; 243 243 else … … 254 254 sizss=size(ss); 255 255 if isnumeric(ss) 256 if sizss(1)<=1 & length(ss)<5256 if sizss(1)<=1 && length(ss)<5 257 257 displ{icell}=num2str(ss); 258 258 else … … 263 263 elseif iscell(ss) 264 264 sizcell=size(ss); 265 if sizcell(1)==1 & length(sizcell)==2 %line cell265 if sizcell(1)==1 && length(sizcell)==2 %line cell 266 266 ssline='{'''; 267 267 for icolumn=1:sizcell(2) 268 268 if isnumeric(ss{icolumn}) 269 if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5269 if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5 270 270 sscolumn=num2str(ss{icolumn});%line vector 271 271 else … … 321 321 plotstr='hhh=plot('; 322 322 textmean={}; 323 abscissa_name='';323 % abscissa_name=''; 324 324 coord_x_index=[]; 325 325 test_newplot=1; 326 326 hh=findobj(haxes,'tag','plot_line'); 327 num_curve=numel(hh);327 % num_curve=numel(hh); 328 328 icurve=0; 329 329 for icell=1:length(CellVarIndex) … … 351 351 testcoordvar=0; 352 352 charplot_0='''-''';%default 353 if isfield(data,'ObjectProjMode')& isequal(data.ObjectProjMode,'projection')353 if isfield(data,'ObjectProjMode')&& isequal(data.ObjectProjMode,'projection') 354 354 charplot_0='+'; 355 355 end … … 374 374 VarAttribute=data.VarAttribute; 375 375 for ivar=1:length(VarIndex) 376 if length(VarAttribute)>=VarIndex(ivar) & isfield(VarAttribute{VarIndex(ivar)},'long_name')376 if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name') 377 377 plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name; 378 378 else … … 461 461 else 462 462 legend_old=get(hlegend,'String'); 463 if isequal(size(legend_old,1),size(legend_str,1))& ~isequal(legend_old,legend_str)463 if isequal(size(legend_old,1),size(legend_str,1))&&~isequal(legend_old,legend_str) 464 464 set(hlegend,'String',[legend_old legend_str]); 465 465 end … … 537 537 y_units=''; 538 538 for icell=1:length(CellVarIndex) % length(CellVarIndex) =1 or 2 (from the calling function) 539 % VarIndex=CellVarIndex{icell};540 539 VarType=VarTypeCell{icell}; 541 540 ivar_X=VarType.coord_x; % defines (unique) index for the variable representing unstructured x coordinate (default =[]) … … 564 563 eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';']) 565 564 eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';']) 565 'TESTplot' 566 VarType.coord 566 567 if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty) 567 568 eval(['vec_X=Data.' Data.ListVarName{ivar_X} ';']) … … 614 615 [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256'); % interpolate on a grid 615 616 if isfield(Data,'VarAttribute') 616 if numel(Data.VarAttribute)>=ivar_X & isfield(Data.VarAttribute{ivar_X},'units')617 if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units') 617 618 x_units=['(' Data.VarAttribute{ivar_X}.units ')']; 618 619 end 619 if numel(Data.VarAttribute)>=ivar_Y & isfield(Data.VarAttribute{ivar_Y},'units')620 if numel(Data.VarAttribute)>=ivar_Y && isfield(Data.VarAttribute{ivar_Y},'units') 620 621 y_units=['(' Data.VarAttribute{ivar_Y}.units ')']; 621 622 end … … 629 630 test_interp_Y=0; %default, regularly meshed Y coordinate 630 631 if isfield(Data,'VarAttribute') 631 if numel(Data.VarAttribute)>=VarType.coord(2) & isfield(Data.VarAttribute{VarType.coord(2)},'units')632 if numel(Data.VarAttribute)>=VarType.coord(2) && isfield(Data.VarAttribute{VarType.coord(2)},'units') 632 633 x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')']; 633 634 end … … 714 715 end 715 716 %set the color map 717 if isfield(PlotParam.Scalar,'BW') 718 BW=PlotParam.Scalar.BW; %test for BW gray scale images 719 else 720 BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default 721 end 716 722 if siz==2 %for black and white images 717 723 if ~isfield(PlotParam.Scalar,'AutoScal') … … 729 735 MinA=PlotParam.Scalar.MinA; 730 736 end; 731 if isequal(PlotParam.Scalar.AutoScal,0)| isempty(PlotParam.Scalar.MaxA)|~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box737 if isequal(PlotParam.Scalar.AutoScal,0)||isempty(PlotParam.Scalar.MaxA)||~isa(PlotParam.Scalar.MaxA,'double') %correct if there is no numerical data in edit box 732 738 MaxA=double(max(max(A))); 733 739 else … … 756 762 contmin=intercont*floor(min(min(B))/intercont); 757 763 contmax=intercont*ceil(max(max(B))/intercont); 758 cont_pos_plus= [0:intercont:contmax];759 cont_pos_min= [double(contmin):intercont:-intercont];764 cont_pos_plus=0:intercont:contmax; 765 cont_pos_min=double(contmin):intercont:-intercont; 760 766 cont_pos=[cont_pos_min cont_pos_plus]; 761 767 sizpx=(AX(end)-AX(1))/(np(2)-1); 762 768 sizpy=(AY(1)-AY(end))/(np(1)-1); 763 769 x_cont=[AX(1):sizpx:AX(end)]; % pixel x coordinates for image display 764 y_cont= [AY(1):-sizpy:AY(end)]; % pixel x coordinates for image display770 y_cont=AY(1):-sizpy:AY(end); % pixel x coordinates for image display 765 771 txt=ver;%version of Matlab 766 772 Release=txt(1).Release; … … 783 789 colormap(map); 784 790 end 785 if ~isequal(PlotParam.Scalar.Contours,1) 791 if ~isequal(PlotParam.Scalar.Contours,1) 786 792 % rescale the grey levels with min and max, put a grey scale colorbar 787 if (isfield(PlotParam.Scalar,'BW')& (isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16'))%images793 if BW 788 794 B=A; 789 795 vec=linspace(0,1,255);%define a linear greyscale colormap … … 797 803 else %color images 798 804 axes(haxes) 799 B=uint8(A); 805 if BW 806 B=uint16(sum(A,3)); 807 else 808 B=uint8(A); 809 end 800 810 MinA=0; 801 811 MaxA=255; … … 846 856 test_ima=1; 847 857 %display the colorbar code for B/W images if Poscolorbar not empty 848 if siz==2 & exist('PosColorbar','var')& ~isempty(PosColorbar)858 if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar) 849 859 if isempty(hcol)|~ishandle(hcol) 850 860 hcol=colorbar;%create new colorbar … … 966 976 dy_thresh=max(abs(diffy))/2; 967 977 ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line 968 ind_sel= [1:ind_jump(1)];%select the first line978 ind_sel=1:ind_jump(1);%select the first line 969 979 for i=2:2:length(ind_jump)-1 970 980 ind_sel=[ind_sel [ind_jump(i)+1:ind_jump(i+1)]];% select the odd lines … … 1191 1201 siz=size(ind); 1192 1202 if siz(2)<4%if there are less than 4 selected values (4 levels) 1193 values= [-9:0.5*div:9];1203 values=-9:0.5*div:9; 1194 1204 ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0); 1195 1205 end
Note: See TracChangeset
for help on using the changeset viewer.