[201] | 1 | %'plot_field': plot any field with the structure defined in the uvmat package
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | %
|
---|
| 4 | % This function is used by uvmat to plot fields. It automatically chooses the representation
|
---|
| 5 | % appropriate to the input field structure:
|
---|
[292] | 6 | % 2D vector fields are represented by arrows, 2D scalar fields by grey scale images or contour plots, 1D fields are represented by usual plot with (abscissa, ordinate).
|
---|
[201] | 7 | % The input field structure is first tested by check_field_structure.m,
|
---|
[512] | 8 | % then split into blocks of related variables by find_field_cells.m.
|
---|
[292] | 9 | % The dimensionality of each block is obtained by this function
|
---|
[201] | 10 | % considering the presence of variables with the attribute .Role='coord_x'
|
---|
| 11 | % and/or coord_y and/or coord_z (case of unstructured coordinates), or
|
---|
| 12 | % dimension variables (case of matrices).
|
---|
| 13 | %
|
---|
[625] | 14 | % function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
|
---|
[201] | 15 | %
|
---|
[822] | 16 | % OUPUT:
|
---|
[201] | 17 | % PlotType: type of plot: 'text','line'(curve plot),'plane':2D view,'volume'
|
---|
| 18 | % PlotParamOut: structure, representing the updated plotting parameters, in case of automatic scaling
|
---|
| 19 | % haxes: handle of the plotting axis, when a new figure is created.
|
---|
| 20 | %
|
---|
[822] | 21 | %INPUT
|
---|
[201] | 22 | % Data: structure describing the field to plot
|
---|
| 23 | % (optional) .ListGlobalAttribute: cell listing the names of the global attributes
|
---|
| 24 | % .Att_1,Att_2... : values of the global attributes
|
---|
| 25 | % (requested) .ListVarName: list of variable names to select (cell array of char strings {'VarName1', 'VarName2',...} )
|
---|
| 26 | % (requested) .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)
|
---|
| 27 | % .VarAttribute: cell of attributes for each element of .ListVarName (cell array of structures of the form VarAtt.key=value)
|
---|
| 28 | % (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
|
---|
| 29 | %
|
---|
| 30 | % Variable attribute .Role :
|
---|
| 31 | % The only variable attribute used for plotting purpose is .Role which can take
|
---|
| 32 | % the values
|
---|
| 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 | % haxes: handle of the plotting axes to update with the new plot. If this input is absent or not a valid axes handle, a new figure is created.
|
---|
| 44 | %
|
---|
[294] | 45 | % PlotParam: structure containing the parameters for plotting, as read on the uvmat or view_field GUI (by function 'read_GUI.m').
|
---|
| 46 | % Contains three substructures:
|
---|
[748] | 47 | % .Axes: coordinate parameters:
|
---|
[294] | 48 | % .CheckFixLimits:=0 (default) adjust axes limit to the X,Y data, =1: preserves the previous axes limits
|
---|
[748] | 49 | % .Axes.CheckFixAspectRatio: =0 (default):automatic adjustment of the graph, keep 1 to 1 aspect ratio for x and y scales.
|
---|
| 50 | % .Axes.AspectRatio: imposed aspect ratio y/x of axis unit plots
|
---|
[201] | 51 | % --scalars--
|
---|
| 52 | % .Scalar.MaxA: upper bound (saturation color) for the scalar representation, max(field) by default
|
---|
| 53 | % .Scalar.MinA: lower bound (saturation) for the scalar representation, min(field) by default
|
---|
[292] | 54 | % .Scalar.CheckFixScal: =0 (default) lower and upper bounds of the scalar representation set to the min and max of the field
|
---|
[201] | 55 | % =1 lower and upper bound imposed by .AMax and .MinA
|
---|
[421] | 56 | % .Scalar.CheckBW= 1: black and white representation imposed, =0 color imposed (color scale or rgb),
|
---|
| 57 | % =[]: automatic (B/W for integer positive scalars, color else)
|
---|
[292] | 58 | % .Scalar.CheckContours= 1: represent scalars by contour plots (Matlab function 'contour'); =0 by default
|
---|
[201] | 59 | % .IncrA : contour interval
|
---|
| 60 | % -- vectors--
|
---|
| 61 | % .Vectors.VecScale: scale for the vector representation
|
---|
[292] | 62 | % .Vectors.CheckFixVec: =0 (default) automatic length for vector representation, =1: length set by .VecScale
|
---|
| 63 | % .Vectors.CheckHideFalse= 0 (default) false vectors represented in magenta, =1: false vectors not represented;
|
---|
| 64 | % .Vectors.CheckHideWarning= 0 (default) vectors marked by warnflag~=0 marked in black, 1: no warning representation;
|
---|
| 65 | % .Vectors.CheckDecimate4 = 0 (default) all vectors reprtesented, =1: half of the vectors represented along each coordinate
|
---|
[201] | 66 | % -- vector color--
|
---|
| 67 | % .Vectors.ColorCode= 'black','white': imposed color (default ='blue')
|
---|
| 68 | % 'rgb', : three colors red, blue, green depending
|
---|
| 69 | % on thresholds .colcode1 and .colcode2 on the input scalar value (C)
|
---|
| 70 | % 'brg': like rgb but reversed color order (blue, green, red)
|
---|
| 71 | % '64 colors': continuous color from blue to red (multijet)
|
---|
| 72 | % .Vectors.colcode1 : first threshold for rgb, first value for'continuous'
|
---|
| 73 | % .Vectors.colcode2 : second threshold for rgb, last value (saturation) for 'continuous'
|
---|
[292] | 74 | % .Vectors.CheckFixedCbounds; =0 (default): the bounds on C representation are min and max, =1: they are fixed by .Minc and .MaxC
|
---|
[201] | 75 | % .Vectors.MinC = imposed minimum of the scalar field used for vector color;
|
---|
| 76 | % .Vectors.MaxC = imposed maximum of the scalar field used for vector color;
|
---|
| 77 | %
|
---|
[546] | 78 | % PosColorbar: % if absent, no action on colorbar
|
---|
| 79 | % % if empty, suppress any existing colorbar
|
---|
| 80 | % % if not empty, display a colorbar for B&W images at position PosColorbar
|
---|
| 81 | % expressed in figure relative unit (ex [0.821 0.471 0.019 0.445])
|
---|
[201] | 82 |
|
---|
[822] | 83 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 84 | % Copyright 2008-2014, LEGI / CNRS UJF G-INP, Joel.Sommeria@legi.grenoble-inp.fr
|
---|
| 85 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
[201] | 86 | % This file is part of the toolbox UVMAT.
|
---|
[822] | 87 | %
|
---|
[201] | 88 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
[822] | 89 | % it under the terms of the GNU General Public License as published by
|
---|
| 90 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 91 | % (at your option) any later version.
|
---|
| 92 | %
|
---|
[201] | 93 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 94 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 95 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
[822] | 96 | % GNU General Public License (file UVMAT/COPYING.txt) for more details.
|
---|
| 97 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
[201] | 98 |
|
---|
[781] | 99 | function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam)
|
---|
[247] | 100 |
|
---|
[388] | 101 | %% default input and output
|
---|
[201] | 102 | if ~exist('PlotParam','var'),PlotParam=[];end;
|
---|
| 103 | PlotType='text'; %default
|
---|
[749] | 104 | if ~isfield(PlotParam,'Axes')
|
---|
[748] | 105 | PlotParam.Axes=[];
|
---|
[582] | 106 | if isfield(Data,'CoordUnit')
|
---|
[748] | 107 | PlotParam.Axes.CheckFixAspectRatio=1;
|
---|
| 108 | PlotParam.Axes.AspectRatio=1; %set axes equal by default if CoordUnit is defined
|
---|
[582] | 109 | end
|
---|
[292] | 110 | end
|
---|
[569] | 111 | PlotParamOut=PlotParam;%default
|
---|
[201] | 112 |
|
---|
[388] | 113 | %% check input structure
|
---|
| 114 | % check the cells of fields :
|
---|
[530] | 115 | [CellInfo,NbDimArray,errormsg]=find_field_cells(Data);
|
---|
[388] | 116 | if ~isempty(errormsg)
|
---|
[512] | 117 | msgbox_uvmat('ERROR',['input of plot_field/find_field_cells: ' errormsg]);
|
---|
[388] | 118 | return
|
---|
| 119 | end
|
---|
[530] | 120 |
|
---|
| 121 | index_3D=find(NbDimArray>2,1);
|
---|
[388] | 122 | if ~isempty(index_3D)
|
---|
[546] | 123 | msgbox_uvmat('ERROR','volume plot not implemented yet');
|
---|
| 124 | return
|
---|
[388] | 125 | end
|
---|
[530] | 126 | index_2D=find(NbDimArray==2);%find 2D fields
|
---|
| 127 | index_1D=find(NbDimArray==1);
|
---|
| 128 | index_0D=find(NbDimArray==0);
|
---|
[294] | 129 |
|
---|
[388] | 130 | %% test axes and figure
|
---|
[429] | 131 | testnewfig=1;%test to create a new figure (default)
|
---|
| 132 | testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes
|
---|
| 133 | if exist('haxes','var')
|
---|
| 134 | if ishandle(haxes)
|
---|
| 135 | if isequal(get(haxes,'Type'),'axes')
|
---|
| 136 | testnewfig=0;
|
---|
| 137 | AxeData=get(haxes,'UserData');
|
---|
| 138 | if isfield(AxeData,'ZoomAxes')&& ishandle(AxeData.ZoomAxes)
|
---|
| 139 | if isequal(get(AxeData.ZoomAxes,'Type'),'axes')
|
---|
| 140 | testzoomaxes=1;
|
---|
| 141 | zoomaxes=AxeData.ZoomAxes;
|
---|
[388] | 142 | end
|
---|
| 143 | end
|
---|
| 144 | end
|
---|
[201] | 145 | end
|
---|
[429] | 146 | end
|
---|
| 147 |
|
---|
| 148 | %% create a new figure and axes if the plotting axes does not exist
|
---|
| 149 | if testnewfig
|
---|
| 150 | hfig=figure;
|
---|
| 151 | set(hfig,'Units','normalized')
|
---|
| 152 | haxes=axes;
|
---|
| 153 | set(haxes,'position',[0.13,0.2,0.775,0.73])
|
---|
[569] | 154 | PlotParamOut.NextPlot='add'; %parameter for plot_profile
|
---|
[429] | 155 | else
|
---|
| 156 | hfig=get(haxes,'parent');
|
---|
| 157 | set(0,'CurrentFigure',hfig)% the parent of haxes becomes the current figure
|
---|
| 158 | set(hfig,'CurrentAxes',haxes)% haxes becomes the current axes of the parent figure
|
---|
| 159 | end
|
---|
| 160 |
|
---|
| 161 | %% set axes properties
|
---|
[748] | 162 | if isfield(PlotParamOut.Axes,'CheckFixLimits') && isequal(PlotParamOut.Axes.CheckFixLimits,1) %adjust the graph limits
|
---|
[429] | 163 | set(haxes,'XLimMode', 'manual')
|
---|
| 164 | set(haxes,'YLimMode', 'manual')
|
---|
| 165 | else
|
---|
| 166 | set(haxes,'XLimMode', 'auto')
|
---|
| 167 | set(haxes,'YLimMode', 'auto')
|
---|
| 168 | end
|
---|
[760] | 169 |
|
---|
| 170 | if isfield(PlotParamOut.Axes,'CheckFixAspectRatio') && isequal(PlotParamOut.Axes.CheckFixAspectRatio,1)&&isfield(PlotParamOut.Axes,'AspectRatio')
|
---|
| 171 | set(haxes,'DataAspectRatioMode','manual')
|
---|
| 172 | set(haxes,'DataAspectRatio',[PlotParamOut.Axes.AspectRatio 1 1])
|
---|
| 173 | else
|
---|
| 174 | set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
|
---|
| 175 | end
|
---|
| 176 |
|
---|
[429] | 177 | errormsg='';
|
---|
| 178 | AxeData=get(haxes,'UserData');
|
---|
| 179 |
|
---|
| 180 | %% 2D plots
|
---|
| 181 | if isempty(index_2D)
|
---|
[781] | 182 | plot_plane([],[],haxes,[]);%removes images or vector plots in the absence of 2D field plot
|
---|
[429] | 183 | else %plot 2D field
|
---|
[781] | 184 | % if ~exist('PosColorbar','var'),PosColorbar=[];end;
|
---|
| 185 | [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut);
|
---|
[429] | 186 | AxeData.NbDim=2;
|
---|
| 187 | if testzoomaxes && isempty(errormsg)
|
---|
[781] | 188 | [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut);
|
---|
[429] | 189 | AxeData.ZoomAxes=zoomaxes;
|
---|
[201] | 190 | end
|
---|
[429] | 191 | end
|
---|
| 192 |
|
---|
| 193 | %% 1D plot (usual graph y vs x)
|
---|
| 194 | if isempty(index_1D)
|
---|
| 195 | if ~isempty(haxes)
|
---|
[530] | 196 | plot_profile([],[],haxes);%removes usual praphs y vs x in the absence of 1D field plot
|
---|
[201] | 197 | end
|
---|
[429] | 198 | else %plot 1D field (usual graph y vs x)
|
---|
[644] | 199 | CheckHold=0;
|
---|
| 200 | if isfield(PlotParam,'CheckHold')
|
---|
| 201 | CheckHold= PlotParam.CheckHold;
|
---|
| 202 | end
|
---|
[748] | 203 | PlotParamOut.Axes=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Axes,CheckHold);%
|
---|
[429] | 204 | if testzoomaxes
|
---|
[748] | 205 | [zoomaxes,PlotParamOut.Axes]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParamOut.Axes,CheckHold);
|
---|
[429] | 206 | AxeData.ZoomAxes=zoomaxes;
|
---|
[201] | 207 | end
|
---|
[429] | 208 | PlotType='line';
|
---|
| 209 | end
|
---|
| 210 |
|
---|
[760] | 211 | %% aspect ratio
|
---|
| 212 | AspectRatio=get(haxes,'DataAspectRatio');
|
---|
| 213 | PlotParamOut.Axes.AspectRatio=AspectRatio(1)/AspectRatio(2);
|
---|
| 214 |
|
---|
[429] | 215 | %% text display
|
---|
[690] | 216 | htext=findobj(hfig,'Tag','TableDisplay');
|
---|
| 217 | hchecktable=findobj(hfig,'Tag','CheckTable');
|
---|
| 218 | % if isempty(index_2D) && isempty(index_1D)%text display alone
|
---|
| 219 | % htext=findobj(hfig,'Tag','TableDisplay');
|
---|
| 220 | % else %text display added to plot
|
---|
| 221 | % %htext=findobj(hfig,'Tag','text_display');
|
---|
| 222 | % end
|
---|
| 223 | if ~isempty(htext)&&~isempty(hchecktable)
|
---|
[429] | 224 | if isempty(index_0D)
|
---|
[690] | 225 | set(htext,'Data',{})
|
---|
| 226 | set(htext,'visible','off')
|
---|
| 227 | set(hchecktable,'visible','off')
|
---|
| 228 | set(hchecktable,'Value',0)
|
---|
| 229 | else
|
---|
| 230 | errormsg=plot_text(Data,CellInfo(index_0D),htext);
|
---|
| 231 | set(htext,'visible','on')
|
---|
| 232 | set(hchecktable,'visible','on')
|
---|
| 233 | set(hchecktable,'Value',1)
|
---|
| 234 | end
|
---|
| 235 | set(hfig,'Unit','pixels');
|
---|
| 236 | set(htext,'Unit','pixels')
|
---|
| 237 | PosFig=get(hfig,'Position');
|
---|
| 238 | % case of no plot with view_field: only text display
|
---|
| 239 | if strcmp(get(hfig,'Tag'),'view_field')
|
---|
| 240 | if isempty(index_1D) && isempty(index_2D)% case of no plot: only text display
|
---|
| 241 | set(haxes,'Visible','off')
|
---|
| 242 | PosTable=get(htext,'Position');
|
---|
| 243 | set(hfig,'Position',[PosFig(1) PosFig(2) PosTable(3) PosTable(4)])
|
---|
[434] | 244 | else
|
---|
[690] | 245 | set(haxes,'Visible','on')
|
---|
| 246 | set(hfig,'Position',[PosFig(1) PosFig(2) 877 677])%default size for view_field
|
---|
[434] | 247 | end
|
---|
[294] | 248 | end
|
---|
[201] | 249 | end
|
---|
| 250 |
|
---|
[388] | 251 | %% display error message
|
---|
[201] | 252 | if ~isempty(errormsg)
|
---|
| 253 | msgbox_uvmat('ERROR', errormsg)
|
---|
| 254 | end
|
---|
| 255 |
|
---|
| 256 | %% update the parameters stored in AxeData
|
---|
[429] | 257 | if ishandle(haxes)&&( ~isempty(index_2D)|| ~isempty(index_1D))
|
---|
| 258 | % AxeData=[];
|
---|
[388] | 259 | if isfield(PlotParamOut,'MinX')
|
---|
[569] | 260 | AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX];
|
---|
| 261 | AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY];
|
---|
[388] | 262 | end
|
---|
| 263 | set(haxes,'UserData',AxeData)
|
---|
| 264 | end
|
---|
[201] | 265 |
|
---|
[206] | 266 | %% update the plotted field stored in parent figure
|
---|
[429] | 267 | if ~isempty(index_2D)|| ~isempty(index_1D)
|
---|
| 268 | FigData=get(hfig,'UserData');
|
---|
[511] | 269 | if strcmp(get(hfig,'tag'),'view_field')||strcmp(get(hfig,'tag'),'uvmat')
|
---|
| 270 | FigData.(get(haxes,'tag'))=Data;
|
---|
[429] | 271 | set(hfig,'UserData',FigData)
|
---|
| 272 | end
|
---|
[388] | 273 | end
|
---|
[292] | 274 |
|
---|
[201] | 275 | %-------------------------------------------------------------------
|
---|
[690] | 276 | % --- plot 0D fields: display data values without plot
|
---|
| 277 | %------------------------------------------------------------------
|
---|
[530] | 278 | function errormsg=plot_text(FieldData,CellInfo,htext)
|
---|
[690] | 279 |
|
---|
[581] | 280 | errormsg='';
|
---|
[201] | 281 | txt_cell={};
|
---|
[429] | 282 | Data={};
|
---|
[690] | 283 | VarIndex=[];
|
---|
[530] | 284 | for icell=1:length(CellInfo)
|
---|
[535] | 285 |
|
---|
| 286 | % select types of variables to be projected
|
---|
| 287 | ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'};
|
---|
| 288 | check_proj=false(size(FieldData.ListVarName));
|
---|
| 289 | for ilist=1:numel(ListProj)
|
---|
| 290 | if isfield(CellInfo{icell},ListProj{ilist})
|
---|
| 291 | check_proj(CellInfo{icell}.(ListProj{ilist}))=1;
|
---|
| 292 | end
|
---|
| 293 | end
|
---|
[690] | 294 | VarIndex=[VarIndex find(check_proj)];
|
---|
| 295 | end
|
---|
| 296 |
|
---|
| 297 | % data need to be displayed in a table
|
---|
| 298 | if strcmp(get(htext,'Type'),'uitable')% display data in a table
|
---|
| 299 | VarNameCell=cell(1,numel(VarIndex));% prepare list of variable names to display (titles of columns)
|
---|
| 300 | VarLength=zeros(1,numel(VarIndex)); % default number of values for each variable
|
---|
| 301 | for ivar=1:numel(VarIndex)
|
---|
| 302 | VarNameCell{ivar}=FieldData.ListVarName{VarIndex(ivar)};
|
---|
| 303 | VarLength(ivar)=numel(FieldData.(VarNameCell{ivar}));
|
---|
[535] | 304 | end
|
---|
[690] | 305 | set(htext,'ColumnName',VarNameCell)
|
---|
| 306 | Data=cell(max(VarLength),numel(VarIndex));% prepare the table of data display
|
---|
| 307 |
|
---|
| 308 | for ivar=1:numel(VarIndex)
|
---|
| 309 | VarValue=FieldData.(VarNameCell{ivar});
|
---|
| 310 | VarValue=reshape(VarValue,[],1);% reshape values array in a column
|
---|
| 311 | Data(1:numel(VarValue),ivar)=num2cell(VarValue);
|
---|
[201] | 312 | end
|
---|
[690] | 313 | set(htext,'Data',Data)
|
---|
[201] | 314 | end
|
---|
[690] | 315 | % if numel(VarValue)>1 && numel(VarValue)<10 % case of a variable with several values
|
---|
| 316 | % for ind=1:numel(VarValue)
|
---|
| 317 | % VarNameCell{1,ind}=[VarName '_' num2str(ind)];% indicate each value by an index
|
---|
| 318 | % end
|
---|
| 319 | % else
|
---|
| 320 | % VarNameCell={VarName};
|
---|
| 321 | % end
|
---|
| 322 | % if numel(VarValue)<10
|
---|
| 323 | % if isempty(VarValue)
|
---|
| 324 | % VarValueCell={'[]'};
|
---|
| 325 | % else
|
---|
| 326 | % VarValueCell=num2cell(VarValue);
|
---|
| 327 | % end
|
---|
| 328 | % if isempty(Data)
|
---|
| 329 | % Data =[VarNameCell VarValueCell];
|
---|
| 330 | % else
|
---|
| 331 | % Data =[Data [VarNameCell VarValueCell]];
|
---|
| 332 | % end
|
---|
| 333 | % else
|
---|
| 334 | % if isempty(Data)
|
---|
| 335 | % Data =[VarNameCell; num2cell(VarValue)];
|
---|
| 336 | % else
|
---|
| 337 | % Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]];
|
---|
| 338 | % end
|
---|
| 339 | % end
|
---|
| 340 | % if size(VarValue,1)==1
|
---|
| 341 | % txt=[VarName '=' num2str(VarValue)];
|
---|
| 342 | % txt_cell=[txt_cell;{txt}];
|
---|
| 343 | % end
|
---|
| 344 | % end
|
---|
| 345 | % end
|
---|
| 346 | % if strcmp(get(htext,'Type'),'uitable')% display data in a table
|
---|
| 347 | %
|
---|
| 348 | %
|
---|
| 349 | % set(htext,'Data',Data(2:end,:))
|
---|
| 350 | % else % display in a text edit box
|
---|
| 351 | % set(htext,'String',txt_cell)
|
---|
| 352 | % set(htext,'UserData',txt_cell)% for temporary storage when the edit box is used for mouse display
|
---|
| 353 | % end
|
---|
[201] | 354 |
|
---|
[429] | 355 |
|
---|
[201] | 356 | %-------------------------------------------------------------------
|
---|
[690] | 357 | % --- plot 1D fields (usual x,y plots)
|
---|
| 358 | %-------------------------------------------------------------------
|
---|
[644] | 359 | function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates,CheckHold)
|
---|
[201] | 360 |
|
---|
[644] | 361 | %% initialization
|
---|
[292] | 362 | if ~exist('Coordinates','var')
|
---|
| 363 | Coordinates=[];
|
---|
[201] | 364 | end
|
---|
[292] | 365 | CoordinatesOut=Coordinates; %default
|
---|
[201] | 366 | hfig=get(haxes,'parent');
|
---|
[644] | 367 | legend_str={};
|
---|
| 368 |
|
---|
| 369 | %% suppress existing plot if empty data
|
---|
[201] | 370 | if isempty(data)
|
---|
| 371 | hplot=findobj(haxes,'tag','plot_line');
|
---|
| 372 | if ~isempty(hplot)
|
---|
| 373 | delete(hplot)
|
---|
| 374 | end
|
---|
| 375 | hlegend=findobj(hfig,'tag','legend');
|
---|
| 376 | if ~isempty(hlegend)
|
---|
| 377 | delete(hlegend)
|
---|
| 378 | end
|
---|
| 379 | return
|
---|
| 380 | end
|
---|
| 381 |
|
---|
[644] | 382 | %% set the colors of the successive plots (designed to produce rgb for the three components of color images)
|
---|
[651] | 383 | ColorOrder=[1 0 0;0 1 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25];
|
---|
| 384 | set(hfig,'DefaultAxesColorOrder',ColorOrder)
|
---|
[644] | 385 | % if isfield(Coordinates,'NextPlot')
|
---|
| 386 | % set(haxes,'NextPlot',Coordinates.NextPlot)
|
---|
| 387 | % end
|
---|
| 388 | if CheckHold
|
---|
[690] | 389 | set(haxes,'NextPlot','add')
|
---|
[644] | 390 | else
|
---|
| 391 | set(haxes,'NextPlot','replace')
|
---|
[201] | 392 | end
|
---|
| 393 |
|
---|
| 394 | %% prepare the string for plot command
|
---|
| 395 | plotstr='hhh=plot(';
|
---|
[644] | 396 | % coord_x_index=[];
|
---|
[201] | 397 | xtitle='';
|
---|
| 398 | ytitle='';
|
---|
[644] | 399 | test_newplot=~CheckHold;
|
---|
[569] | 400 | MinX=[];
|
---|
| 401 | MaxX=[];
|
---|
| 402 | MinY_cell=[];
|
---|
| 403 | MaxY_cell=[];
|
---|
[201] | 404 | %loop on input fields
|
---|
[530] | 405 | for icell=1:numel(CellInfo)
|
---|
| 406 | VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list data.ListVarName
|
---|
| 407 | coord_x_index=CellInfo{icell}.CoordIndex;
|
---|
[201] | 408 | testplot=ones(size(data.ListVarName));%default test for plotted variables
|
---|
[426] | 409 | coord_x_name{icell}=data.ListVarName{coord_x_index};
|
---|
| 410 | coord_x{icell}=data.(data.ListVarName{coord_x_index});%coordinate variable set as coord_x
|
---|
[569] | 411 | if isempty(find(strcmp(coord_x_name{icell},coord_x_name(1:end-1)), 1)) %xtitle not already selected
|
---|
[426] | 412 | xtitle=[xtitle coord_x_name{icell}];
|
---|
| 413 | if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
|
---|
| 414 | xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units '), '];
|
---|
| 415 | else
|
---|
| 416 | xtitle=[xtitle ', '];
|
---|
| 417 | end
|
---|
[201] | 418 | end
|
---|
[729] | 419 | if ~isempty(coord_x{icell})
|
---|
| 420 | MinX(icell)=min(coord_x{icell});
|
---|
| 421 | MaxX(icell)=max(coord_x{icell});
|
---|
| 422 | testplot(coord_x_index)=0;
|
---|
| 423 | if isfield(CellInfo{icell},'VarIndex_ancillary')
|
---|
| 424 | testplot(CellInfo{icell}.VarIndex_ancillary)=0;
|
---|
| 425 | end
|
---|
| 426 | if isfield(CellInfo{icell},'VarIndex_warnflag')
|
---|
| 427 | testplot(CellInfo{icell}.VarIndex_warnflag)=0;
|
---|
| 428 | end
|
---|
| 429 | if isfield(data,'VarAttribute')
|
---|
| 430 | VarAttribute=data.VarAttribute;
|
---|
| 431 | for ivar=1:length(VarIndex)
|
---|
| 432 | if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')
|
---|
| 433 | plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;
|
---|
| 434 | else
|
---|
| 435 | plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
|
---|
| 436 | end
|
---|
[201] | 437 | end
|
---|
| 438 | end
|
---|
[729] | 439 | if isfield(CellInfo{icell},'VarIndex_discrete')
|
---|
| 440 | charplot_0='''+''';
|
---|
| 441 | else
|
---|
| 442 | charplot_0='''-''';
|
---|
| 443 | end
|
---|
| 444 | MinY=[];
|
---|
| 445 | MaxY=[];%default
|
---|
| 446 |
|
---|
| 447 | nbplot=0;
|
---|
| 448 | for ivar=1:length(VarIndex)
|
---|
| 449 | if testplot(VarIndex(ivar))
|
---|
| 450 | VarName=data.ListVarName{VarIndex(ivar)};
|
---|
| 451 | nbplot=nbplot+1;
|
---|
| 452 | ytitle=[ytitle VarName];
|
---|
| 453 | if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
|
---|
| 454 | ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), '];
|
---|
| 455 | else
|
---|
| 456 | ytitle=[ytitle ', '];
|
---|
| 457 | end
|
---|
| 458 | eval(['data.' VarName '=squeeze(data.' VarName ');'])
|
---|
| 459 | MinY(ivar)=min(min(data.(VarName)));
|
---|
| 460 | MaxY(ivar)=max(max(data.(VarName)));
|
---|
| 461 | plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
|
---|
| 462 | eval(['nbcomponent2=size(data.' VarName ',2);']);
|
---|
| 463 | eval(['nbcomponent1=size(data.' VarName ',1);']);
|
---|
| 464 | if numel(coord_x{icell})==2
|
---|
| 465 | coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1);
|
---|
| 466 | end
|
---|
| 467 | if nbcomponent1==1|| nbcomponent2==1
|
---|
| 468 | legend_str=[legend_str {VarName}]; %variable with one component
|
---|
| 469 | else %variable with severals components
|
---|
| 470 | for ic=1:min(nbcomponent1,nbcomponent2)
|
---|
| 471 | legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals components
|
---|
| 472 | end % labeled by their index (e.g. color component)
|
---|
| 473 | end
|
---|
[201] | 474 | end
|
---|
| 475 | end
|
---|
[729] | 476 | if ~isempty(MinY)
|
---|
| 477 | MinY_cell(icell)=min(MinY);
|
---|
| 478 | MaxY_cell(icell)=max(MaxY);
|
---|
| 479 | end
|
---|
[201] | 480 | end
|
---|
| 481 | end
|
---|
| 482 |
|
---|
| 483 | %% activate the plot
|
---|
[644] | 484 | if ~isequal(plotstr,'hhh=plot(')
|
---|
[201] | 485 | set(hfig,'CurrentAxes',haxes)
|
---|
| 486 | tag=get(haxes,'tag');
|
---|
| 487 | %%%
|
---|
| 488 | plotstr=[plotstr '''tag'',''plot_line'');'];
|
---|
| 489 | eval(plotstr) %execute plot (instruction plotstr)
|
---|
| 490 | %%%
|
---|
[651] | 491 | set(haxes,'tag',tag)% restitute the axes tag (removed by the command plot)
|
---|
| 492 | set(haxes,'ColorOrder',ColorOrder)% restitute the plot color order (to get red green blue for histograms or cuts of color images)
|
---|
[201] | 493 | grid(haxes, 'on')
|
---|
| 494 | hxlabel=xlabel(xtitle(1:end-2));% xlabel (removes ', ' at the end)
|
---|
| 495 | set(hxlabel,'Interpreter','none')% desable tex interpreter
|
---|
| 496 | if length(legend_str)>=1
|
---|
| 497 | hylabel=ylabel(ytitle(1:end-2));% ylabel (removes ', ' at the end)
|
---|
| 498 | set(hylabel,'Interpreter','none')% desable tex interpreter
|
---|
| 499 | end
|
---|
| 500 | if ~isempty(legend_str)
|
---|
| 501 | hlegend=findobj(hfig,'Tag','legend');
|
---|
| 502 | if isempty(hlegend)
|
---|
| 503 | hlegend=legend(legend_str);
|
---|
| 504 | txt=ver('MATLAB');
|
---|
| 505 | Release=txt.Release;
|
---|
| 506 | relnumb=str2double(Release(3:4));% should be changed to Version for better compatibility
|
---|
| 507 | if relnumb >= 14
|
---|
| 508 | set(hlegend,'Interpreter','none')% desable tex interpreter
|
---|
| 509 | end
|
---|
| 510 | else
|
---|
| 511 | legend_old=get(hlegend,'String');
|
---|
| 512 | if isequal(size(legend_old,1),size(legend_str,1))&&~isequal(legend_old,legend_str)
|
---|
| 513 | set(hlegend,'String',[legend_old legend_str]);
|
---|
| 514 | end
|
---|
| 515 | end
|
---|
| 516 | end
|
---|
| 517 | title_str='';
|
---|
| 518 | if isfield(data,'filename')
|
---|
| 519 | [Path, title_str, ext]=fileparts(data.filename);
|
---|
| 520 | title_str=[title_str ext];
|
---|
| 521 | end
|
---|
[477] | 522 | if isfield(data,'Action')&&isfield(data.Action,'ActionName')
|
---|
[201] | 523 | if ~isequal(title_str,'')
|
---|
| 524 | title_str=[title_str ', '];
|
---|
| 525 | end
|
---|
[477] | 526 | title_str=[title_str data.Action.ActionName];
|
---|
[201] | 527 | end
|
---|
| 528 | htitle=title(title_str);
|
---|
[428] | 529 | set(htitle,'Interpreter','none')% desable tex interpreter
|
---|
[201] | 530 | end
|
---|
| 531 |
|
---|
| 532 | %% determine axes bounds
|
---|
[294] | 533 | fix_lim=isfield(Coordinates,'CheckFixLimits') && Coordinates.CheckFixLimits;
|
---|
[569] | 534 | check_lim=isfield(Coordinates,'MinX')&&isfield(Coordinates,'MaxX')&&isfield(Coordinates,'MinY')&&isfield(Coordinates,'MaxY');
|
---|
[201] | 535 | if fix_lim
|
---|
[569] | 536 | if ~check_lim
|
---|
| 537 | fix_lim=0; %free limits if limits are not set,
|
---|
[221] | 538 | end
|
---|
[201] | 539 | end
|
---|
[294] | 540 | if fix_lim
|
---|
| 541 | set(haxes,'XLim',[Coordinates.MinX Coordinates.MaxX])
|
---|
| 542 | set(haxes,'YLim',[Coordinates.MinY Coordinates.MaxY])
|
---|
[569] | 543 | else
|
---|
| 544 | if ~isempty(MinX)
|
---|
| 545 | if check_lim
|
---|
| 546 | CoordinatesOut.MinX=min(min(MinX),CoordinatesOut.MinX);
|
---|
| 547 | CoordinatesOut.MaxX=max(max(MaxX),CoordinatesOut.MaxX);
|
---|
| 548 | else
|
---|
| 549 | CoordinatesOut.MinX=min(MinX);
|
---|
| 550 | CoordinatesOut.MaxX=max(MaxX);
|
---|
| 551 | end
|
---|
| 552 | end
|
---|
| 553 | if ~isempty(MinY_cell)
|
---|
| 554 | if check_lim
|
---|
| 555 | CoordinatesOut.MinY=min(min(MinY_cell),CoordinatesOut.MinY);
|
---|
| 556 | CoordinatesOut.MaxY=max(max(MaxY_cell),CoordinatesOut.MaxY);
|
---|
| 557 | else
|
---|
| 558 | CoordinatesOut.MinY=min(MinY_cell);
|
---|
| 559 | CoordinatesOut.MaxY=max(MaxY_cell);
|
---|
| 560 | end
|
---|
| 561 | end
|
---|
[201] | 562 | end
|
---|
| 563 |
|
---|
[428] | 564 | %% determine plot aspect ratio
|
---|
[789] | 565 | if isfield(Coordinates,'CheckFixAspectRatio') && isequal(Coordinates.CheckFixAspectRatio,1)&&isfield(Coordinates,'AspectRatio')
|
---|
| 566 | set(haxes,'DataAspectRatioMode','manual')
|
---|
| 567 | set(haxes,'DataAspectRatio',[Coordinates.AspectRatio 1 1])
|
---|
| 568 | else
|
---|
| 569 | set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio
|
---|
| 570 | AspectRatio=get(haxes,'DataAspectRatio');
|
---|
| 571 | CoordinatesOut.AspectRatio=AspectRatio(1)/AspectRatio(2);
|
---|
| 572 | end
|
---|
[428] | 573 |
|
---|
[201] | 574 | %-------------------------------------------------------------------
|
---|
[781] | 575 | function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam)
|
---|
[201] | 576 | %-------------------------------------------------------------------
|
---|
[674] | 577 | PlotType='plane';
|
---|
| 578 | grid(haxes, 'off')% remove grid (possibly remaining from other graphs)
|
---|
[411] | 579 |
|
---|
[201] | 580 | %default plotting parameters
|
---|
| 581 | if ~isfield(PlotParam,'Scalar')
|
---|
| 582 | PlotParam.Scalar=[];
|
---|
| 583 | end
|
---|
| 584 | if ~isfield(PlotParam,'Vectors')
|
---|
| 585 | PlotParam.Vectors=[];
|
---|
| 586 | end
|
---|
[674] | 587 | PlotParamOut=PlotParam;%default
|
---|
| 588 | errormsg='';%default
|
---|
[201] | 589 |
|
---|
[674] | 590 | hfig=get(haxes,'parent');%handle of the figure containing the plot axes
|
---|
[781] | 591 | PosColorbar=[];
|
---|
| 592 | FigData=get(hfig,'UserData');
|
---|
| 593 | if isfield(FigData,'PosColorbar')
|
---|
| 594 | PosColorbar=FigData.PosColorbar;
|
---|
| 595 | end
|
---|
[201] | 596 | hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
|
---|
| 597 | hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
|
---|
| 598 | test_ima=0; %default: test for image or map plot
|
---|
| 599 | test_vec=0; %default: test for vector plots
|
---|
| 600 | test_black=0;
|
---|
| 601 | test_false=0;
|
---|
| 602 | test_C=0;
|
---|
| 603 | XName='';
|
---|
| 604 | x_units='';
|
---|
| 605 | YName='';
|
---|
| 606 | y_units='';
|
---|
[674] | 607 |
|
---|
| 608 | % loop on the input field cells
|
---|
| 609 | for icell=1:numel(CellInfo)
|
---|
[530] | 610 | if strcmp(CellInfo{icell}.CoordType,'tps') %do not plot directly tps data (used for projection only)
|
---|
[402] | 611 | continue
|
---|
| 612 | end
|
---|
[530] | 613 | ivar_X=CellInfo{icell}.CoordIndex(end); % defines (unique) index for the variable representing unstructured x coordinate (default =[])
|
---|
| 614 | ivar_Y=CellInfo{icell}.CoordIndex(end-1); % defines (unique)index for the variable representing unstructured y coordinate (default =[])
|
---|
| 615 | ivar_C=[];
|
---|
| 616 | if isfield(CellInfo{icell},'VarIndex_scalar')
|
---|
| 617 | ivar_C=[ivar_C CellInfo{icell}.VarIndex_scalar];
|
---|
| 618 | end
|
---|
| 619 | if isfield(CellInfo{icell},'VarIndex_image')
|
---|
| 620 | ivar_C=[ivar_C CellInfo{icell}.VarIndex_image];
|
---|
| 621 | end
|
---|
| 622 | if isfield(CellInfo{icell},'VarIndex_color')
|
---|
| 623 | ivar_C=[ivar_C CellInfo{icell}.VarIndex_color];
|
---|
| 624 | end
|
---|
| 625 | if isfield(CellInfo{icell},'VarIndex_ancillary')
|
---|
| 626 | ivar_C=[ivar_C CellInfo{icell}.VarIndex_ancillary];
|
---|
| 627 | end
|
---|
[201] | 628 | if numel(ivar_C)>1
|
---|
| 629 | errormsg= 'error in plot_field: too many scalar inputs';
|
---|
| 630 | return
|
---|
| 631 | end
|
---|
[530] | 632 | ivar_F=[];
|
---|
| 633 | if isfield(CellInfo{icell},'VarIndex_warnflag')
|
---|
[674] | 634 | ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable
|
---|
[201] | 635 | end
|
---|
[674] | 636 | ivar_FF_vec=[];
|
---|
[530] | 637 | if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected
|
---|
[674] | 638 | if test_vec% a vector field has been already detected
|
---|
[515] | 639 | errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp';
|
---|
[201] | 640 | return
|
---|
| 641 | else
|
---|
| 642 | test_vec=1;
|
---|
[674] | 643 | if isfield(CellInfo{icell},'VarIndex_errorflag')
|
---|
| 644 | ivar_FF_vec=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable
|
---|
| 645 | end
|
---|
| 646 | vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x});
|
---|
[530] | 647 | vec_V=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_y});
|
---|
[674] | 648 | if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
|
---|
[530] | 649 | XName=Data.ListVarName{CellInfo{icell}.CoordIndex(end)};
|
---|
| 650 | YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
|
---|
[517] | 651 | vec_X=reshape(Data.(XName),[],1); %transform vectors in column matlab vectors
|
---|
| 652 | vec_Y=reshape(Data.(YName),[],1);
|
---|
[674] | 653 | elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
|
---|
[530] | 654 | y=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
|
---|
| 655 | x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
|
---|
[201] | 656 | if numel(y)==2 % y defined by first and last values on aregular mesh
|
---|
| 657 | y=linspace(y(1),y(2),size(vec_U,1));
|
---|
| 658 | end
|
---|
| 659 | if numel(x)==2 % y defined by first and last values on aregular mesh
|
---|
| 660 | x=linspace(x(1),x(2),size(vec_U,2));
|
---|
| 661 | end
|
---|
[674] | 662 | [vec_X,vec_Y]=meshgrid(x,y);
|
---|
[201] | 663 | end
|
---|
[517] | 664 | if isfield(PlotParam.Vectors,'ColorScalar') && ~isempty(PlotParam.Vectors.ColorScalar)
|
---|
| 665 | [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp([],Data,PlotParam.Vectors.ColorScalar);
|
---|
[530] | 666 | if ~isempty(VarVal)
|
---|
| 667 | vec_C=reshape(VarVal{1},1,numel(VarVal{1}));
|
---|
| 668 | test_C=1;
|
---|
| 669 | end
|
---|
[201] | 670 | end
|
---|
[674] | 671 | if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
|
---|
| 672 | % if test_vec
|
---|
[313] | 673 | vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for dubious vectors
|
---|
[674] | 674 | if ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
|
---|
[201] | 675 | test_black=1;
|
---|
| 676 | end
|
---|
[674] | 677 | % end
|
---|
[201] | 678 | end
|
---|
[674] | 679 | if ~isempty(ivar_FF_vec) %&& ~test_false
|
---|
| 680 | % if test_vec% TODO: deal with FF for structured coordinates
|
---|
| 681 | vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors
|
---|
| 682 | % end
|
---|
[201] | 683 | end
|
---|
| 684 | end
|
---|
| 685 | elseif ~isempty(ivar_C) %scalar or image
|
---|
| 686 | if test_ima
|
---|
[674] | 687 | errormsg='attempt to plot two scalar fields or images';
|
---|
[201] | 688 | return
|
---|
| 689 | end
|
---|
[530] | 690 | A=squeeze(Data.(Data.ListVarName{ivar_C}));% scalar represented as color image
|
---|
[201] | 691 | test_ima=1;
|
---|
[674] | 692 | if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
|
---|
[227] | 693 | A=reshape(A,1,[]);
|
---|
[201] | 694 | XName=Data.ListVarName{ivar_X};
|
---|
| 695 | YName=Data.ListVarName{ivar_Y};
|
---|
[782] | 696 | eval(['Coord_x=reshape(Data.' XName ',1,[]);'])
|
---|
| 697 | eval(['Coord_y=reshape(Data.' YName ',1,[]);'])
|
---|
| 698 | [A,Coord_x,Coord_y]=proj_grid(Coord_x',Coord_y',A',[],[],'np>256'); % interpolate on a grid
|
---|
[201] | 699 | if isfield(Data,'VarAttribute')
|
---|
| 700 | if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units')
|
---|
| 701 | x_units=[' (' Data.VarAttribute{ivar_X}.units ')'];
|
---|
| 702 | end
|
---|
| 703 | if numel(Data.VarAttribute)>=ivar_Y && isfield(Data.VarAttribute{ivar_Y},'units')
|
---|
| 704 | y_units=[' (' Data.VarAttribute{ivar_Y}.units ')'];
|
---|
| 705 | end
|
---|
[674] | 706 | end
|
---|
| 707 | elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
|
---|
[530] | 708 | YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
|
---|
[782] | 709 | Coord_y=Data.(YName);
|
---|
| 710 | Coord_x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
|
---|
[201] | 711 | test_interp_X=0; %default, regularly meshed X coordinate
|
---|
| 712 | test_interp_Y=0; %default, regularly meshed Y coordinate
|
---|
| 713 | if isfield(Data,'VarAttribute')
|
---|
[530] | 714 | if numel(Data.VarAttribute)>=CellInfo{icell}.CoordIndex(end) && isfield(Data.VarAttribute{CellInfo{icell}.CoordIndex(end)},'units')
|
---|
| 715 | x_units=Data.VarAttribute{CellInfo{icell}.CoordIndex(end)}.units;
|
---|
[201] | 716 | end
|
---|
[530] | 717 | if numel(Data.VarAttribute)>=CellInfo{icell}.CoordIndex(end-1) && isfield(Data.VarAttribute{CellInfo{icell}.CoordIndex(end-1)},'units')
|
---|
| 718 | y_units=Data.VarAttribute{CellInfo{icell}.CoordIndex(end-1)}.units;
|
---|
[201] | 719 | end
|
---|
[674] | 720 | end
|
---|
[782] | 721 | if numel(Coord_y)>2
|
---|
| 722 | DCoord_y=diff(Coord_y);
|
---|
| 723 | DCoord_y_min=min(DCoord_y);
|
---|
| 724 | DCoord_y_max=max(DCoord_y);
|
---|
| 725 | if sign(DCoord_y_min)~=sign(DCoord_y_max);% =1 for increasing values, 0 otherwise
|
---|
[674] | 726 | errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
|
---|
| 727 | return
|
---|
| 728 | end
|
---|
[782] | 729 | test_interp_Y=(DCoord_y_max-DCoord_y_min)> 0.0001*abs(DCoord_y_max);
|
---|
[201] | 730 | end
|
---|
[782] | 731 | if numel(Coord_x)>2
|
---|
| 732 | DCoord_x=diff(Coord_x);
|
---|
| 733 | DCoord_x_min=min(DCoord_x);
|
---|
| 734 | DCoord_x_max=max(DCoord_x);
|
---|
| 735 | if sign(DCoord_x_min)~=sign(DCoord_x_max);% =1 for increasing values, 0 otherwise
|
---|
[674] | 736 | errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
|
---|
| 737 | return
|
---|
| 738 | end
|
---|
[782] | 739 | test_interp_X=(DCoord_x_max-DCoord_x_min)> 0.0001*abs(DCoord_x_max);
|
---|
[674] | 740 | end
|
---|
| 741 | if test_interp_Y
|
---|
[782] | 742 | npxy(1)=max([256 floor((Coord_y(end)-Coord_y(1))/DCoord_y_min) floor((Coord_y(end)-Coord_y(1))/DCoord_y_max)]);
|
---|
| 743 | yI=linspace(Coord_y(1),Coord_y(end),npxy(1));
|
---|
[201] | 744 | if ~test_interp_X
|
---|
[782] | 745 | xI=linspace(Coord_x(1),Coord_x(end),size(A,2));%default
|
---|
| 746 | Coord_x=xI;
|
---|
[201] | 747 | end
|
---|
| 748 | end
|
---|
[674] | 749 | if test_interp_X
|
---|
[782] | 750 | npxy(2)=max([256 floor((Coord_x(end)-Coord_x(1))/DCoord_x_min) floor((Coord_x(end)-Coord_x(1))/DCoord_x_max)]);
|
---|
| 751 | xI=linspace(Coord_x(1),Coord_x(end),npxy(2));
|
---|
[201] | 752 | if ~test_interp_Y
|
---|
[782] | 753 | yI=linspace(Coord_y(1),Coord_y(end),size(A,1));
|
---|
| 754 | Coord_y=yI;
|
---|
[201] | 755 | end
|
---|
| 756 | end
|
---|
[674] | 757 | if test_interp_X || test_interp_Y
|
---|
[782] | 758 | [Coord_x2D,Coord_y2D]=meshgrid(Coord_x,Coord_y);
|
---|
| 759 | A=interp2(Coord_x2D,Coord_y2D,double(A),xI,yI');
|
---|
[201] | 760 | end
|
---|
[782] | 761 | Coord_x=[Coord_x(1) Coord_x(end)];% keep only the lower and upper bounds for image represnetation
|
---|
| 762 | Coord_y=[Coord_y(1) Coord_y(end)];
|
---|
[201] | 763 | end
|
---|
| 764 | end
|
---|
| 765 | %define coordinates as CoordUnits, if not defined as attribute for each variable
|
---|
| 766 | if isfield(Data,'CoordUnit')
|
---|
| 767 | if isempty(x_units)
|
---|
| 768 | x_units=Data.CoordUnit;
|
---|
| 769 | end
|
---|
| 770 | if isempty(y_units)
|
---|
| 771 | y_units=Data.CoordUnit;
|
---|
| 772 | end
|
---|
[674] | 773 | end
|
---|
| 774 | end
|
---|
[688] | 775 | PlotParamOut=PlotParam; % output plot parameters equal to input by default
|
---|
[201] | 776 |
|
---|
| 777 | %% image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 778 | if test_ima
|
---|
| 779 | % distinguish B/W and color images
|
---|
| 780 | np=size(A);%size of image
|
---|
| 781 | siz=numel(np);
|
---|
| 782 | if siz>3
|
---|
[428] | 783 | errormsg=['unrecognized scalar type: ' num2str(siz) ' dimensions'];
|
---|
| 784 | return
|
---|
[201] | 785 | end
|
---|
| 786 | if siz==3
|
---|
| 787 | if np(3)==1
|
---|
| 788 | siz=2;%B W image
|
---|
| 789 | elseif np(3)==3
|
---|
| 790 | siz=3;%color image
|
---|
| 791 | else
|
---|
[206] | 792 | errormsg=['unrecognized scalar type in plot_field: considered as 2D field with ' num2str(np(3)) ' color components'];
|
---|
[201] | 793 | return
|
---|
| 794 | end
|
---|
| 795 | end
|
---|
| 796 |
|
---|
[822] | 797 | %set for grey scale setting
|
---|
[421] | 798 | if isfield(PlotParam.Scalar,'CheckBW') && ~isempty(PlotParam.Scalar.CheckBW)
|
---|
| 799 | BW=PlotParam.Scalar.CheckBW; %BW=0 color imposed, else gray scale imposed.
|
---|
| 800 | else % BW imposed automatically chosen
|
---|
[201] | 801 | BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
|
---|
[421] | 802 | PlotParamOut.Scalar.CheckBW=BW;
|
---|
[428] | 803 | end
|
---|
[688] | 804 |
|
---|
[822] | 805 | % determine the plot option 'image' or 'contours'
|
---|
| 806 | CheckContour=0; %default
|
---|
[688] | 807 | if isfield(PlotParam.Scalar,'ListContour')
|
---|
| 808 | CheckContour=strcmp(PlotParam.Scalar.ListContour,'contours');% =1 for contour plot option
|
---|
[822] | 809 | end
|
---|
| 810 |
|
---|
| 811 | %case of grey level images or contour plot
|
---|
| 812 | if ~isfield(PlotParam.Scalar,'CheckFixScalar')
|
---|
| 813 | PlotParam.Scalar.CheckFixScalar=0;% free scalar threshold value scale (from min to max) by default
|
---|
| 814 | end
|
---|
| 815 | if ~isfield(PlotParam.Scalar,'MinA')
|
---|
| 816 | PlotParam.Scalar.MinA=[];%no min scalar threshold value set
|
---|
| 817 | end
|
---|
| 818 | if ~isfield(PlotParam.Scalar,'MaxA')
|
---|
| 819 | PlotParam.Scalar.MaxA=[];%no max scalar threshold value set
|
---|
| 820 | end
|
---|
| 821 |
|
---|
| 822 | % determine the min scalar value
|
---|
| 823 | if PlotParam.Scalar.CheckFixScalar && ~isempty(PlotParam.Scalar.MinA) && isnumeric(PlotParam.Scalar.MinA)
|
---|
| 824 | MinA=double(PlotParam.Scalar.MinA); % min value set as input
|
---|
[688] | 825 | else
|
---|
[822] | 826 | MinA=double(min(min(min(A)))); % min value set as min of non NaN scalar values
|
---|
[688] | 827 | end
|
---|
| 828 |
|
---|
[822] | 829 | % error if the input scalar is NaN everywhere
|
---|
| 830 | if isnan(MinA)
|
---|
| 831 | errormsg='NaN input scalar or image in plot_field';
|
---|
| 832 | return
|
---|
| 833 | end
|
---|
| 834 |
|
---|
| 835 | % determine the max scalar value
|
---|
| 836 | CheckFixScalar=0;
|
---|
| 837 | if PlotParam.Scalar.CheckFixScalar && ~isempty(PlotParam.Scalar.MaxA) && isnumeric(PlotParam.Scalar.MaxA)
|
---|
| 838 | MaxA=double(PlotParam.Scalar.MaxA); % max value set as input
|
---|
| 839 | CheckFixScalar=1;
|
---|
| 840 | else
|
---|
| 841 | MaxA=double(max(max(max(A)))); % max value set as min of non NaN scalar values
|
---|
| 842 | end
|
---|
| 843 |
|
---|
| 844 | PlotParamOut.Scalar.MinA=MinA;
|
---|
| 845 | PlotParamOut.Scalar.MaxA=MaxA;
|
---|
| 846 | PlotParamOut.Scalar.Npx=size(A,2);
|
---|
| 847 | PlotParamOut.Scalar.Npy=size(A,1);
|
---|
| 848 | % if siz==2
|
---|
| 849 | % case of contour plot
|
---|
| 850 | if CheckContour
|
---|
| 851 | if ~isempty(hima) && ishandle(hima)
|
---|
| 852 | delete(hima) % delete existing image
|
---|
[201] | 853 | end
|
---|
[822] | 854 |
|
---|
| 855 | % set the contour values
|
---|
| 856 | if ~isfield(PlotParam.Scalar,'IncrA')
|
---|
| 857 | PlotParam.Scalar.IncrA=[];% automatic contour interval
|
---|
[201] | 858 | end
|
---|
[822] | 859 | if ~isempty(PlotParam.Scalar.IncrA) && isnumeric(PlotParam.Scalar.IncrA)
|
---|
| 860 | interval=PlotParam.Scalar.IncrA;
|
---|
| 861 | else % automatic contour interval
|
---|
| 862 | cont=colbartick(MinA,MaxA);
|
---|
| 863 | interval=cont(2)-cont(1);%default
|
---|
| 864 | PlotParamOut.Scalar.IncrA=interval;% set the interval as output for display on the GUI
|
---|
[201] | 865 | end
|
---|
[822] | 866 | abscontmin=interval*floor(MinA/interval);
|
---|
| 867 | abscontmax=interval*ceil(MaxA/interval);
|
---|
| 868 | contmin=interval*floor(min(min(A))/interval);
|
---|
| 869 | contmax=interval*ceil(max(max(A))/interval);
|
---|
| 870 | cont_pos_plus=0:interval:contmax;% zero and positive contour values (plotted as solid lines)
|
---|
| 871 | cont_pos_min=double(contmin):interval:-interval;% negative contour values (plotted as dashed lines)
|
---|
| 872 | cont_pos=[cont_pos_min cont_pos_plus];% set of all contour values
|
---|
[688] | 873 |
|
---|
[822] | 874 | sizpx=(Coord_x(end)-Coord_x(1))/(np(2)-1);
|
---|
| 875 | sizpy=(Coord_y(1)-Coord_y(end))/(np(1)-1);
|
---|
| 876 | x_cont=Coord_x(1):sizpx:Coord_x(end); % pixel x coordinates for image display
|
---|
| 877 | y_cont=Coord_y(1):-sizpy:Coord_y(end); % pixel x coordinates for image display
|
---|
[688] | 878 |
|
---|
[822] | 879 | %axes(haxes)% set the input axes handle as current axis
|
---|
| 880 |
|
---|
| 881 | % colormap(map);
|
---|
| 882 | tag_axes=get(haxes,'Tag');% axes tag
|
---|
| 883 | Opacity=1;
|
---|
| 884 | if isfield(PlotParam.Scalar,'Opacity')&&~isempty(PlotParam.Scalar.Opacity)
|
---|
| 885 | Opacity=PlotParam.Scalar.Opacity;
|
---|
[688] | 886 | end
|
---|
[822] | 887 | % fill the space between contours if opacity is undefined or =1
|
---|
| 888 | if isequal(Opacity,1)
|
---|
| 889 | [var,hcontour]=contour(haxes,x_cont,y_cont,A,cont_pos);% determine all contours
|
---|
| 890 | set(hcontour,'Fill','on')% fill the space between contours
|
---|
| 891 | set(hcontour,'LineStyle','none')
|
---|
| 892 | hold on
|
---|
| 893 | end
|
---|
| 894 | [var_p,hcontour_p]=contour(haxes,x_cont,y_cont,A,cont_pos_plus,'k-');% draw the contours for positive values as solid lines
|
---|
| 895 | hold on
|
---|
| 896 | [var_m,hcontour_m]=contour(haxes,x_cont,y_cont,A,cont_pos_min,'--');% draw the contours for negative values as dashed lines
|
---|
| 897 | if isequal(Opacity,1)
|
---|
| 898 | set(hcontour_m,'LineColor',[1 1 1])% draw negative contours in white (better visibility in dark background)
|
---|
| 899 | end
|
---|
| 900 | set(haxes,'Tag',tag_axes);% restore axes tag (removed by the matlab fct contour !)
|
---|
| 901 | hold off
|
---|
[688] | 902 |
|
---|
[822] | 903 | %determine the color scale and map
|
---|
| 904 | caxis([abscontmin abscontmax])
|
---|
| 905 | if BW
|
---|
| 906 | vec=linspace(0,1,(abscontmax-abscontmin)/interval);%define a greyscale colormap with steps interval
|
---|
| 907 | map=[vec' vec' vec'];
|
---|
| 908 | colormap(map);
|
---|
[201] | 909 | else
|
---|
[822] | 910 | colormap('default'); % default matlab colormap ('jet')
|
---|
| 911 | end
|
---|
[688] | 912 |
|
---|
[822] | 913 | if isfield(PlotParam.Axes,'CheckFixAspectRatio') && isequal(PlotParam.Axes.CheckFixAspectRatio,1)
|
---|
| 914 | set(haxes,'DataAspectRatioMode','manual')
|
---|
| 915 | if isfield(PlotParam.Axes,'AspectRatio')
|
---|
| 916 | set(haxes,'DataAspectRatio',[PlotParam.Axes.AspectRatio 1 1])
|
---|
[688] | 917 | else
|
---|
[822] | 918 | set(haxes,'DataAspectRatio',[1 1 1])
|
---|
[201] | 919 | end
|
---|
[822] | 920 | end
|
---|
| 921 | else %usual images (no contour)
|
---|
[201] | 922 | % set colormap for image display
|
---|
[822] | 923 | if BW
|
---|
| 924 | vec=linspace(0,1,255);%define a linear greyscale colormap
|
---|
| 925 | map=[vec' vec' vec'];
|
---|
| 926 | colormap(map); %grey scale color map
|
---|
| 927 | if siz==3% true color images visualized in BW
|
---|
| 928 | A=uint16(sum(A,3));%sum the three color components for color images displayed with BW option
|
---|
[201] | 929 | end
|
---|
[822] | 930 | else
|
---|
| 931 | if siz==3 && CheckFixScalar % true color images rescaled by MaxA
|
---|
| 932 | A=uint8(255*double(A)/double(MaxA));
|
---|
| 933 | end
|
---|
| 934 | colormap('default'); % standard false colors for div, vort , scalar fields
|
---|
[201] | 935 | end
|
---|
| 936 |
|
---|
| 937 | % interpolate field to increase resolution of image display
|
---|
[652] | 938 | test_interp=0;
|
---|
[822] | 939 | if size(A,3)==1 % scalar or B/W image
|
---|
[652] | 940 | test_interp=1;
|
---|
| 941 | if max(np) <= 64
|
---|
| 942 | npxy=8*np;% increase the resolution 8 times
|
---|
| 943 | elseif max(np) <= 128
|
---|
| 944 | npxy=4*np;% increase the resolution 4 times
|
---|
| 945 | elseif max(np) <= 256
|
---|
| 946 | npxy=2*np;% increase the resolution 2 times
|
---|
| 947 | else
|
---|
| 948 | npxy=np;
|
---|
| 949 | test_interp=0; % no interpolation done
|
---|
| 950 | end
|
---|
[201] | 951 | end
|
---|
[652] | 952 | if test_interp%if we interpolate
|
---|
[782] | 953 | x=linspace(Coord_x(1),Coord_x(2),np(2));
|
---|
| 954 | y=linspace(Coord_y(1),Coord_y(2),np(1));
|
---|
[201] | 955 | [X,Y]=meshgrid(x,y);
|
---|
[782] | 956 | xi=linspace(Coord_x(1),Coord_x(2),npxy(2));
|
---|
| 957 | yi=linspace(Coord_y(1),Coord_y(2),npxy(1));
|
---|
[688] | 958 | A = interp2(X,Y,double(A),xi,yi');
|
---|
[428] | 959 | end
|
---|
[848] | 960 | % create new image if no image handle is found
|
---|
[428] | 961 | if isempty(hima)
|
---|
[201] | 962 | tag=get(haxes,'Tag');
|
---|
| 963 | if MinA<MaxA
|
---|
[782] | 964 | hima=imagesc(Coord_x,Coord_y,A,[MinA MaxA]);
|
---|
[201] | 965 | else % to deal with uniform field
|
---|
[782] | 966 | hima=imagesc(Coord_x,Coord_y,A,[MaxA-1 MaxA]);
|
---|
[201] | 967 | end
|
---|
[428] | 968 | % the function imagesc reset the axes 'DataAspectRatioMode'='auto', change if .CheckFixAspectRatio is
|
---|
[411] | 969 | % requested:
|
---|
| 970 | set(hima,'Tag','ima')
|
---|
| 971 | set(hima,'HitTest','off')
|
---|
[428] | 972 | set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!)
|
---|
[201] | 973 | uistack(hima, 'bottom')
|
---|
[428] | 974 | % update an existing image
|
---|
[201] | 975 | else
|
---|
[688] | 976 | set(hima,'CData',A);
|
---|
[201] | 977 | if MinA<MaxA
|
---|
| 978 | set(haxes,'CLim',[MinA MaxA])
|
---|
| 979 | else
|
---|
[238] | 980 | set(haxes,'CLim',[MinA MaxA+1])
|
---|
[201] | 981 | end
|
---|
[782] | 982 | set(hima,'XData',Coord_x);
|
---|
| 983 | set(hima,'YData',Coord_y);
|
---|
[201] | 984 | end
|
---|
[546] | 985 |
|
---|
[405] | 986 | % set the transparency to 0.5 if vectors are also plotted
|
---|
[428] | 987 | if isfield(PlotParam.Scalar,'Opacity')&& ~isempty(PlotParam.Scalar.Opacity)
|
---|
| 988 | set(hima,'AlphaData',PlotParam.Scalar.Opacity)
|
---|
[405] | 989 | else
|
---|
[428] | 990 | if test_vec
|
---|
| 991 | set(hima,'AlphaData',0.5)%set opacity to 0.5 by default in the presence of vectors
|
---|
| 992 | PlotParamOut.Scalar.Opacity=0.5;
|
---|
| 993 | else
|
---|
| 994 | set(hima,'AlphaData',1)% full opacity (no transparency) by default
|
---|
| 995 | end
|
---|
[405] | 996 | end
|
---|
[201] | 997 | end
|
---|
| 998 | test_ima=1;
|
---|
| 999 |
|
---|
| 1000 | %display the colorbar code for B/W images if Poscolorbar not empty
|
---|
[546] | 1001 | if ~isempty(PosColorbar)
|
---|
[822] | 1002 | if size(A,3)==1 && exist('PosColorbar','var')
|
---|
[546] | 1003 | if isempty(hcol)||~ishandle(hcol)
|
---|
| 1004 | hcol=colorbar;%create new colorbar
|
---|
| 1005 | end
|
---|
| 1006 | if length(PosColorbar)==4
|
---|
| 1007 | set(hcol,'Position',PosColorbar)
|
---|
| 1008 | end
|
---|
| 1009 | %YTick=0;%default
|
---|
| 1010 | if MaxA>MinA
|
---|
| 1011 | if CheckContour
|
---|
| 1012 | colbarlim=get(hcol,'YLim');
|
---|
| 1013 | scale_bar=(colbarlim(2)-colbarlim(1))/(abscontmax-abscontmin);
|
---|
| 1014 | YTick=cont_pos(2:end-1);
|
---|
| 1015 | YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin);
|
---|
| 1016 | set(hcol,'YTick',YTick_scaled);
|
---|
| 1017 | elseif (isfield(PlotParam.Scalar,'CheckBW') && isequal(PlotParam.Scalar.CheckBW,1))||isa(A,'uint8')|| isa(A,'uint16')%images
|
---|
| 1018 | hi=get(hcol,'children');
|
---|
| 1019 | if iscell(hi)%multiple images in colorbar
|
---|
| 1020 | hi=hi{1};
|
---|
| 1021 | end
|
---|
| 1022 | set(hi,'YData',[MinA MaxA])
|
---|
| 1023 | set(hi,'CData',(1:256)')
|
---|
| 1024 | set(hcol,'YLim',[MinA MaxA])
|
---|
| 1025 | YTick=colbartick(MinA,MaxA);
|
---|
| 1026 | set(hcol,'YTick',YTick)
|
---|
| 1027 | else
|
---|
| 1028 | hi=get(hcol,'children');
|
---|
| 1029 | if iscell(hi)%multiple images in colorbar
|
---|
| 1030 | hi=hi{1};
|
---|
| 1031 | end
|
---|
| 1032 | set(hi,'YData',[MinA MaxA])
|
---|
| 1033 | set(hi,'CData',(1:64)')
|
---|
| 1034 | YTick=colbartick(MinA,MaxA);
|
---|
| 1035 | set(hcol,'YLim',[MinA MaxA])
|
---|
| 1036 | set(hcol,'YTick',YTick)
|
---|
[201] | 1037 | end
|
---|
[546] | 1038 | set(hcol,'Yticklabel',num2str(YTick'));
|
---|
[201] | 1039 | end
|
---|
[546] | 1040 | elseif ishandle(hcol)
|
---|
| 1041 | delete(hcol); %erase existing colorbar if not needed
|
---|
[201] | 1042 | end
|
---|
| 1043 | end
|
---|
| 1044 | else%no scalar plot
|
---|
[428] | 1045 | if ~isempty(hima) && ishandle(hima)
|
---|
[201] | 1046 | delete(hima)
|
---|
| 1047 | end
|
---|
[546] | 1048 | if ~isempty(PosColorbar) && ~isempty(hcol)&& ishandle(hcol)
|
---|
[428] | 1049 | delete(hcol)
|
---|
[201] | 1050 | end
|
---|
| 1051 | PlotParamOut=rmfield(PlotParamOut,'Scalar');
|
---|
| 1052 | end
|
---|
| 1053 |
|
---|
| 1054 | %% vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 1055 | if test_vec
|
---|
| 1056 | %vector scale representation
|
---|
| 1057 | if size(vec_U,1)==numel(vec_Y) && size(vec_U,2)==numel(vec_X); % x, y coordinate variables
|
---|
| 1058 | [vec_X,vec_Y]=meshgrid(vec_X,vec_Y);
|
---|
| 1059 | end
|
---|
| 1060 | vec_X=reshape(vec_X,1,numel(vec_X));%reshape in matlab vectors
|
---|
| 1061 | vec_Y=reshape(vec_Y,1,numel(vec_Y));
|
---|
| 1062 | vec_U=reshape(vec_U,1,numel(vec_U));
|
---|
| 1063 | vec_V=reshape(vec_V,1,numel(vec_V));
|
---|
| 1064 | MinMaxX=max(vec_X)-min(vec_X);
|
---|
[294] | 1065 | if isfield(PlotParam.Vectors,'CheckFixVectors') && isequal(PlotParam.Vectors.CheckFixVectors,1)&& isfield(PlotParam.Vectors,'VecScale')...
|
---|
[210] | 1066 | &&~isempty(PlotParam.Vectors.VecScale) && isa(PlotParam.Vectors.VecScale,'double') %fixed vector scale
|
---|
| 1067 | scale=PlotParam.Vectors.VecScale; %impose the length of vector representation
|
---|
| 1068 | else
|
---|
| 1069 | if ~test_false %remove false vectors
|
---|
[201] | 1070 | indsel=1:numel(vec_X);%
|
---|
| 1071 | end
|
---|
| 1072 | if isempty(vec_U)
|
---|
| 1073 | scale=1;
|
---|
| 1074 | else
|
---|
| 1075 | if isempty(indsel)
|
---|
| 1076 | MaxU=max(abs(vec_U));
|
---|
| 1077 | MaxV=max(abs(vec_V));
|
---|
| 1078 | else
|
---|
| 1079 | MaxU=max(abs(vec_U(indsel)));
|
---|
| 1080 | MaxV=max(abs(vec_V(indsel)));
|
---|
| 1081 | end
|
---|
| 1082 | scale=MinMaxX/(max(MaxU,MaxV)*50);
|
---|
| 1083 | PlotParam.Vectors.VecScale=scale;%update the 'scale' display
|
---|
| 1084 | end
|
---|
[210] | 1085 | end
|
---|
[201] | 1086 |
|
---|
| 1087 | %record vectors on the plotting axes
|
---|
| 1088 | if test_C==0
|
---|
| 1089 | vec_C=ones(1,numel(vec_X));
|
---|
| 1090 | end
|
---|
| 1091 |
|
---|
| 1092 | %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
|
---|
[581] | 1093 | check_decimate=0;
|
---|
[294] | 1094 | if isfield(PlotParam.Vectors,'CheckDecimate4') && PlotParam.Vectors.CheckDecimate4
|
---|
[581] | 1095 | check_decimate=1;
|
---|
[201] | 1096 | diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
|
---|
| 1097 | dy_thresh=max(abs(diffy))/2;
|
---|
| 1098 | ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
|
---|
| 1099 | ind_sel=1:ind_jump(1);%select the first line
|
---|
| 1100 | for i=2:2:length(ind_jump)-1
|
---|
| 1101 | ind_sel=[ind_sel (ind_jump(i)+1:ind_jump(i+1))];% select the odd lines
|
---|
| 1102 | end
|
---|
| 1103 | nb_sel=length(ind_sel);
|
---|
| 1104 | ind_sel=ind_sel(1:2:nb_sel);% take half the points on a line
|
---|
[581] | 1105 | elseif isfield(PlotParam.Vectors,'CheckDecimate16') && PlotParam.Vectors.CheckDecimate16
|
---|
| 1106 | check_decimate=1;
|
---|
| 1107 | diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
|
---|
| 1108 | dy_thresh=max(abs(diffy))/2;
|
---|
| 1109 | ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
|
---|
| 1110 | ind_sel=1:ind_jump(1);%select the first line
|
---|
| 1111 | for i=2:4:length(ind_jump)-1
|
---|
| 1112 | ind_sel=[ind_sel (ind_jump(i)+1:ind_jump(i+1))];% select the odd lines
|
---|
| 1113 | end
|
---|
| 1114 | nb_sel=length(ind_sel);
|
---|
| 1115 | ind_sel=ind_sel(1:4:nb_sel);% take half the points on a line
|
---|
| 1116 | end
|
---|
| 1117 | if check_decimate
|
---|
[201] | 1118 | vec_X=vec_X(ind_sel);
|
---|
| 1119 | vec_Y=vec_Y(ind_sel);
|
---|
| 1120 | vec_U=vec_U(ind_sel);
|
---|
| 1121 | vec_V=vec_V(ind_sel);
|
---|
| 1122 | vec_C=vec_C(ind_sel);
|
---|
| 1123 | if ~isempty(ivar_F)
|
---|
| 1124 | vec_F=vec_F(ind_sel);
|
---|
| 1125 | end
|
---|
[674] | 1126 | if ~isempty(ivar_FF_vec)
|
---|
[201] | 1127 | vec_FF=vec_FF(ind_sel);
|
---|
| 1128 | end
|
---|
| 1129 | end
|
---|
| 1130 |
|
---|
| 1131 | %get main level color code
|
---|
| 1132 | [colorlist,col_vec,PlotParamOut.Vectors]=set_col_vec(PlotParam.Vectors,vec_C);
|
---|
| 1133 |
|
---|
| 1134 | % take flags into account: add flag colors to the list of colors
|
---|
| 1135 | sizlist=size(colorlist);
|
---|
| 1136 | nbcolor=sizlist(1);
|
---|
| 1137 | if test_black
|
---|
| 1138 | nbcolor=nbcolor+1;
|
---|
| 1139 | colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors
|
---|
[674] | 1140 | if ~isempty(ivar_FF_vec)
|
---|
[210] | 1141 | col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor;
|
---|
[201] | 1142 | else
|
---|
[210] | 1143 | col_vec(vec_F~=1 & vec_F~=0)=nbcolor;
|
---|
[201] | 1144 | end
|
---|
| 1145 | end
|
---|
| 1146 | nbcolor=nbcolor+1;
|
---|
[674] | 1147 | if ~isempty(ivar_FF_vec)
|
---|
[294] | 1148 | if isfield(PlotParam.Vectors,'CheckHideFalse') && PlotParam.Vectors.CheckHideFalse==1
|
---|
[201] | 1149 | colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
|
---|
| 1150 | else
|
---|
| 1151 | colorlist(nbcolor,:)=[1 0 1];% magenta color
|
---|
| 1152 | end
|
---|
[210] | 1153 | col_vec(vec_FF~=0)=nbcolor;
|
---|
[201] | 1154 | end
|
---|
| 1155 | %plot vectors:
|
---|
| 1156 | quiresetn(haxes,vec_X,vec_Y,vec_U,vec_V,scale,colorlist,col_vec);
|
---|
| 1157 |
|
---|
| 1158 | else
|
---|
| 1159 | hvec=findobj(haxes,'Tag','vel');
|
---|
| 1160 | if ~isempty(hvec)
|
---|
| 1161 | delete(hvec);
|
---|
| 1162 | end
|
---|
| 1163 | PlotParamOut=rmfield(PlotParamOut,'Vectors');
|
---|
| 1164 | end
|
---|
[546] | 1165 | % nbvar=0;
|
---|
[201] | 1166 |
|
---|
| 1167 | %store the coordinate extrema occupied by the field
|
---|
| 1168 | if ~isempty(Data)
|
---|
[569] | 1169 | MinX=[];
|
---|
| 1170 | MaxX=[];
|
---|
| 1171 | MinY=[];
|
---|
| 1172 | MaxY=[];
|
---|
[748] | 1173 | fix_lim=isfield(PlotParam.Axes,'CheckFixLimits') && PlotParam.Axes.CheckFixLimits;
|
---|
[201] | 1174 | if fix_lim
|
---|
[748] | 1175 | if isfield(PlotParam.Axes,'MinX')&&isfield(PlotParam.Axes,'MaxX')&&isfield(PlotParam.Axes,'MinY')&&isfield(PlotParam.Axes,'MaxY')
|
---|
| 1176 | MinX=PlotParam.Axes.MinX;
|
---|
| 1177 | MaxX=PlotParam.Axes.MaxX;
|
---|
| 1178 | MinY=PlotParam.Axes.MinY;
|
---|
| 1179 | MaxY=PlotParam.Axes.MaxY;
|
---|
[569] | 1180 | end %else PlotParamOut.MinX =PlotParam.MinX...
|
---|
[252] | 1181 | else
|
---|
| 1182 | if test_ima %both background image and vectors coexist, take the wider bound
|
---|
[782] | 1183 | MinX=min(Coord_x);
|
---|
| 1184 | MaxX=max(Coord_x);
|
---|
| 1185 | MinY=min(Coord_y);
|
---|
| 1186 | MaxY=max(Coord_y);
|
---|
[252] | 1187 | if test_vec
|
---|
[569] | 1188 | MinX=min(MinX,min(vec_X));
|
---|
| 1189 | MaxX=max(MaxX,max(vec_X));
|
---|
| 1190 | MinY=min(MinY,min(vec_Y));
|
---|
| 1191 | MaxY=max(MaxY,max(vec_Y));
|
---|
[252] | 1192 | end
|
---|
| 1193 | elseif test_vec
|
---|
[569] | 1194 | MinX=min(vec_X);
|
---|
| 1195 | MaxX=max(vec_X);
|
---|
| 1196 | MinY=min(vec_Y);
|
---|
| 1197 | MaxY=max(vec_Y);
|
---|
[201] | 1198 | end
|
---|
[252] | 1199 | end
|
---|
[748] | 1200 | PlotParamOut.Axes.MinX=MinX;
|
---|
| 1201 | PlotParamOut.Axes.MaxX=MaxX;
|
---|
| 1202 | PlotParamOut.Axes.MinY=MinY;
|
---|
| 1203 | PlotParamOut.Axes.MaxY=MaxY;
|
---|
[569] | 1204 | if MaxX>MinX
|
---|
| 1205 | set(haxes,'XLim',[MinX MaxX]);% set x limits of frame in axes coordinates
|
---|
[546] | 1206 | end
|
---|
[569] | 1207 | if MaxY>MinY
|
---|
| 1208 | set(haxes,'YLim',[MinY MaxY]);% set x limits of frame in axes coordinates
|
---|
[546] | 1209 | end
|
---|
[201] | 1210 | set(haxes,'YDir','normal')
|
---|
| 1211 | set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']);
|
---|
| 1212 | set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']);
|
---|
[748] | 1213 | PlotParamOut.Axes.x_units=x_units;
|
---|
| 1214 | PlotParamOut.Axes.y_units=y_units;
|
---|
[201] | 1215 | end
|
---|
[760] | 1216 | % if isfield(PlotParam,'Axes') && isfield(PlotParam.Axes,'CheckFixAspectRatio') && isequal(PlotParam.Axes.CheckFixAspectRatio,1)
|
---|
| 1217 | % set(haxes,'DataAspectRatioMode','manual')
|
---|
| 1218 | % if isfield(PlotParam.Axes,'AspectRatio')
|
---|
| 1219 | % set(haxes,'DataAspectRatio',[PlotParam.Axes.AspectRatio 1 1])
|
---|
| 1220 | % end
|
---|
| 1221 | % else
|
---|
| 1222 | % set(haxes,'DataAspectRatioMode','auto')
|
---|
| 1223 | % end
|
---|
| 1224 |
|
---|
[201] | 1225 | %-------------------------------------------------------------------
|
---|
| 1226 | % --- function for plotting vectors
|
---|
| 1227 | %INPUT:
|
---|
| 1228 | % haxes: handles of the plotting axes
|
---|
| 1229 | % x,y,u,v: vectors coordinates and vector components to plot, arrays withb the same dimension
|
---|
| 1230 | % scale: scaling factor for vector length representation
|
---|
| 1231 | % colorlist(icolor,:): list of vector colors, dim (nbcolor,3), depending on color #i
|
---|
| 1232 | % col_vec: matlab vector setting the color number #i for each velocity vector
|
---|
| 1233 | function quiresetn(haxes,x,y,u,v,scale,colorlist,col_vec)
|
---|
| 1234 | %-------------------------------------------------------------------
|
---|
| 1235 | %define arrows
|
---|
| 1236 | theta=0.5 ;%angle arrow
|
---|
| 1237 | alpha=0.3 ;%length arrow
|
---|
| 1238 | rot=alpha*[cos(theta) -sin(theta); sin(theta) cos(theta)]';
|
---|
| 1239 | %find the existing lines
|
---|
| 1240 | h=findobj(haxes,'Tag','vel');% search existing lines in the current axes
|
---|
| 1241 | sizh=size(h);
|
---|
| 1242 | set(h,'EraseMode','xor');
|
---|
| 1243 | set(haxes,'NextPlot','replacechildren');
|
---|
| 1244 |
|
---|
| 1245 | %drawnow
|
---|
| 1246 | %create lines (if no lines) or modify them
|
---|
| 1247 | if ~isequal(size(col_vec),size(x))
|
---|
| 1248 | col_vec=ones(size(x));% case of error in col_vec input
|
---|
| 1249 | end
|
---|
| 1250 | sizlist=size(colorlist);
|
---|
| 1251 | ncolor=sizlist(1);
|
---|
| 1252 |
|
---|
| 1253 | for icolor=1:ncolor
|
---|
| 1254 | %determine the line positions for each color icolor
|
---|
| 1255 | ind=find(col_vec==icolor);
|
---|
| 1256 | xc=x(ind);
|
---|
| 1257 | yc=y(ind);
|
---|
| 1258 | uc=u(ind)*scale;
|
---|
| 1259 | vc=v(ind)*scale;
|
---|
| 1260 | n=size(xc);
|
---|
| 1261 | xN=NaN*ones(size(xc));
|
---|
| 1262 | matx=[xc(:)-uc(:)/2 xc(:)+uc(:)/2 xN(:)]';
|
---|
| 1263 | matx=reshape(matx,1,3*n(2));
|
---|
| 1264 | maty=[yc(:)-vc(:)/2 yc(:)+vc(:)/2 xN(:)]';
|
---|
| 1265 | maty=reshape(maty,1,3*n(2));
|
---|
| 1266 |
|
---|
| 1267 | %determine arrow heads
|
---|
| 1268 | arrowplus=rot*[uc;vc];
|
---|
| 1269 | arrowmoins=rot'*[uc;vc];
|
---|
| 1270 | x1=xc+uc/2-arrowplus(1,:);
|
---|
| 1271 | x2=xc+uc/2;
|
---|
| 1272 | x3=xc+uc/2-arrowmoins(1,:);
|
---|
| 1273 | y1=yc+vc/2-arrowplus(2,:);
|
---|
| 1274 | y2=yc+vc/2;
|
---|
| 1275 | y3=yc+vc/2-arrowmoins(2,:);
|
---|
| 1276 | matxar=[x1(:) x2(:) x3(:) xN(:)]';
|
---|
| 1277 | matxar=reshape(matxar,1,4*n(2));
|
---|
| 1278 | matyar=[y1(:) y2(:) y3(:) xN(:)]';
|
---|
| 1279 | matyar=reshape(matyar,1,4*n(2));
|
---|
| 1280 | %draw the line or modify the existing ones
|
---|
[421] | 1281 | % tri=reshape(1:3*length(uc),3,[])';
|
---|
[201] | 1282 | isn=isnan(colorlist(icolor,:));%test if color NaN
|
---|
| 1283 | if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones
|
---|
| 1284 | if ~isn(1) %if the vectors are visible color not nan
|
---|
| 1285 | if n(2)>0
|
---|
| 1286 | hold on
|
---|
| 1287 | line(matx,maty,'Color',colorlist(icolor,:),'Tag','vel');% plot new lines
|
---|
| 1288 | line(matxar,matyar,'Color',colorlist(icolor,:),'Tag','vel');% plot arrows
|
---|
| 1289 | end
|
---|
| 1290 | end
|
---|
| 1291 | else
|
---|
| 1292 | if isn(1)
|
---|
| 1293 | delete(h(2*icolor-1))
|
---|
| 1294 | delete(h(2*icolor))
|
---|
| 1295 | else
|
---|
| 1296 | set(h(2*icolor-1),'Xdata',matx,'Ydata',maty);
|
---|
| 1297 | set(h(2*icolor-1),'Color',colorlist(icolor,:));
|
---|
| 1298 | set(h(2*icolor-1),'EraseMode','xor');
|
---|
| 1299 | set(h(2*icolor),'Xdata',matxar,'Ydata',matyar);
|
---|
| 1300 | set(h(2*icolor),'Color',colorlist(icolor,:));
|
---|
| 1301 | set(h(2*icolor),'EraseMode','xor');
|
---|
| 1302 | end
|
---|
| 1303 | end
|
---|
| 1304 | end
|
---|
| 1305 | if sizh(1) > 2*ncolor
|
---|
| 1306 | for icolor=ncolor+1 : sizh(1)/2%delete additional objects
|
---|
| 1307 | delete(h(2*icolor-1))
|
---|
| 1308 | delete(h(2*icolor))
|
---|
| 1309 | end
|
---|
| 1310 | end
|
---|
| 1311 |
|
---|
| 1312 | %-------------------------------------------------------------------
|
---|
| 1313 | % ---- determine tick positions for colorbar
|
---|
| 1314 | function YTick=colbartick(MinA,MaxA)
|
---|
| 1315 | %-------------------------------------------------------------------
|
---|
| 1316 | %determine tick positions with "simple" values between MinA and MaxA
|
---|
| 1317 | YTick=0;%default
|
---|
| 1318 | maxabs=max([abs(MinA) abs(MaxA)]);
|
---|
| 1319 | if maxabs>0
|
---|
| 1320 | ord=10^(floor(log10(maxabs)));%order of magnitude
|
---|
| 1321 | div=1;
|
---|
| 1322 | siz2=1;
|
---|
| 1323 | while siz2<2
|
---|
| 1324 | values=-10:div:10;
|
---|
| 1325 | ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);%indices of 'values' such that MinA<ord*values<MaxA
|
---|
| 1326 | siz=size(ind);
|
---|
| 1327 | if siz(2)<4%if there are less than 4 selected values (4 levels)
|
---|
| 1328 | values=-9:0.5*div:9;
|
---|
| 1329 | ind=find((ord*values-MaxA)<0 & (ord*values-MinA)>0);
|
---|
| 1330 | end
|
---|
| 1331 | siz2=size(ind,2);
|
---|
| 1332 | div=div/10;
|
---|
| 1333 | end
|
---|
| 1334 | YTick=ord*values(ind);
|
---|
| 1335 | end
|
---|
| 1336 |
|
---|
[356] | 1337 | % -------------------------------------------------------------------------
|
---|
[389] | 1338 | % --- 'proj_grid': project fields with unstructured coordinantes on a regular grid
|
---|
[356] | 1339 | function [A,rangx,rangy]=proj_grid(vec_X,vec_Y,vec_A,rgx_in,rgy_in,npxy_in)
|
---|
[389] | 1340 | % -------------------------------------------------------------------------
|
---|
[356] | 1341 | if length(vec_Y)<2
|
---|
| 1342 | msgbox_uvmat('ERROR','less than 2 points in proj_grid.m');
|
---|
| 1343 | return;
|
---|
| 1344 | end
|
---|
| 1345 | diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
|
---|
| 1346 | index=find(diffy);% find the indices of vec_Y after wich a change of horizontal line occurs(diffy non zero)
|
---|
| 1347 | if isempty(index); msgbox_uvmat('ERROR','points aligned along abscissa in proj_grid.m'); return; end;%points aligned% A FAIRE: switch to line plot.
|
---|
| 1348 | diff2=diff(diffy(index));% diff2 = fluctuations of the detected vertical grid mesh dy
|
---|
| 1349 | if max(abs(diff2))>0.001*abs(diffy(index(1))) % if max(diff2) is larger than 1/1000 of the first mesh dy
|
---|
| 1350 | % the data are not regularly spaced and must be interpolated on a regular grid
|
---|
| 1351 | if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2% positions imposed from input
|
---|
| 1352 | rangx=rgx_in; % first and last positions
|
---|
| 1353 | rangy=rgy_in;
|
---|
| 1354 | dxy(1)=1/(npxy_in(1)-1);%grid mesh in y
|
---|
| 1355 | dxy(2)=1/(npxy_in(2)-1);%grid mesh in x
|
---|
| 1356 | dxy(1)=(rangy(2)-rangy(1))/(npxy_in(1)-1);%grid mesh in y
|
---|
| 1357 | dxy(2)=(rangx(2)-rangx(1))/(npxy_in(2)-1);%grid mesh in x
|
---|
| 1358 | else % interpolation grid automatically determined
|
---|
| 1359 | rangx(1)=min(vec_X);
|
---|
| 1360 | rangx(2)=max(vec_X);
|
---|
| 1361 | rangy(2)=min(vec_Y);
|
---|
| 1362 | rangy(1)=max(vec_Y);
|
---|
| 1363 | dxymod=sqrt((rangx(2)-rangx(1))*(rangy(1)-rangy(2))/length(vec_X));
|
---|
| 1364 | dxy=[-dxymod/4 dxymod/4];% increase the resolution 4 times
|
---|
| 1365 | end
|
---|
| 1366 | xi=[rangx(1):dxy(2):rangx(2)];
|
---|
| 1367 | yi=[rangy(1):dxy(1):rangy(2)];
|
---|
| 1368 | A=griddata_uvmat(vec_X,vec_Y,vec_A,xi,yi');
|
---|
| 1369 | A=reshape(A,length(yi),length(xi));
|
---|
| 1370 | else
|
---|
| 1371 | x=vec_X(1:index(1));% the set of abscissa (obtained on the first line)
|
---|
| 1372 | indexend=index(end);% last vector index of line change
|
---|
| 1373 | ymax=vec_Y(indexend+1);% y coordinate AFTER line change
|
---|
| 1374 | ymin=vec_Y(index(1));
|
---|
| 1375 | y=vec_Y(index);
|
---|
| 1376 | y(length(y)+1)=ymax;
|
---|
| 1377 | nx=length(x); %number of grid points in x
|
---|
| 1378 | ny=length(y); % number of grid points in y
|
---|
| 1379 | B=(reshape(vec_A,nx,ny))'; %vec_A reshaped as a rectangular matrix
|
---|
| 1380 | [X,Y]=meshgrid(x,y);% positions X and Y also reshaped as matrix
|
---|
| 1381 |
|
---|
| 1382 | %linear interpolation to improve the image resolution and/or adjust
|
---|
| 1383 | %to prescribed positions
|
---|
| 1384 | test_interp=1;
|
---|
| 1385 | if exist('rgx_in','var') & ~isempty (rgx_in) & isnumeric(rgx_in) & length(rgx_in)==2% positions imposed from input
|
---|
| 1386 | rangx=rgx_in; % first and last positions
|
---|
| 1387 | rangy=rgy_in;
|
---|
| 1388 | npxy=npxy_in;
|
---|
| 1389 | else
|
---|
| 1390 | rangx=[vec_X(1) vec_X(nx)];% first and last position found for x
|
---|
| 1391 | rangy=[max(ymax,ymin) min(ymax,ymin)];
|
---|
| 1392 | if max(nx,ny) <= 64 & isequal(npxy_in,'np>256')
|
---|
| 1393 | npxy=[8*ny 8*nx];% increase the resolution 8 times
|
---|
| 1394 | elseif max(nx,ny) <= 128 & isequal(npxy_in,'np>256')
|
---|
| 1395 | npxy=[4*ny 4*nx];% increase the resolution 4 times
|
---|
| 1396 | elseif max(nx,ny) <= 256 & isequal(npxy_in,'np>256')
|
---|
| 1397 | npxy=[2*ny 2*nx];% increase the resolution 2 times
|
---|
| 1398 | else
|
---|
| 1399 | npxy=[ny nx];
|
---|
| 1400 | test_interp=0; % no interpolation done
|
---|
| 1401 | end
|
---|
| 1402 | end
|
---|
| 1403 | if test_interp==1%if we interpolate
|
---|
| 1404 | xi=[rangx(1):(rangx(2)-rangx(1))/(npxy(2)-1):rangx(2)];
|
---|
| 1405 | yi=[rangy(1):(rangy(2)-rangy(1))/(npxy(1)-1):rangy(2)];
|
---|
| 1406 | [XI,YI]=meshgrid(xi,yi);
|
---|
| 1407 | A = interp2(X,Y,B,XI,YI);
|
---|
| 1408 | else %no interpolation for a resolution higher than 256
|
---|
| 1409 | A=B;
|
---|
| 1410 | end
|
---|
[801] | 1411 | end
|
---|