[581] | 1 | %'get_field': display variables and attributes from a Netcdf file, and OK selected fields |
---|
[204] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | %function varargout = get_field(varargin) |
---|
| 4 | % associated with the GUI get_field.fig |
---|
| 5 | % |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = get_field(varargin) |
---|
| 23 | |
---|
[646] | 24 | % Last Modified by GUIDE v2.5 02-Jun-2013 14:00:39 |
---|
[204] | 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
[581] | 27 | gui_Singleton = 1; |
---|
[204] | 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
| 45 | %------------------------------------------------------------------------ |
---|
| 46 | % --- Executes just before get_field is made visible. |
---|
[581] | 47 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
---|
[204] | 48 | %------------------------------------------------------------------------ |
---|
| 49 | global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN |
---|
| 50 | |
---|
| 51 | %% Choose default command line output for get_field |
---|
[581] | 52 | handles.output = 'Cancel'; |
---|
[204] | 53 | |
---|
| 54 | %% Update handles structure |
---|
| 55 | guidata(hObject, handles); |
---|
[434] | 56 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[204] | 57 | |
---|
[581] | 58 | %% settings for 'slave' mode, called by uvmat, or 'master' mode |
---|
[204] | 59 | if exist('filename','var') && ischar(filename) %transfer input file name in slave mode |
---|
[227] | 60 | set(handles.inputfile,'String',filename)% prefill the input file name |
---|
[581] | 61 | Field=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
[204] | 62 | if isfield(Field,'Txt') |
---|
[581] | 63 | msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt]) |
---|
[204] | 64 | else |
---|
[581] | 65 | if ~exist('ParamIn','var') |
---|
| 66 | ParamIn=[]; |
---|
| 67 | end |
---|
| 68 | Field_input(handles,Field,ParamIn); |
---|
[204] | 69 | end |
---|
| 70 | else %master mode |
---|
[227] | 71 | set(handles.inputfile,'String','') |
---|
| 72 | end |
---|
| 73 | |
---|
[434] | 74 | %% put the GUI on the lower right of the sceen |
---|
[581] | 75 | set(hObject,'Unit','pixel') |
---|
[434] | 76 | pos_view_field=get(hObject,'Position'); |
---|
[646] | 77 | set(0,'Unit','pixels') |
---|
[434] | 78 | ScreenSize=get(0,'ScreenSize'); |
---|
| 79 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
---|
| 80 | pos_view_field(2)=ScreenSize(2); |
---|
| 81 | set(hObject,'Position',pos_view_field) |
---|
[581] | 82 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
---|
| 83 | drawnow |
---|
[582] | 84 | uiwait(handles.get_field); |
---|
[204] | 85 | |
---|
| 86 | %------------------------------------------------------------------------ |
---|
[582] | 87 | % --- update the display when a new field is introduced. |
---|
| 88 | function Field_input(handles,Field,ParamIn) |
---|
[204] | 89 | %------------------------------------------------------------------------ |
---|
| 90 | |
---|
[582] | 91 | %% fill the list and values of dimensions |
---|
[204] | 92 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
| 93 | Tabcell(:,1)=Field.ListDimName; |
---|
| 94 | for iline=1:length(Field.ListDimName) |
---|
| 95 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
| 96 | end |
---|
[227] | 97 | Tabchar=cell2tab(Tabcell,' = '); |
---|
[204] | 98 | set(handles.dimensions,'String',Tabchar) |
---|
| 99 | end |
---|
| 100 | if ~isfield(Field,'ListVarName') |
---|
| 101 | return |
---|
| 102 | end |
---|
[582] | 103 | |
---|
| 104 | %% fill the list of variables |
---|
[204] | 105 | Txt=Field.ListVarName; |
---|
| 106 | set(handles.variables,'Value',1) |
---|
| 107 | set(handles.variables,'String',[{'*'} Txt]) |
---|
| 108 | variables_Callback(handles.variables,[], handles) |
---|
| 109 | set(handles.ordinate,'String',Txt) |
---|
[646] | 110 | set(handles.vector_x,'String',Txt) |
---|
| 111 | set(handles.vector_y,'String',Txt ) |
---|
[204] | 112 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
| 113 | set(handles.vec_color,'String',[{''} Txt ]) |
---|
[646] | 114 | set(handles.XVarName,'String',Txt ) |
---|
| 115 | set(handles.YVarName,'String',Txt ) |
---|
| 116 | set(handles.ZVarName,'String',Txt ) |
---|
[204] | 117 | set(handles.scalar,'Value',1) |
---|
[582] | 118 | set(handles.scalar,'String', Txt ) |
---|
[227] | 119 | |
---|
[646] | 120 | %% analyse the input field cells |
---|
[530] | 121 | [CellInfo,NbDim,errormsg]=find_field_cells(Field); |
---|
[204] | 122 | if ~isempty(errormsg) |
---|
[530] | 123 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
---|
[204] | 124 | return |
---|
| 125 | end |
---|
[582] | 126 | [Field.MaxDim,imax]=max(NbDim); |
---|
| 127 | % look at variables with a single dimension |
---|
| 128 | for ilist=1:numel(Field.VarDimName) |
---|
| 129 | if ischar(Field.VarDimName{ilist}) |
---|
| 130 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 131 | end |
---|
| 132 | NbDim=numel(Field.VarDimName{ilist});% TODO eliminate singleton dimensions |
---|
| 133 | check_singleton=false(1,NbDim); |
---|
| 134 | for idim=1:NbDim |
---|
| 135 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName); |
---|
| 136 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1); |
---|
| 137 | end |
---|
| 138 | Field.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton); |
---|
| 139 | Field.NbDim(ilist)=numel(Field.VarDimName{ilist}); |
---|
| 140 | if Field.NbDim(ilist)==1 |
---|
| 141 | Field.VarDimName{ilist}=cell2mat(Field.VarDimName{ilist}); |
---|
| 142 | end |
---|
| 143 | end |
---|
| 144 | SingleVarName=Field.ListVarName(Field.NbDim==1);%list of variables with a single dim |
---|
| 145 | MultiVarName=Field.ListVarName(Field.NbDim>1); |
---|
| 146 | check_dim=zeros(size(Field.VarDimName)); |
---|
| 147 | for ilist=1:numel(Field.VarDimName); |
---|
| 148 | if iscell(Field.VarDimName{ilist})% exclude single dim |
---|
| 149 | for idim=1:numel(Field.VarDimName{ilist}) |
---|
| 150 | check_dim=check_dim|strcmp(Field.VarDimName{ilist}{idim},Field.VarDimName); |
---|
| 151 | end |
---|
| 152 | end |
---|
| 153 | end |
---|
| 154 | Field.SingleVarName=Field.ListVarName(find(check_dim));%list of variables with a single dim |
---|
| 155 | Field.SingleDimName=Field.VarDimName(find(check_dim));% corresponding list of dimensions for variables with a single dim |
---|
| 156 | Field.MaxDim=max(Field.NbDim); |
---|
[581] | 157 | |
---|
| 158 | %% set time mode |
---|
[646] | 159 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
---|
[582] | 160 | % look at global attributes with numerical values |
---|
| 161 | check_numvalue=false; |
---|
| 162 | check_time=false; |
---|
[646] | 163 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 164 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 165 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 166 | check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); |
---|
| 167 | end |
---|
[582] | 168 | Field.ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 169 | if ~isempty(Field.ListNumAttributes) |
---|
[646] | 170 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
---|
[582] | 171 | end |
---|
| 172 | nboption=numel(ListSwitchVarIndexTime); |
---|
| 173 | if Field.MaxDim>=2 |
---|
[646] | 174 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index |
---|
[582] | 175 | end |
---|
[646] | 176 | if Field.MaxDim>=4% for dim >=4, one dim is proposed as time |
---|
| 177 | option=nboption+1; |
---|
[582] | 178 | elseif ~isempty(find(check_time, 1)) |
---|
| 179 | option=2; |
---|
[581] | 180 | else |
---|
[582] | 181 | option=1; |
---|
[581] | 182 | end |
---|
[646] | 183 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
| 184 | set(handles.SwitchVarIndexTime,'Value',option) |
---|
[582] | 185 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[646] | 186 | SwitchVarIndexTime_Callback([],[], handles) |
---|
[581] | 187 | |
---|
[582] | 188 | %% set z coordinate menu if relevant |
---|
| 189 | if Field.MaxDim>=3 |
---|
[204] | 190 | set(handles.vector_z,'Visible','on') |
---|
| 191 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
[581] | 192 | set(handles.ZVarName,'Visible','on') |
---|
| 193 | set(handles.SwitchVarIndexZ,'Visible','on') |
---|
| 194 | set(handles.Z_title,'Visible','on') |
---|
[204] | 195 | else |
---|
| 196 | set(handles.vector_z,'Visible','off') |
---|
[581] | 197 | set(handles.ZVarName,'Visible','off') |
---|
[644] | 198 | % set(handles.SwitchVarIndexZ,'Visible','off') |
---|
[581] | 199 | set(handles.Z_title,'Visible','off') |
---|
[204] | 200 | end |
---|
[582] | 201 | |
---|
| 202 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
| 203 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
---|
[646] | 204 | if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y') |
---|
| 205 | set(handles.XVarName,'Value',CellInfo{imax}.VarIndex_coord_x(1)) |
---|
| 206 | set(handles.YVarName,'Value',CellInfo{imax}.VarIndex_coord_y(1)) |
---|
| 207 | end |
---|
[530] | 208 | if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
---|
[646] | 209 | set(handles.FieldOption,'Value',3)% set vector selection option |
---|
[530] | 210 | set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) |
---|
| 211 | set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) |
---|
[644] | 212 | set(handles.FieldOption,'Value',3) |
---|
[204] | 213 | else |
---|
[644] | 214 | set(handles.FieldOption,'Value',2) |
---|
[204] | 215 | end |
---|
[582] | 216 | else % case of 1D fields |
---|
[644] | 217 | set(handles.FieldOption,'Value',1) |
---|
[204] | 218 | end |
---|
[582] | 219 | |
---|
[644] | 220 | |
---|
[582] | 221 | %% Make choices in menus from input |
---|
| 222 | if exist('ParamIn','var')&&~isempty(ParamIn) |
---|
[591] | 223 | fill_GUI(ParamIn,handles.get_field); |
---|
[581] | 224 | end |
---|
[644] | 225 | FieldOption_Callback([],[],handles) |
---|
[204] | 226 | |
---|
| 227 | %------------------------------------------------------------------------ |
---|
[582] | 228 | % --- Outputs from this function are returned to the command line. |
---|
| 229 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
| 230 | %------------------------------------------------------------------------ |
---|
| 231 | varargout{1} = handles.output; |
---|
| 232 | delete(handles.get_field) |
---|
| 233 | |
---|
| 234 | |
---|
| 235 | % ----------------------------------------------------------------------- |
---|
| 236 | % --- Activated by selection in the list of variables |
---|
| 237 | function variables_Callback(hObject, eventdata, handles) |
---|
| 238 | % ----------------------------------------------------------------------- |
---|
| 239 | Tabchar={''};%default |
---|
| 240 | Tabcell=[]; |
---|
| 241 | hselect_field=get(handles.variables,'parent'); |
---|
| 242 | Field=get(handles.get_field,'UserData'); |
---|
| 243 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
| 244 | |
---|
| 245 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
---|
| 246 | if isequal(index,1) |
---|
| 247 | set(handles.attributes_txt,'String','global attributes') |
---|
| 248 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 249 | for iline=1:length(Field.ListGlobalAttribute) |
---|
| 250 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
| 251 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
| 252 | eval(['val=Field.' Field.ListGlobalAttribute{iline} ';']) |
---|
| 253 | if ischar(val);% attribute value is char string |
---|
| 254 | Tabcell{iline,2}=val; |
---|
| 255 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
| 256 | Tabcell{iline,2}=num2str(val); |
---|
| 257 | end |
---|
| 258 | end |
---|
| 259 | end |
---|
| 260 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 261 | end |
---|
| 262 | %% list Attribute names and values associated to the Variable # index-1 |
---|
| 263 | else |
---|
| 264 | list_var=get(handles.variables,'String'); |
---|
| 265 | var_select=list_var{index}; |
---|
| 266 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
| 267 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
| 268 | % nbline=0; |
---|
| 269 | VarAttr=Field.VarAttribute{index-1}; |
---|
| 270 | if isstruct(VarAttr) |
---|
| 271 | attr_list=fieldnames(VarAttr); |
---|
| 272 | for iline=1:length(attr_list) |
---|
| 273 | Tabcell{iline,1}=attr_list{iline}; |
---|
| 274 | eval(['val=VarAttr.' attr_list{iline} ';']) |
---|
| 275 | if ischar(val); |
---|
| 276 | Tabcell{iline,2}=val; |
---|
| 277 | else |
---|
| 278 | Tabcell{iline,2}=num2str(val); |
---|
| 279 | end |
---|
| 280 | end |
---|
| 281 | end |
---|
| 282 | end |
---|
| 283 | |
---|
| 284 | end |
---|
| 285 | if ~isempty(Tabcell) |
---|
| 286 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 287 | Tabchar=[{''};Tabchar]; |
---|
| 288 | end |
---|
| 289 | set(handles.attributes,'Value',1);% select the first item |
---|
| 290 | set(handles.attributes,'String',Tabchar); |
---|
| 291 | |
---|
| 292 | %% update dimensions; |
---|
| 293 | if isfield(Field,'ListDimName') |
---|
| 294 | Tabdim={};%default |
---|
| 295 | if isequal(index,1)%list all dimensions |
---|
| 296 | dim_indices=1:length(Field.ListDimName); |
---|
| 297 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
| 298 | else |
---|
| 299 | DimCell=Field.VarDimName{index-1}; |
---|
| 300 | if ischar(DimCell) |
---|
| 301 | DimCell={DimCell}; |
---|
| 302 | end |
---|
| 303 | dim_indices=[]; |
---|
| 304 | for idim=1:length(DimCell) |
---|
| 305 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
| 306 | dim_index=find(dim_index,1); |
---|
| 307 | dim_indices=[dim_indices dim_index]; |
---|
| 308 | end |
---|
| 309 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
| 310 | end |
---|
| 311 | for iline=1:length(dim_indices) |
---|
| 312 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
| 313 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
| 314 | end |
---|
| 315 | Tabchar=cell2tab(Tabdim,' = '); |
---|
| 316 | Tabchar=[{''} ;Tabchar]; |
---|
| 317 | set(handles.dimensions,'Value',1) |
---|
| 318 | set(handles.dimensions,'String',Tabchar) |
---|
| 319 | end |
---|
| 320 | |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | %------------------------------------------------------------------------ |
---|
| 324 | % --- Executes on button press in CheckPlot1D. |
---|
| 325 | function CheckPlot1D_Callback(hObject, eventdata, handles) |
---|
| 326 | %------------------------------------------------------------------------ |
---|
| 327 | val=get(handles.CheckPlot1D,'Value'); |
---|
| 328 | if isequal(val,0) |
---|
| 329 | set(handles.Panel1Dplot,'Visible','off') |
---|
| 330 | else |
---|
[644] | 331 | |
---|
[582] | 332 | end |
---|
| 333 | |
---|
| 334 | %------------------------------------------------------------------------ |
---|
[204] | 335 | function ordinate_Callback(hObject, eventdata, handles) |
---|
| 336 | %------------------------------------------------------------------------ |
---|
[582] | 337 | Field=get(handles.get_field,'UserData'); |
---|
[204] | 338 | list=get(handles.ordinate,'String'); |
---|
| 339 | yindex=get(handles.ordinate,'Value'); |
---|
| 340 | yindex=name2index(list{yindex(1)},Field.ListVarName); |
---|
| 341 | if ~isempty(yindex) |
---|
| 342 | set(handles.variables,'Value',yindex+1) |
---|
| 343 | variables_Callback(hObject, eventdata, handles) |
---|
| 344 | end |
---|
[530] | 345 | [CellInfo,NbDim,errormsg]=find_field_cells(Field); |
---|
| 346 | %[CellVarIndex,NbDim,VarRole,errormsg]=find_field_cells(Field); |
---|
[582] | 347 | for icell=1:numel(CellInfo) |
---|
| 348 | VarIndex=CellInfo{icell}.VarIndex; |
---|
[606] | 349 | if ~isempty(find(VarIndex==yindex,1)) && (isempty(CellInfo{icell}.VarIndex_coord_x)||~isequal(CellInfo{icell}.VarIndex_coord_x,VarIndex)) |
---|
[582] | 350 | cell_select=icell; |
---|
| 351 | break |
---|
| 352 | end |
---|
| 353 | end |
---|
[646] | 354 | %val=get(handles.abscissa,'Value'); |
---|
| 355 | %set(handles.abscissa,'Value',min(val,2)); |
---|
[606] | 356 | coord_x_index=CellInfo{cell_select}.VarIndex_coord_x; |
---|
[582] | 357 | coord_x_index=coord_x_index(coord_x_index~=0); |
---|
[646] | 358 | %set(handles.XVarName,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) |
---|
| 359 | set(handles.XVarName,'String',[(Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) |
---|
[204] | 360 | |
---|
| 361 | %------------------------------------------------------------------------ |
---|
[582] | 362 | % --- Executes on button press in CheckScalar. |
---|
| 363 | function CheckScalar_Callback(hObject, eventdata, handles) |
---|
[204] | 364 | %------------------------------------------------------------------------ |
---|
[582] | 365 | val=get(handles.CheckScalar,'Value'); |
---|
| 366 | if isequal(val,0) |
---|
| 367 | set(handles.PanelScalar,'Visible','off') |
---|
| 368 | else |
---|
[644] | 369 | |
---|
[582] | 370 | end |
---|
[204] | 371 | |
---|
| 372 | %------------------------------------------------------------------------ |
---|
[582] | 373 | % --- Executes on button press in CheckVector. |
---|
| 374 | function CheckVector_Callback(hObject, eventdata, handles) |
---|
| 375 | %------------------------------------------------------------------------ |
---|
| 376 | val=get(handles.CheckVector,'Value'); |
---|
| 377 | if isequal(val,0) |
---|
| 378 | set(handles.PanelVectors,'Visible','off') |
---|
| 379 | else |
---|
[644] | 380 | |
---|
[582] | 381 | end |
---|
| 382 | |
---|
| 383 | |
---|
| 384 | %------------------------------------------------------------------------ |
---|
[204] | 385 | % --- Executes on selection change in scalar menu. |
---|
| 386 | function scalar_Callback(hObject, eventdata, handles) |
---|
| 387 | %------------------------------------------------------------------------ |
---|
[586] | 388 | Field=get(handles.get_field,'UserData'); |
---|
[227] | 389 | index=get(handles.scalar,'Value'); |
---|
| 390 | string=get(handles.scalar,'String'); |
---|
| 391 | VarName=string{index}; |
---|
[204] | 392 | update_field(hObject, eventdata, handles,VarName) |
---|
| 393 | |
---|
[227] | 394 | %eliminate time |
---|
| 395 | TimeDimName='';%default |
---|
[646] | 396 | |
---|
[644] | 397 | % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); |
---|
| 398 | % TimeVarOption=SwitchVarIndexTime{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[646] | 399 | List=get(handles.TimeVarName,'String'); |
---|
| 400 | if get(handles.CheckDimensionTime) |
---|
| 401 | TimeDimName=List{get(handles.TimeVarName,'Value')}; |
---|
| 402 | elseif ~get(handles.CheckAttributeTime) |
---|
[586] | 403 | TimeVarName=List{get(handles.TimeVarName,'Value')}; |
---|
[227] | 404 | end |
---|
[586] | 405 | % A completer |
---|
| 406 | % if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on') |
---|
| 407 | % TimeDimList=get(handles.TimeDimensionMenu,'String'); |
---|
| 408 | % TimeDimIndex=get(handles.TimeDimensionMenu,'Value'); |
---|
| 409 | % TimeDimName=TimeDimList{TimeDimIndex}; |
---|
| 410 | % end |
---|
[227] | 411 | |
---|
| 412 | %check possible coordinates |
---|
| 413 | Field=get(handles.get_field,'UserData'); |
---|
| 414 | dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar |
---|
| 415 | test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate |
---|
| 416 | for ilist=1:numel(Field.VarDimName) |
---|
| 417 | dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
[586] | 418 | if isequal(dimnames,TimeDimName) |
---|
[227] | 419 | test_coord(ilist)=0;%mark time variables fo elimination |
---|
| 420 | end |
---|
[586] | 421 | if ischar(dimnames) |
---|
| 422 | dimnames={dimnames}; |
---|
| 423 | end |
---|
[227] | 424 | for idim=1:numel(dimnames) |
---|
| 425 | if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable |
---|
| 426 | test_coord(ilist)=0; |
---|
| 427 | break |
---|
| 428 | end |
---|
| 429 | end |
---|
| 430 | end |
---|
| 431 | test_coord(index)=0;%the coordinate variable must be different from the scalar |
---|
| 432 | |
---|
| 433 | string_coord=[{''};string(test_coord==1)]; |
---|
[581] | 434 | val=get(handles.XVarName,'Value'); |
---|
[227] | 435 | if val>numel(string_coord) |
---|
[581] | 436 | set(handles.XVarName,'Value',1) |
---|
[227] | 437 | end |
---|
[581] | 438 | set(handles.XVarName,'String',string_coord); |
---|
| 439 | val=get(handles.ZVarName,'Value'); |
---|
[227] | 440 | if val>numel(string_coord) |
---|
[581] | 441 | set(handles.ZVarName,'Value',1) |
---|
[227] | 442 | end |
---|
[581] | 443 | set(handles.ZVarName,'String',string_coord); |
---|
| 444 | val=get(handles.ZVarName,'Value'); |
---|
[227] | 445 | if val>numel(string_coord) |
---|
[581] | 446 | set(handles.ZVarName,'Value',1) |
---|
[227] | 447 | end |
---|
[581] | 448 | set(handles.YVarName,'String',string_coord); |
---|
[227] | 449 | |
---|
| 450 | |
---|
[204] | 451 | %------------------------------------------------------------------------ |
---|
[582] | 452 | % --- Executes on selection change in abscissa. |
---|
| 453 | function abscissa_Callback(hObject, eventdata, handles) |
---|
| 454 | %------------------------------------------------------------------------ |
---|
| 455 | hselect_field=get(handles.inputfile,'parent'); |
---|
| 456 | Field=get(hselect_field,'UserData');%current input field |
---|
| 457 | xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa |
---|
| 458 | % test_2D=get(handles.CheckVector,'Value');% =1 for vector fields |
---|
| 459 | % test_scalar=get(handles.CheckScalar,'Value');% =1 for scalar fields |
---|
| 460 | %if isequal(xdispindex,1)% blank selection, no selected TimeVariable for abscissa |
---|
| 461 | % Txt=Field.ListVarName; |
---|
| 462 | % set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates |
---|
| 463 | % xindex=[]; |
---|
| 464 | % else |
---|
| 465 | xlist=get(handles.abscissa,'String');%list of abscissa |
---|
| 466 | VarName=xlist{xdispindex}; %selected variable name |
---|
| 467 | update_field(hObject, eventdata, handles,VarName) |
---|
| 468 | % xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables |
---|
| 469 | % if ~isempty(xindex) |
---|
| 470 | % set(handles.variables,'Value',xindex+1) |
---|
| 471 | % variables_Callback(hObject, eventdata, handles) |
---|
| 472 | % end |
---|
| 473 | % set(handles.variables,'Value',xindex+1)%outline in the list of variables |
---|
| 474 | % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) |
---|
| 475 | % if ~test_2D & ~test_scalar% look for possible varaibles to OK in ordinate |
---|
| 476 | % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa |
---|
| 477 | % VarIndex=[]; |
---|
| 478 | % for ilist=1:length(Field.VarDimIndex)%detect |
---|
| 479 | % index_i=Field.VarDimIndex{ilist}; |
---|
| 480 | % if ~isempty(index_i) |
---|
| 481 | % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible |
---|
| 482 | % VarIndex=[VarIndex ilist]; |
---|
| 483 | % end |
---|
| 484 | % end |
---|
| 485 | % end |
---|
| 486 | % % set(handles.ordinate,'Value',1) |
---|
| 487 | % set(handles.ordinate,'String',Field.ListVarName(VarIndex)) |
---|
| 488 | % end |
---|
| 489 | % end |
---|
| 490 | % |
---|
| 491 | % update_UserData(handles) |
---|
| 492 | |
---|
| 493 | |
---|
| 494 | |
---|
| 495 | %------------------------------------------------------------------------ |
---|
[581] | 496 | % --- Executes on selection change in XVarName. |
---|
| 497 | function XVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 498 | %------------------------------------------------------------------------ |
---|
[581] | 499 | index=get(handles.XVarName,'Value'); |
---|
| 500 | string=get(handles.XVarName,'String'); |
---|
[204] | 501 | VarName=string{index}; |
---|
| 502 | update_field(hObject, eventdata, handles,VarName) |
---|
| 503 | |
---|
| 504 | %------------------------------------------------------------------------ |
---|
[581] | 505 | % --- Executes on selection change in ZVarName. |
---|
| 506 | function ZVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 507 | %------------------------------------------------------------------------ |
---|
[581] | 508 | index=get(handles.ZVarName,'Value'); |
---|
| 509 | string=get(handles.ZVarName,'String'); |
---|
[204] | 510 | VarName=string{index}; |
---|
| 511 | update_field(hObject, eventdata, handles,VarName) |
---|
| 512 | |
---|
| 513 | %------------------------------------------------------------------------ |
---|
[581] | 514 | % --- Executes on selection change in YVarName. |
---|
| 515 | function YVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 516 | %------------------------------------------------------------------------ |
---|
[581] | 517 | index=get(handles.YVarName,'Value'); |
---|
| 518 | string=get(handles.YVarName,'String'); |
---|
[204] | 519 | VarName=string{index}; |
---|
| 520 | update_field(hObject, eventdata, handles,VarName) |
---|
| 521 | |
---|
| 522 | %------------------------------------------------------------------------ |
---|
| 523 | % --- Executes on selection change in vector_x. |
---|
| 524 | function vector_x_Callback(hObject, eventdata, handles) |
---|
| 525 | %------------------------------------------------------------------------ |
---|
| 526 | index=get(handles.vector_x,'Value'); |
---|
| 527 | string=get(handles.vector_x,'String'); |
---|
| 528 | VarName=string{index}; |
---|
[227] | 529 | |
---|
| 530 | %check possible coordinates |
---|
| 531 | Field=get(handles.get_field,'UserData'); |
---|
[582] | 532 | dim_var=Field.VarDimName{index};%list of dimensions of the selected variable |
---|
[227] | 533 | test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate |
---|
| 534 | test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component |
---|
| 535 | for ilist=1:numel(Field.VarDimName) |
---|
| 536 | dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 537 | if ~isequal(dimnames,dim_var) |
---|
| 538 | test_component(ilist)=0; |
---|
| 539 | end |
---|
| 540 | for idim=1:numel(dimnames) |
---|
| 541 | if isempty(find(strcmp(dimnames{idim},dim_var),1))%dimension not found in the scalar variable |
---|
| 542 | test_coord(ilist)=0; |
---|
| 543 | break |
---|
| 544 | end |
---|
| 545 | end |
---|
| 546 | end |
---|
| 547 | %eliminate time |
---|
| 548 | if get(handles.TimeVariable,'Value') |
---|
| 549 | TimeName=get(handles.TimeName,'String'); |
---|
| 550 | index_time=find(strcmp( TimeName,Field.ListVarName)); |
---|
| 551 | test_coord(index_time)=0; |
---|
| 552 | end |
---|
| 553 | vlength=numel(string(test_component==1)); |
---|
| 554 | val=get(handles.vector_y,'Value'); |
---|
| 555 | if val>vlength |
---|
| 556 | set(handles.vector_y,'Value',1) |
---|
| 557 | end |
---|
| 558 | set(handles.vector_y,'String',[string(test_component==1)]) |
---|
| 559 | val=get(handles.vector_z,'Value'); |
---|
| 560 | if val>vlength+1 |
---|
| 561 | set(handles.vector_z,'Value',1) |
---|
| 562 | end |
---|
| 563 | set(handles.vector_z,'String',[{''};string(test_component==1)]) |
---|
| 564 | val=get(handles.vec_color,'Value'); |
---|
| 565 | if val>vlength+1 |
---|
| 566 | set(handles.vec_color,'Value',1) |
---|
| 567 | end |
---|
| 568 | set(handles.vec_color,'String',[{''};string(test_component==1)]) |
---|
| 569 | string_coord=[{''};string(test_coord==1)]; |
---|
[582] | 570 | val=get(handles.XVarName,'Value'); |
---|
[227] | 571 | if val>numel(string_coord) |
---|
[582] | 572 | set(handles.XVarName,'Value',1) |
---|
[227] | 573 | end |
---|
[582] | 574 | set(handles.XVarName,'Visible','on'); |
---|
| 575 | set(handles.XVarName,'String',string_coord); |
---|
| 576 | val=get(handles.YVarName,'Value'); |
---|
[227] | 577 | if val>numel(string_coord) |
---|
[582] | 578 | set(handles.YVarName,'Value',1) |
---|
[227] | 579 | end |
---|
[582] | 580 | set(handles.YVarName,'Visible','on'); |
---|
| 581 | set(handles.YVarName,'String',string_coord); |
---|
[581] | 582 | val=get(handles.TimeVarName,'Value'); |
---|
[227] | 583 | if val>numel(string_coord) |
---|
[581] | 584 | set(handles.TimeVarName,'Value',1) |
---|
[227] | 585 | end |
---|
[581] | 586 | set(handles.TimeVarName,'String',string_coord); |
---|
[227] | 587 | |
---|
[204] | 588 | update_field(hObject, eventdata, handles,VarName) |
---|
| 589 | |
---|
| 590 | %------------------------------------------------------------------------ |
---|
| 591 | % --- Executes on selection change in vector_y. |
---|
| 592 | function vector_y_Callback(hObject, eventdata, handles) |
---|
| 593 | %------------------------------------------------------------------------ |
---|
| 594 | index=get(handles.vector_y,'Value'); |
---|
| 595 | string=get(handles.vector_y,'String'); |
---|
| 596 | VarName=string{index}; |
---|
| 597 | update_field(hObject, eventdata, handles,VarName) |
---|
| 598 | |
---|
| 599 | %------------------------------------------------------------------------ |
---|
| 600 | % --- Executes on selection change in vector_z. |
---|
| 601 | function vector_z_Callback(hObject, eventdata, handles) |
---|
| 602 | %------------------------------------------------------------------------ |
---|
| 603 | index=get(handles.vector_z,'Value'); |
---|
| 604 | string=get(handles.vector_z,'String'); |
---|
| 605 | VarName=Astring{index}; |
---|
| 606 | update_field(hObject, eventdata, handles,VarName) |
---|
| 607 | |
---|
| 608 | %------------------------------------------------------------------------ |
---|
| 609 | % --- Executes on selection change in coord_x_vectors. |
---|
| 610 | function coord_x_vectors_Callback(hObject, eventdata, handles) |
---|
| 611 | %------------------------------------------------------------------------ |
---|
| 612 | index=get(handles.coord_x_vectors,'Value'); |
---|
| 613 | string=get(handles.coord_x_vectors,'String'); |
---|
| 614 | VarName=string{index}; |
---|
| 615 | update_field(hObject, eventdata, handles,VarName) |
---|
| 616 | |
---|
[227] | 617 | %------------------------------------------------------------------------ |
---|
[204] | 618 | % --- Executes on selection change in coord_y_vectors. |
---|
| 619 | function coord_y_vectors_Callback(hObject, eventdata, handles) |
---|
[227] | 620 | %------------------------------------------------------------------------ |
---|
[204] | 621 | index=get(handles.coord_y_vectors,'Value'); |
---|
| 622 | string=get(handles.coord_y_vectors,'String'); |
---|
| 623 | VarName=string{index}; |
---|
| 624 | update_field(hObject, eventdata, handles,VarName) |
---|
| 625 | |
---|
[227] | 626 | %------------------------------------------------------------------------ |
---|
[581] | 627 | % --- Executes on selection change in YVarName. |
---|
| 628 | function TimeVarName_Callback(hObject, eventdata, handles) |
---|
[227] | 629 | %------------------------------------------------------------------------ |
---|
[581] | 630 | index=get(handles.TimeVarName,'Value'); |
---|
| 631 | string=get(handles.TimeVarName,'String'); |
---|
[204] | 632 | VarName=string{index}; |
---|
| 633 | update_field(hObject, eventdata, handles,VarName) |
---|
| 634 | |
---|
[227] | 635 | %------------------------------------------------------------------------ |
---|
[204] | 636 | % --- Executes on selection change in vec_color. |
---|
| 637 | function vec_color_Callback(hObject, eventdata, handles) |
---|
[227] | 638 | %------------------------------------------------------------------------ |
---|
[204] | 639 | index=get(handles.vec_color,'Value'); |
---|
| 640 | string=get(handles.vec_color,'String'); |
---|
| 641 | VarName=string{index}; |
---|
| 642 | update_field(hObject, eventdata, handles,VarName) |
---|
| 643 | |
---|
[227] | 644 | %----------------------------------------------------------------------- |
---|
[204] | 645 | function update_field(hObject, eventdata, handles,VarName) |
---|
[227] | 646 | %----------------------------------------------------------------------- |
---|
| 647 | Field=get(handles.get_field,'UserData'); |
---|
[204] | 648 | index=name2index(VarName,Field.ListVarName); |
---|
| 649 | if ~isempty(index) |
---|
| 650 | set(handles.variables,'Value',index+1) |
---|
| 651 | variables_Callback(hObject, eventdata, handles) |
---|
| 652 | end |
---|
| 653 | |
---|
[227] | 654 | %------------------------------------------------------------------------ |
---|
[204] | 655 | % update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback) |
---|
| 656 | function update_UserData(handles) |
---|
[227] | 657 | %------------------------------------------------------------------------ |
---|
[204] | 658 | return |
---|
| 659 | % global SubField |
---|
| 660 | hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface |
---|
| 661 | Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface |
---|
| 662 | if isfield(Field,'VarAttribute') |
---|
| 663 | VarAttribute=Field.VarAttribute; |
---|
| 664 | else |
---|
| 665 | VarAttribute={}; |
---|
| 666 | end |
---|
| 667 | |
---|
| 668 | |
---|
| 669 | % select the indices of field variables for 2D plots |
---|
[503] | 670 | test_CheckPlot1D=get(handles.CheckPlot1D,'Value'); |
---|
| 671 | test_scalar=get(handles.CheckScalar,'Value'); |
---|
| 672 | test_vector=get(handles.CheckVector,'Value'); |
---|
[204] | 673 | |
---|
| 674 | %transform if needed (calibration) |
---|
| 675 | list=get(handles.menu_coord,'String'); |
---|
| 676 | index=get(handles.menu_coord,'Value'); |
---|
| 677 | transform=list{index}; |
---|
| 678 | if ~isequal(transform,'') |
---|
| 679 | Field=feval(transform,Field); |
---|
| 680 | end |
---|
| 681 | VarIndex.u=[]; |
---|
| 682 | VarIndex.v=[]; |
---|
| 683 | VarIndex.w=[]; |
---|
| 684 | VarIndex.A=[]; |
---|
| 685 | VarIndex_tot=[]; |
---|
| 686 | iuA=[]; |
---|
| 687 | if test_scalar |
---|
| 688 | Astring=get(handles.scalar,'String'); |
---|
| 689 | Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox |
---|
| 690 | list_var=Astring(Aindex); |
---|
| 691 | VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName |
---|
| 692 | VarIndex_tot= [VarIndex_tot VarIndex.A]; |
---|
| 693 | DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable |
---|
| 694 | DimValue=Field.DimValue(DimIndex); |
---|
| 695 | ind=find(DimValue==1); |
---|
| 696 | DimIndex(ind)=[];%Mremove singleton |
---|
| 697 | end |
---|
| 698 | if test_vector |
---|
| 699 | Ustring=get(handles.vector_x,'String'); |
---|
| 700 | Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox |
---|
| 701 | list_var=Ustring{Uindex};%name of the selected scalar |
---|
| 702 | VarIndex.u=name2index(list_var,Field.ListVarName); |
---|
| 703 | Vstring=get(handles.vector_y,'String'); |
---|
| 704 | Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox |
---|
| 705 | list_var=Ustring{Vindex};%name of the selected scalar |
---|
| 706 | VarIndex.v=name2index(list_var,Field.ListVarName); |
---|
| 707 | if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A) |
---|
| 708 | iuA=VarIndex.A; %same variable used for vector and scalar |
---|
| 709 | VarIndex_tot(iuA)=[]; |
---|
| 710 | end |
---|
| 711 | VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v]; |
---|
| 712 | %dimensions |
---|
| 713 | DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable |
---|
| 714 | DimValue=Field.DimValue(DimIndex_u); |
---|
| 715 | ind=find(DimValue==1); |
---|
| 716 | DimIndex_u(ind)=[];%Mremove singleton |
---|
| 717 | DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable |
---|
| 718 | DimValue=Field.DimValue(DimIndex_v); |
---|
| 719 | ind=find(DimValue==1); |
---|
| 720 | DimIndex_v(ind)=[];%Mremove singleton |
---|
| 721 | if ~isequal(DimIndex_u,DimIndex_v) |
---|
| 722 | msgbox_uvmat('ERROR','inconsistent dimensions for u and v') |
---|
| 723 | set(handles.vector_y,'Value',1); |
---|
| 724 | return |
---|
| 725 | elseif test_scalar & ~isequal(DimIndex_u,DimIndex) |
---|
| 726 | msgbox_uvmat('ERROR','inconsistent dimensions for vector and scalar represented as vector color') |
---|
| 727 | set(handles.scalar,'Value',1); |
---|
| 728 | return |
---|
| 729 | end |
---|
| 730 | DimIndex=DimIndex_u; |
---|
[227] | 731 | %TODO possibility of selecting 3 times the same TimeVariable for u, v, w components |
---|
[204] | 732 | end |
---|
| 733 | |
---|
| 734 | |
---|
[227] | 735 | % select the TimeVariable index (or indices) for z coordinates |
---|
[204] | 736 | test_grid=0; |
---|
| 737 | if test_scalar | test_vector |
---|
| 738 | nbdim=length(DimIndex); |
---|
| 739 | if nbdim > 3 |
---|
| 740 | msgbox_uvmat('ERROR','array with more than three dimensions, not supported') |
---|
| 741 | return |
---|
| 742 | else |
---|
[213] | 743 | perm_ind=1:nbdim; |
---|
[204] | 744 | end |
---|
| 745 | if nbdim==3 |
---|
| 746 | zstring=get(handles.coord_z_vectors_scalar,'String'); |
---|
| 747 | zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox |
---|
| 748 | list_var=zstring(zindex); |
---|
| 749 | VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable |
---|
| 750 | if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z) |
---|
| 751 | if zindex ~= 1 |
---|
| 752 | set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
| 753 | return |
---|
| 754 | end |
---|
| 755 | else |
---|
| 756 | VarIndex_tot=[VarIndex_tot VarIndex_z]; |
---|
| 757 | DimIndex_z=Field.VarDimIndex{VarIndex_z}; |
---|
| 758 | DimValue=Field.DimValue(DimIndex_z); |
---|
| 759 | ind=find(DimValue==1); |
---|
| 760 | DimIndex_z(ind)=[];%Mremove singleton |
---|
| 761 | if isequal(DimIndex_z,DimIndex) |
---|
| 762 | VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates |
---|
| 763 | elseif length(DimIndex_z)==1 |
---|
| 764 | VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; %dimension variable |
---|
| 765 | ind_z=find(DimIndex==DimIndex_z(1)); |
---|
| 766 | perm_ind(ind_z)=1; |
---|
| 767 | test_grid=1; |
---|
| 768 | else |
---|
| 769 | msgbox_uvmat('ERROR','multiple dimensions for the z coordinate') |
---|
| 770 | return |
---|
| 771 | end |
---|
| 772 | end |
---|
| 773 | % if ~isempty(VarIndex_z) |
---|
[227] | 774 | % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the TimeVariable |
---|
| 775 | % if length(DimIndex_z)==1 & nbdim==3 %dimension TimeVariable |
---|
[204] | 776 | % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; |
---|
| 777 | % ind_z=find(DimIndex==DimIndex_z(1)); |
---|
| 778 | % perm_ind(ind_z)=1; |
---|
| 779 | % test_grid=1; |
---|
| 780 | % end |
---|
| 781 | % end |
---|
| 782 | end |
---|
| 783 | end |
---|
| 784 | |
---|
[227] | 785 | % select the TimeVariable index (or indices) for ordinate |
---|
[204] | 786 | ystring=get(handles.ordinate,'String'); |
---|
| 787 | yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox |
---|
| 788 | list_var=ystring(yindex); |
---|
| 789 | VarIndex.y=name2index(list_var,Field.ListVarName); |
---|
| 790 | if isequal(VarIndex.A,VarIndex.y) |
---|
[581] | 791 | set(handles.ZVarName,'Value',1) |
---|
[204] | 792 | elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) |
---|
| 793 | set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
| 794 | else |
---|
| 795 | for ivar=1:length(VarIndex.y) |
---|
| 796 | VarAttribute{VarIndex.y(ivar)}.Role='coord_y'; |
---|
| 797 | end |
---|
| 798 | VarIndex_tot=[VarIndex_tot VarIndex.y]; |
---|
| 799 | end |
---|
| 800 | if (test_scalar | test_vector) & ~isempty(VarIndex.y) |
---|
| 801 | DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable |
---|
| 802 | if length(DimIndex_y)==1 |
---|
| 803 | ind_y=find(DimIndex==DimIndex_y(1)); |
---|
| 804 | test_grid=1; |
---|
| 805 | if nbdim==3 |
---|
| 806 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
| 807 | perm_ind(ind_y)=2; |
---|
| 808 | elseif nbdim==2 |
---|
| 809 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
| 810 | perm_ind(ind_y)=1; |
---|
| 811 | end |
---|
| 812 | elseif test_grid |
---|
| 813 | msgbox_uvmat('ERROR','the dimension of the y coordinate variable should be 1') |
---|
| 814 | end |
---|
| 815 | end |
---|
| 816 | |
---|
[227] | 817 | %select the TimeVariable index for the abscissa |
---|
[204] | 818 | xstring=get(handles.abscissa,'String'); |
---|
| 819 | xindex=get(handles.abscissa,'Value'); |
---|
| 820 | list_var=xstring(xindex); |
---|
| 821 | VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var |
---|
| 822 | if length(VarIndex.x)==1 |
---|
| 823 | DimIndex_x=Field.VarDimIndex{VarIndex.x}; |
---|
| 824 | DimValue=Field.DimValue(DimIndex_x); |
---|
| 825 | ind=find(DimValue==1); |
---|
| 826 | DimIndex_x(ind)=[];%Mremove singleton |
---|
| 827 | VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; %dimension variable |
---|
| 828 | % VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified) |
---|
| 829 | index_detect=find(VarIndex_tot==VarIndex.x); |
---|
| 830 | else |
---|
| 831 | index_detect=[];%coord x variable not already used |
---|
| 832 | end |
---|
| 833 | if isempty(index_detect) |
---|
| 834 | VarIndex_tot=[VarIndex_tot VarIndex.x]; |
---|
[503] | 835 | elseif ~test_CheckPlot1D |
---|
[204] | 836 | VarIndex.x=[]; |
---|
| 837 | set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa |
---|
| 838 | end |
---|
| 839 | |
---|
| 840 | if (test_scalar | test_vector) & ~isempty(VarIndex.x) |
---|
| 841 | DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable |
---|
| 842 | if length(DimIndex_x)==1 |
---|
| 843 | ind_x=find(DimIndex==DimIndex_x(1)); |
---|
| 844 | if nbdim==3 |
---|
| 845 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
| 846 | perm_ind(ind_x)=3; |
---|
| 847 | elseif nbdim==2 |
---|
| 848 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
| 849 | perm_ind(ind_x)=2; |
---|
| 850 | end |
---|
| 851 | if isequal(perm_ind,1:nbdim) |
---|
| 852 | test_grid=0; |
---|
| 853 | end |
---|
| 854 | DimIndex=DimIndex(perm_ind); |
---|
| 855 | elseif test_grid |
---|
| 856 | msgbox_uvmat('ERROR','the dimension of the x coordinate variable should be 1') |
---|
| 857 | end |
---|
| 858 | if isequal(DimIndex_x,DimIndex) |
---|
| 859 | VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates |
---|
| 860 | end |
---|
| 861 | end |
---|
| 862 | |
---|
| 863 | %defined the selected sub-field SubField |
---|
| 864 | SubField.ListGlobalAttribute{1}='InputFile'; |
---|
| 865 | SubField.InputFile=get(handles.inputfile,'String'); |
---|
| 866 | SubField.ListDimName=Field.ListDimName; |
---|
| 867 | SubField.DimValue=Field.DimValue; |
---|
| 868 | SubField.ListVarName=Field.ListVarName(VarIndex_tot); |
---|
| 869 | SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot); |
---|
| 870 | |
---|
| 871 | testperm=0; |
---|
| 872 | testattr=0; |
---|
| 873 | for ivar=VarIndex.u |
---|
| 874 | VarAttribute{ivar}.Role='vector_x'; |
---|
| 875 | testattr=1; |
---|
| 876 | if test_grid |
---|
| 877 | VarDimIndex{ivar}=DimIndex; %permute dimensions |
---|
| 878 | testperm=1; |
---|
| 879 | end |
---|
| 880 | end |
---|
| 881 | for ivar=VarIndex.v |
---|
| 882 | VarAttribute{ivar}.Role='vector_y'; |
---|
| 883 | testattr=1; |
---|
| 884 | if test_grid |
---|
| 885 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
| 886 | testperm=1; |
---|
| 887 | end |
---|
| 888 | end |
---|
| 889 | for ivar=VarIndex.A |
---|
| 890 | if test_grid |
---|
| 891 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
| 892 | testperm=1; |
---|
| 893 | end |
---|
| 894 | if isempty(iuA) |
---|
| 895 | VarAttribute{ivar}.Role='scalar';%Role =scalar |
---|
| 896 | testattr=1; |
---|
| 897 | else |
---|
| 898 | VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable |
---|
| 899 | nbattr=length(VarAttribute); |
---|
| 900 | VarAttribute{nbattr}.Role='scalar'; |
---|
| 901 | testattr=1; |
---|
| 902 | end |
---|
| 903 | end |
---|
| 904 | if testperm |
---|
| 905 | SubField.VarDimIndex=VarDimIndex(VarIndex_tot); |
---|
| 906 | end |
---|
| 907 | if testattr |
---|
| 908 | SubField.VarAttribute=VarAttribute(VarIndex_tot); |
---|
| 909 | end |
---|
| 910 | set(hselect_field,'UserData',Field) |
---|
| 911 | |
---|
| 912 | %--------------------------------------------------------- |
---|
[581] | 913 | % --- Executes on button press in OK. |
---|
[204] | 914 | |
---|
[581] | 915 | function OK_Callback(hObject, eventdata, handles) |
---|
[204] | 916 | %--------------------------------------------------------- |
---|
[581] | 917 | |
---|
| 918 | handles.output=read_GUI(handles.get_field); |
---|
| 919 | guidata(hObject, handles);% Update handles structure |
---|
| 920 | uiresume(handles.get_field); |
---|
| 921 | drawnow |
---|
| 922 | return |
---|
| 923 | |
---|
| 924 | %%%% SKIPPED %%%% |
---|
[526] | 925 | hfield=[]; |
---|
[517] | 926 | huvmat=findobj(allchild(0),'tag','uvmat'); |
---|
[526] | 927 | hseries=findobj(allchild(0),'tag','series'); |
---|
| 928 | check_series=0; |
---|
[528] | 929 | % look for the status of the GUI uvmat |
---|
[517] | 930 | if ~isempty(huvmat) |
---|
[526] | 931 | hh=guidata(huvmat); |
---|
| 932 | FieldMenu=get(hh.FieldName,'String'); |
---|
| 933 | FieldName=FieldMenu{get(hh.FieldName,'Value')}; |
---|
| 934 | if strcmp(FieldName,'get_field...') |
---|
| 935 | hfield=hh.FieldName; %FieldName on uvmat |
---|
| 936 | elseif strcmp(get(hh.FieldName_1,'Visible'),'on') |
---|
| 937 | FieldMenu=get(hh.FieldName_1,'String'); |
---|
| 938 | if ~isempty(FieldMenu) |
---|
| 939 | FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; |
---|
| 940 | if strcmp(FieldName,'get_field...') |
---|
| 941 | hfield=hh.FieldName_1; %FieldName_1 on uvmat |
---|
| 942 | end |
---|
| 943 | end |
---|
| 944 | end |
---|
[204] | 945 | end |
---|
[528] | 946 | % if no filed data is concerned on uvmat, look at the GUI series |
---|
[526] | 947 | if isempty(hfield) && ~isempty(hseries) |
---|
| 948 | check_series=1; |
---|
[528] | 949 | hh=guidata(hseries); |
---|
[526] | 950 | FieldMenu=get(hh.FieldName,'String'); |
---|
| 951 | FieldName=FieldMenu{get(hh.FieldName,'Value')}; |
---|
| 952 | if strcmp(FieldName,'get_field...') |
---|
| 953 | hfield=hh.FieldName; %FieldName on series |
---|
| 954 | else |
---|
| 955 | FieldMenu=get(hh.FieldName_1,'String'); |
---|
| 956 | FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; |
---|
| 957 | if strcmp(FieldName,'get_field...') |
---|
| 958 | hfield=hh.FieldName_1; %FieldName_1 on series |
---|
| 959 | end |
---|
| 960 | end |
---|
| 961 | end |
---|
| 962 | if ~isempty(hfield) |
---|
| 963 | get_field_GUI=read_GUI(handles.get_field); |
---|
| 964 | if isfield(get_field_GUI,'PanelVectors') |
---|
| 965 | set(hh.Coord_x,'value',1) |
---|
| 966 | set(hh.Coord_y,'value',1) |
---|
| 967 | set(hh.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors}) |
---|
| 968 | set(hh.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors}) |
---|
| 969 | UName=get_field_GUI.PanelVectors.vector_x; |
---|
| 970 | VName=get_field_GUI.PanelVectors.vector_y; |
---|
| 971 | menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}]; |
---|
| 972 | menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}]; |
---|
| 973 | set(hfield,'Value',1) |
---|
| 974 | set(hfield,'String',menu_str) |
---|
| 975 | if ~check_series |
---|
| 976 | ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color)); |
---|
| 977 | if ~isempty(ind_menu) |
---|
| 978 | set(hh.ColorScalar,'Value',ind_menu) |
---|
| 979 | else |
---|
| 980 | set(hh.ColorScalar,'Value',1) |
---|
| 981 | end |
---|
| 982 | set(hh.ColorScalar,'String',menu_color) |
---|
| 983 | end |
---|
| 984 | elseif isfield(get_field_GUI,'PanelScalar') |
---|
| 985 | set(hh.Coord_x,'value',1) |
---|
| 986 | set(hh.Coord_y,'value',1) |
---|
| 987 | set(hh.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar}) |
---|
| 988 | set(hh.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar}) |
---|
| 989 | AName=get_field_GUI.PanelScalar.scalar; |
---|
| 990 | menu=get(hfield,'String'); |
---|
| 991 | ind_select=find(strcmp(AName,menu)); |
---|
| 992 | if isempty(ind_select) |
---|
| 993 | menu=[menu(1:end-1);{AName};{'get_field...'}]; |
---|
| 994 | ind_select=numel(menu)-1; |
---|
| 995 | end |
---|
| 996 | set(hfield,'Value',ind_select); |
---|
| 997 | set(hfield,'String',menu); |
---|
| 998 | elseif isfield(get_field_GUI,'Panel1Dplot') |
---|
| 999 | set(hh.Coord_x,'Value',1) |
---|
| 1000 | set(hh.Coord_x,'String',{get_field_GUI.Panel1Dplot.abscissa}) |
---|
[537] | 1001 | set(hh.Coord_y,'String',get_field_GUI.Panel1Dplot.ordinate) |
---|
[538] | 1002 | set(hh.Coord_y,'Max', numel(get_field_GUI.Panel1Dplot.ordinate)) |
---|
[526] | 1003 | set(hh.Coord_y,'Value',1:numel(get_field_GUI.Panel1Dplot.ordinate)) |
---|
| 1004 | set(hfield,'Value',1) |
---|
| 1005 | set(hfield,'String',[{''};{'get_field...'}]) |
---|
| 1006 | end |
---|
| 1007 | if ~check_series && strcmp(get(gcbf,'tag'),'get_field')%get_field is not called by another GUI (uvmat) |
---|
| 1008 | uvmat('run0_Callback',hObject,eventdata,hh); %refresh uvmat |
---|
| 1009 | end |
---|
| 1010 | end |
---|
[517] | 1011 | delete(handles.get_field) |
---|
[204] | 1012 | |
---|
| 1013 | |
---|
| 1014 | |
---|
| 1015 | %------------------------------------------------- |
---|
| 1016 | % give index numbers of the strings str in the list ListvarName |
---|
| 1017 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
| 1018 | VarIndex_y=[]; |
---|
| 1019 | if ischar(cell_str) |
---|
| 1020 | for ivar=1:length(ListVarName) |
---|
| 1021 | varlist=ListVarName{ivar}; |
---|
| 1022 | if isequal(varlist,cell_str) |
---|
| 1023 | VarIndex_y= ivar; |
---|
| 1024 | break |
---|
| 1025 | end |
---|
| 1026 | end |
---|
| 1027 | elseif iscell(cell_str) |
---|
| 1028 | for isel=1:length(cell_str) |
---|
| 1029 | varsel=cell_str{isel}; |
---|
| 1030 | for ivar=1:length(ListVarName) |
---|
| 1031 | varlist=ListVarName{ivar}; |
---|
| 1032 | if isequal(varlist,varsel) |
---|
| 1033 | VarIndex_y=[VarIndex_y ivar]; |
---|
| 1034 | end |
---|
| 1035 | end |
---|
| 1036 | end |
---|
| 1037 | end |
---|
| 1038 | |
---|
| 1039 | |
---|
[227] | 1040 | % ----------------------------------------------------------------------- |
---|
| 1041 | function TimeName_Callback(hObject, eventdata, handles) |
---|
| 1042 | |
---|
| 1043 | scalar_Callback(hObject, eventdata, handles)% suppress time variable from possible spatial coordinates |
---|
| 1044 | vector_x_Callback(hObject, eventdata, handles) |
---|
| 1045 | |
---|
| 1046 | %------------------------------------------------------------------------ |
---|
| 1047 | % --- Executes on button press in TimeAttribute. |
---|
| 1048 | function TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1049 | %------------------------------------------------------------------------ |
---|
| 1050 | val=get(handles.TimeAttribute,'Value'); |
---|
| 1051 | if val |
---|
| 1052 | set(handles.TimeAttributeMenu,'Visible','on') |
---|
| 1053 | Field=get(handles.get_field,'UserData'); |
---|
| 1054 | time_value=zeros(size(Field.ListGlobalAttribute)); |
---|
| 1055 | test_time=zeros(size(Field.ListGlobalAttribute)); |
---|
| 1056 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 1057 | if isnumeric(eval(['Field.' Field.ListGlobalAttribute{ilist}])) |
---|
| 1058 | eval(['time_val=Field.' Field.ListGlobalAttribute{ilist} ';']) |
---|
| 1059 | if ~isempty(time_val) |
---|
| 1060 | time_value(ilist)=time_val; |
---|
| 1061 | test_time(ilist)=1; |
---|
| 1062 | end |
---|
| 1063 | end |
---|
| 1064 | end |
---|
| 1065 | ListTimeAttribute=Field.ListGlobalAttribute(test_time==1); |
---|
| 1066 | attr_index=get(handles.TimeAttributeMenu,'Value'); |
---|
| 1067 | if attr_index>numel(ListTimeAttribute) |
---|
| 1068 | attr_index=1; |
---|
| 1069 | set(handles.TimeAttributeMenu,'Value',1); |
---|
| 1070 | end |
---|
| 1071 | if isempty(ListTimeAttribute) |
---|
| 1072 | set(handles.TimeAttributeMenu,'String',{''}) |
---|
| 1073 | set(handles.TimeValue,'Visible','off') |
---|
| 1074 | else |
---|
| 1075 | set(handles.TimeValue,'Visible','on') |
---|
| 1076 | set(handles.TimeAttributeMenu,'String',ListTimeAttribute) |
---|
| 1077 | set(handles.TimeValue,'String',num2str(time_value(attr_index))) |
---|
| 1078 | end |
---|
| 1079 | set(handles.TimeDimension,'Value',0) |
---|
| 1080 | TimeDimension_Callback(hObject, eventdata, handles) |
---|
| 1081 | set(handles.TimeVariable,'Value',0) |
---|
| 1082 | TimeVariable_Callback(hObject, eventdata, handles) |
---|
| 1083 | else |
---|
| 1084 | set(handles.TimeAttributeMenu,'Visible','off') |
---|
| 1085 | set(handles.TimeValue,'Visible','off') |
---|
| 1086 | end |
---|
| 1087 | |
---|
| 1088 | %------------------------------------------------------------------------ |
---|
| 1089 | % --- Executes on selection change in TimeAttributeMenu. |
---|
| 1090 | function TimeAttributeMenu_Callback(hObject, eventdata, handles) |
---|
| 1091 | ListTimeAttribute=get(handles.TimeAttributeMenu,'String'); |
---|
| 1092 | index=get(handles.TimeAttributeMenu,'Value'); |
---|
| 1093 | AttrName=ListTimeAttribute{index}; |
---|
| 1094 | Field=get(handles.get_field,'UserData'); |
---|
| 1095 | eval(['time_val=Field.' AttrName ';']) |
---|
| 1096 | set(handles.TimeValue,'String',num2str(time_val)) |
---|
| 1097 | %------------------------------------------------------------------------ |
---|
| 1098 | |
---|
| 1099 | %------------------------------------------------------------------------ |
---|
| 1100 | % --- Executes on button press in TimeVariable. |
---|
| 1101 | function TimeDimension_Callback(hObject, eventdata, handles) |
---|
| 1102 | %------------------------------------------------------------------------ |
---|
| 1103 | val=get(handles.TimeDimension,'Value');%=1 if check box TimeDimension is selected |
---|
| 1104 | if val %if check box TimeDimension is selected |
---|
| 1105 | Field=get(handles.get_field,'UserData');% structure describing the currently opened field |
---|
| 1106 | previous_menu=get(handles.TimeDimensionMenu,'String'); |
---|
| 1107 | if ~isequal(previous_menu,Field.ListDimName)%update the list of available dimensions in the menu |
---|
| 1108 | ind_select=find(strcmpi('time',Field.ListDimName),1);% look for a dimension named 'time' or 'Time' |
---|
| 1109 | if isempty(ind_select) |
---|
| 1110 | ind_select=1;% select the first item in the list if 'time' is not found |
---|
| 1111 | end |
---|
| 1112 | set(handles.TimeDimensionMenu,'Value',ind_select); |
---|
| 1113 | set(handles.TimeDimensionMenu,'String',Field.ListDimName)% put the list of available dimensions in the menu |
---|
| 1114 | end |
---|
| 1115 | set(handles.TimeDimensionMenu,'Visible','on')% the menu is made visible |
---|
| 1116 | set(handles.TimeIndexValue,'Visible','on')% the time matrix index value selected is made visible |
---|
| 1117 | TimeDimensionMenu_Callback(hObject, eventdata, handles) |
---|
| 1118 | set(handles.TimeAttribute,'Value',0) %deselect alternative options for time |
---|
| 1119 | set(handles.TimeVariable,'Value',0) |
---|
| 1120 | TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1121 | else |
---|
| 1122 | set(handles.TimeDimensionMenu,'Visible','off') |
---|
| 1123 | set(handles.TimeIndexValue,'Visible','off') |
---|
| 1124 | end |
---|
[581] | 1125 | % |
---|
| 1126 | % %------------------------------------------------------------------------ |
---|
| 1127 | % % --- Executes on selection change in TimeDimensionMenu. |
---|
| 1128 | % function TimeDimensionMenu_Callback(hObject, eventdata, handles) |
---|
| 1129 | % %------------------------------------------------------------------------ |
---|
| 1130 | % index=get(handles.TimeDimensionMenu,'Value'); |
---|
| 1131 | % DimList=get(handles.TimeDimensionMenu,'String'); |
---|
| 1132 | % DimName=DimList{index}; |
---|
| 1133 | % Field=get(handles.get_field,'UserData'); |
---|
| 1134 | % DimIndex=find(strcmp(DimName,Field.ListDimName),1); |
---|
| 1135 | % ref_index=round(Field.DimValue(DimIndex)/2); |
---|
| 1136 | % set(handles.TimeIndexValue,'String',num2str(ref_index)) |
---|
| 1137 | % scalar_Callback(hObject, eventdata, handles) |
---|
| 1138 | % vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) |
---|
| 1139 | % % look for a corresponding time variable and value |
---|
| 1140 | % time_test=zeros(size(Field.VarDimName)); |
---|
| 1141 | % for ilist=1:numel(Field.VarDimName) |
---|
| 1142 | % if isequal(Field.VarDimName{ilist},{DimName}) |
---|
| 1143 | % time_test(ilist)=1; |
---|
| 1144 | % end |
---|
| 1145 | % end |
---|
| 1146 | % ListVariable=Field.ListVarName(time_test==1); |
---|
| 1147 | % set(handles.TimeVariableMenu,'Value',1) |
---|
| 1148 | % if isempty(ListVariable) |
---|
| 1149 | % set(handles.TimeVariableMenu,'String',{''}) |
---|
| 1150 | % set(handles.TimeVarValue,'String','') |
---|
| 1151 | % else |
---|
| 1152 | % set(handles.TimeVariableMenu,'String',ListVariable) |
---|
| 1153 | % TimeVarName=ListVariable{1}; |
---|
| 1154 | % VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables |
---|
| 1155 | % inputfile=get(handles.inputfile,'String');% read the input file |
---|
| 1156 | % SubField=nc2struct(inputfile,{TimeVarName}); |
---|
| 1157 | % eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) |
---|
| 1158 | % set(handles.TimeVarValue,'Visible','on') |
---|
| 1159 | % set(handles.TimeVariableMenu,'Visible','on') |
---|
| 1160 | % set(handles.TimeVarValue,'String',num2str(TimeValue)) |
---|
| 1161 | % end |
---|
| 1162 | % |
---|
| 1163 | % |
---|
| 1164 | % % % ----------------------------------------------------------------------- |
---|
| 1165 | % % % --- Executes on button press in TimeVariable. |
---|
| 1166 | % % function TimeVariable_Callback(hObject, eventdata, handles) |
---|
| 1167 | % % % ----------------------------------------------------------------------- |
---|
| 1168 | % % val=get(handles.TimeVariable,'Value'); |
---|
| 1169 | % % if val |
---|
| 1170 | % % Field=get(handles.get_field,'UserData'); |
---|
| 1171 | % % time_test=zeros(size(Field.VarDimName)); |
---|
| 1172 | % % for ilist=1:numel(Field.VarDimName) |
---|
| 1173 | % % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension |
---|
| 1174 | % % time_test(ilist)=1; |
---|
| 1175 | % % end |
---|
| 1176 | % % end |
---|
| 1177 | % % ind_test=find(time_test); |
---|
| 1178 | % % if isempty(time_test) |
---|
| 1179 | % % set(handles.TimeVariable,'Value',0) |
---|
| 1180 | % % set(handles.TimeVariableMenu,'Visible','off') |
---|
| 1181 | % % set(handles.TimeVarValue,'Visible','off') |
---|
| 1182 | % % else |
---|
| 1183 | % % set(handles.TimeVariableMenu,'Visible','on') |
---|
| 1184 | % % set(handles.TimeVarValue,'Visible','on') |
---|
| 1185 | % % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) |
---|
| 1186 | % % set(handles.TimeVariableMenu,'Value',1) |
---|
| 1187 | % % end |
---|
| 1188 | % % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) |
---|
| 1189 | % % TimeVariableMenu_Callback(hObject, eventdata, handles) |
---|
| 1190 | % % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time |
---|
| 1191 | % % set(handles.TimeAttribute,'Value',0) |
---|
| 1192 | % % TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1193 | % % end |
---|
| 1194 | % % else |
---|
| 1195 | % % set(handles.TimeVariableMenu,'Visible','off') |
---|
| 1196 | % % set(handles.TimeVarValue,'Visible','off') |
---|
| 1197 | % % end |
---|
| 1198 | % |
---|
[227] | 1199 | % % ----------------------------------------------------------------------- |
---|
[581] | 1200 | % % --- Executes on selection change in TimeVariableMenu. |
---|
| 1201 | % function TimeVariableMenu_Callback(hObject, eventdata, handles) |
---|
[227] | 1202 | % % ----------------------------------------------------------------------- |
---|
[581] | 1203 | % ListVar=get(handles.TimeVariableMenu,'String'); |
---|
| 1204 | % index=get(handles.TimeVariableMenu,'Value'); |
---|
| 1205 | % TimeVariable=ListVar{index};% name of the selected variable |
---|
| 1206 | % if isempty(TimeVariable)% case of blank selection |
---|
| 1207 | % return |
---|
[227] | 1208 | % end |
---|
[581] | 1209 | % Field=get(handles.get_field,'UserData'); %index of |
---|
| 1210 | % VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables |
---|
| 1211 | % DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable |
---|
| 1212 | % set(handles.TimeDimensionMenu,'Value',1) |
---|
| 1213 | % set(handles.TimeDimensionMenu,'String',DimName) |
---|
| 1214 | % inputfile=get(handles.inputfile,'String');% read the input file |
---|
| 1215 | % SubField=nc2struct(inputfile,{TimeVariable}); |
---|
| 1216 | % eval(['TimeDimension=numel(SubField.' TimeVariable ');']) |
---|
| 1217 | % ref_index=round(TimeDimension/2); |
---|
| 1218 | % eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) |
---|
| 1219 | % set(handles.TimeIndexValue,'String',num2str(ref_index)) |
---|
| 1220 | % set(handles.TimeVarValue,'String',num2str(TimeValue)) |
---|
[227] | 1221 | |
---|
| 1222 | |
---|
[581] | 1223 | % --- Executes on button press in check_rgb. |
---|
| 1224 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[227] | 1225 | |
---|
| 1226 | |
---|
[581] | 1227 | % --- Executes when user attempts to close get_field. |
---|
| 1228 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 1229 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 1230 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 1231 | uiresume(handles.get_field); |
---|
[227] | 1232 | else |
---|
[581] | 1233 | % The GUI is no longer waiting, just close it |
---|
| 1234 | delete(handles.get_field); |
---|
[227] | 1235 | end |
---|
| 1236 | |
---|
| 1237 | |
---|
| 1238 | |
---|
[646] | 1239 | %------------------------------------------------------------------------ |
---|
[581] | 1240 | % --- Executes on selection change in SwitchVarIndexX. |
---|
[646] | 1241 | %------------------------------------------------------------------------ |
---|
[581] | 1242 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
| 1243 | |
---|
[646] | 1244 | %------------------------------------------------------------------------ |
---|
[581] | 1245 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
[646] | 1246 | %------------------------------------------------------------------------ |
---|
[581] | 1247 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
[646] | 1248 | |
---|
[581] | 1249 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 1250 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[582] | 1251 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 1252 | switch option |
---|
| 1253 | case 'file index' |
---|
| 1254 | set(handles.TimeVarName, 'Visible','off') |
---|
| 1255 | case 'attribute' |
---|
| 1256 | set(handles.TimeVarName, 'Visible','on') |
---|
| 1257 | time_index=[]; |
---|
[582] | 1258 | PreviousList=get(handles.TimeVarName, 'String'); |
---|
| 1259 | index=[]; |
---|
| 1260 | if ~isempty(PreviousList) |
---|
| 1261 | PreviousAttr=PreviousList{get(handles.TimeVarName, 'Value')}; |
---|
| 1262 | index=find(strcmp(PreviousAttr,Field.ListNumAttributes)); |
---|
[581] | 1263 | end |
---|
[582] | 1264 | if isempty(index) |
---|
| 1265 | time_index=find(~cellfun('isempty',regexp(Field.ListNumAttributes,'Time')));% index of the attributes containing the string 'Time' |
---|
| 1266 | end |
---|
[581] | 1267 | if ~isempty(time_index) |
---|
| 1268 | set(handles.TimeVarName,'Value',time_index(1)) |
---|
| 1269 | else |
---|
| 1270 | set(handles.TimeVarName,'Value',1) |
---|
| 1271 | end |
---|
[582] | 1272 | set(handles.TimeVarName, 'String',Field.ListNumAttributes) |
---|
[581] | 1273 | case 'variable' |
---|
| 1274 | set(handles.TimeVarName, 'Visible','on') |
---|
[582] | 1275 | TimeVarName=Field.SingleVarName; |
---|
[581] | 1276 | List=get(handles.TimeVarName,'String'); |
---|
| 1277 | option=List{get(handles.TimeVarName,'Value')}; |
---|
[582] | 1278 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 1279 | if isempty(ind) |
---|
| 1280 | set(handles.TimeVarName, 'Value',1); |
---|
| 1281 | else |
---|
| 1282 | set(handles.TimeVarName, 'Value',ind); |
---|
| 1283 | end |
---|
| 1284 | set(handles.TimeVarName, 'String',TimeVarName) |
---|
| 1285 | case 'dim index' |
---|
| 1286 | set(handles.TimeVarName, 'Visible','on') |
---|
[582] | 1287 | TimeVarName=Field.SingleDimName; |
---|
[581] | 1288 | List=get(handles.TimeVarName,'String'); |
---|
| 1289 | option=List{get(handles.TimeVarName,'Value')}; |
---|
[582] | 1290 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 1291 | if isempty(ind) |
---|
| 1292 | set(handles.TimeVarName, 'Value',1); |
---|
| 1293 | else |
---|
| 1294 | set(handles.TimeVarName, 'Value',ind); |
---|
| 1295 | end |
---|
[582] | 1296 | set(handles.TimeVarName, 'String',TimeVarName) |
---|
[581] | 1297 | end |
---|
| 1298 | |
---|
[644] | 1299 | % --- Executes on selection change in FieldOption. |
---|
| 1300 | function FieldOption_Callback(hObject, eventdata, handles) |
---|
| 1301 | FieldList=get(handles.FieldOption,'String'); |
---|
| 1302 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
---|
| 1303 | switch FieldOption |
---|
| 1304 | case '1D plot' |
---|
[646] | 1305 | set(handles.Panel1Dplot,'Visible','on') |
---|
| 1306 | pos=get(handles.Panel1Dplot,'Position'); |
---|
| 1307 | pos(1)=2; |
---|
| 1308 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 1309 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 1310 | set(handles.Panel1Dplot,'Position',pos) |
---|
| 1311 | set(handles.PanelScalar,'Visible','off') |
---|
| 1312 | set(handles.PanelVectors,'Visible','off') |
---|
| 1313 | set(handles.YVarName,'Visible','off') |
---|
| 1314 | % set(handles.SwitchVarIndexY,'Visible','off') |
---|
| 1315 | set(handles.Y_title,'Visible','off') |
---|
| 1316 | set(handles.ZVarName,'Visible','off') |
---|
| 1317 | % set(handles.SwitchVarIndexZ,'Visible','off') |
---|
| 1318 | set(handles.Z_title,'Visible','off') |
---|
[644] | 1319 | case 'scalar' |
---|
| 1320 | set(handles.Panel1Dplot,'Visible','off') |
---|
[646] | 1321 | set(handles.PanelScalar,'Visible','on') |
---|
| 1322 | set(handles.PanelVectors,'Visible','off') |
---|
| 1323 | pos=get(handles.PanelScalar,'Position'); |
---|
| 1324 | pos(1)=2; |
---|
| 1325 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 1326 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 1327 | set(handles.PanelScalar,'Position',pos) |
---|
| 1328 | set(handles.YVarName,'Visible','on') |
---|
| 1329 | set(handles.Y_title,'Visible','on') |
---|
[644] | 1330 | case 'vectors' |
---|
| 1331 | set(handles.Panel1Dplot,'Visible','off') |
---|
[646] | 1332 | set(handles.PanelScalar,'Visible','off') |
---|
| 1333 | set(handles.PanelVectors,'Visible','on') |
---|
| 1334 | pos=get(handles.PanelVectors,'Position'); |
---|
| 1335 | pos(1)=2; |
---|
| 1336 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 1337 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 1338 | set(handles.PanelVectors,'Position',pos) |
---|
| 1339 | set(handles.YVarName,'Visible','on') |
---|
| 1340 | set(handles.Y_title,'Visible','on') |
---|
[644] | 1341 | end |
---|