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