[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 | %======================================================================= |
---|
[1061] | 27 | % Copyright 2008-2019, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 28 | % http://www.legi.grenoble-inp.fr |
---|
| 29 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.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 |
---|
[775] | 81 | [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
[674] | 82 | else |
---|
[775] | 83 | msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading |
---|
| 84 | return |
---|
[674] | 85 | end |
---|
[775] | 86 | if ~isempty(errormsg) |
---|
| 87 | msgbox_uvmat('ERROR',['get_field/nc2struct/' errormsg])% display error message for input file reading |
---|
[648] | 88 | return |
---|
[227] | 89 | end |
---|
[204] | 90 | if ~isfield(Field,'ListVarName') |
---|
[775] | 91 | msgbox_uvmat('ERROR',['no variable found in ' filename])% display error message for input file reading |
---|
[204] | 92 | return |
---|
| 93 | end |
---|
[775] | 94 | if ~exist('ParamIn','var') |
---|
[1009] | 95 | ParamIn.Coord_z=''; |
---|
[775] | 96 | end |
---|
[582] | 97 | |
---|
[648] | 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 |
---|
[747] | 101 | NbVar=numel(Field.VarDimName);%nbre of variables in the input data |
---|
[648] | 102 | for ilist=1:NbVar |
---|
[582] | 103 | if ischar(Field.VarDimName{ilist}) |
---|
| 104 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 105 | end |
---|
[648] | 106 | NbDim=numel(Field.VarDimName{ilist}); |
---|
[747] | 107 | check_singleton=false(1,NbDim);% check singleton, false by default |
---|
[582] | 108 | for idim=1:NbDim |
---|
[648] | 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 |
---|
[582] | 111 | end |
---|
[701] | 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 |
---|
[648] | 113 | if ~Field.Check0D(ilist) |
---|
| 114 | Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions |
---|
[582] | 115 | end |
---|
| 116 | end |
---|
[669] | 117 | if ~isfield(Field,'VarAttribute') |
---|
| 118 | Field.VarAttribute={}; |
---|
| 119 | end |
---|
[648] | 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)); |
---|
[582] | 122 | end |
---|
[747] | 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 |
---|
[648] | 125 | Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); |
---|
| 126 | Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); |
---|
[747] | 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 |
---|
[581] | 129 | |
---|
[747] | 130 | |
---|
[648] | 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 |
---|
[1045] | 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 |
---|
[648] | 144 | |
---|
[581] | 145 | %% set time mode |
---|
[646] | 146 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
---|
[582] | 147 | % look at global attributes with numerical values |
---|
[674] | 148 | check_numvalue=false(1,numel(Field.ListGlobalAttribute)); |
---|
[646] | 149 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 150 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 151 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 152 | end |
---|
[648] | 153 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 154 | if ~isempty(Field.Display.ListGlobalAttribute) |
---|
[646] | 155 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
---|
[582] | 156 | end |
---|
[1028] | 157 | |
---|
| 158 | Check_index=0; |
---|
[582] | 159 | if Field.MaxDim>=2 |
---|
[693] | 160 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index |
---|
[1028] | 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 |
---|
[582] | 170 | end |
---|
[674] | 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 |
---|
[693] | 176 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time' |
---|
[674] | 177 | end |
---|
[1009] | 178 | if isempty(time_index) |
---|
| 179 | set(handles.SwitchVarIndexTime,'Value',1); |
---|
| 180 | else |
---|
[648] | 181 | set(handles.SwitchVarIndexTime,'Value',2); |
---|
[674] | 182 | set(handles.TimeName,'UserData',time_index) |
---|
[581] | 183 | end |
---|
[646] | 184 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
[974] | 185 | set(handles.SwitchVarIndexTime,'UserData',ListSwitchVarIndexTime); % keep string in memory for check3D |
---|
[582] | 186 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[648] | 187 | SwitchVarIndexTime_Callback([], [], handles) |
---|
[581] | 188 | |
---|
[582] | 189 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
[648] | 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 |
---|
[748] | 192 | set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
---|
[672] | 193 | set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
---|
[648] | 194 | set(handles.scalar,'Value',1)% fill the menu of y vector components |
---|
[747] | 195 | set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar |
---|
[648] | 196 | set(handles.ordinate,'Value',1)% fill the menu of y vector components |
---|
[747] | 197 | set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots |
---|
[748] | 198 | checkseries=0; |
---|
[764] | 199 | if isfield(ParamIn,'SeriesInput') && ParamIn.SeriesInput% case of call by series |
---|
[748] | 200 | set(handles.FieldOption,'value',1) |
---|
[764] | 201 | if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
---|
[771] | 202 | set(handles.FieldOption,'String',{'scalar';'vectors';'civdata...'}) |
---|
[764] | 203 | else |
---|
[771] | 204 | set(handles.FieldOption,'String',{'scalar';'vectors'}) |
---|
[764] | 205 | end |
---|
[748] | 206 | checkseries=1; |
---|
| 207 | set(handles.scalar,'Max',2) |
---|
| 208 | elseif isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
---|
[747] | 209 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata |
---|
[748] | 210 | set(handles.scalar,'Max',1) |
---|
[654] | 211 | else |
---|
[672] | 212 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) |
---|
[748] | 213 | set(handles.scalar,'Max',1) |
---|
[654] | 214 | end |
---|
[1023] | 215 | |
---|
| 216 | %% set default field options |
---|
| 217 | checknbdim=cellfun('size',Field.Display.VarDimName,2); |
---|
[1045] | 218 | % if max(checknbdim)<=1 |
---|
| 219 | % Field.MaxDim=1;% only 1D fields, considered as a time series by default |
---|
| 220 | % end |
---|
[748] | 221 | if Field.MaxDim>=2 && ~checkseries% case of 2D (or 3D) fields |
---|
[674] | 222 | check_vec_input=0; |
---|
[1045] | 223 | % case of vector initially selected from uvmat input |
---|
[674] | 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 |
---|
[1045] | 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') |
---|
[674] | 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 |
---|
[646] | 240 | set(handles.FieldOption,'Value',3)% set vector selection option |
---|
[1028] | 241 | else |
---|
[674] | 242 | set(handles.FieldOption,'Value',2)% set scalar selection option |
---|
[204] | 243 | end |
---|
[582] | 244 | else % case of 1D fields |
---|
[644] | 245 | set(handles.FieldOption,'Value',1) |
---|
[204] | 246 | end |
---|
[582] | 247 | |
---|
[648] | 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 |
---|
[644] | 257 | |
---|
[648] | 258 | %% fill menus for coordinates and time |
---|
| 259 | FieldOption_Callback(handles.variables,[], handles)% list the global attributes |
---|
| 260 | |
---|
[672] | 261 | %% Make choices of coordinates from input |
---|
[1045] | 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 |
---|
[648] | 303 | |
---|
| 304 | %% put the GUI on the lower right of the sceen |
---|
[911] | 305 | set(hObject,'Unit','pixels') |
---|
| 306 | %pos_view_field=get(hObject,'Position'); |
---|
[648] | 307 | set(0,'Unit','pixels') |
---|
| 308 | ScreenSize=get(0,'ScreenSize'); |
---|
[911] | 309 | pos_view_field(3:4)=[955 648]; |
---|
[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 |
---|
[771] | 314 | if isfield(ParamIn,'Title') |
---|
| 315 | set(hObject,'Name',ParamIn.Title) |
---|
| 316 | end |
---|
[648] | 317 | |
---|
| 318 | %% set z coordinate menu if relevant |
---|
[1009] | 319 | if Field.MaxDim>=3 && prod(Field.DimValue)<10^8 && ~isempty(ParamIn.Coord_z); % 3D field (with memory content smaller than 400 Mo) |
---|
[747] | 320 | set(handles.Check3D,'Value',1) |
---|
[648] | 321 | else |
---|
[747] | 322 | set(handles.Check3D,'Value',0) |
---|
[581] | 323 | end |
---|
[747] | 324 | Check3D_Callback(hObject, eventdata, handles) |
---|
[748] | 325 | set(handles.variables,'Value',1) |
---|
| 326 | set(handles.variables,'String',[{'*'} Field.ListVarName]) |
---|
| 327 | variables_Callback(handles.variables,[], handles)% list the global attributes |
---|
[747] | 328 | drawnow |
---|
| 329 | uiwait(handles.get_field); |
---|
[204] | 330 | |
---|
[582] | 331 | % ----------------------------------------------------------------------- |
---|
| 332 | % --- Activated by selection in the list of variables |
---|
[672] | 333 | % ---------------------------------------------------------------------- |
---|
[1045] | 334 | function variables_Callback(hObject, VarName, handles) |
---|
[672] | 335 | |
---|
[582] | 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 |
---|
[672] | 343 | if isequal(index,1) |
---|
[582] | 344 | set(handles.attributes_txt,'String','global attributes') |
---|
| 345 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 346 | for iline=1:length(Field.ListGlobalAttribute) |
---|
[672] | 347 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
[582] | 348 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
[648] | 349 | val=Field.(Field.ListGlobalAttribute{iline}); |
---|
[582] | 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 |
---|
[672] | 359 | %% list Attribute names and values associated to the Variable # index-1 |
---|
[582] | 360 | else |
---|
| 361 | list_var=get(handles.variables,'String'); |
---|
[748] | 362 | if index>numel(list_var) |
---|
| 363 | return |
---|
| 364 | end |
---|
[1040] | 365 | VarName=list_var{index}; |
---|
| 366 | set(handles.attributes_txt,'String', ['attributes of ' VarName]) |
---|
[582] | 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}; |
---|
[674] | 373 | val=VarAttr.(attr_list{iline}) ; |
---|
[582] | 374 | if ischar(val); |
---|
| 375 | Tabcell{iline,2}=val; |
---|
| 376 | else |
---|
[672] | 377 | Tabcell{iline,2}=num2str(val); |
---|
[582] | 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 |
---|
[1040] | 392 | if isequal(index,1)%list all dimensions if '*' is selected as the variable |
---|
[582] | 393 | dim_indices=1:length(Field.ListDimName); |
---|
| 394 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
[1040] | 395 | else % a specific variable has been selected |
---|
[582] | 396 | DimCell=Field.VarDimName{index-1}; |
---|
| 397 | if ischar(DimCell) |
---|
[1040] | 398 | DimCell={DimCell};% transform into a cell for a single dimension defined by a char string |
---|
[672] | 399 | end |
---|
[582] | 400 | dim_indices=[]; |
---|
| 401 | for idim=1:length(DimCell) |
---|
[672] | 402 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
[582] | 403 | dim_index=find(dim_index,1); |
---|
| 404 | dim_indices=[dim_indices dim_index]; |
---|
| 405 | end |
---|
[1040] | 406 | set(handles.dimensions_txt,'String', ['dimensions of ' VarName]) |
---|
[582] | 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) |
---|
[672] | 415 | set(handles.dimensions,'String',Tabchar) |
---|
| 416 | end |
---|
[582] | 417 | |
---|
[1045] | 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) |
---|
[1040] | 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 | |
---|
[582] | 433 | %------------------------------------------------------------------------ |
---|
[648] | 434 | % --- Executes on selection change in FieldOption. |
---|
[582] | 435 | %------------------------------------------------------------------------ |
---|
[1040] | 436 | function FieldOption_Callback(hObject, VarName, handles) |
---|
[648] | 437 | |
---|
[672] | 438 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 439 | FieldList=get(handles.FieldOption,'String'); |
---|
| 440 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
---|
| 441 | switch FieldOption |
---|
| 442 | case '1D plot' |
---|
[654] | 443 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 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') |
---|
[1045] | 452 | set(handles.Coord_y,'Visible','on') |
---|
| 453 | set(handles.Y_title,'Visible','on') |
---|
[648] | 454 | set(handles.Coord_z,'Visible','off') |
---|
| 455 | set(handles.Z_title,'Visible','off') |
---|
[1045] | 456 | %ordinate_Callback(hObject, VarName, handles) |
---|
[771] | 457 | case {'scalar'} |
---|
[654] | 458 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 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') |
---|
[1045] | 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 |
---|
[672] | 481 | test_coord(ilist)=1; |
---|
| 482 | end |
---|
| 483 | end |
---|
[1045] | 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) |
---|
[672] | 489 | end |
---|
| 490 | end |
---|
[1045] | 491 | scalar_Callback(hObject,VarName, handles) |
---|
[648] | 492 | case 'vectors' |
---|
[674] | 493 | set(handles.PanelVectors,'Visible','on') |
---|
[654] | 494 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 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') |
---|
[672] | 503 | set(handles.Y_title,'Visible','on') |
---|
| 504 | %default vector selection |
---|
[674] | 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 |
---|
[672] | 521 | test_coord(ilist)=1; |
---|
| 522 | end |
---|
| 523 | end |
---|
[674] | 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)) |
---|
[672] | 531 | end |
---|
| 532 | end |
---|
[1045] | 533 | vector_Callback(handles) |
---|
[654] | 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') |
---|
[582] | 539 | end |
---|
| 540 | |
---|
| 541 | %------------------------------------------------------------------------ |
---|
[1040] | 542 | function ordinate_Callback(hObject, DimCell, handles) |
---|
[204] | 543 | %------------------------------------------------------------------------ |
---|
[582] | 544 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 545 | y_index=get(handles.ordinate,'Value'); |
---|
| 546 | y_menu=get(handles.ordinate,'String'); |
---|
[701] | 547 | if isempty(y_menu) |
---|
| 548 | return |
---|
| 549 | else |
---|
[648] | 550 | YName=y_menu{y_index}; |
---|
[701] | 551 | end |
---|
[648] | 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; |
---|
[582] | 565 | end |
---|
| 566 | end |
---|
[648] | 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]); |
---|
[204] | 570 | |
---|
[648] | 571 | %% set default coord selection |
---|
| 572 | if numel(find(test_coord))>3 |
---|
[693] | 573 | SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); |
---|
| 574 | if numel(SwitchVarIndexTime)<3 |
---|
| 575 | SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index']; |
---|
| 576 | set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime) |
---|
| 577 | end |
---|
[648] | 578 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[693] | 579 | SwitchVarIndexTime_Callback([], [], handles) |
---|
[582] | 580 | end |
---|
[648] | 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 |
---|
[582] | 588 | else |
---|
[648] | 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 |
---|
[1045] | 599 | set(handles.Coord_x,'Value',coord_val+1) |
---|
[582] | 600 | end |
---|
[1045] | 601 | set(handles.Coord_x,'String',[{''}; ListCoord]) |
---|
[582] | 602 | |
---|
| 603 | |
---|
[648] | 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) |
---|
[693] | 616 | case 'matrix index' |
---|
[648] | 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 |
---|
[1040] | 625 | if ~ischar(DimCell) |
---|
[648] | 626 | update_field(handles,YName) |
---|
[1040] | 627 | end |
---|
[674] | 628 | |
---|
[582] | 629 | %------------------------------------------------------------------------ |
---|
[204] | 630 | % --- Executes on selection change in scalar menu. |
---|
[648] | 631 | %------------------------------------------------------------------------ |
---|
[1040] | 632 | function scalar_Callback(hObject, VarName, handles) |
---|
[648] | 633 | |
---|
[1045] | 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 |
---|
[1040] | 637 | ScalarName=VarName; |
---|
| 638 | scalar_index=find(strcmp(VarName,scalar_menu)); |
---|
[1045] | 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 |
---|
[1040] | 641 | scalar_index=get(handles.scalar,'Value'); |
---|
[1050] | 642 | ScalarName=scalar_menu{scalar_index}; |
---|
[1040] | 643 | end |
---|
[204] | 644 | |
---|
[648] | 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 |
---|
[1050] | 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; |
---|
[648] | 657 | end |
---|
[1050] | 658 | end |
---|
[1045] | 659 | %end |
---|
[672] | 660 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
[1045] | 661 | var_coord=find(test_coord);% % list of variable indices elligible as gridded coordinates |
---|
[874] | 662 | var_coord(var_coord==scalar_index)=[]; |
---|
| 663 | var_component(var_component==scalar_index)=[]; |
---|
| 664 | ListCoord=Field.Display.ListVarName([var_coord var_component]); |
---|
[227] | 665 | |
---|
[648] | 666 | %% set default coord selection |
---|
[750] | 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 |
---|
[747] | 676 | |
---|
[672] | 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; |
---|
[1045] | 687 | elseif strcmp(Role,'coord_z') |
---|
[874] | 688 | coord_val(3)=ilist; |
---|
[227] | 689 | end |
---|
| 690 | end |
---|
| 691 | end |
---|
[1050] | 692 | if numel(find(coord_val))<2 % no predefiend components |
---|
[874] | 693 | if numel(var_coord)>=3 |
---|
[1050] | 694 | coord_val(3)=3; |
---|
[672] | 695 | end |
---|
[1050] | 696 | coord_val([1 2])=[1 2]; |
---|
[672] | 697 | end |
---|
[1050] | 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)) |
---|
[747] | 706 | set(handles.Coord_z,'String',ListCoord) |
---|
[1045] | 707 | set(handles.Coord_z,'Visible','on') |
---|
| 708 | set(handles.Check3D,'Value', 1) |
---|
[747] | 709 | end |
---|
[227] | 710 | |
---|
[648] | 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) |
---|
[1050] | 731 | end |
---|
[1040] | 732 | if ~ischar(VarName) |
---|
[1050] | 733 | update_field(handles,ScalarName) |
---|
[1040] | 734 | end |
---|
[582] | 735 | |
---|
[648] | 736 | % --- Executes on button press in check_rgb. |
---|
| 737 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[582] | 738 | |
---|
| 739 | |
---|
| 740 | %------------------------------------------------------------------------ |
---|
[204] | 741 | % --- Executes on selection change in vector_x. |
---|
[672] | 742 | %------------------------------------------------------------------------ |
---|
[1040] | 743 | function vector_x_Callback(hObject, DimCell, handles) |
---|
[672] | 744 | |
---|
[648] | 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) |
---|
[1040] | 749 | if ~ischar(DimCell) |
---|
[648] | 750 | update_field(handles,vector_x) |
---|
[1040] | 751 | end |
---|
[227] | 752 | |
---|
[204] | 753 | %------------------------------------------------------------------------ |
---|
[648] | 754 | % --- Executes on selection change in vector_x. |
---|
[204] | 755 | %------------------------------------------------------------------------ |
---|
[1040] | 756 | function vector_y_Callback(hObject, DimCell, handles) |
---|
| 757 | |
---|
[648] | 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) |
---|
[1040] | 762 | if ~ischar(DimCell) |
---|
[648] | 763 | update_field(handles,vector_y) |
---|
[1040] | 764 | end |
---|
[204] | 765 | |
---|
| 766 | %------------------------------------------------------------------------ |
---|
| 767 | % --- Executes on selection change in vector_z. |
---|
[1040] | 768 | function vector_z_Callback(hObject, DimCell, handles) |
---|
[204] | 769 | %------------------------------------------------------------------------ |
---|
[648] | 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) |
---|
[1040] | 774 | if ~ischar(DimCell) |
---|
[648] | 775 | update_field(handles,vector_z) |
---|
[1040] | 776 | end |
---|
[204] | 777 | %------------------------------------------------------------------------ |
---|
| 778 | % --- Executes on selection change in vec_color. |
---|
[1040] | 779 | function vec_color_Callback(hObject, DimCell, handles) |
---|
[227] | 780 | %------------------------------------------------------------------------ |
---|
[204] | 781 | index=get(handles.vec_color,'Value'); |
---|
| 782 | string=get(handles.vec_color,'String'); |
---|
| 783 | VarName=string{index}; |
---|
[648] | 784 | vector_Callback(handles) |
---|
[1040] | 785 | if ~ischar(DimCell) |
---|
[648] | 786 | update_field(handles,VarName) |
---|
[1040] | 787 | end |
---|
[227] | 788 | %------------------------------------------------------------------------ |
---|
[648] | 789 | % --- Executes on selection change in vector_x or vector_y |
---|
| 790 | function vector_Callback( handles) |
---|
[227] | 791 | %------------------------------------------------------------------------ |
---|
[648] | 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'); |
---|
[204] | 796 | |
---|
[648] | 797 | %% set list of possible coordinates |
---|
| 798 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
[874] | 799 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate |
---|
[648] | 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; |
---|
[204] | 807 | end |
---|
[672] | 808 | % the two vector components have consistent dimensions |
---|
[648] | 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; |
---|
[204] | 816 | end |
---|
| 817 | end |
---|
[675] | 818 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
[648] | 819 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
[874] | 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]); |
---|
[648] | 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 |
---|
[204] | 827 | end |
---|
[648] | 828 | if numel(var_component)<2 |
---|
[876] | 829 | if numel(find(test_coord))<2 |
---|
[648] | 830 | ListCoord={''}; |
---|
| 831 | else |
---|
[876] | 832 | if numel(find(test_coord))>=3 |
---|
[874] | 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 |
---|
[204] | 840 | end |
---|
| 841 | else |
---|
[874] | 842 | coord_val=[0 0 0]; |
---|
[648] | 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; |
---|
[874] | 851 | elseif strcmp(Role,'coord_z') |
---|
| 852 | coord_val(3)=ilist; |
---|
[648] | 853 | end |
---|
[526] | 854 | end |
---|
| 855 | end |
---|
[675] | 856 | if isempty(find(coord_val)) |
---|
[672] | 857 | coord_val=var_coord;% case of dimension coordinates |
---|
| 858 | end |
---|
| 859 | if numel(find(coord_val))<2 |
---|
[675] | 860 | %coord_val=[numel(var_component)+2 numel(var_component)+1]; |
---|
[874] | 861 | coord_val=[1 2 3]; |
---|
[672] | 862 | end |
---|
[648] | 863 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 864 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[879] | 865 | if numel(coord_val)>=3 |
---|
[874] | 866 | set(handles.Coord_z,'Value',coord_val(3)) |
---|
| 867 | end |
---|
[526] | 868 | end |
---|
[204] | 869 | end |
---|
[874] | 870 | set(handles.Coord_z,'String',ListCoord) |
---|
[648] | 871 | set(handles.Coord_y,'String',ListCoord) |
---|
| 872 | set(handles.Coord_x,'String',ListCoord) |
---|
[204] | 873 | |
---|
| 874 | |
---|
[648] | 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)); |
---|
[204] | 884 | end |
---|
[648] | 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)}; |
---|
[204] | 892 | end |
---|
[648] | 893 | set(handles.TimeName,'Value',1) |
---|
| 894 | set(handles.TimeName,'String',ListTime) |
---|
| 895 | end |
---|
[204] | 896 | |
---|
[227] | 897 | %------------------------------------------------------------------------ |
---|
[648] | 898 | % --- Executes on selection change in SwitchVarIndexX. |
---|
[227] | 899 | %------------------------------------------------------------------------ |
---|
[648] | 900 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
[227] | 901 | |
---|
| 902 | %------------------------------------------------------------------------ |
---|
[648] | 903 | % --- Executes on selection change in Coord_x. |
---|
[672] | 904 | %------------------------------------------------------------------------ |
---|
[1040] | 905 | function Coord_x_Callback(hObject, DimCell, handles) |
---|
[672] | 906 | |
---|
[648] | 907 | index=get(handles.Coord_x,'Value'); |
---|
| 908 | string=get(handles.Coord_x,'String'); |
---|
| 909 | VarName=string{index}; |
---|
[1040] | 910 | if ~ischar(DimCell) |
---|
[648] | 911 | update_field(handles,VarName) |
---|
[1040] | 912 | end |
---|
[227] | 913 | %------------------------------------------------------------------------ |
---|
[648] | 914 | % --- Executes on selection change in Coord_y. |
---|
[672] | 915 | %------------------------------------------------------------------------ |
---|
[1040] | 916 | function Coord_y_Callback(hObject, DimCell, handles) |
---|
[672] | 917 | |
---|
[648] | 918 | index=get(handles.Coord_y,'Value'); |
---|
| 919 | string=get(handles.Coord_y,'String'); |
---|
| 920 | VarName=string{index}; |
---|
[1045] | 921 | |
---|
[1040] | 922 | if ~ischar(DimCell) |
---|
[648] | 923 | update_field(handles,VarName) |
---|
[1040] | 924 | end |
---|
[227] | 925 | |
---|
[646] | 926 | %------------------------------------------------------------------------ |
---|
[648] | 927 | % --- Executes on selection change in Coord_z. |
---|
[672] | 928 | %------------------------------------------------------------------------ |
---|
[1040] | 929 | function Coord_z_Callback(hObject, DimCell, handles) |
---|
[672] | 930 | |
---|
[648] | 931 | index=get(handles.Coord_z,'Value'); |
---|
| 932 | string=get(handles.Coord_z,'String'); |
---|
| 933 | VarName=string{index}; |
---|
[1040] | 934 | if ~ischar(DimCell) |
---|
[648] | 935 | update_field(handles,VarName) |
---|
[1040] | 936 | end |
---|
[581] | 937 | |
---|
[646] | 938 | %------------------------------------------------------------------------ |
---|
[581] | 939 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
[646] | 940 | %------------------------------------------------------------------------ |
---|
[747] | 941 | |
---|
[581] | 942 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
[672] | 943 | |
---|
[648] | 944 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 945 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 946 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[648] | 947 | |
---|
[581] | 948 | switch option |
---|
| 949 | case 'file index' |
---|
[648] | 950 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
---|
[581] | 951 | case 'attribute' |
---|
[648] | 952 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
---|
[674] | 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 |
---|
[581] | 960 | end |
---|
[674] | 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 |
---|
[581] | 964 | if ~isempty(time_index) |
---|
[674] | 965 | set(handles.TimeName,'Value',time_index) |
---|
[581] | 966 | else |
---|
[648] | 967 | set(handles.TimeName,'Value',1) |
---|
[581] | 968 | end |
---|
[648] | 969 | set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) |
---|
[674] | 970 | |
---|
[648] | 971 | case 'variable'% TimeName menu represents the available variables |
---|
| 972 | set(handles.TimeName, 'Visible','on') |
---|
[747] | 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; |
---|
[581] | 978 | else |
---|
[747] | 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 |
---|
[581] | 984 | end |
---|
[747] | 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 |
---|
[693] | 990 | set(handles.TimeName, 'Visible','on') |
---|
| 991 | set(handles.TimeName, 'Value',1); |
---|
| 992 | set(handles.TimeName, 'String',Field.Display.ListDimName) |
---|
[581] | 993 | end |
---|
[752] | 994 | TimeName_Callback(hObject, [], handles) |
---|
[581] | 995 | |
---|
[648] | 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) |
---|
[1045] | 1003 | variables_Callback(handles.variables, VarName, handles) |
---|
[644] | 1004 | end |
---|
[648] | 1005 | |
---|
[672] | 1006 | %------------------------------------------------------------------------ |
---|
| 1007 | % --- give index numbers of the strings str in the list ListvarName |
---|
| 1008 | % ----------------------------------------------------------------------- |
---|
[648] | 1009 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
[672] | 1010 | |
---|
[648] | 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 |
---|
[693] | 1031 | |
---|
| 1032 | % --- Executes on button press in CheckDimensionY. |
---|
[1045] | 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 |
---|
[890] | 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 |
---|
[693] | 1049 | |
---|
[764] | 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 |
---|
[693] | 1074 | |
---|
[747] | 1075 | % --- Executes on selection change in TimeName. |
---|
| 1076 | function TimeName_Callback(hObject, eventdata, handles) |
---|
[752] | 1077 | Field=get(handles.get_field,'UserData'); |
---|
[747] | 1078 | index=get(handles.SwitchVarIndexTime,'Value'); |
---|
[754] | 1079 | MenuIndex=get(handles.TimeName,'Value'); |
---|
| 1080 | string=get(handles.TimeName,'String'); |
---|
[756] | 1081 | TimeName='';%default |
---|
| 1082 | if ~isempty(string)&&iscell(string) |
---|
[754] | 1083 | TimeName=string{MenuIndex}; |
---|
[756] | 1084 | end |
---|
[752] | 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','') |
---|
[754] | 1091 | attr_index=find(strcmpi([TimeName 'Unit'],Field.ListGlobalAttribute));% look for time unit |
---|
[752] | 1092 | if ~isempty(attr_index) |
---|
| 1093 | AttrName=Field.ListGlobalAttribute{attr_index}; |
---|
| 1094 | set(handles.TimeUnit,'String',Field.(AttrName)) |
---|
[756] | 1095 | else |
---|
| 1096 | set(handles.TimeUnit,'String','') |
---|
[752] | 1097 | end |
---|
| 1098 | case {3 ,4} |
---|
| 1099 | if index==3 % TimeName is used to chose a variable |
---|
[754] | 1100 | VarIndex=name2index(TimeName,Field.ListVarName); |
---|
[752] | 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) |
---|
[754] | 1110 | update_field(handles,TimeName) |
---|
[752] | 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 |
---|
[747] | 1118 | end |
---|
| 1119 | |
---|
| 1120 | |
---|
| 1121 | % --- Executes on button press in Check3D. |
---|
| 1122 | function Check3D_Callback(hObject, eventdata, handles) |
---|
[874] | 1123 | if get(handles.Check3D,'Value')% 3D fields |
---|
[747] | 1124 | status='on'; |
---|
[874] | 1125 | else% fields studied as 2D |
---|
[747] | 1126 | status='off'; |
---|
| 1127 | end |
---|
[974] | 1128 | |
---|
[747] | 1129 | set(handles.Coord_z,'Visible',status) |
---|
[752] | 1130 | % set(handles.CheckDimensionZ,'Visible',status) |
---|
[747] | 1131 | set(handles.Z_title,'Visible',status) |
---|
| 1132 | set(handles.vector_z,'Visible',status) |
---|
[974] | 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') |
---|
[874] | 1138 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 1139 | val=find(strcmp('variable',menu)); |
---|
| 1140 | if ~isempty(val) |
---|
| 1141 | set(handles.SwitchVarIndexTime,'Value',val) |
---|
| 1142 | end |
---|
[974] | 1143 | else |
---|
| 1144 | set(handles.SwitchVarIndexTime,'Value',1) |
---|
| 1145 | set(handles.SwitchVarIndexTime,'String',{'file index'}) |
---|
[874] | 1146 | end |
---|
[974] | 1147 | else |
---|
| 1148 | set(handles.SwitchVarIndexTime,'String',get(handles.SwitchVarIndexTime,'UserData')) |
---|
| 1149 | end |
---|
| 1150 | SwitchVarIndexTime_Callback(handles.SwitchVarIndexTime,[], handles) |
---|
| 1151 | |
---|
[874] | 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) |
---|