[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 | |
---|
[648] | 24 | % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54 |
---|
[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. |
---|
[648] | 47 | %------------------------------------------------------------------------ |
---|
[581] | 48 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
---|
[204] | 49 | |
---|
[648] | 50 | %% GUI settings |
---|
[581] | 51 | handles.output = 'Cancel'; |
---|
[204] | 52 | guidata(hObject, handles); |
---|
[434] | 53 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[204] | 54 | |
---|
[648] | 55 | %% enter input data |
---|
| 56 | set(handles.inputfile,'String',filename)% fill the input file name |
---|
| 57 | Field=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
| 58 | if isfield(Field,'Txt') |
---|
| 59 | msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fiel reading |
---|
| 60 | return |
---|
[227] | 61 | end |
---|
[204] | 62 | if ~isfield(Field,'ListVarName') |
---|
| 63 | return |
---|
| 64 | end |
---|
[648] | 65 | if ~exist('ParamIn','var') |
---|
| 66 | ParamIn=[]; |
---|
| 67 | end |
---|
[582] | 68 | |
---|
[648] | 69 | %% look at singletons and variables with a single dimension |
---|
| 70 | Field.Display=Field; |
---|
| 71 | Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value |
---|
| 72 | NbVar=numel(Field.VarDimName); |
---|
| 73 | for ilist=1:NbVar |
---|
[582] | 74 | if ischar(Field.VarDimName{ilist}) |
---|
| 75 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 76 | end |
---|
[648] | 77 | NbDim=numel(Field.VarDimName{ilist}); |
---|
[582] | 78 | check_singleton=false(1,NbDim); |
---|
| 79 | for idim=1:NbDim |
---|
[648] | 80 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions |
---|
| 81 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton |
---|
[582] | 82 | end |
---|
[648] | 83 | Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)));% =1 if the variable reduces to a single value |
---|
| 84 | if ~Field.Check0D(ilist) |
---|
| 85 | Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions |
---|
[582] | 86 | end |
---|
[648] | 87 | %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons |
---|
[582] | 88 | end |
---|
[648] | 89 | if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded |
---|
| 90 | Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); |
---|
[582] | 91 | end |
---|
[648] | 92 | Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); |
---|
| 93 | Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); |
---|
| 94 | Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); |
---|
| 95 | Field.Display.DimValue=Field.DimValue(Field.DimValue~=1); |
---|
| 96 | Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1); |
---|
[581] | 97 | |
---|
[648] | 98 | %% analyse the input field cells |
---|
| 99 | [CellInfo,NbDim,errormsg]=find_field_cells(Field.Display); |
---|
| 100 | if ~isempty(errormsg) |
---|
| 101 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
---|
| 102 | return |
---|
| 103 | end |
---|
| 104 | [Field.MaxDim,imax]=max(NbDim); |
---|
| 105 | |
---|
[581] | 106 | %% set time mode |
---|
[646] | 107 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
---|
[582] | 108 | % look at global attributes with numerical values |
---|
| 109 | check_numvalue=false; |
---|
| 110 | check_time=false; |
---|
[646] | 111 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 112 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 113 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 114 | check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); |
---|
| 115 | end |
---|
[648] | 116 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 117 | if ~isempty(Field.Display.ListGlobalAttribute) |
---|
[646] | 118 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
---|
[582] | 119 | end |
---|
| 120 | nboption=numel(ListSwitchVarIndexTime); |
---|
| 121 | if Field.MaxDim>=2 |
---|
[646] | 122 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index |
---|
[582] | 123 | end |
---|
[648] | 124 | if ~isempty(find(check_time, 1)) |
---|
| 125 | set(handles.SwitchVarIndexTime,'Value',2); |
---|
[581] | 126 | else |
---|
[648] | 127 | set(handles.SwitchVarIndexTime,'Value',1); |
---|
[581] | 128 | end |
---|
[646] | 129 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
[582] | 130 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[648] | 131 | SwitchVarIndexTime_Callback([], [], handles) |
---|
[581] | 132 | |
---|
[582] | 133 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
[648] | 134 | set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components |
---|
| 135 | set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components |
---|
| 136 | set(handles.vector_z,'String',[{''} Field.ListVarName])% fill the menu of y vector components |
---|
| 137 | set(handles.vec_color,'String',[{''} Field.ListVarName])% fill the menu of y vector components |
---|
| 138 | set(handles.scalar,'Value',1)% fill the menu of y vector components |
---|
| 139 | set(handles.scalar,'String',Field.ListVarName)% fill the menu of y vector components |
---|
| 140 | set(handles.ordinate,'Value',1)% fill the menu of y vector components |
---|
| 141 | set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components |
---|
[654] | 142 | if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
---|
| 143 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'}) |
---|
| 144 | else |
---|
| 145 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) |
---|
| 146 | end |
---|
[582] | 147 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
---|
[648] | 148 | if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
---|
[646] | 149 | set(handles.FieldOption,'Value',3)% set vector selection option |
---|
[530] | 150 | set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) |
---|
| 151 | set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) |
---|
[644] | 152 | set(handles.FieldOption,'Value',3) |
---|
[204] | 153 | else |
---|
[644] | 154 | set(handles.FieldOption,'Value',2) |
---|
[204] | 155 | end |
---|
[654] | 156 | |
---|
[582] | 157 | else % case of 1D fields |
---|
[644] | 158 | set(handles.FieldOption,'Value',1) |
---|
[204] | 159 | end |
---|
[582] | 160 | |
---|
[648] | 161 | %% fill the general list of dimensions, variables, attributes |
---|
| 162 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
| 163 | Tabcell(:,1)=Field.ListDimName; |
---|
| 164 | for iline=1:length(Field.ListDimName) |
---|
| 165 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
| 166 | end |
---|
| 167 | Tabchar=cell2tab(Tabcell,' = '); |
---|
| 168 | set(handles.dimensions,'String',Tabchar) |
---|
| 169 | end |
---|
| 170 | set(handles.variables,'Value',1) |
---|
| 171 | set(handles.variables,'String',[{'*'} Field.ListVarName]) |
---|
| 172 | variables_Callback(handles.variables,[], handles)% list the global attributes |
---|
[644] | 173 | |
---|
[648] | 174 | %% fill menus for coordinates and time |
---|
| 175 | FieldOption_Callback(handles.variables,[], handles)% list the global attributes |
---|
| 176 | % if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y') |
---|
| 177 | % set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1)) |
---|
| 178 | % set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1)) |
---|
| 179 | % end |
---|
| 180 | |
---|
[582] | 181 | %% Make choices in menus from input |
---|
[648] | 182 | % if exist('ParamIn','var')&&~isempty(ParamIn) |
---|
| 183 | % fill_GUI(ParamIn,handles.get_field); |
---|
| 184 | % end |
---|
| 185 | %FieldOption_Callback([],[],handles) |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | %% put the GUI on the lower right of the sceen |
---|
| 189 | set(hObject,'Unit','pixel') |
---|
| 190 | pos_view_field=get(hObject,'Position'); |
---|
| 191 | set(0,'Unit','pixels') |
---|
| 192 | ScreenSize=get(0,'ScreenSize'); |
---|
| 193 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
---|
| 194 | pos_view_field(2)=ScreenSize(2); |
---|
| 195 | set(hObject,'Position',pos_view_field) |
---|
| 196 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
---|
| 197 | drawnow |
---|
| 198 | uiwait(handles.get_field); |
---|
| 199 | |
---|
| 200 | return |
---|
| 201 | |
---|
| 202 | SwitchVarIndexTime_Callback([],[], handles) |
---|
| 203 | |
---|
| 204 | %% set z coordinate menu if relevant |
---|
| 205 | if Field.MaxDim>=3 |
---|
| 206 | set(handles.vector_z,'Visible','on') |
---|
| 207 | set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D)) |
---|
| 208 | set(handles.Coord_z,'Visible','on') |
---|
| 209 | set(handles.SwitchVarIndexZ,'Visible','on') |
---|
| 210 | set(handles.Z_title,'Visible','on') |
---|
| 211 | else |
---|
| 212 | set(handles.vector_z,'Visible','off') |
---|
| 213 | set(handles.Coord_z,'Visible','off') |
---|
| 214 | set(handles.Z_title,'Visible','off') |
---|
[581] | 215 | end |
---|
[204] | 216 | |
---|
[648] | 217 | |
---|
| 218 | |
---|
[204] | 219 | %------------------------------------------------------------------------ |
---|
[648] | 220 | |
---|
| 221 | %------------------------------------------------------------------------ |
---|
[582] | 222 | % --- Outputs from this function are returned to the command line. |
---|
| 223 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
| 224 | %------------------------------------------------------------------------ |
---|
| 225 | varargout{1} = handles.output; |
---|
| 226 | delete(handles.get_field) |
---|
| 227 | |
---|
[648] | 228 | %------------------------------------------------------------------------ |
---|
| 229 | % --- Executes when user attempts to close get_field. |
---|
| 230 | %------------------------------------------------------------------------ |
---|
| 231 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
---|
[582] | 232 | |
---|
[648] | 233 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 234 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 235 | uiresume(handles.get_field); |
---|
| 236 | else |
---|
| 237 | % The GUI is no longer waiting, just close it |
---|
| 238 | delete(handles.get_field); |
---|
| 239 | end |
---|
| 240 | |
---|
| 241 | %--------------------------------------------------------- |
---|
| 242 | % --- Executes on button press in OK. |
---|
| 243 | %------------------------------------------------------------------------ |
---|
| 244 | function OK_Callback(hObject, eventdata, handles) |
---|
| 245 | |
---|
| 246 | handles.output=read_GUI(handles.get_field); |
---|
| 247 | guidata(hObject, handles);% Update handles structure |
---|
| 248 | uiresume(handles.get_field); |
---|
| 249 | drawnow |
---|
| 250 | |
---|
[582] | 251 | % ----------------------------------------------------------------------- |
---|
| 252 | % --- Activated by selection in the list of variables |
---|
| 253 | function variables_Callback(hObject, eventdata, handles) |
---|
| 254 | % ----------------------------------------------------------------------- |
---|
| 255 | Tabchar={''};%default |
---|
| 256 | Tabcell=[]; |
---|
| 257 | hselect_field=get(handles.variables,'parent'); |
---|
| 258 | Field=get(handles.get_field,'UserData'); |
---|
| 259 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
| 260 | |
---|
| 261 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
---|
| 262 | if isequal(index,1) |
---|
| 263 | set(handles.attributes_txt,'String','global attributes') |
---|
| 264 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 265 | for iline=1:length(Field.ListGlobalAttribute) |
---|
| 266 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
| 267 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
[648] | 268 | val=Field.(Field.ListGlobalAttribute{iline}); |
---|
[582] | 269 | if ischar(val);% attribute value is char string |
---|
| 270 | Tabcell{iline,2}=val; |
---|
| 271 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
| 272 | Tabcell{iline,2}=num2str(val); |
---|
| 273 | end |
---|
| 274 | end |
---|
| 275 | end |
---|
| 276 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 277 | end |
---|
| 278 | %% list Attribute names and values associated to the Variable # index-1 |
---|
| 279 | else |
---|
| 280 | list_var=get(handles.variables,'String'); |
---|
| 281 | var_select=list_var{index}; |
---|
| 282 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
| 283 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
| 284 | % nbline=0; |
---|
| 285 | VarAttr=Field.VarAttribute{index-1}; |
---|
| 286 | if isstruct(VarAttr) |
---|
| 287 | attr_list=fieldnames(VarAttr); |
---|
| 288 | for iline=1:length(attr_list) |
---|
| 289 | Tabcell{iline,1}=attr_list{iline}; |
---|
| 290 | eval(['val=VarAttr.' attr_list{iline} ';']) |
---|
| 291 | if ischar(val); |
---|
| 292 | Tabcell{iline,2}=val; |
---|
| 293 | else |
---|
| 294 | Tabcell{iline,2}=num2str(val); |
---|
| 295 | end |
---|
| 296 | end |
---|
| 297 | end |
---|
| 298 | end |
---|
| 299 | |
---|
| 300 | end |
---|
| 301 | if ~isempty(Tabcell) |
---|
| 302 | Tabchar=cell2tab(Tabcell,'='); |
---|
[648] | 303 | % Tabchar=[{''};Tabchar]; |
---|
[582] | 304 | end |
---|
| 305 | set(handles.attributes,'Value',1);% select the first item |
---|
| 306 | set(handles.attributes,'String',Tabchar); |
---|
| 307 | |
---|
| 308 | %% update dimensions; |
---|
| 309 | if isfield(Field,'ListDimName') |
---|
| 310 | Tabdim={};%default |
---|
| 311 | if isequal(index,1)%list all dimensions |
---|
| 312 | dim_indices=1:length(Field.ListDimName); |
---|
| 313 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
| 314 | else |
---|
| 315 | DimCell=Field.VarDimName{index-1}; |
---|
| 316 | if ischar(DimCell) |
---|
| 317 | DimCell={DimCell}; |
---|
| 318 | end |
---|
| 319 | dim_indices=[]; |
---|
| 320 | for idim=1:length(DimCell) |
---|
| 321 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
| 322 | dim_index=find(dim_index,1); |
---|
| 323 | dim_indices=[dim_indices dim_index]; |
---|
| 324 | end |
---|
| 325 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
| 326 | end |
---|
| 327 | for iline=1:length(dim_indices) |
---|
| 328 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
| 329 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
| 330 | end |
---|
| 331 | Tabchar=cell2tab(Tabdim,' = '); |
---|
| 332 | Tabchar=[{''} ;Tabchar]; |
---|
| 333 | set(handles.dimensions,'Value',1) |
---|
| 334 | set(handles.dimensions,'String',Tabchar) |
---|
| 335 | end |
---|
| 336 | |
---|
| 337 | %------------------------------------------------------------------------ |
---|
[648] | 338 | % --- Executes on selection change in FieldOption. |
---|
[582] | 339 | %------------------------------------------------------------------------ |
---|
[648] | 340 | function FieldOption_Callback(hObject, eventdata, handles) |
---|
| 341 | |
---|
| 342 | FieldList=get(handles.FieldOption,'String'); |
---|
| 343 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
---|
| 344 | switch FieldOption |
---|
| 345 | case '1D plot' |
---|
[654] | 346 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 347 | set(handles.PanelOrdinate,'Visible','on') |
---|
| 348 | pos=get(handles.PanelOrdinate,'Position'); |
---|
| 349 | pos(1)=2; |
---|
| 350 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 351 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 352 | set(handles.PanelOrdinate,'Position',pos) |
---|
| 353 | set(handles.PanelScalar,'Visible','off') |
---|
| 354 | set(handles.PanelVectors,'Visible','off') |
---|
| 355 | set(handles.Coord_y,'Visible','off') |
---|
| 356 | set(handles.Y_title,'Visible','off') |
---|
| 357 | set(handles.Coord_z,'Visible','off') |
---|
| 358 | set(handles.Z_title,'Visible','off') |
---|
| 359 | ordinate_Callback(hObject, eventdata, handles) |
---|
| 360 | case 'scalar' |
---|
[654] | 361 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 362 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 363 | set(handles.PanelScalar,'Visible','on') |
---|
| 364 | set(handles.PanelVectors,'Visible','off') |
---|
| 365 | pos=get(handles.PanelScalar,'Position'); |
---|
| 366 | pos(1)=2; |
---|
| 367 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 368 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 369 | set(handles.PanelScalar,'Position',pos) |
---|
| 370 | set(handles.Coord_y,'Visible','on') |
---|
| 371 | set(handles.Y_title,'Visible','on') |
---|
| 372 | scalar_Callback(hObject, eventdata, handles) |
---|
| 373 | case 'vectors' |
---|
[654] | 374 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 375 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 376 | set(handles.PanelScalar,'Visible','off') |
---|
| 377 | set(handles.PanelVectors,'Visible','on') |
---|
| 378 | pos=get(handles.PanelVectors,'Position'); |
---|
| 379 | pos(1)=2; |
---|
| 380 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 381 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 382 | set(handles.PanelVectors,'Position',pos) |
---|
| 383 | set(handles.Coord_y,'Visible','on') |
---|
| 384 | set(handles.Y_title,'Visible','on') |
---|
| 385 | vector_Callback(handles) |
---|
[654] | 386 | case 'civdata...' |
---|
| 387 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 388 | set(handles.PanelScalar,'Visible','off') |
---|
| 389 | set(handles.PanelVectors,'Visible','off') |
---|
| 390 | set(handles.Coordinates,'Visible','off') |
---|
[582] | 391 | end |
---|
| 392 | |
---|
| 393 | %------------------------------------------------------------------------ |
---|
[204] | 394 | function ordinate_Callback(hObject, eventdata, handles) |
---|
| 395 | %------------------------------------------------------------------------ |
---|
[582] | 396 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 397 | y_index=get(handles.ordinate,'Value'); |
---|
| 398 | y_menu=get(handles.ordinate,'String'); |
---|
| 399 | YName=y_menu{y_index}; |
---|
| 400 | |
---|
| 401 | %% set list of possible coordinates |
---|
| 402 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 403 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 404 | ListCoord={''}; |
---|
| 405 | dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable |
---|
| 406 | |
---|
| 407 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 408 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 409 | if isequal(dimnames,dim_var) |
---|
| 410 | test_component(ilist)=1; |
---|
| 411 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 412 | test_coord(ilist)=1; |
---|
[582] | 413 | end |
---|
| 414 | end |
---|
[648] | 415 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
| 416 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 417 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[204] | 418 | |
---|
[648] | 419 | %% set default coord selection |
---|
| 420 | if numel(find(test_coord))>3 |
---|
| 421 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[582] | 422 | end |
---|
[648] | 423 | if numel(var_component)<2 |
---|
| 424 | if numel(test_coord)<2 |
---|
| 425 | ListCoord={''}; |
---|
| 426 | else |
---|
| 427 | set(handles.Coord_x,'Value',2) |
---|
| 428 | set(handles.Coord_y,'Value',1) |
---|
| 429 | end |
---|
[582] | 430 | else |
---|
[648] | 431 | coord_val=1; |
---|
| 432 | for ilist=1:numel(var_component) |
---|
| 433 | ivar=var_component(ilist); |
---|
| 434 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 435 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 436 | if strcmp(Role,'coord_x') |
---|
| 437 | coord_val=ilist; |
---|
| 438 | end |
---|
| 439 | end |
---|
| 440 | end |
---|
| 441 | set(handles.Coord_x,'Value',coord_val) |
---|
[582] | 442 | end |
---|
[648] | 443 | set(handles.Coord_x,'String',ListCoord) |
---|
[582] | 444 | |
---|
| 445 | |
---|
[648] | 446 | %% set list of time coordinates |
---|
| 447 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 448 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 449 | switch TimeOption |
---|
| 450 | case 'variable' |
---|
| 451 | if numel(find(test_coord))<3 |
---|
| 452 | ListTime={''}; |
---|
| 453 | else |
---|
| 454 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 455 | end |
---|
| 456 | set(handles.TimeName,'Value',1) |
---|
| 457 | set(handles.TimeName,'String',ListTime) |
---|
| 458 | case 'dim index' |
---|
| 459 | if numel(find(test_coord))<3 |
---|
| 460 | ListTime={''}; |
---|
| 461 | else |
---|
| 462 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 463 | end |
---|
| 464 | set(handles.TimeName,'Value',1) |
---|
| 465 | set(handles.TimeName,'String',ListTime) |
---|
| 466 | end |
---|
| 467 | update_field(handles,YName) |
---|
| 468 | |
---|
[582] | 469 | %------------------------------------------------------------------------ |
---|
[204] | 470 | % --- Executes on selection change in scalar menu. |
---|
[648] | 471 | %------------------------------------------------------------------------ |
---|
[204] | 472 | function scalar_Callback(hObject, eventdata, handles) |
---|
[648] | 473 | |
---|
[586] | 474 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 475 | scalar_index=get(handles.scalar,'Value'); |
---|
| 476 | scalar_menu=get(handles.scalar,'String'); |
---|
| 477 | ScalarName=scalar_menu{scalar_index}; |
---|
[204] | 478 | |
---|
[648] | 479 | %% set list of possible coordinates |
---|
| 480 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 481 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 482 | ListCoord={''}; |
---|
| 483 | dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable |
---|
[646] | 484 | |
---|
[648] | 485 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 486 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 487 | if isequal(dimnames,dim_var) |
---|
| 488 | test_component(ilist)=1; |
---|
| 489 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 490 | test_coord(ilist)=1; |
---|
| 491 | end |
---|
[227] | 492 | end |
---|
[648] | 493 | var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes |
---|
| 494 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 495 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[227] | 496 | |
---|
[648] | 497 | %% set default coord selection |
---|
| 498 | if numel(find(test_coord))>3 |
---|
| 499 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
| 500 | end |
---|
| 501 | if numel(var_component)<2 |
---|
| 502 | if numel(test_coord)<2 |
---|
| 503 | ListCoord={''}; |
---|
| 504 | else |
---|
| 505 | set(handles.Coord_x,'Value',2) |
---|
| 506 | set(handles.Coord_y,'Value',1) |
---|
[227] | 507 | end |
---|
[648] | 508 | else |
---|
| 509 | coord_val=[1 2]; |
---|
| 510 | for ilist=1:numel(var_component) |
---|
| 511 | ivar=var_component(ilist); |
---|
| 512 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 513 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 514 | if strcmp(Role,'coord_x') |
---|
| 515 | coord_val(1)=ilist; |
---|
| 516 | elseif strcmp(Role,'coord_y') |
---|
| 517 | coord_val(2)=ilist; |
---|
| 518 | end |
---|
[227] | 519 | end |
---|
| 520 | end |
---|
[648] | 521 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 522 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[227] | 523 | end |
---|
| 524 | |
---|
[648] | 525 | set(handles.Coord_y,'String',ListCoord) |
---|
| 526 | set(handles.Coord_x,'String',ListCoord) |
---|
[227] | 527 | |
---|
| 528 | |
---|
[648] | 529 | %% set list of time coordinates |
---|
| 530 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 531 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 532 | switch TimeOption |
---|
| 533 | case 'variable' |
---|
| 534 | if numel(find(test_coord))<3 |
---|
| 535 | ListTime={''}; |
---|
| 536 | else |
---|
| 537 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 538 | end |
---|
| 539 | set(handles.TimeName,'Value',1) |
---|
| 540 | set(handles.TimeName,'String',ListTime) |
---|
| 541 | case 'dim index' |
---|
| 542 | if numel(find(test_coord))<3 |
---|
| 543 | ListTime={''}; |
---|
| 544 | else |
---|
| 545 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 546 | end |
---|
| 547 | set(handles.TimeName,'Value',1) |
---|
| 548 | set(handles.TimeName,'String',ListTime) |
---|
| 549 | end |
---|
| 550 | update_field(handles,ScalarName) |
---|
[582] | 551 | |
---|
[648] | 552 | % --- Executes on button press in check_rgb. |
---|
| 553 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[582] | 554 | |
---|
| 555 | |
---|
| 556 | %------------------------------------------------------------------------ |
---|
[204] | 557 | % --- Executes on selection change in vector_x. |
---|
| 558 | function vector_x_Callback(hObject, eventdata, handles) |
---|
| 559 | %------------------------------------------------------------------------ |
---|
[648] | 560 | vector_x_menu=get(handles.vector_x,'String'); |
---|
| 561 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 562 | vector_x=vector_x_menu{vector_x_index}; |
---|
| 563 | vector_Callback(handles) |
---|
| 564 | update_field(handles,vector_x) |
---|
[227] | 565 | |
---|
[204] | 566 | %------------------------------------------------------------------------ |
---|
[648] | 567 | % --- Executes on selection change in vector_x. |
---|
[204] | 568 | function vector_y_Callback(hObject, eventdata, handles) |
---|
| 569 | %------------------------------------------------------------------------ |
---|
[648] | 570 | vector_y_menu=get(handles.vector_x,'String'); |
---|
| 571 | vector_y_index=get(handles.vector_x,'Value'); |
---|
| 572 | vector_y=vector_y_menu{vector_y_index}; |
---|
| 573 | vector_Callback(handles) |
---|
| 574 | update_field(handles,vector_y) |
---|
[204] | 575 | |
---|
| 576 | %------------------------------------------------------------------------ |
---|
| 577 | % --- Executes on selection change in vector_z. |
---|
| 578 | function vector_z_Callback(hObject, eventdata, handles) |
---|
| 579 | %------------------------------------------------------------------------ |
---|
[648] | 580 | vector_z_menu=get(handles.vector_z,'String'); |
---|
| 581 | vector_z_index=get(handles.vector_z,'Value'); |
---|
| 582 | vector_z=vector_z_menu{vector_z_index}; |
---|
| 583 | vector_Callback(handles) |
---|
| 584 | update_field(handles,vector_z) |
---|
[204] | 585 | |
---|
| 586 | %------------------------------------------------------------------------ |
---|
| 587 | % --- Executes on selection change in vec_color. |
---|
| 588 | function vec_color_Callback(hObject, eventdata, handles) |
---|
[227] | 589 | %------------------------------------------------------------------------ |
---|
[204] | 590 | index=get(handles.vec_color,'Value'); |
---|
| 591 | string=get(handles.vec_color,'String'); |
---|
| 592 | VarName=string{index}; |
---|
[648] | 593 | vector_Callback(handles) |
---|
| 594 | update_field(handles,VarName) |
---|
[204] | 595 | |
---|
[227] | 596 | %------------------------------------------------------------------------ |
---|
[648] | 597 | % --- Executes on selection change in vector_x or vector_y |
---|
| 598 | function vector_Callback( handles) |
---|
[227] | 599 | %------------------------------------------------------------------------ |
---|
[648] | 600 | Field=get(handles.get_field,'UserData'); |
---|
| 601 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 602 | vector_y_index=get(handles.vector_y,'Value'); |
---|
| 603 | vec_color_index=get(handles.vec_color,'Value'); |
---|
[204] | 604 | |
---|
[648] | 605 | %% set list of possible coordinates |
---|
| 606 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 607 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 608 | check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn |
---|
| 609 | ListCoord={''}; |
---|
| 610 | dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable |
---|
| 611 | if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index}) |
---|
| 612 | check_consistent=0; |
---|
| 613 | elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index}) |
---|
| 614 | check_consistent=0; |
---|
[204] | 615 | end |
---|
[648] | 616 | if check_consistent |
---|
| 617 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 618 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 619 | if isequal(dimnames,dim_var) |
---|
| 620 | test_component(ilist)=1; |
---|
| 621 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 622 | test_coord(ilist)=1; |
---|
[204] | 623 | end |
---|
| 624 | end |
---|
[648] | 625 | var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes |
---|
| 626 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 627 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
| 628 | |
---|
| 629 | %% set default coord selection |
---|
| 630 | if numel(find(test_coord))>3 |
---|
| 631 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[204] | 632 | end |
---|
[648] | 633 | if numel(var_component)<2 |
---|
| 634 | if numel(test_coord)<2 |
---|
| 635 | ListCoord={''}; |
---|
| 636 | else |
---|
| 637 | set(handles.Coord_x,'Value',2) |
---|
| 638 | set(handles.Coord_y,'Value',1) |
---|
[204] | 639 | end |
---|
| 640 | else |
---|
[648] | 641 | coord_val=[1 2]; |
---|
| 642 | for ilist=1:numel(var_component) |
---|
| 643 | ivar=var_component(ilist); |
---|
| 644 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 645 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 646 | if strcmp(Role,'coord_x') |
---|
| 647 | coord_val(1)=ilist; |
---|
| 648 | elseif strcmp(Role,'coord_y') |
---|
| 649 | coord_val(2)=ilist; |
---|
| 650 | end |
---|
[526] | 651 | end |
---|
| 652 | end |
---|
[648] | 653 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 654 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[526] | 655 | end |
---|
[204] | 656 | end |
---|
[648] | 657 | set(handles.Coord_y,'String',ListCoord) |
---|
| 658 | set(handles.Coord_x,'String',ListCoord) |
---|
[204] | 659 | |
---|
| 660 | |
---|
[648] | 661 | %% set list of time coordinates |
---|
| 662 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 663 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 664 | switch TimeOption |
---|
| 665 | case 'variable' |
---|
| 666 | if numel(find(test_coord))<3 |
---|
| 667 | ListTime={''}; |
---|
| 668 | else |
---|
| 669 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
[204] | 670 | end |
---|
[648] | 671 | set(handles.TimeName,'Value',1) |
---|
| 672 | set(handles.TimeName,'String',ListTime) |
---|
| 673 | case 'dim index' |
---|
| 674 | if numel(find(test_coord))<3 |
---|
| 675 | ListTime={''}; |
---|
| 676 | else |
---|
| 677 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
[204] | 678 | end |
---|
[648] | 679 | set(handles.TimeName,'Value',1) |
---|
| 680 | set(handles.TimeName,'String',ListTime) |
---|
| 681 | end |
---|
[204] | 682 | |
---|
[227] | 683 | %------------------------------------------------------------------------ |
---|
[648] | 684 | % --- Executes on selection change in SwitchVarIndexX. |
---|
[227] | 685 | %------------------------------------------------------------------------ |
---|
[648] | 686 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
[227] | 687 | |
---|
| 688 | %------------------------------------------------------------------------ |
---|
[648] | 689 | % --- Executes on selection change in Coord_x. |
---|
| 690 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[227] | 691 | %------------------------------------------------------------------------ |
---|
[648] | 692 | index=get(handles.Coord_x,'Value'); |
---|
| 693 | string=get(handles.Coord_x,'String'); |
---|
| 694 | VarName=string{index}; |
---|
| 695 | update_field(handles,VarName) |
---|
[227] | 696 | |
---|
| 697 | %------------------------------------------------------------------------ |
---|
[648] | 698 | % --- Executes on selection change in Coord_y. |
---|
| 699 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
[227] | 700 | %------------------------------------------------------------------------ |
---|
[648] | 701 | index=get(handles.Coord_y,'Value'); |
---|
| 702 | string=get(handles.Coord_y,'String'); |
---|
| 703 | VarName=string{index}; |
---|
| 704 | update_field(handles,VarName) |
---|
[227] | 705 | |
---|
[646] | 706 | %------------------------------------------------------------------------ |
---|
[648] | 707 | % --- Executes on selection change in Coord_z. |
---|
| 708 | function Coord_z_Callback(hObject, eventdata, handles) |
---|
[646] | 709 | %------------------------------------------------------------------------ |
---|
[648] | 710 | index=get(handles.Coord_z,'Value'); |
---|
| 711 | string=get(handles.Coord_z,'String'); |
---|
| 712 | VarName=string{index}; |
---|
| 713 | update_field(handles,VarName) |
---|
[581] | 714 | |
---|
[646] | 715 | %------------------------------------------------------------------------ |
---|
[581] | 716 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
[646] | 717 | %------------------------------------------------------------------------ |
---|
[581] | 718 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
[648] | 719 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 720 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 721 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[648] | 722 | |
---|
[581] | 723 | switch option |
---|
| 724 | case 'file index' |
---|
[648] | 725 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
---|
[581] | 726 | case 'attribute' |
---|
[648] | 727 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
---|
[581] | 728 | time_index=[]; |
---|
[648] | 729 | PreviousList=get(handles.TimeName, 'String'); |
---|
| 730 | index=[]; |
---|
[582] | 731 | if ~isempty(PreviousList) |
---|
[648] | 732 | PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; |
---|
| 733 | index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes)); |
---|
[581] | 734 | end |
---|
[582] | 735 | if isempty(index) |
---|
[648] | 736 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' |
---|
[582] | 737 | end |
---|
[581] | 738 | if ~isempty(time_index) |
---|
[648] | 739 | set(handles.TimeName,'Value',time_index(1)) |
---|
[581] | 740 | else |
---|
[648] | 741 | set(handles.TimeName,'Value',1) |
---|
[581] | 742 | end |
---|
[648] | 743 | set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) |
---|
| 744 | case 'variable'% TimeName menu represents the available variables |
---|
| 745 | set(handles.TimeName, 'Visible','on') |
---|
| 746 | TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time) |
---|
| 747 | List=get(handles.TimeName,'String'); |
---|
| 748 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 749 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 750 | if isempty(ind) |
---|
[648] | 751 | set(handles.TimeName, 'Value',1); |
---|
[581] | 752 | else |
---|
[648] | 753 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 754 | end |
---|
[648] | 755 | set(handles.TimeName, 'String',TimeVarName) |
---|
| 756 | case 'dim index'% TimeName menu represents the available dimensions |
---|
| 757 | set(handles.TimeName, 'Visible','on') |
---|
| 758 | TimeVarName=Field.Display.SingleDimName; |
---|
| 759 | List=get(handles.TimeName,'String'); |
---|
| 760 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 761 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 762 | if isempty(ind) |
---|
[648] | 763 | set(handles.TimeName, 'Value',1); |
---|
[581] | 764 | else |
---|
[648] | 765 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 766 | end |
---|
[648] | 767 | set(handles.TimeName, 'String',TimeVarName) |
---|
[581] | 768 | end |
---|
| 769 | |
---|
[648] | 770 | %----------------------------------------------------------------------- |
---|
| 771 | function update_field(handles,VarName) |
---|
| 772 | %----------------------------------------------------------------------- |
---|
| 773 | Field=get(handles.get_field,'UserData'); |
---|
| 774 | index=name2index(VarName,Field.ListVarName); |
---|
| 775 | if ~isempty(index) |
---|
| 776 | set(handles.variables,'Value',index+1) |
---|
| 777 | variables_Callback(handles.variables, [], handles) |
---|
[644] | 778 | end |
---|
[648] | 779 | |
---|
| 780 | %------------------------------------------------- |
---|
| 781 | % give index numbers of the strings str in the list ListvarName |
---|
| 782 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
| 783 | VarIndex_y=[]; |
---|
| 784 | if ischar(cell_str) |
---|
| 785 | for ivar=1:length(ListVarName) |
---|
| 786 | varlist=ListVarName{ivar}; |
---|
| 787 | if isequal(varlist,cell_str) |
---|
| 788 | VarIndex_y= ivar; |
---|
| 789 | break |
---|
| 790 | end |
---|
| 791 | end |
---|
| 792 | elseif iscell(cell_str) |
---|
| 793 | for isel=1:length(cell_str) |
---|
| 794 | varsel=cell_str{isel}; |
---|
| 795 | for ivar=1:length(ListVarName) |
---|
| 796 | varlist=ListVarName{ivar}; |
---|
| 797 | if isequal(varlist,varsel) |
---|
| 798 | VarIndex_y=[VarIndex_y ivar]; |
---|
| 799 | end |
---|
| 800 | end |
---|
| 801 | end |
---|
| 802 | end |
---|