| 1 | %'get_field': display variables and attributes from a Netcdf file, and OK selected fields |
|---|
| 2 | %------------------------------------------------------------------------ |
|---|
| 3 | % GetFieldData=get_field(FileName,ParamIn) |
|---|
| 4 | % associated with the GUI get_field.fig |
|---|
| 5 | % |
|---|
| 6 | % OUTPUT: |
|---|
| 7 | % GetFieldData: structure containing the information on the selected |
|---|
| 8 | % fields, obtained by applying the fct red_GUI to the GUI get_field |
|---|
| 9 | % .FieldOption='vectors': variables are used for vector plot |
|---|
| 10 | % 'scalar': variables are used for scalar plot, |
|---|
| 11 | % '1Dplot': variables are used for usual x-y plot, |
|---|
| 12 | % 'civdata...': go back to automatic reading of civ data |
|---|
| 13 | % .PanelVectors: sub-structure variables used as vector components |
|---|
| 14 | % .PanelScalar: |
|---|
| 15 | % INPUT: |
|---|
| 16 | % FileName: name (including path) of the netcdf file to open |
|---|
| 17 | % ParmIn: structure containing parameters for preselecting menus: |
|---|
| 18 | % .Title: set the title of the GUI get_field |
|---|
| 19 | % .SwitchVarIndexTime='file index','variable' or 'matrix index': select the default option for 'time' |
|---|
| 20 | % .TimeAttrName: preselect the name of a global attribute for time |
|---|
| 21 | % .SeriesInput=1 if get_field is called by the GUI series,=0 otherwise (plot options provided in the latter case) |
|---|
| 22 | % .Coord_x,.Coord_y,.Coord_z, names of the variables used as the three coordinates |
|---|
| 23 | % .scalar : set the default choise of the scale variable |
|---|
| 24 | % .vector_x, .vector_y : set the default choise for the variables used for the x and y vector components |
|---|
| 25 | |
|---|
| 26 | %======================================================================= |
|---|
| 27 | % Copyright 2008-2018, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
|---|
| 28 | % http://www.legi.grenoble-inp.fr |
|---|
| 29 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
|---|
| 30 | % |
|---|
| 31 | % This file is part of the toolbox UVMAT. |
|---|
| 32 | % |
|---|
| 33 | % UVMAT is free software; you can redistribute it and/or modify |
|---|
| 34 | % it under the terms of the GNU General Public License as published |
|---|
| 35 | % by the Free Software Foundation; either version 2 of the license, |
|---|
| 36 | % or (at your option) any later version. |
|---|
| 37 | % |
|---|
| 38 | % UVMAT is distributed in the hope that it will be useful, |
|---|
| 39 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 40 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 41 | % GNU General Public License (see LICENSE.txt) for more details. |
|---|
| 42 | %======================================================================= |
|---|
| 43 | |
|---|
| 44 | function varargout = get_field(varargin) |
|---|
| 45 | |
|---|
| 46 | % Last Modified by GUIDE v2.5 18-Feb-2015 23:42:12 |
|---|
| 47 | |
|---|
| 48 | % Begin initialization code - DO NOT EDIT |
|---|
| 49 | gui_Singleton = 1; |
|---|
| 50 | gui_State = struct('gui_Name', mfilename, ... |
|---|
| 51 | 'gui_Singleton', gui_Singleton, ... |
|---|
| 52 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
|---|
| 53 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
|---|
| 54 | 'gui_LayoutFcn', [] , ... |
|---|
| 55 | 'gui_Callback', []); |
|---|
| 56 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
|---|
| 57 | gui_State.gui_Callback = str2func(varargin{1}); |
|---|
| 58 | end |
|---|
| 59 | |
|---|
| 60 | if nargout |
|---|
| 61 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
|---|
| 62 | else |
|---|
| 63 | gui_mainfcn(gui_State, varargin{:}); |
|---|
| 64 | end |
|---|
| 65 | % End initialization code - DO NOT EDIT |
|---|
| 66 | |
|---|
| 67 | %------------------------------------------------------------------------ |
|---|
| 68 | % --- Executes just before get_field is made visible. |
|---|
| 69 | %------------------------------------------------------------------------ |
|---|
| 70 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
|---|
| 71 | |
|---|
| 72 | %% GUI settings |
|---|
| 73 | handles.output = 'Cancel'; |
|---|
| 74 | guidata(hObject, handles); |
|---|
| 75 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
|---|
| 76 | set(hObject,'CloseRequestFcn',{@closefcn,handles}) |
|---|
| 77 | |
|---|
| 78 | %% enter input data |
|---|
| 79 | if ischar(filename) % input file name |
|---|
| 80 | set(handles.inputfile,'String',filename)% fill the input file name |
|---|
| 81 | [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the field structure, without the variables |
|---|
| 82 | else |
|---|
| 83 | msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading |
|---|
| 84 | return |
|---|
| 85 | end |
|---|
| 86 | if ~isempty(errormsg) |
|---|
| 87 | msgbox_uvmat('ERROR',['get_field/nc2struct/' errormsg])% display error message for input file reading |
|---|
| 88 | return |
|---|
| 89 | end |
|---|
| 90 | if ~isfield(Field,'ListVarName') |
|---|
| 91 | msgbox_uvmat('ERROR',['no variable found in ' filename])% display error message for input file reading |
|---|
| 92 | return |
|---|
| 93 | end |
|---|
| 94 | if ~exist('ParamIn','var') |
|---|
| 95 | ParamIn.Coord_z=''; |
|---|
| 96 | end |
|---|
| 97 | |
|---|
| 98 | %% look at singletons and variables with a single dimension |
|---|
| 99 | Field.Display=Field; |
|---|
| 100 | Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value |
|---|
| 101 | NbVar=numel(Field.VarDimName);%nbre of variables in the input data |
|---|
| 102 | for ilist=1:NbVar |
|---|
| 103 | if ischar(Field.VarDimName{ilist}) |
|---|
| 104 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
|---|
| 105 | end |
|---|
| 106 | NbDim=numel(Field.VarDimName{ilist}); |
|---|
| 107 | check_singleton=false(1,NbDim);% check singleton, false by default |
|---|
| 108 | for idim=1:NbDim |
|---|
| 109 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions |
|---|
| 110 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton |
|---|
| 111 | end |
|---|
| 112 | Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)))||(~isequal(Field.VarType(ilist),4)&&~isequal(Field.VarType(ilist),5)&&~isequal(Field.VarType(ilist),6));% =1 if the variable reduces to a single value |
|---|
| 113 | if ~Field.Check0D(ilist) |
|---|
| 114 | Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions |
|---|
| 115 | end |
|---|
| 116 | end |
|---|
| 117 | if ~isfield(Field,'VarAttribute') |
|---|
| 118 | Field.VarAttribute={}; |
|---|
| 119 | end |
|---|
| 120 | if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded |
|---|
| 121 | Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); |
|---|
| 122 | end |
|---|
| 123 | % Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions |
|---|
| 124 | Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value |
|---|
| 125 | Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); |
|---|
| 126 | Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); |
|---|
| 127 | Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names |
|---|
| 128 | Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | %% analyse the input field cells |
|---|
| 132 | [CellInfo,NbDim,errormsg]=find_field_cells(Field.Display); |
|---|
| 133 | if ~isempty(errormsg) |
|---|
| 134 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
|---|
| 135 | return |
|---|
| 136 | end |
|---|
| 137 | if isempty(CellInfo) |
|---|
| 138 | Field.MaxDim=max(cellfun(@numel,Field.Display.VarDimName)); |
|---|
| 139 | check_cellinfo=false; |
|---|
| 140 | else |
|---|
| 141 | [Field.MaxDim,imax]=max(NbDim); |
|---|
| 142 | check_cellinfo=true; |
|---|
| 143 | end |
|---|
| 144 | |
|---|
| 145 | %% set time mode |
|---|
| 146 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
|---|
| 147 | % look at global attributes with numerical values |
|---|
| 148 | check_numvalue=false(1,numel(Field.ListGlobalAttribute)); |
|---|
| 149 | for ilist=1:numel(Field.ListGlobalAttribute) |
|---|
| 150 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
|---|
| 151 | check_numvalue(ilist)=isnumeric(Value); |
|---|
| 152 | end |
|---|
| 153 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
|---|
| 154 | if ~isempty(Field.Display.ListGlobalAttribute) |
|---|
| 155 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
|---|
| 156 | end |
|---|
| 157 | |
|---|
| 158 | Check_index=0; |
|---|
| 159 | if Field.MaxDim>=2 |
|---|
| 160 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index |
|---|
| 161 | else |
|---|
| 162 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 163 | NbComponent=numel(Field.Display.VarDimName{ilist}); |
|---|
| 164 | if NbComponent>=2% multicomponent matrices without coordinate variables (thus not considered in the fct find_field_cell) |
|---|
| 165 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'matrix index'}];% the time can be chosen as a dim index |
|---|
| 166 | Check_index=1; |
|---|
| 167 | break |
|---|
| 168 | end |
|---|
| 169 | end |
|---|
| 170 | end |
|---|
| 171 | |
|---|
| 172 | %% select the Time attribute from input |
|---|
| 173 | if isfield(ParamIn,'TimeAttrName') |
|---|
| 174 | time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); |
|---|
| 175 | else |
|---|
| 176 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time' |
|---|
| 177 | end |
|---|
| 178 | if isempty(time_index) |
|---|
| 179 | set(handles.SwitchVarIndexTime,'Value',1); |
|---|
| 180 | else |
|---|
| 181 | set(handles.SwitchVarIndexTime,'Value',2); |
|---|
| 182 | set(handles.TimeName,'UserData',time_index) |
|---|
| 183 | end |
|---|
| 184 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
|---|
| 185 | set(handles.SwitchVarIndexTime,'UserData',ListSwitchVarIndexTime); % keep string in memory for check3D |
|---|
| 186 | set(handles.get_field,'UserData',Field);% record the finput field structure |
|---|
| 187 | SwitchVarIndexTime_Callback([], [], handles) |
|---|
| 188 | |
|---|
| 189 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
|---|
| 190 | set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components |
|---|
| 191 | set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components |
|---|
| 192 | set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
|---|
| 193 | set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
|---|
| 194 | set(handles.scalar,'Value',1)% fill the menu of y vector components |
|---|
| 195 | set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar |
|---|
| 196 | set(handles.ordinate,'Value',1)% fill the menu of y vector components |
|---|
| 197 | set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots |
|---|
| 198 | checkseries=0; |
|---|
| 199 | if isfield(ParamIn,'SeriesInput') && ParamIn.SeriesInput% case of call by series |
|---|
| 200 | set(handles.FieldOption,'value',1) |
|---|
| 201 | if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
|---|
| 202 | set(handles.FieldOption,'String',{'scalar';'vectors';'civdata...'}) |
|---|
| 203 | else |
|---|
| 204 | set(handles.FieldOption,'String',{'scalar';'vectors'}) |
|---|
| 205 | end |
|---|
| 206 | checkseries=1; |
|---|
| 207 | set(handles.scalar,'Max',2) |
|---|
| 208 | elseif isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
|---|
| 209 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata |
|---|
| 210 | set(handles.scalar,'Max',1) |
|---|
| 211 | else |
|---|
| 212 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) |
|---|
| 213 | set(handles.scalar,'Max',1) |
|---|
| 214 | end |
|---|
| 215 | |
|---|
| 216 | %% set default field options |
|---|
| 217 | checknbdim=cellfun('size',Field.Display.VarDimName,2); |
|---|
| 218 | % if max(checknbdim)<=1 |
|---|
| 219 | % Field.MaxDim=1;% only 1D fields, considered as a time series by default |
|---|
| 220 | % end |
|---|
| 221 | if Field.MaxDim>=2 && ~checkseries% case of 2D (or 3D) fields |
|---|
| 222 | check_vec_input=0; |
|---|
| 223 | % case of vector initially selected from uvmat input |
|---|
| 224 | if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y') |
|---|
| 225 | ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1); |
|---|
| 226 | ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1); |
|---|
| 227 | if ~isempty(ichoice_x)&&~isempty(ichoice_y) |
|---|
| 228 | set(handles.vector_x,'UserData',ichoice_x) |
|---|
| 229 | set(handles.vector_y,'UserData',ichoice_y) |
|---|
| 230 | check_vec_input=1; |
|---|
| 231 | end |
|---|
| 232 | end |
|---|
| 233 | % otherwise select vectors marked as attributes in the input field |
|---|
| 234 | if check_cellinfo && ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
|---|
| 235 | set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1)) |
|---|
| 236 | set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1)) |
|---|
| 237 | check_vec_input=1; |
|---|
| 238 | end |
|---|
| 239 | if check_vec_input |
|---|
| 240 | set(handles.FieldOption,'Value',3)% set vector selection option |
|---|
| 241 | else |
|---|
| 242 | set(handles.FieldOption,'Value',2)% set scalar selection option |
|---|
| 243 | end |
|---|
| 244 | else % case of 1D fields |
|---|
| 245 | set(handles.FieldOption,'Value',1) |
|---|
| 246 | end |
|---|
| 247 | |
|---|
| 248 | %% fill the general list of dimensions, variables, attributes |
|---|
| 249 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
|---|
| 250 | Tabcell(:,1)=Field.ListDimName; |
|---|
| 251 | for iline=1:length(Field.ListDimName) |
|---|
| 252 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
|---|
| 253 | end |
|---|
| 254 | Tabchar=cell2tab(Tabcell,' = '); |
|---|
| 255 | set(handles.dimensions,'String',Tabchar) |
|---|
| 256 | end |
|---|
| 257 | |
|---|
| 258 | %% fill menus for coordinates and time |
|---|
| 259 | FieldOption_Callback(handles.variables,[], handles)% list the global attributes |
|---|
| 260 | |
|---|
| 261 | %% Make choices of coordinates from input |
|---|
| 262 | % check_menu=false(1,numel(Data.ListVarName)); |
|---|
| 263 | % ListCoordMenu=1:numel(Data.ListVarName); |
|---|
| 264 | % CoordIndex=CellInfo{icell}.CoordIndex(CellInfo{icell}.CoordIndex~=0); |
|---|
| 265 | % |
|---|
| 266 | % for ivar=find(check_coord_names) |
|---|
| 267 | % check_dim=strcmp(Data.VarDimName{ivar},DimCell_var); |
|---|
| 268 | % if ~isempty(find(check_dim)) |
|---|
| 269 | % check_menu(ivar)=true; |
|---|
| 270 | % end |
|---|
| 271 | % end |
|---|
| 272 | % CellInfo{icell}.CoordMenu=[CoordIndex find(check_menu)]; |
|---|
| 273 | % ListCoordMenu(CoordIndex)=[]; |
|---|
| 274 | % for ivar=ListCoordMenu |
|---|
| 275 | % DimCell=Data.VarDimName{ivar}; |
|---|
| 276 | % if isequal(DimCell,DimCell_var) |
|---|
| 277 | % check_menu(ivar)=true; |
|---|
| 278 | % end |
|---|
| 279 | % end |
|---|
| 280 | % CellInfo{icell}.CoordMenu=[CellInfo{icell}.CoordMenu find(check_menu)]; |
|---|
| 281 | % |
|---|
| 282 | % if isfield(CellInfo{imax},'CoordIndex') |
|---|
| 283 | % CoordIndex=CellInfo{imax}.CoordIndex; |
|---|
| 284 | % if numel(CoordIndex)==2 |
|---|
| 285 | % if isfield(ParamIn,'Coord_x')&& isfield(ParamIn,'Coord_y') |
|---|
| 286 | % YName=ParamIn.Coord_y; |
|---|
| 287 | % XName=ParamIn.Coord_x; |
|---|
| 288 | % else |
|---|
| 289 | % YName=Field.ListVarName{CoordIndex(1)}; |
|---|
| 290 | % XName=Field.ListVarName{CoordIndex(2)}; |
|---|
| 291 | % end |
|---|
| 292 | % ListCoord=get(handles.Coord_x,'String'); |
|---|
| 293 | % XIndex=find(strcmp(XName,ListCoord)); |
|---|
| 294 | % if ~isempty(XIndex) |
|---|
| 295 | % set(handles.Coord_x,'Value',XIndex) |
|---|
| 296 | % end |
|---|
| 297 | % YIndex=find(strcmp(YName,ListCoord)); |
|---|
| 298 | % if ~isempty(YIndex) |
|---|
| 299 | % set(handles.Coord_y,'Value',YIndex) |
|---|
| 300 | % end |
|---|
| 301 | % end |
|---|
| 302 | % end |
|---|
| 303 | |
|---|
| 304 | %% put the GUI on the lower right of the sceen |
|---|
| 305 | set(hObject,'Unit','pixels') |
|---|
| 306 | %pos_view_field=get(hObject,'Position'); |
|---|
| 307 | set(0,'Unit','pixels') |
|---|
| 308 | ScreenSize=get(0,'ScreenSize'); |
|---|
| 309 | pos_view_field(3:4)=[955 648]; |
|---|
| 310 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
|---|
| 311 | pos_view_field(2)=ScreenSize(2); |
|---|
| 312 | set(hObject,'Position',pos_view_field) |
|---|
| 313 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
|---|
| 314 | if isfield(ParamIn,'Title') |
|---|
| 315 | set(hObject,'Name',ParamIn.Title) |
|---|
| 316 | end |
|---|
| 317 | |
|---|
| 318 | %% set z coordinate menu if relevant |
|---|
| 319 | if Field.MaxDim>=3 && prod(Field.DimValue)<10^8 && ~isempty(ParamIn.Coord_z); % 3D field (with memory content smaller than 400 Mo) |
|---|
| 320 | set(handles.Check3D,'Value',1) |
|---|
| 321 | else |
|---|
| 322 | set(handles.Check3D,'Value',0) |
|---|
| 323 | end |
|---|
| 324 | Check3D_Callback(hObject, eventdata, handles) |
|---|
| 325 | set(handles.variables,'Value',1) |
|---|
| 326 | set(handles.variables,'String',[{'*'} Field.ListVarName]) |
|---|
| 327 | variables_Callback(handles.variables,[], handles)% list the global attributes |
|---|
| 328 | drawnow |
|---|
| 329 | uiwait(handles.get_field); |
|---|
| 330 | |
|---|
| 331 | % ----------------------------------------------------------------------- |
|---|
| 332 | % --- Activated by selection in the list of variables |
|---|
| 333 | % ---------------------------------------------------------------------- |
|---|
| 334 | function variables_Callback(hObject, VarName, handles) |
|---|
| 335 | |
|---|
| 336 | Tabchar={''};%default |
|---|
| 337 | Tabcell=[]; |
|---|
| 338 | hselect_field=get(handles.variables,'parent'); |
|---|
| 339 | Field=get(handles.get_field,'UserData'); |
|---|
| 340 | index=get(handles.variables,'Value');%index in the list 'variables' |
|---|
| 341 | |
|---|
| 342 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
|---|
| 343 | if isequal(index,1) |
|---|
| 344 | set(handles.attributes_txt,'String','global attributes') |
|---|
| 345 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
|---|
| 346 | for iline=1:length(Field.ListGlobalAttribute) |
|---|
| 347 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
|---|
| 348 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
|---|
| 349 | val=Field.(Field.ListGlobalAttribute{iline}); |
|---|
| 350 | if ischar(val);% attribute value is char string |
|---|
| 351 | Tabcell{iline,2}=val; |
|---|
| 352 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
|---|
| 353 | Tabcell{iline,2}=num2str(val); |
|---|
| 354 | end |
|---|
| 355 | end |
|---|
| 356 | end |
|---|
| 357 | Tabchar=cell2tab(Tabcell,'='); |
|---|
| 358 | end |
|---|
| 359 | %% list Attribute names and values associated to the Variable # index-1 |
|---|
| 360 | else |
|---|
| 361 | list_var=get(handles.variables,'String'); |
|---|
| 362 | if index>numel(list_var) |
|---|
| 363 | return |
|---|
| 364 | end |
|---|
| 365 | VarName=list_var{index}; |
|---|
| 366 | set(handles.attributes_txt,'String', ['attributes of ' VarName]) |
|---|
| 367 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
|---|
| 368 | VarAttr=Field.VarAttribute{index-1}; |
|---|
| 369 | if isstruct(VarAttr) |
|---|
| 370 | attr_list=fieldnames(VarAttr); |
|---|
| 371 | for iline=1:length(attr_list) |
|---|
| 372 | Tabcell{iline,1}=attr_list{iline}; |
|---|
| 373 | val=VarAttr.(attr_list{iline}) ; |
|---|
| 374 | if ischar(val); |
|---|
| 375 | Tabcell{iline,2}=val; |
|---|
| 376 | else |
|---|
| 377 | Tabcell{iline,2}=num2str(val); |
|---|
| 378 | end |
|---|
| 379 | end |
|---|
| 380 | end |
|---|
| 381 | end |
|---|
| 382 | end |
|---|
| 383 | if ~isempty(Tabcell) |
|---|
| 384 | Tabchar=cell2tab(Tabcell,'='); |
|---|
| 385 | end |
|---|
| 386 | set(handles.attributes,'Value',1);% select the first item |
|---|
| 387 | set(handles.attributes,'String',Tabchar); |
|---|
| 388 | |
|---|
| 389 | %% update dimensions; |
|---|
| 390 | if isfield(Field,'ListDimName') |
|---|
| 391 | Tabdim={};%default |
|---|
| 392 | if isequal(index,1)%list all dimensions if '*' is selected as the variable |
|---|
| 393 | dim_indices=1:length(Field.ListDimName); |
|---|
| 394 | set(handles.dimensions_txt,'String', 'dimensions') |
|---|
| 395 | else % a specific variable has been selected |
|---|
| 396 | DimCell=Field.VarDimName{index-1}; |
|---|
| 397 | if ischar(DimCell) |
|---|
| 398 | DimCell={DimCell};% transform into a cell for a single dimension defined by a char string |
|---|
| 399 | end |
|---|
| 400 | dim_indices=[]; |
|---|
| 401 | for idim=1:length(DimCell) |
|---|
| 402 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
|---|
| 403 | dim_index=find(dim_index,1); |
|---|
| 404 | dim_indices=[dim_indices dim_index]; |
|---|
| 405 | end |
|---|
| 406 | set(handles.dimensions_txt,'String', ['dimensions of ' VarName]) |
|---|
| 407 | end |
|---|
| 408 | for iline=1:length(dim_indices) |
|---|
| 409 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
|---|
| 410 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
|---|
| 411 | end |
|---|
| 412 | Tabchar=cell2tab(Tabdim,' = '); |
|---|
| 413 | Tabchar=[{''} ;Tabchar]; |
|---|
| 414 | set(handles.dimensions,'Value',1) |
|---|
| 415 | set(handles.dimensions,'String',Tabchar) |
|---|
| 416 | end |
|---|
| 417 | |
|---|
| 418 | %% propose a plot by default if variables_Callback has not been already called by FieldOption_Callback (VarName is not a char string) |
|---|
| 419 | if ~ischar(VarName) && ~isequal(index,1) |
|---|
| 420 | if numel(DimCell)==1 |
|---|
| 421 | set(handles.FieldOption,'Value',1)%propose 1D plot |
|---|
| 422 | else |
|---|
| 423 | set(handles.FieldOption,'Value',2)%propose scalar plot |
|---|
| 424 | end |
|---|
| 425 | if numel(DimCell)<=2 |
|---|
| 426 | set(handles.Check3D,'Value',0) |
|---|
| 427 | else |
|---|
| 428 | set(handles.Check3D,'Value',1) |
|---|
| 429 | end |
|---|
| 430 | FieldOption_Callback(hObject, VarName, handles) |
|---|
| 431 | end |
|---|
| 432 | |
|---|
| 433 | %------------------------------------------------------------------------ |
|---|
| 434 | % --- Executes on selection change in FieldOption. |
|---|
| 435 | %------------------------------------------------------------------------ |
|---|
| 436 | function FieldOption_Callback(hObject, VarName, handles) |
|---|
| 437 | |
|---|
| 438 | Field=get(handles.get_field,'UserData'); |
|---|
| 439 | FieldList=get(handles.FieldOption,'String'); |
|---|
| 440 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
|---|
| 441 | switch FieldOption |
|---|
| 442 | case '1D plot' |
|---|
| 443 | set(handles.Coordinates,'Visible','on') |
|---|
| 444 | set(handles.PanelOrdinate,'Visible','on') |
|---|
| 445 | pos=get(handles.PanelOrdinate,'Position'); |
|---|
| 446 | pos(1)=2; |
|---|
| 447 | pos_coord=get(handles.Coordinates,'Position'); |
|---|
| 448 | pos(2)=pos_coord(2)-pos(4)-2; |
|---|
| 449 | set(handles.PanelOrdinate,'Position',pos) |
|---|
| 450 | set(handles.PanelScalar,'Visible','off') |
|---|
| 451 | set(handles.PanelVectors,'Visible','off') |
|---|
| 452 | set(handles.Coord_y,'Visible','on') |
|---|
| 453 | set(handles.Y_title,'Visible','on') |
|---|
| 454 | set(handles.Coord_z,'Visible','off') |
|---|
| 455 | set(handles.Z_title,'Visible','off') |
|---|
| 456 | %ordinate_Callback(hObject, VarName, handles) |
|---|
| 457 | case {'scalar'} |
|---|
| 458 | set(handles.Coordinates,'Visible','on') |
|---|
| 459 | set(handles.PanelOrdinate,'Visible','off') |
|---|
| 460 | set(handles.PanelScalar,'Visible','on') |
|---|
| 461 | set(handles.PanelVectors,'Visible','off') |
|---|
| 462 | pos=get(handles.PanelScalar,'Position'); |
|---|
| 463 | pos(1)=2; |
|---|
| 464 | pos_coord=get(handles.Coordinates,'Position'); |
|---|
| 465 | pos(2)=pos_coord(2)-pos(4)-2; |
|---|
| 466 | set(handles.PanelScalar,'Position',pos) |
|---|
| 467 | set(handles.Coord_y,'Visible','on') |
|---|
| 468 | set(handles.Y_title,'Visible','on') |
|---|
| 469 | if ~ischar(VarName) |
|---|
| 470 | %default scalar selection |
|---|
| 471 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
|---|
| 472 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 473 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') |
|---|
| 474 | Role=Field.Display.VarAttribute{ilist}.Role; |
|---|
| 475 | if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') |
|---|
| 476 | test_coord(ilist)=1; |
|---|
| 477 | end |
|---|
| 478 | end |
|---|
| 479 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
|---|
| 480 | if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable |
|---|
| 481 | test_coord(ilist)=1; |
|---|
| 482 | end |
|---|
| 483 | end |
|---|
| 484 | scalar_index=find(~test_coord,1);%get the first variable not a coordinate |
|---|
| 485 | if isempty(scalar_index) |
|---|
| 486 | set(handles.scalar,'Value',1) |
|---|
| 487 | else |
|---|
| 488 | set(handles.scalar,'Value',scalar_index) |
|---|
| 489 | end |
|---|
| 490 | end |
|---|
| 491 | scalar_Callback(hObject,VarName, handles) |
|---|
| 492 | case 'vectors' |
|---|
| 493 | set(handles.PanelVectors,'Visible','on') |
|---|
| 494 | set(handles.Coordinates,'Visible','on') |
|---|
| 495 | set(handles.PanelOrdinate,'Visible','off') |
|---|
| 496 | set(handles.PanelScalar,'Visible','off') |
|---|
| 497 | pos=get(handles.PanelVectors,'Position'); |
|---|
| 498 | pos(1)=2; |
|---|
| 499 | pos_coord=get(handles.Coordinates,'Position'); |
|---|
| 500 | pos(2)=pos_coord(2)-pos(4)-2; |
|---|
| 501 | set(handles.PanelVectors,'Position',pos) |
|---|
| 502 | set(handles.Coord_y,'Visible','on') |
|---|
| 503 | set(handles.Y_title,'Visible','on') |
|---|
| 504 | %default vector selection |
|---|
| 505 | vector_x_value=get(handles.vector_x,'UserData'); |
|---|
| 506 | vector_y_value=get(handles.vector_y,'UserData'); |
|---|
| 507 | if ~isempty(vector_x_value)&&~isempty(vector_y_value) |
|---|
| 508 | set(handles.vector_x,'Value',vector_x_value) |
|---|
| 509 | set(handles.vector_y,'Value',vector_y_value) |
|---|
| 510 | else |
|---|
| 511 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate |
|---|
| 512 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 513 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') |
|---|
| 514 | Role=Field.Display.VarAttribute{ilist}.Role; |
|---|
| 515 | if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') |
|---|
| 516 | test_coord(ilist)=1; |
|---|
| 517 | end |
|---|
| 518 | end |
|---|
| 519 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
|---|
| 520 | if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable |
|---|
| 521 | test_coord(ilist)=1; |
|---|
| 522 | end |
|---|
| 523 | end |
|---|
| 524 | vector_index=find(~test_coord,2);%get the two first variables not a coordinate |
|---|
| 525 | if isempty(vector_index) |
|---|
| 526 | set(handles.vector_x,'Value',1) |
|---|
| 527 | set(handles.vector_y,'Value',2) |
|---|
| 528 | else |
|---|
| 529 | set(handles.vector_x,'Value',vector_index(1)) |
|---|
| 530 | set(handles.vector_y,'Value',vector_index(2)) |
|---|
| 531 | end |
|---|
| 532 | end |
|---|
| 533 | vector_Callback(handles) |
|---|
| 534 | case 'civdata...' |
|---|
| 535 | set(handles.PanelOrdinate,'Visible','off') |
|---|
| 536 | set(handles.PanelScalar,'Visible','off') |
|---|
| 537 | set(handles.PanelVectors,'Visible','off') |
|---|
| 538 | set(handles.Coordinates,'Visible','off') |
|---|
| 539 | end |
|---|
| 540 | |
|---|
| 541 | %------------------------------------------------------------------------ |
|---|
| 542 | function ordinate_Callback(hObject, DimCell, handles) |
|---|
| 543 | %------------------------------------------------------------------------ |
|---|
| 544 | Field=get(handles.get_field,'UserData'); |
|---|
| 545 | y_index=get(handles.ordinate,'Value'); |
|---|
| 546 | y_menu=get(handles.ordinate,'String'); |
|---|
| 547 | if isempty(y_menu) |
|---|
| 548 | return |
|---|
| 549 | else |
|---|
| 550 | YName=y_menu{y_index}; |
|---|
| 551 | end |
|---|
| 552 | |
|---|
| 553 | %% set list of possible coordinates |
|---|
| 554 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
|---|
| 555 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
|---|
| 556 | ListCoord={''}; |
|---|
| 557 | dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable |
|---|
| 558 | |
|---|
| 559 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 560 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
|---|
| 561 | if isequal(dimnames,dim_var) |
|---|
| 562 | test_component(ilist)=1; |
|---|
| 563 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
|---|
| 564 | test_coord(ilist)=1; |
|---|
| 565 | end |
|---|
| 566 | end |
|---|
| 567 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
|---|
| 568 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
|---|
| 569 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
|---|
| 570 | |
|---|
| 571 | %% set default coord selection |
|---|
| 572 | if numel(find(test_coord))>3 |
|---|
| 573 | SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 574 | if numel(SwitchVarIndexTime)<3 |
|---|
| 575 | SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index']; |
|---|
| 576 | set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime) |
|---|
| 577 | end |
|---|
| 578 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
|---|
| 579 | SwitchVarIndexTime_Callback([], [], handles) |
|---|
| 580 | end |
|---|
| 581 | if numel(var_component)<2 |
|---|
| 582 | if numel(test_coord)<2 |
|---|
| 583 | ListCoord={''}; |
|---|
| 584 | else |
|---|
| 585 | set(handles.Coord_x,'Value',2) |
|---|
| 586 | set(handles.Coord_y,'Value',1) |
|---|
| 587 | end |
|---|
| 588 | else |
|---|
| 589 | coord_val=1; |
|---|
| 590 | for ilist=1:numel(var_component) |
|---|
| 591 | ivar=var_component(ilist); |
|---|
| 592 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
|---|
| 593 | Role=Field.Display.VarAttribute{ivar}.Role; |
|---|
| 594 | if strcmp(Role,'coord_x') |
|---|
| 595 | coord_val=ilist; |
|---|
| 596 | end |
|---|
| 597 | end |
|---|
| 598 | end |
|---|
| 599 | set(handles.Coord_x,'Value',coord_val+1) |
|---|
| 600 | end |
|---|
| 601 | set(handles.Coord_x,'String',[{''}; ListCoord]) |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | %% set list of time coordinates |
|---|
| 605 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 606 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
|---|
| 607 | switch TimeOption |
|---|
| 608 | case 'variable' |
|---|
| 609 | if numel(find(test_coord))<3 |
|---|
| 610 | ListTime={''}; |
|---|
| 611 | else |
|---|
| 612 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
|---|
| 613 | end |
|---|
| 614 | set(handles.TimeName,'Value',1) |
|---|
| 615 | set(handles.TimeName,'String',ListTime) |
|---|
| 616 | case 'matrix index' |
|---|
| 617 | if numel(find(test_coord))<3 |
|---|
| 618 | ListTime={''}; |
|---|
| 619 | else |
|---|
| 620 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
|---|
| 621 | end |
|---|
| 622 | set(handles.TimeName,'Value',1) |
|---|
| 623 | set(handles.TimeName,'String',ListTime) |
|---|
| 624 | end |
|---|
| 625 | if ~ischar(DimCell) |
|---|
| 626 | update_field(handles,YName) |
|---|
| 627 | end |
|---|
| 628 | |
|---|
| 629 | %------------------------------------------------------------------------ |
|---|
| 630 | % --- Executes on selection change in scalar menu. |
|---|
| 631 | %------------------------------------------------------------------------ |
|---|
| 632 | function scalar_Callback(hObject, VarName, handles) |
|---|
| 633 | |
|---|
| 634 | Field=get(handles.get_field,'UserData');% get the input field info stored in UserData of the GUI |
|---|
| 635 | scalar_menu=get(handles.scalar,'String');% read the menu for scalar selection |
|---|
| 636 | if ischar(VarName)% case of a call with input variable |
|---|
| 637 | ScalarName=VarName; |
|---|
| 638 | scalar_index=find(strcmp(VarName,scalar_menu)); |
|---|
| 639 | set(handles.scalar,'Value',scalar_index)% select the input variable field in the menu |
|---|
| 640 | else % no input variable, the variable ScalarName is selected from the menu |
|---|
| 641 | scalar_index=get(handles.scalar,'Value'); |
|---|
| 642 | ScalarName=scalar_menu{scalar_index}; |
|---|
| 643 | end |
|---|
| 644 | |
|---|
| 645 | %% set list of possible coordinates |
|---|
| 646 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
|---|
| 647 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
|---|
| 648 | dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable |
|---|
| 649 | %if ~get(handles.CheckDimensionX,'Value') |
|---|
| 650 | %look for coordinate variables among the other variables |
|---|
| 651 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 652 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
|---|
| 653 | if isequal(dimnames,dim_var) |
|---|
| 654 | test_component(ilist)=1;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate |
|---|
| 655 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var), 1))%variable ilist is a 1D array which can be coordinate variable |
|---|
| 656 | test_coord(ilist)=1; |
|---|
| 657 | end |
|---|
| 658 | end |
|---|
| 659 | %end |
|---|
| 660 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
|---|
| 661 | var_coord=find(test_coord);% % list of variable indices elligible as gridded coordinates |
|---|
| 662 | var_coord(var_coord==scalar_index)=[]; |
|---|
| 663 | var_component(var_component==scalar_index)=[]; |
|---|
| 664 | ListCoord=Field.Display.ListVarName([var_coord var_component]); |
|---|
| 665 | |
|---|
| 666 | %% set default coord selection |
|---|
| 667 | % if numel(find(test_coord))>3 |
|---|
| 668 | % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 669 | % if numel(SwitchVarIndexTime)<3 |
|---|
| 670 | % SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index']; |
|---|
| 671 | % set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime) |
|---|
| 672 | % end |
|---|
| 673 | % set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
|---|
| 674 | % SwitchVarIndexTime_Callback([], [], handles) |
|---|
| 675 | % end |
|---|
| 676 | |
|---|
| 677 | coord_val=[0 0]; |
|---|
| 678 | % look for labelled unstructured coordinates |
|---|
| 679 | for ilist=1:numel(var_component) |
|---|
| 680 | ivar=var_component(ilist); |
|---|
| 681 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
|---|
| 682 | Role=Field.Display.VarAttribute{ivar}.Role; |
|---|
| 683 | if strcmp(Role,'coord_x') |
|---|
| 684 | coord_val(1)=ilist; |
|---|
| 685 | elseif strcmp(Role,'coord_y') |
|---|
| 686 | coord_val(2)=ilist; |
|---|
| 687 | elseif strcmp(Role,'coord_z') |
|---|
| 688 | coord_val(3)=ilist; |
|---|
| 689 | end |
|---|
| 690 | end |
|---|
| 691 | end |
|---|
| 692 | if numel(find(coord_val))<2 % no predefiend components |
|---|
| 693 | if numel(var_coord)>=3 |
|---|
| 694 | coord_val(3)=3; |
|---|
| 695 | end |
|---|
| 696 | coord_val([1 2])=[1 2]; |
|---|
| 697 | end |
|---|
| 698 | set(handles.Coord_x,'Value',coord_val(1)) |
|---|
| 699 | set(handles.Coord_x,'String',ListCoord) |
|---|
| 700 | |
|---|
| 701 | set(handles.Coord_y,'Value',coord_val(2)) |
|---|
| 702 | set(handles.Coord_y,'String',ListCoord) |
|---|
| 703 | |
|---|
| 704 | if numel(coord_val)>=3 |
|---|
| 705 | set(handles.Coord_z,'Value',coord_val(3)) |
|---|
| 706 | set(handles.Coord_z,'String',ListCoord) |
|---|
| 707 | set(handles.Coord_z,'Visible','on') |
|---|
| 708 | set(handles.Check3D,'Value', 1) |
|---|
| 709 | end |
|---|
| 710 | |
|---|
| 711 | %% set list of time coordinates |
|---|
| 712 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 713 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
|---|
| 714 | switch TimeOption |
|---|
| 715 | case 'variable' |
|---|
| 716 | if numel(find(test_coord))<3 |
|---|
| 717 | ListTime={''}; |
|---|
| 718 | else |
|---|
| 719 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
|---|
| 720 | end |
|---|
| 721 | set(handles.TimeName,'Value',1) |
|---|
| 722 | set(handles.TimeName,'String',ListTime) |
|---|
| 723 | case 'dim index' |
|---|
| 724 | if numel(find(test_coord))<3 |
|---|
| 725 | ListTime={''}; |
|---|
| 726 | else |
|---|
| 727 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
|---|
| 728 | end |
|---|
| 729 | set(handles.TimeName,'Value',1) |
|---|
| 730 | set(handles.TimeName,'String',ListTime) |
|---|
| 731 | end |
|---|
| 732 | if ~ischar(VarName) |
|---|
| 733 | update_field(handles,ScalarName) |
|---|
| 734 | end |
|---|
| 735 | |
|---|
| 736 | % --- Executes on button press in check_rgb. |
|---|
| 737 | function check_rgb_Callback(hObject, eventdata, handles) |
|---|
| 738 | |
|---|
| 739 | |
|---|
| 740 | %------------------------------------------------------------------------ |
|---|
| 741 | % --- Executes on selection change in vector_x. |
|---|
| 742 | %------------------------------------------------------------------------ |
|---|
| 743 | function vector_x_Callback(hObject, DimCell, handles) |
|---|
| 744 | |
|---|
| 745 | vector_x_menu=get(handles.vector_x,'String'); |
|---|
| 746 | vector_x_index=get(handles.vector_x,'Value'); |
|---|
| 747 | vector_x=vector_x_menu{vector_x_index}; |
|---|
| 748 | vector_Callback(handles) |
|---|
| 749 | if ~ischar(DimCell) |
|---|
| 750 | update_field(handles,vector_x) |
|---|
| 751 | end |
|---|
| 752 | |
|---|
| 753 | %------------------------------------------------------------------------ |
|---|
| 754 | % --- Executes on selection change in vector_x. |
|---|
| 755 | %------------------------------------------------------------------------ |
|---|
| 756 | function vector_y_Callback(hObject, DimCell, handles) |
|---|
| 757 | |
|---|
| 758 | vector_y_menu=get(handles.vector_x,'String'); |
|---|
| 759 | vector_y_index=get(handles.vector_x,'Value'); |
|---|
| 760 | vector_y=vector_y_menu{vector_y_index}; |
|---|
| 761 | vector_Callback(handles) |
|---|
| 762 | if ~ischar(DimCell) |
|---|
| 763 | update_field(handles,vector_y) |
|---|
| 764 | end |
|---|
| 765 | |
|---|
| 766 | %------------------------------------------------------------------------ |
|---|
| 767 | % --- Executes on selection change in vector_z. |
|---|
| 768 | function vector_z_Callback(hObject, DimCell, handles) |
|---|
| 769 | %------------------------------------------------------------------------ |
|---|
| 770 | vector_z_menu=get(handles.vector_z,'String'); |
|---|
| 771 | vector_z_index=get(handles.vector_z,'Value'); |
|---|
| 772 | vector_z=vector_z_menu{vector_z_index}; |
|---|
| 773 | vector_Callback(handles) |
|---|
| 774 | if ~ischar(DimCell) |
|---|
| 775 | update_field(handles,vector_z) |
|---|
| 776 | end |
|---|
| 777 | %------------------------------------------------------------------------ |
|---|
| 778 | % --- Executes on selection change in vec_color. |
|---|
| 779 | function vec_color_Callback(hObject, DimCell, handles) |
|---|
| 780 | %------------------------------------------------------------------------ |
|---|
| 781 | index=get(handles.vec_color,'Value'); |
|---|
| 782 | string=get(handles.vec_color,'String'); |
|---|
| 783 | VarName=string{index}; |
|---|
| 784 | vector_Callback(handles) |
|---|
| 785 | if ~ischar(DimCell) |
|---|
| 786 | update_field(handles,VarName) |
|---|
| 787 | end |
|---|
| 788 | %------------------------------------------------------------------------ |
|---|
| 789 | % --- Executes on selection change in vector_x or vector_y |
|---|
| 790 | function vector_Callback( handles) |
|---|
| 791 | %------------------------------------------------------------------------ |
|---|
| 792 | Field=get(handles.get_field,'UserData'); |
|---|
| 793 | vector_x_index=get(handles.vector_x,'Value'); |
|---|
| 794 | vector_y_index=get(handles.vector_y,'Value'); |
|---|
| 795 | vec_color_index=get(handles.vec_color,'Value'); |
|---|
| 796 | |
|---|
| 797 | %% set list of possible coordinates |
|---|
| 798 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
|---|
| 799 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate |
|---|
| 800 | check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn |
|---|
| 801 | ListCoord={''}; |
|---|
| 802 | dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable |
|---|
| 803 | if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index}) |
|---|
| 804 | check_consistent=0; |
|---|
| 805 | elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index}) |
|---|
| 806 | check_consistent=0; |
|---|
| 807 | end |
|---|
| 808 | % the two vector components have consistent dimensions |
|---|
| 809 | if check_consistent |
|---|
| 810 | for ilist=1:numel(Field.Display.VarDimName) |
|---|
| 811 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
|---|
| 812 | if isequal(dimnames,dim_var) |
|---|
| 813 | test_component(ilist)=1; |
|---|
| 814 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
|---|
| 815 | test_coord(ilist)=1; |
|---|
| 816 | end |
|---|
| 817 | end |
|---|
| 818 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
|---|
| 819 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
|---|
| 820 | var_component(var_component==vector_x_index|var_component==vector_y_index)=[]; |
|---|
| 821 | var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components form te possible list of coordinates |
|---|
| 822 | ListCoord=Field.Display.ListVarName([var_coord var_component]); |
|---|
| 823 | |
|---|
| 824 | %% set default coord selection |
|---|
| 825 | if numel(find(test_coord))>3 |
|---|
| 826 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
|---|
| 827 | end |
|---|
| 828 | if numel(var_component)<2 |
|---|
| 829 | if numel(find(test_coord))<2 |
|---|
| 830 | ListCoord={''}; |
|---|
| 831 | else |
|---|
| 832 | if numel(find(test_coord))>=3 |
|---|
| 833 | set(handles.Coord_x,'Value',3) |
|---|
| 834 | set(handles.Coord_y,'Value',2) |
|---|
| 835 | set(handles.Coord_z,'Value',1) |
|---|
| 836 | else |
|---|
| 837 | set(handles.Coord_x,'Value',2) |
|---|
| 838 | set(handles.Coord_y,'Value',1) |
|---|
| 839 | end |
|---|
| 840 | end |
|---|
| 841 | else |
|---|
| 842 | coord_val=[0 0 0]; |
|---|
| 843 | for ilist=1:numel(var_component) |
|---|
| 844 | ivar=var_component(ilist); |
|---|
| 845 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
|---|
| 846 | Role=Field.Display.VarAttribute{ivar}.Role; |
|---|
| 847 | if strcmp(Role,'coord_x') |
|---|
| 848 | coord_val(1)=ilist; |
|---|
| 849 | elseif strcmp(Role,'coord_y') |
|---|
| 850 | coord_val(2)=ilist; |
|---|
| 851 | elseif strcmp(Role,'coord_z') |
|---|
| 852 | coord_val(3)=ilist; |
|---|
| 853 | end |
|---|
| 854 | end |
|---|
| 855 | end |
|---|
| 856 | if isempty(find(coord_val)) |
|---|
| 857 | coord_val=var_coord;% case of dimension coordinates |
|---|
| 858 | end |
|---|
| 859 | if numel(find(coord_val))<2 |
|---|
| 860 | %coord_val=[numel(var_component)+2 numel(var_component)+1]; |
|---|
| 861 | coord_val=[1 2 3]; |
|---|
| 862 | end |
|---|
| 863 | set(handles.Coord_x,'Value',coord_val(1)) |
|---|
| 864 | set(handles.Coord_y,'Value',coord_val(2)) |
|---|
| 865 | if numel(coord_val)>=3 |
|---|
| 866 | set(handles.Coord_z,'Value',coord_val(3)) |
|---|
| 867 | end |
|---|
| 868 | end |
|---|
| 869 | end |
|---|
| 870 | set(handles.Coord_z,'String',ListCoord) |
|---|
| 871 | set(handles.Coord_y,'String',ListCoord) |
|---|
| 872 | set(handles.Coord_x,'String',ListCoord) |
|---|
| 873 | |
|---|
| 874 | |
|---|
| 875 | %% set list of time coordinates |
|---|
| 876 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 877 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
|---|
| 878 | switch TimeOption |
|---|
| 879 | case 'variable' |
|---|
| 880 | if numel(find(test_coord))<3 |
|---|
| 881 | ListTime={''}; |
|---|
| 882 | else |
|---|
| 883 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
|---|
| 884 | end |
|---|
| 885 | set(handles.TimeName,'Value',1) |
|---|
| 886 | set(handles.TimeName,'String',ListTime) |
|---|
| 887 | case 'dim index' |
|---|
| 888 | if numel(find(test_coord))<3 |
|---|
| 889 | ListTime={''}; |
|---|
| 890 | else |
|---|
| 891 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
|---|
| 892 | end |
|---|
| 893 | set(handles.TimeName,'Value',1) |
|---|
| 894 | set(handles.TimeName,'String',ListTime) |
|---|
| 895 | end |
|---|
| 896 | |
|---|
| 897 | %------------------------------------------------------------------------ |
|---|
| 898 | % --- Executes on selection change in SwitchVarIndexX. |
|---|
| 899 | %------------------------------------------------------------------------ |
|---|
| 900 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
|---|
| 901 | |
|---|
| 902 | %------------------------------------------------------------------------ |
|---|
| 903 | % --- Executes on selection change in Coord_x. |
|---|
| 904 | %------------------------------------------------------------------------ |
|---|
| 905 | function Coord_x_Callback(hObject, DimCell, handles) |
|---|
| 906 | |
|---|
| 907 | index=get(handles.Coord_x,'Value'); |
|---|
| 908 | string=get(handles.Coord_x,'String'); |
|---|
| 909 | VarName=string{index}; |
|---|
| 910 | if ~ischar(DimCell) |
|---|
| 911 | update_field(handles,VarName) |
|---|
| 912 | end |
|---|
| 913 | %------------------------------------------------------------------------ |
|---|
| 914 | % --- Executes on selection change in Coord_y. |
|---|
| 915 | %------------------------------------------------------------------------ |
|---|
| 916 | function Coord_y_Callback(hObject, DimCell, handles) |
|---|
| 917 | |
|---|
| 918 | index=get(handles.Coord_y,'Value'); |
|---|
| 919 | string=get(handles.Coord_y,'String'); |
|---|
| 920 | VarName=string{index}; |
|---|
| 921 | |
|---|
| 922 | if ~ischar(DimCell) |
|---|
| 923 | update_field(handles,VarName) |
|---|
| 924 | end |
|---|
| 925 | |
|---|
| 926 | %------------------------------------------------------------------------ |
|---|
| 927 | % --- Executes on selection change in Coord_z. |
|---|
| 928 | %------------------------------------------------------------------------ |
|---|
| 929 | function Coord_z_Callback(hObject, DimCell, handles) |
|---|
| 930 | |
|---|
| 931 | index=get(handles.Coord_z,'Value'); |
|---|
| 932 | string=get(handles.Coord_z,'String'); |
|---|
| 933 | VarName=string{index}; |
|---|
| 934 | if ~ischar(DimCell) |
|---|
| 935 | update_field(handles,VarName) |
|---|
| 936 | end |
|---|
| 937 | |
|---|
| 938 | %------------------------------------------------------------------------ |
|---|
| 939 | % --- Executes on selection change in SwitchVarIndexTime. |
|---|
| 940 | %------------------------------------------------------------------------ |
|---|
| 941 | |
|---|
| 942 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
|---|
| 943 | |
|---|
| 944 | Field=get(handles.get_field,'UserData'); |
|---|
| 945 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 946 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
|---|
| 947 | |
|---|
| 948 | switch option |
|---|
| 949 | case 'file index' |
|---|
| 950 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
|---|
| 951 | case 'attribute' |
|---|
| 952 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
|---|
| 953 | time_index=get(handles.TimeName,'UserData'); %select the input data |
|---|
| 954 | if isempty(time_index) |
|---|
| 955 | PreviousList=get(handles.TimeName, 'String'); |
|---|
| 956 | if ~isempty(PreviousList) |
|---|
| 957 | PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; |
|---|
| 958 | index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1); |
|---|
| 959 | end |
|---|
| 960 | end |
|---|
| 961 | if isempty(time_index) |
|---|
| 962 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time' |
|---|
| 963 | end |
|---|
| 964 | if ~isempty(time_index) |
|---|
| 965 | set(handles.TimeName,'Value',time_index) |
|---|
| 966 | else |
|---|
| 967 | set(handles.TimeName,'Value',1) |
|---|
| 968 | end |
|---|
| 969 | set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) |
|---|
| 970 | |
|---|
| 971 | case 'variable'% TimeName menu represents the available variables |
|---|
| 972 | set(handles.TimeName, 'Visible','on') |
|---|
| 973 | VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable |
|---|
| 974 | TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time) |
|---|
| 975 | List=get(handles.TimeName,'String');% list of names on the menu for time |
|---|
| 976 | if isempty(List) |
|---|
| 977 | ind=1; |
|---|
| 978 | else |
|---|
| 979 | option=List{get(handles.TimeName,'Value')};% previous selected option |
|---|
| 980 | ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist |
|---|
| 981 | if isempty(ind) |
|---|
| 982 | ind=1; |
|---|
| 983 | end |
|---|
| 984 | end |
|---|
| 985 | if ~isempty(TimeVarName) |
|---|
| 986 | set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found |
|---|
| 987 | set(handles.TimeName, 'String',TimeVarName)% update the menu for time name |
|---|
| 988 | end |
|---|
| 989 | case 'matrix index'% TimeName menu represents the available dimensions |
|---|
| 990 | set(handles.TimeName, 'Visible','on') |
|---|
| 991 | set(handles.TimeName, 'Value',1); |
|---|
| 992 | set(handles.TimeName, 'String',Field.Display.ListDimName) |
|---|
| 993 | end |
|---|
| 994 | TimeName_Callback(hObject, [], handles) |
|---|
| 995 | |
|---|
| 996 | %----------------------------------------------------------------------- |
|---|
| 997 | function update_field(handles,VarName) |
|---|
| 998 | %----------------------------------------------------------------------- |
|---|
| 999 | Field=get(handles.get_field,'UserData'); |
|---|
| 1000 | index=name2index(VarName,Field.ListVarName); |
|---|
| 1001 | if ~isempty(index) |
|---|
| 1002 | set(handles.variables,'Value',index+1) |
|---|
| 1003 | variables_Callback(handles.variables, VarName, handles) |
|---|
| 1004 | end |
|---|
| 1005 | |
|---|
| 1006 | %------------------------------------------------------------------------ |
|---|
| 1007 | % --- give index numbers of the strings str in the list ListvarName |
|---|
| 1008 | % ----------------------------------------------------------------------- |
|---|
| 1009 | function VarIndex_y=name2index(cell_str,ListVarName) |
|---|
| 1010 | |
|---|
| 1011 | VarIndex_y=[]; |
|---|
| 1012 | if ischar(cell_str) |
|---|
| 1013 | for ivar=1:length(ListVarName) |
|---|
| 1014 | varlist=ListVarName{ivar}; |
|---|
| 1015 | if isequal(varlist,cell_str) |
|---|
| 1016 | VarIndex_y= ivar; |
|---|
| 1017 | break |
|---|
| 1018 | end |
|---|
| 1019 | end |
|---|
| 1020 | elseif iscell(cell_str) |
|---|
| 1021 | for isel=1:length(cell_str) |
|---|
| 1022 | varsel=cell_str{isel}; |
|---|
| 1023 | for ivar=1:length(ListVarName) |
|---|
| 1024 | varlist=ListVarName{ivar}; |
|---|
| 1025 | if isequal(varlist,varsel) |
|---|
| 1026 | VarIndex_y=[VarIndex_y ivar]; |
|---|
| 1027 | end |
|---|
| 1028 | end |
|---|
| 1029 | end |
|---|
| 1030 | end |
|---|
| 1031 | |
|---|
| 1032 | % --- Executes on button press in CheckDimensionY. |
|---|
| 1033 | % function CheckDimensionX_Callback(hObject, eventdata, handles) |
|---|
| 1034 | % CheckDimensionX=get(handles.CheckDimensionX,'value') |
|---|
| 1035 | % if CheckDimensionX |
|---|
| 1036 | % set(handles.Coordinates,'visible','off') |
|---|
| 1037 | % else |
|---|
| 1038 | % set(handles.Coordinates,'visible','on') |
|---|
| 1039 | % end |
|---|
| 1040 | % FieldList=get(handles.FieldOption,'String'); |
|---|
| 1041 | % FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
|---|
| 1042 | % switch FieldOption |
|---|
| 1043 | % case '1D plot' |
|---|
| 1044 | % |
|---|
| 1045 | % case {'scalar'} |
|---|
| 1046 | % scalar_Callback(hObject, eventdata, handles) |
|---|
| 1047 | % case 'vectors' |
|---|
| 1048 | % end |
|---|
| 1049 | |
|---|
| 1050 | % % --- Executes on button press in CheckDimensionY. |
|---|
| 1051 | % function CheckDimensionY_Callback(hObject, eventdata, handles) |
|---|
| 1052 | % FieldList=get(handles.FieldOption,'String'); |
|---|
| 1053 | % FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
|---|
| 1054 | % switch FieldOption |
|---|
| 1055 | % case '1D plot' |
|---|
| 1056 | % |
|---|
| 1057 | % case {'scalar','pick variables'} |
|---|
| 1058 | % scalar_Callback(hObject, eventdata, handles) |
|---|
| 1059 | % case 'vectors' |
|---|
| 1060 | % end |
|---|
| 1061 | % |
|---|
| 1062 | % |
|---|
| 1063 | % % --- Executes on button press in CheckDimensionZ. |
|---|
| 1064 | % function CheckDimensionZ_Callback(hObject, eventdata, handles) |
|---|
| 1065 | % FieldList=get(handles.FieldOption,'String'); |
|---|
| 1066 | % FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
|---|
| 1067 | % switch FieldOption |
|---|
| 1068 | % case '1D plot' |
|---|
| 1069 | % |
|---|
| 1070 | % case 'scalar' |
|---|
| 1071 | % scalar_Callback(hObject, eventdata, handles) |
|---|
| 1072 | % case 'vectors' |
|---|
| 1073 | % end |
|---|
| 1074 | |
|---|
| 1075 | % --- Executes on selection change in TimeName. |
|---|
| 1076 | function TimeName_Callback(hObject, eventdata, handles) |
|---|
| 1077 | Field=get(handles.get_field,'UserData'); |
|---|
| 1078 | index=get(handles.SwitchVarIndexTime,'Value'); |
|---|
| 1079 | MenuIndex=get(handles.TimeName,'Value'); |
|---|
| 1080 | string=get(handles.TimeName,'String'); |
|---|
| 1081 | TimeName='';%default |
|---|
| 1082 | if ~isempty(string)&&iscell(string) |
|---|
| 1083 | TimeName=string{MenuIndex}; |
|---|
| 1084 | end |
|---|
| 1085 | switch index |
|---|
| 1086 | case 1 |
|---|
| 1087 | set(handles.num_TimeDimension,'String','') |
|---|
| 1088 | set(handles.TimeUnit,'String','index') |
|---|
| 1089 | case 2 |
|---|
| 1090 | set(handles.num_TimeDimension,'String','') |
|---|
| 1091 | attr_index=find(strcmpi([TimeName 'Unit'],Field.ListGlobalAttribute));% look for time unit |
|---|
| 1092 | if ~isempty(attr_index) |
|---|
| 1093 | AttrName=Field.ListGlobalAttribute{attr_index}; |
|---|
| 1094 | set(handles.TimeUnit,'String',Field.(AttrName)) |
|---|
| 1095 | else |
|---|
| 1096 | set(handles.TimeUnit,'String','') |
|---|
| 1097 | end |
|---|
| 1098 | case {3 ,4} |
|---|
| 1099 | if index==3 % TimeName is used to chose a variable |
|---|
| 1100 | VarIndex=name2index(TimeName,Field.ListVarName); |
|---|
| 1101 | DimName=Field.VarDimName{VarIndex}; |
|---|
| 1102 | DimIndex=name2index(DimName,Field.ListDimName); |
|---|
| 1103 | DimValue=Field.DimValue(DimIndex); |
|---|
| 1104 | set(handles.num_TimeDimension,'String',num2str(DimValue)) |
|---|
| 1105 | unit=''; |
|---|
| 1106 | if isfield(Field,'VarAttribute')&& isfield(Field.VarAttribute{VarIndex},'Unit') |
|---|
| 1107 | unit=Field.VarAttribute{VarIndex}.Unit; |
|---|
| 1108 | end |
|---|
| 1109 | set(handles.TimeUnit,'String',unit) |
|---|
| 1110 | update_field(handles,TimeName) |
|---|
| 1111 | elseif index==4% TimeName is used to chose a dimension |
|---|
| 1112 | DimName=string{MenuIndex}; |
|---|
| 1113 | DimIndex=name2index(DimName,Field.ListDimName); |
|---|
| 1114 | DimValue=Field.DimValue(DimIndex); |
|---|
| 1115 | set(handles.num_TimeDimension,'String',num2str(DimValue)) |
|---|
| 1116 | set(handles.TimeUnit,'String','index') |
|---|
| 1117 | end |
|---|
| 1118 | end |
|---|
| 1119 | |
|---|
| 1120 | |
|---|
| 1121 | % --- Executes on button press in Check3D. |
|---|
| 1122 | function Check3D_Callback(hObject, eventdata, handles) |
|---|
| 1123 | if get(handles.Check3D,'Value')% 3D fields |
|---|
| 1124 | status='on'; |
|---|
| 1125 | else% fields studied as 2D |
|---|
| 1126 | status='off'; |
|---|
| 1127 | end |
|---|
| 1128 | |
|---|
| 1129 | set(handles.Coord_z,'Visible',status) |
|---|
| 1130 | % set(handles.CheckDimensionZ,'Visible',status) |
|---|
| 1131 | set(handles.Z_title,'Visible',status) |
|---|
| 1132 | set(handles.vector_z,'Visible',status) |
|---|
| 1133 | set(handles.W_title,'Visible',status) |
|---|
| 1134 | if strcmp(status,'on')% ask for 3D input |
|---|
| 1135 | Field=get(handles.get_field,'UserData'); |
|---|
| 1136 | if Field.MaxDim>3% for 4D fields, propose to use the fourth variable as time |
|---|
| 1137 | %set(handles.Time,'Visible','on') |
|---|
| 1138 | menu=get(handles.SwitchVarIndexTime,'String'); |
|---|
| 1139 | val=find(strcmp('variable',menu)); |
|---|
| 1140 | if ~isempty(val) |
|---|
| 1141 | set(handles.SwitchVarIndexTime,'Value',val) |
|---|
| 1142 | end |
|---|
| 1143 | else |
|---|
| 1144 | set(handles.SwitchVarIndexTime,'Value',1) |
|---|
| 1145 | set(handles.SwitchVarIndexTime,'String',{'file index'}) |
|---|
| 1146 | end |
|---|
| 1147 | else |
|---|
| 1148 | set(handles.SwitchVarIndexTime,'String',get(handles.SwitchVarIndexTime,'UserData')) |
|---|
| 1149 | end |
|---|
| 1150 | SwitchVarIndexTime_Callback(handles.SwitchVarIndexTime,[], handles) |
|---|
| 1151 | |
|---|
| 1152 | %------------------------------------------------------------------------ |
|---|
| 1153 | % --- Executes on button press in OK. |
|---|
| 1154 | %------------------------------------------------------------------------ |
|---|
| 1155 | function OK_Callback(hObject, eventdata, handles) |
|---|
| 1156 | handles.output=read_GUI(handles.get_field); |
|---|
| 1157 | guidata(hObject, handles);% Update handles structure |
|---|
| 1158 | uiresume(handles.get_field); |
|---|
| 1159 | drawnow |
|---|
| 1160 | % this function then activate get_field_OutputFcn |
|---|
| 1161 | |
|---|
| 1162 | %------------------------------------------------------------------------ |
|---|
| 1163 | % --- Executes when the GUI is closed by the mouse on upper right corner. |
|---|
| 1164 | %------------------------------------------------------------------------ |
|---|
| 1165 | function closefcn(hObject, eventdata, handles) |
|---|
| 1166 | handles.output=[]; |
|---|
| 1167 | guidata(hObject, handles);% Update handles structure |
|---|
| 1168 | uiresume(handles.get_field); |
|---|
| 1169 | drawnow |
|---|
| 1170 | |
|---|
| 1171 | %------------------------------------------------------------------------ |
|---|
| 1172 | % --- Outputs from this function are returned to the command line. |
|---|
| 1173 | %------------------------------------------------------------------------ |
|---|
| 1174 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
|---|
| 1175 | |
|---|
| 1176 | varargout{1} =handles.output; |
|---|
| 1177 | delete(handles.get_field) |
|---|