| 1 | %'get_field': display variables and attributes from a Netcdf file, and OK selected fields |
|---|
| 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 | |
|---|
| 24 | % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54 |
|---|
| 25 | |
|---|
| 26 | % Begin initialization code - DO NOT EDIT |
|---|
| 27 | gui_Singleton = 1; |
|---|
| 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. |
|---|
| 47 | %------------------------------------------------------------------------ |
|---|
| 48 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
|---|
| 49 | |
|---|
| 50 | %% GUI settings |
|---|
| 51 | handles.output = 'Cancel'; |
|---|
| 52 | guidata(hObject, handles); |
|---|
| 53 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
|---|
| 54 | |
|---|
| 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 |
|---|
| 61 | end |
|---|
| 62 | if ~isfield(Field,'ListVarName') |
|---|
| 63 | return |
|---|
| 64 | end |
|---|
| 65 | if ~exist('ParamIn','var') |
|---|
| 66 | ParamIn=[]; |
|---|
| 67 | end |
|---|
| 68 | |
|---|
| 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 |
|---|
| 74 | if ischar(Field.VarDimName{ilist}) |
|---|
| 75 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
|---|
| 76 | end |
|---|
| 77 | NbDim=numel(Field.VarDimName{ilist}); |
|---|
| 78 | check_singleton=false(1,NbDim); |
|---|
| 79 | for idim=1:NbDim |
|---|
| 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 |
|---|
| 82 | end |
|---|
| 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 |
|---|
| 86 | end |
|---|
| 87 | %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons |
|---|
| 88 | end |
|---|
| 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)); |
|---|
| 91 | end |
|---|
| 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); |
|---|
| 97 | |
|---|
| 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 | |
|---|
| 106 | %% set time mode |
|---|
| 107 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
|---|
| 108 | % look at global attributes with numerical values |
|---|
| 109 | check_numvalue=false; |
|---|
| 110 | check_time=false; |
|---|
| 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 |
|---|
| 116 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
|---|
| 117 | if ~isempty(Field.Display.ListGlobalAttribute) |
|---|
| 118 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
|---|
| 119 | end |
|---|
| 120 | nboption=numel(ListSwitchVarIndexTime); |
|---|
| 121 | if Field.MaxDim>=2 |
|---|
| 122 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index |
|---|
| 123 | end |
|---|
| 124 | if ~isempty(find(check_time, 1)) |
|---|
| 125 | set(handles.SwitchVarIndexTime,'Value',2); |
|---|
| 126 | else |
|---|
| 127 | set(handles.SwitchVarIndexTime,'Value',1); |
|---|
| 128 | end |
|---|
| 129 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
|---|
| 130 | set(handles.get_field,'UserData',Field);% record the finput field structure |
|---|
| 131 | SwitchVarIndexTime_Callback([], [], handles) |
|---|
| 132 | |
|---|
| 133 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
|---|
| 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 |
|---|
| 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 |
|---|
| 147 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
|---|
| 148 | if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
|---|
| 149 | set(handles.FieldOption,'Value',3)% set vector selection option |
|---|
| 150 | set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) |
|---|
| 151 | set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) |
|---|
| 152 | set(handles.FieldOption,'Value',3) |
|---|
| 153 | else |
|---|
| 154 | set(handles.FieldOption,'Value',2) |
|---|
| 155 | end |
|---|
| 156 | |
|---|
| 157 | else % case of 1D fields |
|---|
| 158 | set(handles.FieldOption,'Value',1) |
|---|
| 159 | end |
|---|
| 160 | |
|---|
| 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 |
|---|
| 173 | |
|---|
| 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 | |
|---|
| 181 | %% Make choices in menus from input |
|---|
| 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') |
|---|
| 215 | end |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | %------------------------------------------------------------------------ |
|---|
| 220 | |
|---|
| 221 | %------------------------------------------------------------------------ |
|---|
| 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 | |
|---|
| 228 | %------------------------------------------------------------------------ |
|---|
| 229 | % --- Executes when user attempts to close get_field. |
|---|
| 230 | %------------------------------------------------------------------------ |
|---|
| 231 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
|---|
| 232 | |
|---|
| 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 | |
|---|
| 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}) |
|---|
| 268 | val=Field.(Field.ListGlobalAttribute{iline}); |
|---|
| 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,'='); |
|---|
| 303 | % Tabchar=[{''};Tabchar]; |
|---|
| 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 | %------------------------------------------------------------------------ |
|---|
| 338 | % --- Executes on selection change in FieldOption. |
|---|
| 339 | %------------------------------------------------------------------------ |
|---|
| 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' |
|---|
| 346 | set(handles.Coordinates,'Visible','on') |
|---|
| 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' |
|---|
| 361 | set(handles.Coordinates,'Visible','on') |
|---|
| 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' |
|---|
| 374 | set(handles.Coordinates,'Visible','on') |
|---|
| 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) |
|---|
| 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') |
|---|
| 391 | end |
|---|
| 392 | |
|---|
| 393 | %------------------------------------------------------------------------ |
|---|
| 394 | function ordinate_Callback(hObject, eventdata, handles) |
|---|
| 395 | %------------------------------------------------------------------------ |
|---|
| 396 | Field=get(handles.get_field,'UserData'); |
|---|
| 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; |
|---|
| 413 | end |
|---|
| 414 | end |
|---|
| 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]); |
|---|
| 418 | |
|---|
| 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 |
|---|
| 422 | end |
|---|
| 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 |
|---|
| 430 | else |
|---|
| 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) |
|---|
| 442 | end |
|---|
| 443 | set(handles.Coord_x,'String',ListCoord) |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 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 | |
|---|
| 469 | %------------------------------------------------------------------------ |
|---|
| 470 | % --- Executes on selection change in scalar menu. |
|---|
| 471 | %------------------------------------------------------------------------ |
|---|
| 472 | function scalar_Callback(hObject, eventdata, handles) |
|---|
| 473 | |
|---|
| 474 | Field=get(handles.get_field,'UserData'); |
|---|
| 475 | scalar_index=get(handles.scalar,'Value'); |
|---|
| 476 | scalar_menu=get(handles.scalar,'String'); |
|---|
| 477 | ScalarName=scalar_menu{scalar_index}; |
|---|
| 478 | |
|---|
| 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 |
|---|
| 484 | |
|---|
| 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 |
|---|
| 492 | end |
|---|
| 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]); |
|---|
| 496 | |
|---|
| 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) |
|---|
| 507 | end |
|---|
| 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 |
|---|
| 519 | end |
|---|
| 520 | end |
|---|
| 521 | set(handles.Coord_x,'Value',coord_val(1)) |
|---|
| 522 | set(handles.Coord_y,'Value',coord_val(2)) |
|---|
| 523 | end |
|---|
| 524 | |
|---|
| 525 | set(handles.Coord_y,'String',ListCoord) |
|---|
| 526 | set(handles.Coord_x,'String',ListCoord) |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 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) |
|---|
| 551 | |
|---|
| 552 | % --- Executes on button press in check_rgb. |
|---|
| 553 | function check_rgb_Callback(hObject, eventdata, handles) |
|---|
| 554 | |
|---|
| 555 | |
|---|
| 556 | %------------------------------------------------------------------------ |
|---|
| 557 | % --- Executes on selection change in vector_x. |
|---|
| 558 | function vector_x_Callback(hObject, eventdata, handles) |
|---|
| 559 | %------------------------------------------------------------------------ |
|---|
| 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) |
|---|
| 565 | |
|---|
| 566 | %------------------------------------------------------------------------ |
|---|
| 567 | % --- Executes on selection change in vector_x. |
|---|
| 568 | function vector_y_Callback(hObject, eventdata, handles) |
|---|
| 569 | %------------------------------------------------------------------------ |
|---|
| 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) |
|---|
| 575 | |
|---|
| 576 | %------------------------------------------------------------------------ |
|---|
| 577 | % --- Executes on selection change in vector_z. |
|---|
| 578 | function vector_z_Callback(hObject, eventdata, handles) |
|---|
| 579 | %------------------------------------------------------------------------ |
|---|
| 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) |
|---|
| 585 | |
|---|
| 586 | %------------------------------------------------------------------------ |
|---|
| 587 | % --- Executes on selection change in vec_color. |
|---|
| 588 | function vec_color_Callback(hObject, eventdata, handles) |
|---|
| 589 | %------------------------------------------------------------------------ |
|---|
| 590 | index=get(handles.vec_color,'Value'); |
|---|
| 591 | string=get(handles.vec_color,'String'); |
|---|
| 592 | VarName=string{index}; |
|---|
| 593 | vector_Callback(handles) |
|---|
| 594 | update_field(handles,VarName) |
|---|
| 595 | |
|---|
| 596 | %------------------------------------------------------------------------ |
|---|
| 597 | % --- Executes on selection change in vector_x or vector_y |
|---|
| 598 | function vector_Callback( handles) |
|---|
| 599 | %------------------------------------------------------------------------ |
|---|
| 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'); |
|---|
| 604 | |
|---|
| 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; |
|---|
| 615 | end |
|---|
| 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; |
|---|
| 623 | end |
|---|
| 624 | end |
|---|
| 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 |
|---|
| 632 | end |
|---|
| 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) |
|---|
| 639 | end |
|---|
| 640 | else |
|---|
| 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 |
|---|
| 651 | end |
|---|
| 652 | end |
|---|
| 653 | set(handles.Coord_x,'Value',coord_val(1)) |
|---|
| 654 | set(handles.Coord_y,'Value',coord_val(2)) |
|---|
| 655 | end |
|---|
| 656 | end |
|---|
| 657 | set(handles.Coord_y,'String',ListCoord) |
|---|
| 658 | set(handles.Coord_x,'String',ListCoord) |
|---|
| 659 | |
|---|
| 660 | |
|---|
| 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)); |
|---|
| 670 | end |
|---|
| 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)}; |
|---|
| 678 | end |
|---|
| 679 | set(handles.TimeName,'Value',1) |
|---|
| 680 | set(handles.TimeName,'String',ListTime) |
|---|
| 681 | end |
|---|
| 682 | |
|---|
| 683 | %------------------------------------------------------------------------ |
|---|
| 684 | % --- Executes on selection change in SwitchVarIndexX. |
|---|
| 685 | %------------------------------------------------------------------------ |
|---|
| 686 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
|---|
| 687 | |
|---|
| 688 | %------------------------------------------------------------------------ |
|---|
| 689 | % --- Executes on selection change in Coord_x. |
|---|
| 690 | function Coord_x_Callback(hObject, eventdata, handles) |
|---|
| 691 | %------------------------------------------------------------------------ |
|---|
| 692 | index=get(handles.Coord_x,'Value'); |
|---|
| 693 | string=get(handles.Coord_x,'String'); |
|---|
| 694 | VarName=string{index}; |
|---|
| 695 | update_field(handles,VarName) |
|---|
| 696 | |
|---|
| 697 | %------------------------------------------------------------------------ |
|---|
| 698 | % --- Executes on selection change in Coord_y. |
|---|
| 699 | function Coord_y_Callback(hObject, eventdata, handles) |
|---|
| 700 | %------------------------------------------------------------------------ |
|---|
| 701 | index=get(handles.Coord_y,'Value'); |
|---|
| 702 | string=get(handles.Coord_y,'String'); |
|---|
| 703 | VarName=string{index}; |
|---|
| 704 | update_field(handles,VarName) |
|---|
| 705 | |
|---|
| 706 | %------------------------------------------------------------------------ |
|---|
| 707 | % --- Executes on selection change in Coord_z. |
|---|
| 708 | function Coord_z_Callback(hObject, eventdata, handles) |
|---|
| 709 | %------------------------------------------------------------------------ |
|---|
| 710 | index=get(handles.Coord_z,'Value'); |
|---|
| 711 | string=get(handles.Coord_z,'String'); |
|---|
| 712 | VarName=string{index}; |
|---|
| 713 | update_field(handles,VarName) |
|---|
| 714 | |
|---|
| 715 | %------------------------------------------------------------------------ |
|---|
| 716 | % --- Executes on selection change in SwitchVarIndexTime. |
|---|
| 717 | %------------------------------------------------------------------------ |
|---|
| 718 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
|---|
| 719 | Field=get(handles.get_field,'UserData'); |
|---|
| 720 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 721 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
|---|
| 722 | |
|---|
| 723 | switch option |
|---|
| 724 | case 'file index' |
|---|
| 725 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
|---|
| 726 | case 'attribute' |
|---|
| 727 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
|---|
| 728 | time_index=[]; |
|---|
| 729 | PreviousList=get(handles.TimeName, 'String'); |
|---|
| 730 | index=[]; |
|---|
| 731 | if ~isempty(PreviousList) |
|---|
| 732 | PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; |
|---|
| 733 | index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes)); |
|---|
| 734 | end |
|---|
| 735 | if isempty(index) |
|---|
| 736 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' |
|---|
| 737 | end |
|---|
| 738 | if ~isempty(time_index) |
|---|
| 739 | set(handles.TimeName,'Value',time_index(1)) |
|---|
| 740 | else |
|---|
| 741 | set(handles.TimeName,'Value',1) |
|---|
| 742 | end |
|---|
| 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')}; |
|---|
| 749 | ind=find(strcmp(option,TimeVarName)); |
|---|
| 750 | if isempty(ind) |
|---|
| 751 | set(handles.TimeName, 'Value',1); |
|---|
| 752 | else |
|---|
| 753 | set(handles.TimeName, 'Value',ind); |
|---|
| 754 | end |
|---|
| 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')}; |
|---|
| 761 | ind=find(strcmp(option,TimeVarName)); |
|---|
| 762 | if isempty(ind) |
|---|
| 763 | set(handles.TimeName, 'Value',1); |
|---|
| 764 | else |
|---|
| 765 | set(handles.TimeName, 'Value',ind); |
|---|
| 766 | end |
|---|
| 767 | set(handles.TimeName, 'String',TimeVarName) |
|---|
| 768 | end |
|---|
| 769 | |
|---|
| 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) |
|---|
| 778 | end |
|---|
| 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 |
|---|