[581] | 1 | %'get_field': display variables and attributes from a Netcdf file, and OK selected fields |
---|
[204] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | %function varargout = get_field(varargin) |
---|
| 4 | % associated with the GUI get_field.fig |
---|
| 5 | % |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = get_field(varargin) |
---|
| 23 | |
---|
[581] | 24 | % Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52 |
---|
[204] | 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
[581] | 27 | gui_Singleton = 1; |
---|
[204] | 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
| 45 | %------------------------------------------------------------------------ |
---|
| 46 | % --- Executes just before get_field is made visible. |
---|
[581] | 47 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
---|
[204] | 48 | %------------------------------------------------------------------------ |
---|
| 49 | global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN |
---|
| 50 | |
---|
| 51 | %% Choose default command line output for get_field |
---|
[581] | 52 | handles.output = 'Cancel'; |
---|
[204] | 53 | |
---|
| 54 | %% Update handles structure |
---|
| 55 | guidata(hObject, handles); |
---|
[434] | 56 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[204] | 57 | |
---|
[581] | 58 | %% settings for 'slave' mode, called by uvmat, or 'master' mode |
---|
[204] | 59 | if exist('filename','var') && ischar(filename) %transfer input file name in slave mode |
---|
[227] | 60 | set(handles.inputfile,'String',filename)% prefill the input file name |
---|
[581] | 61 | Field=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
[204] | 62 | if isfield(Field,'Txt') |
---|
[581] | 63 | msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt]) |
---|
[204] | 64 | else |
---|
[581] | 65 | if ~exist('ParamIn','var') |
---|
| 66 | ParamIn=[]; |
---|
| 67 | end |
---|
| 68 | Field_input(handles,Field,ParamIn); |
---|
[204] | 69 | end |
---|
| 70 | else %master mode |
---|
[227] | 71 | set(handles.inputfile,'String','') |
---|
| 72 | end |
---|
| 73 | |
---|
[434] | 74 | %% put the GUI on the lower right of the sceen |
---|
[581] | 75 | set(hObject,'Unit','pixel') |
---|
[434] | 76 | pos_view_field=get(hObject,'Position'); |
---|
| 77 | ScreenSize=get(0,'ScreenSize'); |
---|
| 78 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
---|
| 79 | pos_view_field(2)=ScreenSize(2); |
---|
| 80 | set(hObject,'Position',pos_view_field) |
---|
[581] | 81 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
---|
| 82 | drawnow |
---|
[582] | 83 | uiwait(handles.get_field); |
---|
[204] | 84 | |
---|
| 85 | %------------------------------------------------------------------------ |
---|
[582] | 86 | % --- update the display when a new field is introduced. |
---|
| 87 | function Field_input(handles,Field,ParamIn) |
---|
[204] | 88 | %------------------------------------------------------------------------ |
---|
| 89 | |
---|
[582] | 90 | %% fill the list and values of dimensions |
---|
[204] | 91 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
| 92 | Tabcell(:,1)=Field.ListDimName; |
---|
| 93 | for iline=1:length(Field.ListDimName) |
---|
| 94 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
| 95 | end |
---|
[227] | 96 | Tabchar=cell2tab(Tabcell,' = '); |
---|
[204] | 97 | set(handles.dimensions,'String',Tabchar) |
---|
| 98 | end |
---|
| 99 | if ~isfield(Field,'ListVarName') |
---|
| 100 | return |
---|
| 101 | end |
---|
[582] | 102 | |
---|
| 103 | %% fill the list of variables |
---|
[204] | 104 | Txt=Field.ListVarName; |
---|
| 105 | set(handles.variables,'Value',1) |
---|
| 106 | set(handles.variables,'String',[{'*'} Txt]) |
---|
| 107 | variables_Callback(handles.variables,[], handles) |
---|
[581] | 108 | |
---|
[582] | 109 | % set(handles.abscissa,'String',[{''} Txt ]) |
---|
[204] | 110 | set(handles.ordinate,'String',Txt) |
---|
| 111 | set(handles.vector_x,'String',[Txt ]) |
---|
| 112 | set(handles.vector_y,'String',[Txt ]) |
---|
| 113 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
| 114 | set(handles.vec_color,'String',[{''} Txt ]) |
---|
[582] | 115 | set(handles.XVarName,'String',[{''} Txt ]) |
---|
| 116 | set(handles.YVarName,'String',[{''} Txt ]) |
---|
| 117 | set(handles.ZVarName,'String',[{''} Txt ]) |
---|
[581] | 118 | % set(handles.coord_x_vectors,'String',[{''} Txt ]) |
---|
| 119 | % set(handles.coord_y_vectors,'String',[{''} Txt ]) |
---|
| 120 | % set(handles.YVarName,'String',[{''} Txt ]) |
---|
| 121 | % set(handles.TimeVarName,'String',[{''} Txt ]) |
---|
[204] | 122 | set(handles.scalar,'Value',1) |
---|
[582] | 123 | set(handles.scalar,'String', Txt ) |
---|
[227] | 124 | |
---|
[582] | 125 | %% ananlyse the input field cells |
---|
[530] | 126 | [CellInfo,NbDim,errormsg]=find_field_cells(Field); |
---|
[204] | 127 | if ~isempty(errormsg) |
---|
[530] | 128 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
---|
[204] | 129 | return |
---|
| 130 | end |
---|
[582] | 131 | [Field.MaxDim,imax]=max(NbDim); |
---|
| 132 | % look at variables with a single dimension |
---|
| 133 | for ilist=1:numel(Field.VarDimName) |
---|
| 134 | if ischar(Field.VarDimName{ilist}) |
---|
| 135 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 136 | end |
---|
| 137 | NbDim=numel(Field.VarDimName{ilist});% TODO eliminate singleton dimensions |
---|
| 138 | check_singleton=false(1,NbDim); |
---|
| 139 | for idim=1:NbDim |
---|
| 140 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName); |
---|
| 141 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1); |
---|
| 142 | end |
---|
| 143 | Field.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton); |
---|
| 144 | Field.NbDim(ilist)=numel(Field.VarDimName{ilist}); |
---|
| 145 | if Field.NbDim(ilist)==1 |
---|
| 146 | Field.VarDimName{ilist}=cell2mat(Field.VarDimName{ilist}); |
---|
| 147 | end |
---|
| 148 | end |
---|
| 149 | SingleVarName=Field.ListVarName(Field.NbDim==1);%list of variables with a single dim |
---|
| 150 | MultiVarName=Field.ListVarName(Field.NbDim>1); |
---|
| 151 | check_dim=zeros(size(Field.VarDimName)); |
---|
| 152 | for ilist=1:numel(Field.VarDimName); |
---|
| 153 | if iscell(Field.VarDimName{ilist})% exclude single dim |
---|
| 154 | for idim=1:numel(Field.VarDimName{ilist}) |
---|
| 155 | check_dim=check_dim|strcmp(Field.VarDimName{ilist}{idim},Field.VarDimName); |
---|
| 156 | end |
---|
| 157 | end |
---|
| 158 | end |
---|
| 159 | Field.SingleVarName=Field.ListVarName(find(check_dim));%list of variables with a single dim |
---|
| 160 | Field.SingleDimName=Field.VarDimName(find(check_dim));% corresponding list of dimensions for variables with a single dim |
---|
| 161 | Field.MaxDim=max(Field.NbDim); |
---|
[581] | 162 | |
---|
| 163 | %% set time mode |
---|
[582] | 164 | ListSwitchVarIndexTime={'file index'}; |
---|
| 165 | % look at global attributes with numerical values |
---|
| 166 | check_numvalue=false; |
---|
| 167 | check_time=false; |
---|
| 168 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 169 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 170 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 171 | check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); |
---|
| 172 | end |
---|
| 173 | Field.ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 174 | if ~isempty(Field.ListNumAttributes) |
---|
| 175 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}]; |
---|
| 176 | end |
---|
| 177 | nboption=numel(ListSwitchVarIndexTime); |
---|
| 178 | if Field.MaxDim>=2 |
---|
| 179 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}]; |
---|
| 180 | end |
---|
| 181 | if Field.MaxDim>=4 |
---|
| 182 | option=nboption+1; |
---|
| 183 | elseif ~isempty(find(check_time, 1)) |
---|
| 184 | option=2; |
---|
[581] | 185 | else |
---|
[582] | 186 | option=1; |
---|
[581] | 187 | end |
---|
[582] | 188 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
| 189 | set(handles.SwitchVarIndexTime,'Value',option) |
---|
| 190 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[581] | 191 | SwitchVarIndexTime_Callback([],[], handles) |
---|
| 192 | |
---|
[582] | 193 | %% set z coordinate menu if relevant |
---|
| 194 | if Field.MaxDim>=3 |
---|
[204] | 195 | set(handles.vector_z,'Visible','on') |
---|
| 196 | set(handles.vector_z,'String',[{''} Txt ]) |
---|
[581] | 197 | set(handles.ZVarName,'Visible','on') |
---|
| 198 | set(handles.SwitchVarIndexZ,'Visible','on') |
---|
| 199 | set(handles.Z_title,'Visible','on') |
---|
[204] | 200 | else |
---|
| 201 | set(handles.vector_z,'Visible','off') |
---|
[581] | 202 | set(handles.ZVarName,'Visible','off') |
---|
| 203 | set(handles.SwitchVarIndexZ,'Visible','off') |
---|
| 204 | set(handles.Z_title,'Visible','off') |
---|
[204] | 205 | end |
---|
[582] | 206 | |
---|
| 207 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
| 208 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
---|
[503] | 209 | set(handles.CheckPlot1D,'Value',0) |
---|
[530] | 210 | if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
---|
[503] | 211 | set(handles.CheckVector,'Value',1) |
---|
| 212 | set(handles.CheckScalar,'Value',0) |
---|
[530] | 213 | set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) |
---|
| 214 | set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) |
---|
[204] | 215 | else |
---|
[503] | 216 | set(handles.CheckScalar,'Value',1) |
---|
| 217 | set(handles.CheckVector,'Value',0) |
---|
[204] | 218 | end |
---|
[582] | 219 | else % case of 1D fields |
---|
[581] | 220 | set(handles.CheckPlot1D,'Value',1) |
---|
| 221 | set(handles.CheckScalar,'Value',0) |
---|
| 222 | set(handles.CheckVector,'Value',0) |
---|
[204] | 223 | end |
---|
[582] | 224 | |
---|
| 225 | %% Make choices in menus from input |
---|
| 226 | if exist('ParamIn','var')&&~isempty(ParamIn) |
---|
| 227 | fill_GUI(ParamIn,handles); |
---|
[581] | 228 | end |
---|
| 229 | CheckPlot1D_Callback(handles.CheckPlot1D, [], handles) |
---|
| 230 | CheckScalar_Callback(handles.CheckScalar, [], handles) |
---|
| 231 | CheckVector_Callback(handles.CheckVector, [], handles) |
---|
[204] | 232 | |
---|
| 233 | %------------------------------------------------------------------------ |
---|
[582] | 234 | % --- Outputs from this function are returned to the command line. |
---|
| 235 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
| 236 | %------------------------------------------------------------------------ |
---|
| 237 | varargout{1} = handles.output; |
---|
| 238 | delete(handles.get_field) |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | % ----------------------------------------------------------------------- |
---|
| 242 | % --- Activated by selection in the list of variables |
---|
| 243 | function variables_Callback(hObject, eventdata, handles) |
---|
| 244 | % ----------------------------------------------------------------------- |
---|
| 245 | Tabchar={''};%default |
---|
| 246 | Tabcell=[]; |
---|
| 247 | hselect_field=get(handles.variables,'parent'); |
---|
| 248 | Field=get(handles.get_field,'UserData'); |
---|
| 249 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
| 250 | |
---|
| 251 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
---|
| 252 | if isequal(index,1) |
---|
| 253 | set(handles.attributes_txt,'String','global attributes') |
---|
| 254 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 255 | for iline=1:length(Field.ListGlobalAttribute) |
---|
| 256 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
| 257 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
| 258 | eval(['val=Field.' Field.ListGlobalAttribute{iline} ';']) |
---|
| 259 | if ischar(val);% attribute value is char string |
---|
| 260 | Tabcell{iline,2}=val; |
---|
| 261 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
| 262 | Tabcell{iline,2}=num2str(val); |
---|
| 263 | end |
---|
| 264 | end |
---|
| 265 | end |
---|
| 266 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 267 | end |
---|
| 268 | %% list Attribute names and values associated to the Variable # index-1 |
---|
| 269 | else |
---|
| 270 | list_var=get(handles.variables,'String'); |
---|
| 271 | var_select=list_var{index}; |
---|
| 272 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
| 273 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
| 274 | % nbline=0; |
---|
| 275 | VarAttr=Field.VarAttribute{index-1}; |
---|
| 276 | if isstruct(VarAttr) |
---|
| 277 | attr_list=fieldnames(VarAttr); |
---|
| 278 | for iline=1:length(attr_list) |
---|
| 279 | Tabcell{iline,1}=attr_list{iline}; |
---|
| 280 | eval(['val=VarAttr.' attr_list{iline} ';']) |
---|
| 281 | if ischar(val); |
---|
| 282 | Tabcell{iline,2}=val; |
---|
| 283 | else |
---|
| 284 | Tabcell{iline,2}=num2str(val); |
---|
| 285 | end |
---|
| 286 | end |
---|
| 287 | end |
---|
| 288 | end |
---|
| 289 | |
---|
| 290 | end |
---|
| 291 | if ~isempty(Tabcell) |
---|
| 292 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 293 | Tabchar=[{''};Tabchar]; |
---|
| 294 | end |
---|
| 295 | set(handles.attributes,'Value',1);% select the first item |
---|
| 296 | set(handles.attributes,'String',Tabchar); |
---|
| 297 | |
---|
| 298 | %% update dimensions; |
---|
| 299 | if isfield(Field,'ListDimName') |
---|
| 300 | Tabdim={};%default |
---|
| 301 | if isequal(index,1)%list all dimensions |
---|
| 302 | dim_indices=1:length(Field.ListDimName); |
---|
| 303 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
| 304 | else |
---|
| 305 | DimCell=Field.VarDimName{index-1}; |
---|
| 306 | if ischar(DimCell) |
---|
| 307 | DimCell={DimCell}; |
---|
| 308 | end |
---|
| 309 | dim_indices=[]; |
---|
| 310 | for idim=1:length(DimCell) |
---|
| 311 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
| 312 | dim_index=find(dim_index,1); |
---|
| 313 | dim_indices=[dim_indices dim_index]; |
---|
| 314 | end |
---|
| 315 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
| 316 | end |
---|
| 317 | for iline=1:length(dim_indices) |
---|
| 318 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
| 319 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
| 320 | end |
---|
| 321 | Tabchar=cell2tab(Tabdim,' = '); |
---|
| 322 | Tabchar=[{''} ;Tabchar]; |
---|
| 323 | set(handles.dimensions,'Value',1) |
---|
| 324 | set(handles.dimensions,'String',Tabchar) |
---|
| 325 | end |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | %------------------------------------------------------------------------ |
---|
| 330 | % --- Executes on button press in CheckPlot1D. |
---|
| 331 | function CheckPlot1D_Callback(hObject, eventdata, handles) |
---|
| 332 | %------------------------------------------------------------------------ |
---|
| 333 | val=get(handles.CheckPlot1D,'Value'); |
---|
| 334 | if isequal(val,0) |
---|
| 335 | set(handles.Panel1Dplot,'Visible','off') |
---|
| 336 | else |
---|
| 337 | set(handles.Panel1Dplot,'Visible','on') |
---|
| 338 | set(handles.PanelScalar,'Visible','off') |
---|
| 339 | set(handles.CheckScalar,'Value',0) |
---|
| 340 | set(handles.PanelVectors,'Visible','off') |
---|
| 341 | set(handles.CheckVector,'Value',0) |
---|
| 342 | set(handles.XVarName,'Visible','on') |
---|
| 343 | set(handles.SwitchVarIndexX,'Visible','on') |
---|
| 344 | set(handles.X_title,'Visible','on') |
---|
| 345 | set(handles.YVarName,'Visible','off') |
---|
| 346 | set(handles.SwitchVarIndexY,'Visible','off') |
---|
| 347 | set(handles.Y_title,'Visible','off') |
---|
| 348 | set(handles.ZVarName,'Visible','off') |
---|
| 349 | set(handles.SwitchVarIndexZ,'Visible','off') |
---|
| 350 | set(handles.Z_title,'Visible','off') |
---|
| 351 | ordinate_Callback(hObject, eventdata, handles) |
---|
| 352 | end |
---|
| 353 | |
---|
| 354 | %------------------------------------------------------------------------ |
---|
[204] | 355 | function ordinate_Callback(hObject, eventdata, handles) |
---|
| 356 | %------------------------------------------------------------------------ |
---|
[582] | 357 | Field=get(handles.get_field,'UserData'); |
---|
[204] | 358 | list=get(handles.ordinate,'String'); |
---|
| 359 | yindex=get(handles.ordinate,'Value'); |
---|
| 360 | yindex=name2index(list{yindex(1)},Field.ListVarName); |
---|
| 361 | if ~isempty(yindex) |
---|
| 362 | set(handles.variables,'Value',yindex+1) |
---|
| 363 | variables_Callback(hObject, eventdata, handles) |
---|
| 364 | end |
---|
[530] | 365 | [CellInfo,NbDim,errormsg]=find_field_cells(Field); |
---|
| 366 | %[CellVarIndex,NbDim,VarRole,errormsg]=find_field_cells(Field); |
---|
[582] | 367 | for icell=1:numel(CellInfo) |
---|
| 368 | VarIndex=CellInfo{icell}.VarIndex; |
---|
| 369 | if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarRole{icell}.coord_x)||~isequal(VarRole{icell}.coord_x,VarIndex)) |
---|
| 370 | cell_select=icell; |
---|
| 371 | break |
---|
| 372 | end |
---|
| 373 | end |
---|
| 374 | val=get(handles.abscissa,'Value'); |
---|
| 375 | set(handles.abscissa,'Value',min(val,2)); |
---|
| 376 | coord_x_index=VarRole{cell_select}.coord; |
---|
| 377 | coord_x_index=coord_x_index(coord_x_index~=0); |
---|
| 378 | set(handles.XVarname,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) |
---|
[204] | 379 | |
---|
| 380 | %------------------------------------------------------------------------ |
---|
[582] | 381 | % --- Executes on button press in CheckScalar. |
---|
| 382 | function CheckScalar_Callback(hObject, eventdata, handles) |
---|
[204] | 383 | %------------------------------------------------------------------------ |
---|
[582] | 384 | val=get(handles.CheckScalar,'Value'); |
---|
| 385 | if isequal(val,0) |
---|
| 386 | set(handles.PanelScalar,'Visible','off') |
---|
| 387 | else |
---|
| 388 | set(handles.Panel1Dplot,'Visible','off') |
---|
| 389 | set(handles.CheckPlot1D,'Value',0) |
---|
| 390 | set(handles.PanelScalar,'Visible','on') |
---|
| 391 | set(handles.PanelVectors,'Visible','off') |
---|
| 392 | set(handles.CheckVector,'Value',0) |
---|
| 393 | end |
---|
[204] | 394 | |
---|
| 395 | %------------------------------------------------------------------------ |
---|
[582] | 396 | % --- Executes on button press in CheckVector. |
---|
| 397 | function CheckVector_Callback(hObject, eventdata, handles) |
---|
| 398 | %------------------------------------------------------------------------ |
---|
| 399 | val=get(handles.CheckVector,'Value'); |
---|
| 400 | if isequal(val,0) |
---|
| 401 | set(handles.PanelVectors,'Visible','off') |
---|
| 402 | else |
---|
| 403 | set(handles.Panel1Dplot,'Visible','off') |
---|
| 404 | set(handles.CheckPlot1D,'Value',0) |
---|
| 405 | set(handles.PanelScalar,'Visible','off') |
---|
| 406 | set(handles.CheckScalar,'Value',0) |
---|
| 407 | set(handles.PanelVectors,'Visible','on') |
---|
| 408 | end |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | %------------------------------------------------------------------------ |
---|
[204] | 412 | % --- Executes on selection change in scalar menu. |
---|
| 413 | function scalar_Callback(hObject, eventdata, handles) |
---|
| 414 | %------------------------------------------------------------------------ |
---|
[227] | 415 | index=get(handles.scalar,'Value'); |
---|
| 416 | string=get(handles.scalar,'String'); |
---|
| 417 | VarName=string{index}; |
---|
[204] | 418 | update_field(hObject, eventdata, handles,VarName) |
---|
| 419 | |
---|
[227] | 420 | %eliminate time |
---|
| 421 | TimeDimName='';%default |
---|
| 422 | if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on') |
---|
| 423 | TimeDimList=get(handles.TimeDimensionMenu,'String'); |
---|
| 424 | TimeDimIndex=get(handles.TimeDimensionMenu,'Value'); |
---|
| 425 | TimeDimName=TimeDimList{TimeDimIndex}; |
---|
| 426 | end |
---|
| 427 | |
---|
| 428 | %check possible coordinates |
---|
| 429 | Field=get(handles.get_field,'UserData'); |
---|
| 430 | dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar |
---|
| 431 | test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate |
---|
| 432 | for ilist=1:numel(Field.VarDimName) |
---|
| 433 | dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 434 | if isequal(dimnames,{TimeDimName}) |
---|
| 435 | test_coord(ilist)=0;%mark time variables fo elimination |
---|
| 436 | end |
---|
| 437 | for idim=1:numel(dimnames) |
---|
| 438 | if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable |
---|
| 439 | test_coord(ilist)=0; |
---|
| 440 | break |
---|
| 441 | end |
---|
| 442 | end |
---|
| 443 | end |
---|
| 444 | test_coord(index)=0;%the coordinate variable must be different from the scalar |
---|
| 445 | |
---|
| 446 | string_coord=[{''};string(test_coord==1)]; |
---|
[581] | 447 | val=get(handles.XVarName,'Value'); |
---|
[227] | 448 | if val>numel(string_coord) |
---|
[581] | 449 | set(handles.XVarName,'Value',1) |
---|
[227] | 450 | end |
---|
[581] | 451 | set(handles.XVarName,'String',string_coord); |
---|
| 452 | val=get(handles.ZVarName,'Value'); |
---|
[227] | 453 | if val>numel(string_coord) |
---|
[581] | 454 | set(handles.ZVarName,'Value',1) |
---|
[227] | 455 | end |
---|
[581] | 456 | set(handles.ZVarName,'String',string_coord); |
---|
| 457 | val=get(handles.ZVarName,'Value'); |
---|
[227] | 458 | if val>numel(string_coord) |
---|
[581] | 459 | set(handles.ZVarName,'Value',1) |
---|
[227] | 460 | end |
---|
[581] | 461 | set(handles.YVarName,'String',string_coord); |
---|
[227] | 462 | |
---|
| 463 | |
---|
[204] | 464 | %------------------------------------------------------------------------ |
---|
[582] | 465 | % --- Executes on selection change in abscissa. |
---|
| 466 | function abscissa_Callback(hObject, eventdata, handles) |
---|
| 467 | %------------------------------------------------------------------------ |
---|
| 468 | hselect_field=get(handles.inputfile,'parent'); |
---|
| 469 | Field=get(hselect_field,'UserData');%current input field |
---|
| 470 | xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa |
---|
| 471 | % test_2D=get(handles.CheckVector,'Value');% =1 for vector fields |
---|
| 472 | % test_scalar=get(handles.CheckScalar,'Value');% =1 for scalar fields |
---|
| 473 | %if isequal(xdispindex,1)% blank selection, no selected TimeVariable for abscissa |
---|
| 474 | % Txt=Field.ListVarName; |
---|
| 475 | % set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates |
---|
| 476 | % xindex=[]; |
---|
| 477 | % else |
---|
| 478 | xlist=get(handles.abscissa,'String');%list of abscissa |
---|
| 479 | VarName=xlist{xdispindex}; %selected variable name |
---|
| 480 | update_field(hObject, eventdata, handles,VarName) |
---|
| 481 | % xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables |
---|
| 482 | % if ~isempty(xindex) |
---|
| 483 | % set(handles.variables,'Value',xindex+1) |
---|
| 484 | % variables_Callback(hObject, eventdata, handles) |
---|
| 485 | % end |
---|
| 486 | % set(handles.variables,'Value',xindex+1)%outline in the list of variables |
---|
| 487 | % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) |
---|
| 488 | % if ~test_2D & ~test_scalar% look for possible varaibles to OK in ordinate |
---|
| 489 | % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa |
---|
| 490 | % VarIndex=[]; |
---|
| 491 | % for ilist=1:length(Field.VarDimIndex)%detect |
---|
| 492 | % index_i=Field.VarDimIndex{ilist}; |
---|
| 493 | % if ~isempty(index_i) |
---|
| 494 | % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible |
---|
| 495 | % VarIndex=[VarIndex ilist]; |
---|
| 496 | % end |
---|
| 497 | % end |
---|
| 498 | % end |
---|
| 499 | % % set(handles.ordinate,'Value',1) |
---|
| 500 | % set(handles.ordinate,'String',Field.ListVarName(VarIndex)) |
---|
| 501 | % end |
---|
| 502 | % end |
---|
| 503 | % |
---|
| 504 | % update_UserData(handles) |
---|
| 505 | |
---|
| 506 | |
---|
| 507 | |
---|
| 508 | %------------------------------------------------------------------------ |
---|
[581] | 509 | % --- Executes on selection change in XVarName. |
---|
| 510 | function XVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 511 | %------------------------------------------------------------------------ |
---|
[581] | 512 | index=get(handles.XVarName,'Value'); |
---|
| 513 | string=get(handles.XVarName,'String'); |
---|
[204] | 514 | VarName=string{index}; |
---|
| 515 | update_field(hObject, eventdata, handles,VarName) |
---|
| 516 | |
---|
| 517 | %------------------------------------------------------------------------ |
---|
[581] | 518 | % --- Executes on selection change in ZVarName. |
---|
| 519 | function ZVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 520 | %------------------------------------------------------------------------ |
---|
[581] | 521 | index=get(handles.ZVarName,'Value'); |
---|
| 522 | string=get(handles.ZVarName,'String'); |
---|
[204] | 523 | VarName=string{index}; |
---|
| 524 | update_field(hObject, eventdata, handles,VarName) |
---|
| 525 | |
---|
| 526 | %------------------------------------------------------------------------ |
---|
[581] | 527 | % --- Executes on selection change in YVarName. |
---|
| 528 | function YVarName_Callback(hObject, eventdata, handles) |
---|
[204] | 529 | %------------------------------------------------------------------------ |
---|
[581] | 530 | index=get(handles.YVarName,'Value'); |
---|
| 531 | string=get(handles.YVarName,'String'); |
---|
[204] | 532 | VarName=string{index}; |
---|
| 533 | update_field(hObject, eventdata, handles,VarName) |
---|
| 534 | |
---|
| 535 | %------------------------------------------------------------------------ |
---|
| 536 | % --- Executes on selection change in vector_x. |
---|
| 537 | function vector_x_Callback(hObject, eventdata, handles) |
---|
| 538 | %------------------------------------------------------------------------ |
---|
| 539 | index=get(handles.vector_x,'Value'); |
---|
| 540 | string=get(handles.vector_x,'String'); |
---|
| 541 | VarName=string{index}; |
---|
[227] | 542 | |
---|
| 543 | %check possible coordinates |
---|
| 544 | Field=get(handles.get_field,'UserData'); |
---|
[582] | 545 | dim_var=Field.VarDimName{index};%list of dimensions of the selected variable |
---|
[227] | 546 | test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate |
---|
| 547 | test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component |
---|
| 548 | for ilist=1:numel(Field.VarDimName) |
---|
| 549 | dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 550 | if ~isequal(dimnames,dim_var) |
---|
| 551 | test_component(ilist)=0; |
---|
| 552 | end |
---|
| 553 | for idim=1:numel(dimnames) |
---|
| 554 | if isempty(find(strcmp(dimnames{idim},dim_var),1))%dimension not found in the scalar variable |
---|
| 555 | test_coord(ilist)=0; |
---|
| 556 | break |
---|
| 557 | end |
---|
| 558 | end |
---|
| 559 | end |
---|
| 560 | %eliminate time |
---|
| 561 | if get(handles.TimeVariable,'Value') |
---|
| 562 | TimeName=get(handles.TimeName,'String'); |
---|
| 563 | index_time=find(strcmp( TimeName,Field.ListVarName)); |
---|
| 564 | test_coord(index_time)=0; |
---|
| 565 | end |
---|
| 566 | vlength=numel(string(test_component==1)); |
---|
| 567 | val=get(handles.vector_y,'Value'); |
---|
| 568 | if val>vlength |
---|
| 569 | set(handles.vector_y,'Value',1) |
---|
| 570 | end |
---|
| 571 | set(handles.vector_y,'String',[string(test_component==1)]) |
---|
| 572 | val=get(handles.vector_z,'Value'); |
---|
| 573 | if val>vlength+1 |
---|
| 574 | set(handles.vector_z,'Value',1) |
---|
| 575 | end |
---|
| 576 | set(handles.vector_z,'String',[{''};string(test_component==1)]) |
---|
| 577 | val=get(handles.vec_color,'Value'); |
---|
| 578 | if val>vlength+1 |
---|
| 579 | set(handles.vec_color,'Value',1) |
---|
| 580 | end |
---|
| 581 | set(handles.vec_color,'String',[{''};string(test_component==1)]) |
---|
| 582 | string_coord=[{''};string(test_coord==1)]; |
---|
[582] | 583 | val=get(handles.XVarName,'Value'); |
---|
[227] | 584 | if val>numel(string_coord) |
---|
[582] | 585 | set(handles.XVarName,'Value',1) |
---|
[227] | 586 | end |
---|
[582] | 587 | set(handles.XVarName,'Visible','on'); |
---|
| 588 | set(handles.XVarName,'String',string_coord); |
---|
| 589 | val=get(handles.YVarName,'Value'); |
---|
[227] | 590 | if val>numel(string_coord) |
---|
[582] | 591 | set(handles.YVarName,'Value',1) |
---|
[227] | 592 | end |
---|
[582] | 593 | set(handles.YVarName,'Visible','on'); |
---|
| 594 | set(handles.YVarName,'String',string_coord); |
---|
[581] | 595 | val=get(handles.TimeVarName,'Value'); |
---|
[227] | 596 | if val>numel(string_coord) |
---|
[581] | 597 | set(handles.TimeVarName,'Value',1) |
---|
[227] | 598 | end |
---|
[581] | 599 | set(handles.TimeVarName,'String',string_coord); |
---|
[227] | 600 | |
---|
[204] | 601 | update_field(hObject, eventdata, handles,VarName) |
---|
| 602 | |
---|
| 603 | %------------------------------------------------------------------------ |
---|
| 604 | % --- Executes on selection change in vector_y. |
---|
| 605 | function vector_y_Callback(hObject, eventdata, handles) |
---|
| 606 | %------------------------------------------------------------------------ |
---|
| 607 | index=get(handles.vector_y,'Value'); |
---|
| 608 | string=get(handles.vector_y,'String'); |
---|
| 609 | VarName=string{index}; |
---|
| 610 | update_field(hObject, eventdata, handles,VarName) |
---|
| 611 | |
---|
| 612 | %------------------------------------------------------------------------ |
---|
| 613 | % --- Executes on selection change in vector_z. |
---|
| 614 | function vector_z_Callback(hObject, eventdata, handles) |
---|
| 615 | %------------------------------------------------------------------------ |
---|
| 616 | index=get(handles.vector_z,'Value'); |
---|
| 617 | string=get(handles.vector_z,'String'); |
---|
| 618 | VarName=Astring{index}; |
---|
| 619 | update_field(hObject, eventdata, handles,VarName) |
---|
| 620 | |
---|
| 621 | %------------------------------------------------------------------------ |
---|
| 622 | % --- Executes on selection change in coord_x_vectors. |
---|
| 623 | function coord_x_vectors_Callback(hObject, eventdata, handles) |
---|
| 624 | %------------------------------------------------------------------------ |
---|
| 625 | index=get(handles.coord_x_vectors,'Value'); |
---|
| 626 | string=get(handles.coord_x_vectors,'String'); |
---|
| 627 | VarName=string{index}; |
---|
| 628 | update_field(hObject, eventdata, handles,VarName) |
---|
| 629 | |
---|
[227] | 630 | %------------------------------------------------------------------------ |
---|
[204] | 631 | % --- Executes on selection change in coord_y_vectors. |
---|
| 632 | function coord_y_vectors_Callback(hObject, eventdata, handles) |
---|
[227] | 633 | %------------------------------------------------------------------------ |
---|
[204] | 634 | index=get(handles.coord_y_vectors,'Value'); |
---|
| 635 | string=get(handles.coord_y_vectors,'String'); |
---|
| 636 | VarName=string{index}; |
---|
| 637 | update_field(hObject, eventdata, handles,VarName) |
---|
| 638 | |
---|
[227] | 639 | %------------------------------------------------------------------------ |
---|
[581] | 640 | % --- Executes on selection change in YVarName. |
---|
| 641 | function TimeVarName_Callback(hObject, eventdata, handles) |
---|
[227] | 642 | %------------------------------------------------------------------------ |
---|
[581] | 643 | index=get(handles.TimeVarName,'Value'); |
---|
| 644 | string=get(handles.TimeVarName,'String'); |
---|
[204] | 645 | VarName=string{index}; |
---|
| 646 | update_field(hObject, eventdata, handles,VarName) |
---|
| 647 | |
---|
[227] | 648 | %------------------------------------------------------------------------ |
---|
[204] | 649 | % --- Executes on selection change in vec_color. |
---|
| 650 | function vec_color_Callback(hObject, eventdata, handles) |
---|
[227] | 651 | %------------------------------------------------------------------------ |
---|
[204] | 652 | index=get(handles.vec_color,'Value'); |
---|
| 653 | string=get(handles.vec_color,'String'); |
---|
| 654 | VarName=string{index}; |
---|
| 655 | update_field(hObject, eventdata, handles,VarName) |
---|
| 656 | |
---|
[227] | 657 | %----------------------------------------------------------------------- |
---|
[204] | 658 | function update_field(hObject, eventdata, handles,VarName) |
---|
[227] | 659 | %----------------------------------------------------------------------- |
---|
| 660 | Field=get(handles.get_field,'UserData'); |
---|
[204] | 661 | index=name2index(VarName,Field.ListVarName); |
---|
| 662 | if ~isempty(index) |
---|
| 663 | set(handles.variables,'Value',index+1) |
---|
| 664 | variables_Callback(hObject, eventdata, handles) |
---|
| 665 | end |
---|
| 666 | |
---|
[227] | 667 | %------------------------------------------------------------------------ |
---|
[204] | 668 | % update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback) |
---|
| 669 | function update_UserData(handles) |
---|
[227] | 670 | %------------------------------------------------------------------------ |
---|
[204] | 671 | return |
---|
| 672 | % global SubField |
---|
| 673 | hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface |
---|
| 674 | Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface |
---|
| 675 | if isfield(Field,'VarAttribute') |
---|
| 676 | VarAttribute=Field.VarAttribute; |
---|
| 677 | else |
---|
| 678 | VarAttribute={}; |
---|
| 679 | end |
---|
| 680 | |
---|
| 681 | |
---|
| 682 | % select the indices of field variables for 2D plots |
---|
[503] | 683 | test_CheckPlot1D=get(handles.CheckPlot1D,'Value'); |
---|
| 684 | test_scalar=get(handles.CheckScalar,'Value'); |
---|
| 685 | test_vector=get(handles.CheckVector,'Value'); |
---|
[204] | 686 | |
---|
| 687 | %transform if needed (calibration) |
---|
| 688 | list=get(handles.menu_coord,'String'); |
---|
| 689 | index=get(handles.menu_coord,'Value'); |
---|
| 690 | transform=list{index}; |
---|
| 691 | if ~isequal(transform,'') |
---|
| 692 | Field=feval(transform,Field); |
---|
| 693 | end |
---|
| 694 | VarIndex.u=[]; |
---|
| 695 | VarIndex.v=[]; |
---|
| 696 | VarIndex.w=[]; |
---|
| 697 | VarIndex.A=[]; |
---|
| 698 | VarIndex_tot=[]; |
---|
| 699 | iuA=[]; |
---|
| 700 | if test_scalar |
---|
| 701 | Astring=get(handles.scalar,'String'); |
---|
| 702 | Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox |
---|
| 703 | list_var=Astring(Aindex); |
---|
| 704 | VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName |
---|
| 705 | VarIndex_tot= [VarIndex_tot VarIndex.A]; |
---|
| 706 | DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable |
---|
| 707 | DimValue=Field.DimValue(DimIndex); |
---|
| 708 | ind=find(DimValue==1); |
---|
| 709 | DimIndex(ind)=[];%Mremove singleton |
---|
| 710 | end |
---|
| 711 | if test_vector |
---|
| 712 | Ustring=get(handles.vector_x,'String'); |
---|
| 713 | Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox |
---|
| 714 | list_var=Ustring{Uindex};%name of the selected scalar |
---|
| 715 | VarIndex.u=name2index(list_var,Field.ListVarName); |
---|
| 716 | Vstring=get(handles.vector_y,'String'); |
---|
| 717 | Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox |
---|
| 718 | list_var=Ustring{Vindex};%name of the selected scalar |
---|
| 719 | VarIndex.v=name2index(list_var,Field.ListVarName); |
---|
| 720 | if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A) |
---|
| 721 | iuA=VarIndex.A; %same variable used for vector and scalar |
---|
| 722 | VarIndex_tot(iuA)=[]; |
---|
| 723 | end |
---|
| 724 | VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v]; |
---|
| 725 | %dimensions |
---|
| 726 | DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable |
---|
| 727 | DimValue=Field.DimValue(DimIndex_u); |
---|
| 728 | ind=find(DimValue==1); |
---|
| 729 | DimIndex_u(ind)=[];%Mremove singleton |
---|
| 730 | DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable |
---|
| 731 | DimValue=Field.DimValue(DimIndex_v); |
---|
| 732 | ind=find(DimValue==1); |
---|
| 733 | DimIndex_v(ind)=[];%Mremove singleton |
---|
| 734 | if ~isequal(DimIndex_u,DimIndex_v) |
---|
| 735 | msgbox_uvmat('ERROR','inconsistent dimensions for u and v') |
---|
| 736 | set(handles.vector_y,'Value',1); |
---|
| 737 | return |
---|
| 738 | elseif test_scalar & ~isequal(DimIndex_u,DimIndex) |
---|
| 739 | msgbox_uvmat('ERROR','inconsistent dimensions for vector and scalar represented as vector color') |
---|
| 740 | set(handles.scalar,'Value',1); |
---|
| 741 | return |
---|
| 742 | end |
---|
| 743 | DimIndex=DimIndex_u; |
---|
[227] | 744 | %TODO possibility of selecting 3 times the same TimeVariable for u, v, w components |
---|
[204] | 745 | end |
---|
| 746 | |
---|
| 747 | |
---|
[227] | 748 | % select the TimeVariable index (or indices) for z coordinates |
---|
[204] | 749 | test_grid=0; |
---|
| 750 | if test_scalar | test_vector |
---|
| 751 | nbdim=length(DimIndex); |
---|
| 752 | if nbdim > 3 |
---|
| 753 | msgbox_uvmat('ERROR','array with more than three dimensions, not supported') |
---|
| 754 | return |
---|
| 755 | else |
---|
[213] | 756 | perm_ind=1:nbdim; |
---|
[204] | 757 | end |
---|
| 758 | if nbdim==3 |
---|
| 759 | zstring=get(handles.coord_z_vectors_scalar,'String'); |
---|
| 760 | zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox |
---|
| 761 | list_var=zstring(zindex); |
---|
| 762 | VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable |
---|
| 763 | if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z) |
---|
| 764 | if zindex ~= 1 |
---|
| 765 | set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
| 766 | return |
---|
| 767 | end |
---|
| 768 | else |
---|
| 769 | VarIndex_tot=[VarIndex_tot VarIndex_z]; |
---|
| 770 | DimIndex_z=Field.VarDimIndex{VarIndex_z}; |
---|
| 771 | DimValue=Field.DimValue(DimIndex_z); |
---|
| 772 | ind=find(DimValue==1); |
---|
| 773 | DimIndex_z(ind)=[];%Mremove singleton |
---|
| 774 | if isequal(DimIndex_z,DimIndex) |
---|
| 775 | VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates |
---|
| 776 | elseif length(DimIndex_z)==1 |
---|
| 777 | VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; %dimension variable |
---|
| 778 | ind_z=find(DimIndex==DimIndex_z(1)); |
---|
| 779 | perm_ind(ind_z)=1; |
---|
| 780 | test_grid=1; |
---|
| 781 | else |
---|
| 782 | msgbox_uvmat('ERROR','multiple dimensions for the z coordinate') |
---|
| 783 | return |
---|
| 784 | end |
---|
| 785 | end |
---|
| 786 | % if ~isempty(VarIndex_z) |
---|
[227] | 787 | % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the TimeVariable |
---|
| 788 | % if length(DimIndex_z)==1 & nbdim==3 %dimension TimeVariable |
---|
[204] | 789 | % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; |
---|
| 790 | % ind_z=find(DimIndex==DimIndex_z(1)); |
---|
| 791 | % perm_ind(ind_z)=1; |
---|
| 792 | % test_grid=1; |
---|
| 793 | % end |
---|
| 794 | % end |
---|
| 795 | end |
---|
| 796 | end |
---|
| 797 | |
---|
[227] | 798 | % select the TimeVariable index (or indices) for ordinate |
---|
[204] | 799 | ystring=get(handles.ordinate,'String'); |
---|
| 800 | yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox |
---|
| 801 | list_var=ystring(yindex); |
---|
| 802 | VarIndex.y=name2index(list_var,Field.ListVarName); |
---|
| 803 | if isequal(VarIndex.A,VarIndex.y) |
---|
[581] | 804 | set(handles.ZVarName,'Value',1) |
---|
[204] | 805 | elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) |
---|
| 806 | set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components |
---|
| 807 | else |
---|
| 808 | for ivar=1:length(VarIndex.y) |
---|
| 809 | VarAttribute{VarIndex.y(ivar)}.Role='coord_y'; |
---|
| 810 | end |
---|
| 811 | VarIndex_tot=[VarIndex_tot VarIndex.y]; |
---|
| 812 | end |
---|
| 813 | if (test_scalar | test_vector) & ~isempty(VarIndex.y) |
---|
| 814 | DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable |
---|
| 815 | if length(DimIndex_y)==1 |
---|
| 816 | ind_y=find(DimIndex==DimIndex_y(1)); |
---|
| 817 | test_grid=1; |
---|
| 818 | if nbdim==3 |
---|
| 819 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
| 820 | perm_ind(ind_y)=2; |
---|
| 821 | elseif nbdim==2 |
---|
| 822 | VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; |
---|
| 823 | perm_ind(ind_y)=1; |
---|
| 824 | end |
---|
| 825 | elseif test_grid |
---|
| 826 | msgbox_uvmat('ERROR','the dimension of the y coordinate variable should be 1') |
---|
| 827 | end |
---|
| 828 | end |
---|
| 829 | |
---|
[227] | 830 | %select the TimeVariable index for the abscissa |
---|
[204] | 831 | xstring=get(handles.abscissa,'String'); |
---|
| 832 | xindex=get(handles.abscissa,'Value'); |
---|
| 833 | list_var=xstring(xindex); |
---|
| 834 | VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var |
---|
| 835 | if length(VarIndex.x)==1 |
---|
| 836 | DimIndex_x=Field.VarDimIndex{VarIndex.x}; |
---|
| 837 | DimValue=Field.DimValue(DimIndex_x); |
---|
| 838 | ind=find(DimValue==1); |
---|
| 839 | DimIndex_x(ind)=[];%Mremove singleton |
---|
| 840 | VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; %dimension variable |
---|
| 841 | % VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified) |
---|
| 842 | index_detect=find(VarIndex_tot==VarIndex.x); |
---|
| 843 | else |
---|
| 844 | index_detect=[];%coord x variable not already used |
---|
| 845 | end |
---|
| 846 | if isempty(index_detect) |
---|
| 847 | VarIndex_tot=[VarIndex_tot VarIndex.x]; |
---|
[503] | 848 | elseif ~test_CheckPlot1D |
---|
[204] | 849 | VarIndex.x=[]; |
---|
| 850 | set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa |
---|
| 851 | end |
---|
| 852 | |
---|
| 853 | if (test_scalar | test_vector) & ~isempty(VarIndex.x) |
---|
| 854 | DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable |
---|
| 855 | if length(DimIndex_x)==1 |
---|
| 856 | ind_x=find(DimIndex==DimIndex_x(1)); |
---|
| 857 | if nbdim==3 |
---|
| 858 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
| 859 | perm_ind(ind_x)=3; |
---|
| 860 | elseif nbdim==2 |
---|
| 861 | %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; |
---|
| 862 | perm_ind(ind_x)=2; |
---|
| 863 | end |
---|
| 864 | if isequal(perm_ind,1:nbdim) |
---|
| 865 | test_grid=0; |
---|
| 866 | end |
---|
| 867 | DimIndex=DimIndex(perm_ind); |
---|
| 868 | elseif test_grid |
---|
| 869 | msgbox_uvmat('ERROR','the dimension of the x coordinate variable should be 1') |
---|
| 870 | end |
---|
| 871 | if isequal(DimIndex_x,DimIndex) |
---|
| 872 | VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates |
---|
| 873 | end |
---|
| 874 | end |
---|
| 875 | |
---|
| 876 | %defined the selected sub-field SubField |
---|
| 877 | SubField.ListGlobalAttribute{1}='InputFile'; |
---|
| 878 | SubField.InputFile=get(handles.inputfile,'String'); |
---|
| 879 | SubField.ListDimName=Field.ListDimName; |
---|
| 880 | SubField.DimValue=Field.DimValue; |
---|
| 881 | SubField.ListVarName=Field.ListVarName(VarIndex_tot); |
---|
| 882 | SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot); |
---|
| 883 | |
---|
| 884 | testperm=0; |
---|
| 885 | testattr=0; |
---|
| 886 | for ivar=VarIndex.u |
---|
| 887 | VarAttribute{ivar}.Role='vector_x'; |
---|
| 888 | testattr=1; |
---|
| 889 | if test_grid |
---|
| 890 | VarDimIndex{ivar}=DimIndex; %permute dimensions |
---|
| 891 | testperm=1; |
---|
| 892 | end |
---|
| 893 | end |
---|
| 894 | for ivar=VarIndex.v |
---|
| 895 | VarAttribute{ivar}.Role='vector_y'; |
---|
| 896 | testattr=1; |
---|
| 897 | if test_grid |
---|
| 898 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
| 899 | testperm=1; |
---|
| 900 | end |
---|
| 901 | end |
---|
| 902 | for ivar=VarIndex.A |
---|
| 903 | if test_grid |
---|
| 904 | VarDimIndex{ivar}=DimIndex;%permute dimensions |
---|
| 905 | testperm=1; |
---|
| 906 | end |
---|
| 907 | if isempty(iuA) |
---|
| 908 | VarAttribute{ivar}.Role='scalar';%Role =scalar |
---|
| 909 | testattr=1; |
---|
| 910 | else |
---|
| 911 | VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable |
---|
| 912 | nbattr=length(VarAttribute); |
---|
| 913 | VarAttribute{nbattr}.Role='scalar'; |
---|
| 914 | testattr=1; |
---|
| 915 | end |
---|
| 916 | end |
---|
| 917 | if testperm |
---|
| 918 | SubField.VarDimIndex=VarDimIndex(VarIndex_tot); |
---|
| 919 | end |
---|
| 920 | if testattr |
---|
| 921 | SubField.VarAttribute=VarAttribute(VarIndex_tot); |
---|
| 922 | end |
---|
| 923 | set(hselect_field,'UserData',Field) |
---|
| 924 | |
---|
| 925 | %--------------------------------------------------------- |
---|
[581] | 926 | % --- Executes on button press in OK. |
---|
[204] | 927 | |
---|
[581] | 928 | function OK_Callback(hObject, eventdata, handles) |
---|
[204] | 929 | %--------------------------------------------------------- |
---|
[581] | 930 | |
---|
| 931 | handles.output=read_GUI(handles.get_field); |
---|
| 932 | guidata(hObject, handles);% Update handles structure |
---|
| 933 | uiresume(handles.get_field); |
---|
| 934 | drawnow |
---|
| 935 | return |
---|
| 936 | |
---|
| 937 | %%%% SKIPPED %%%% |
---|
[526] | 938 | hfield=[]; |
---|
[517] | 939 | huvmat=findobj(allchild(0),'tag','uvmat'); |
---|
[526] | 940 | hseries=findobj(allchild(0),'tag','series'); |
---|
| 941 | check_series=0; |
---|
[528] | 942 | % look for the status of the GUI uvmat |
---|
[517] | 943 | if ~isempty(huvmat) |
---|
[526] | 944 | hh=guidata(huvmat); |
---|
| 945 | FieldMenu=get(hh.FieldName,'String'); |
---|
| 946 | FieldName=FieldMenu{get(hh.FieldName,'Value')}; |
---|
| 947 | if strcmp(FieldName,'get_field...') |
---|
| 948 | hfield=hh.FieldName; %FieldName on uvmat |
---|
| 949 | elseif strcmp(get(hh.FieldName_1,'Visible'),'on') |
---|
| 950 | FieldMenu=get(hh.FieldName_1,'String'); |
---|
| 951 | if ~isempty(FieldMenu) |
---|
| 952 | FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; |
---|
| 953 | if strcmp(FieldName,'get_field...') |
---|
| 954 | hfield=hh.FieldName_1; %FieldName_1 on uvmat |
---|
| 955 | end |
---|
| 956 | end |
---|
| 957 | end |
---|
[204] | 958 | end |
---|
[528] | 959 | % if no filed data is concerned on uvmat, look at the GUI series |
---|
[526] | 960 | if isempty(hfield) && ~isempty(hseries) |
---|
| 961 | check_series=1; |
---|
[528] | 962 | hh=guidata(hseries); |
---|
[526] | 963 | FieldMenu=get(hh.FieldName,'String'); |
---|
| 964 | FieldName=FieldMenu{get(hh.FieldName,'Value')}; |
---|
| 965 | if strcmp(FieldName,'get_field...') |
---|
| 966 | hfield=hh.FieldName; %FieldName on series |
---|
| 967 | else |
---|
| 968 | FieldMenu=get(hh.FieldName_1,'String'); |
---|
| 969 | FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; |
---|
| 970 | if strcmp(FieldName,'get_field...') |
---|
| 971 | hfield=hh.FieldName_1; %FieldName_1 on series |
---|
| 972 | end |
---|
| 973 | end |
---|
| 974 | end |
---|
| 975 | if ~isempty(hfield) |
---|
| 976 | get_field_GUI=read_GUI(handles.get_field); |
---|
| 977 | if isfield(get_field_GUI,'PanelVectors') |
---|
| 978 | set(hh.Coord_x,'value',1) |
---|
| 979 | set(hh.Coord_y,'value',1) |
---|
| 980 | set(hh.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors}) |
---|
| 981 | set(hh.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors}) |
---|
| 982 | UName=get_field_GUI.PanelVectors.vector_x; |
---|
| 983 | VName=get_field_GUI.PanelVectors.vector_y; |
---|
| 984 | menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}]; |
---|
| 985 | menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}]; |
---|
| 986 | set(hfield,'Value',1) |
---|
| 987 | set(hfield,'String',menu_str) |
---|
| 988 | if ~check_series |
---|
| 989 | ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color)); |
---|
| 990 | if ~isempty(ind_menu) |
---|
| 991 | set(hh.ColorScalar,'Value',ind_menu) |
---|
| 992 | else |
---|
| 993 | set(hh.ColorScalar,'Value',1) |
---|
| 994 | end |
---|
| 995 | set(hh.ColorScalar,'String',menu_color) |
---|
| 996 | end |
---|
| 997 | elseif isfield(get_field_GUI,'PanelScalar') |
---|
| 998 | set(hh.Coord_x,'value',1) |
---|
| 999 | set(hh.Coord_y,'value',1) |
---|
| 1000 | set(hh.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar}) |
---|
| 1001 | set(hh.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar}) |
---|
| 1002 | AName=get_field_GUI.PanelScalar.scalar; |
---|
| 1003 | menu=get(hfield,'String'); |
---|
| 1004 | ind_select=find(strcmp(AName,menu)); |
---|
| 1005 | if isempty(ind_select) |
---|
| 1006 | menu=[menu(1:end-1);{AName};{'get_field...'}]; |
---|
| 1007 | ind_select=numel(menu)-1; |
---|
| 1008 | end |
---|
| 1009 | set(hfield,'Value',ind_select); |
---|
| 1010 | set(hfield,'String',menu); |
---|
| 1011 | elseif isfield(get_field_GUI,'Panel1Dplot') |
---|
| 1012 | set(hh.Coord_x,'Value',1) |
---|
| 1013 | set(hh.Coord_x,'String',{get_field_GUI.Panel1Dplot.abscissa}) |
---|
[537] | 1014 | set(hh.Coord_y,'String',get_field_GUI.Panel1Dplot.ordinate) |
---|
[538] | 1015 | set(hh.Coord_y,'Max', numel(get_field_GUI.Panel1Dplot.ordinate)) |
---|
[526] | 1016 | set(hh.Coord_y,'Value',1:numel(get_field_GUI.Panel1Dplot.ordinate)) |
---|
| 1017 | set(hfield,'Value',1) |
---|
| 1018 | set(hfield,'String',[{''};{'get_field...'}]) |
---|
| 1019 | end |
---|
| 1020 | if ~check_series && strcmp(get(gcbf,'tag'),'get_field')%get_field is not called by another GUI (uvmat) |
---|
| 1021 | uvmat('run0_Callback',hObject,eventdata,hh); %refresh uvmat |
---|
| 1022 | end |
---|
| 1023 | end |
---|
[517] | 1024 | delete(handles.get_field) |
---|
[204] | 1025 | |
---|
| 1026 | |
---|
| 1027 | |
---|
[227] | 1028 | % %------------------------------------------------------------------------ |
---|
| 1029 | % function mouse_up_gui(ggg,eventdata,handles) |
---|
| 1030 | % %------------------------------------------------------------------------ |
---|
| 1031 | % if isequal(get(ggg,'SelectionType'),'alt') |
---|
| 1032 | % message=''; |
---|
| 1033 | % global CurData |
---|
| 1034 | % inputfield=get(handles.inputfile,'String'); |
---|
| 1035 | % if exist(inputfield,'file') |
---|
| 1036 | % CurData=nc2struct(inputfield); |
---|
| 1037 | % else |
---|
| 1038 | % CurData=get(ggg,'UserData');% get_field opened from a input field, not a file |
---|
| 1039 | % end |
---|
| 1040 | % %%%% TODO: put the matalb command window in front |
---|
| 1041 | % evalin('base','global CurData')%make CurData global in the workspace |
---|
| 1042 | % evalin('base','CurData') %display CurData in the workspace |
---|
| 1043 | % end |
---|
[204] | 1044 | |
---|
| 1045 | %------------------------------------------------------------------------ |
---|
| 1046 | % --- Executes on selection change in ACTION. |
---|
| 1047 | %------------------------------------------------------------------------ |
---|
| 1048 | function ACTION_Callback(hObject, eventdata, handles) |
---|
| 1049 | global nb_builtin |
---|
| 1050 | list_ACTION=get(handles.ACTION,'String');% list menu fields |
---|
| 1051 | index_ACTION=get(handles.ACTION,'Value');% selected string index |
---|
| 1052 | ACTION= list_ACTION{index_ACTION}; % selected string |
---|
| 1053 | list_func_handles=get(handles.ACTION,'UserData');% get list of function handles (full address of the function, including name and path) |
---|
| 1054 | ff=functions(list_func_handles{end}); |
---|
| 1055 | % add a new function to the menu |
---|
| 1056 | if isequal(ACTION,'more...') |
---|
| 1057 | [FileName, PathName] = uigetfile( ... |
---|
| 1058 | {'*.m', ' (*.m)'; |
---|
| 1059 | '*.m', '.m files '; ... |
---|
| 1060 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1061 | 'Pick a file',ff.file); |
---|
| 1062 | if length(FileName)<2 |
---|
| 1063 | return |
---|
| 1064 | end |
---|
| 1065 | [pp,ACTION,ext_fct]=fileparts(FileName); |
---|
| 1066 | if ~isequal(ext_fct,'.m') |
---|
| 1067 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 1068 | return |
---|
| 1069 | end |
---|
| 1070 | |
---|
| 1071 | % insert the choice in the action menu |
---|
| 1072 | menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed |
---|
| 1073 | index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list |
---|
| 1074 | addpath(PathName) |
---|
| 1075 | list_func_handles{index_ACTION}=str2func(ACTION);% create the function handle corresponding to the newly seleced function |
---|
| 1076 | set(handles.ACTION,'UserData',list_func_handles) |
---|
| 1077 | set(handles.path_action,'enable','inactive')% indicate that the current path is accessible (not 'off') |
---|
| 1078 | %list_path{index_ACTION}=PathName; |
---|
| 1079 | if length(menu_str)>nb_builtin+5; |
---|
| 1080 | nbremove=length(menu_str)-nb_builtin-5; |
---|
| 1081 | menu_str(nb_builtin+1:end-5)=[]; |
---|
| 1082 | list_func_handles(nb_builtin+1:end-4)=[]; |
---|
| 1083 | index_ACTION=index_ACTION-nbremove; |
---|
| 1084 | set(handles.ACTION,'Value',index_ACTION) |
---|
| 1085 | set(handles.ACTION,'String',menu_str) |
---|
| 1086 | end |
---|
| 1087 | %record the current menu in personal file profil_perso |
---|
| 1088 | dir_perso=prefdir; |
---|
| 1089 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1090 | get_field_fct={}; |
---|
| 1091 | for ilist=nb_builtin+1:length(menu_str)-1 |
---|
| 1092 | ff=functions(list_func_handles{ilist}); |
---|
| 1093 | get_field_fct{ilist-nb_builtin}=ff.file; |
---|
| 1094 | end |
---|
| 1095 | if exist(profil_perso,'file') |
---|
| 1096 | save(profil_perso,'get_field_fct','-append') |
---|
| 1097 | else |
---|
| 1098 | txt=ver('MATLAB'); |
---|
| 1099 | Release=txt.Release; |
---|
| 1100 | relnumb=str2num(Release(3:4)); |
---|
| 1101 | if relnumb >= 14 |
---|
| 1102 | save(profil_perso,'get_field_fct','-V6') |
---|
| 1103 | else |
---|
| 1104 | save(profil_perso, 'get_field_fct') |
---|
| 1105 | end |
---|
| 1106 | end |
---|
| 1107 | end |
---|
| 1108 | |
---|
| 1109 | %check the current path to the selected function |
---|
| 1110 | h_fun=list_func_handles{index_ACTION}; |
---|
| 1111 | if isa(h_fun,'function_handle') |
---|
| 1112 | func=functions(h_fun); |
---|
| 1113 | set(handles.path_action,'String',fileparts(func.file)); %show the path to the senlected function |
---|
| 1114 | GUI_input=h_fun();%handles.figure1 =handles of the GUI get_field |
---|
| 1115 | else |
---|
| 1116 | set(handles.path_action,'String','') |
---|
| 1117 | msgbox_uvmat('ERROR','unknown path to ACTION function, reload it') |
---|
| 1118 | return |
---|
| 1119 | end |
---|
| 1120 | |
---|
| 1121 | %prepare the GUI options for the selected ACTION |
---|
| 1122 | test_1Dplot=0; |
---|
| 1123 | test_scalar=0; |
---|
| 1124 | test_vector=0; |
---|
| 1125 | if iscell(GUI_input) |
---|
[503] | 1126 | for ilist=1:size(GUI_input,1) |
---|
| 1127 | switch GUI_input{ilist,1} |
---|
[204] | 1128 | %RootFile always visible |
---|
[503] | 1129 | case 'CheckPlot1D' |
---|
| 1130 | test_1Dplot=isequal(GUI_input{ilist,2},'on'); |
---|
| 1131 | case 'CheckScalar' |
---|
| 1132 | test_scalar=isequal(GUI_input{ilist,2},'on'); |
---|
| 1133 | case 'CheckVector' |
---|
| 1134 | test_vector=isequal(GUI_input{ilist,2},'on'); |
---|
[204] | 1135 | end |
---|
| 1136 | end |
---|
| 1137 | end |
---|
[503] | 1138 | set(handles.CheckPlot1D,'Value',test_1Dplot); |
---|
| 1139 | set(handles.CheckScalar,'Value',test_scalar); |
---|
| 1140 | set(handles.CheckVector,'Value',test_vector); |
---|
| 1141 | CheckPlot1D_Callback(hObject, eventdata, handles) |
---|
| 1142 | CheckScalar_Callback(hObject, eventdata, handles) |
---|
| 1143 | CheckVector_Callback(hObject, eventdata, handles) |
---|
[204] | 1144 | |
---|
| 1145 | |
---|
| 1146 | %----------------------------------------------------- |
---|
| 1147 | % --- browse existing figures |
---|
| 1148 | %----------------------------------------------------- |
---|
| 1149 | function browse_fig(menu_handle) |
---|
| 1150 | hh=findobj(allchild(0),'Type','figure'); |
---|
| 1151 | ilist=0; |
---|
| 1152 | list={}; |
---|
| 1153 | for ifig=1:length(hh) %look for all existing figures |
---|
| 1154 | name=get(hh(ifig),'Name'); |
---|
| 1155 | if ~strcmp(name,'uvmat')&& ~strcmp(name,'view_field') %case of uvmat GUI |
---|
| 1156 | hchild=get(hh(ifig),'children');% look for axes contained in each figure |
---|
| 1157 | nbaxe=0; |
---|
| 1158 | for ichild=1:length(hchild) |
---|
| 1159 | Type=get(hchild(ichild),'Type'); |
---|
| 1160 | Tag=get(hchild(ichild),'Tag'); |
---|
| 1161 | if isequal(Type,'axes') |
---|
| 1162 | if ~isequal(Tag,'Colorbar')& ~isequal(Tag,'legend')% don't select colorbars for plotting |
---|
| 1163 | nbaxe=nbaxe+1;%count the existing axis |
---|
| 1164 | end |
---|
| 1165 | end |
---|
| 1166 | end |
---|
| 1167 | if nbaxe==1 |
---|
| 1168 | ilist=ilist+1;%add a line in the list of axis |
---|
| 1169 | list{ilist,1}=num2str(hh(ifig)); |
---|
| 1170 | elseif nbaxe>1 |
---|
| 1171 | for iaxe=1:nbaxe |
---|
| 1172 | ilist=ilist+1;%add a line in the list of axis |
---|
| 1173 | list{ilist,1}=[num2str(hh(ifig)) '_' num2str(iaxe)]; |
---|
| 1174 | end |
---|
| 1175 | end |
---|
| 1176 | end |
---|
| 1177 | end |
---|
| 1178 | list=['uvmat';list]; |
---|
| 1179 | set(menu_handle,'Value',1) |
---|
| 1180 | set(menu_handle,'String',list) |
---|
| 1181 | |
---|
| 1182 | |
---|
| 1183 | %----------------------------------------------------- |
---|
| 1184 | function list_fig_Callback(hObject, eventdata, handles) |
---|
| 1185 | %----------------------------------------------------- |
---|
| 1186 | list_fig=get(handles.list_fig,'String'); |
---|
| 1187 | fig_val=get(handles.list_fig,'Value'); |
---|
| 1188 | plot_fig=list_fig{fig_val}; |
---|
| 1189 | if strcmp(plot_fig,'view_field') |
---|
| 1190 | % huvmat=findobj(allchild(0),'name','uvmat'); |
---|
| 1191 | % if ~isempty(huvmat) |
---|
| 1192 | % uistack(huvmat,'top') |
---|
| 1193 | % end |
---|
| 1194 | else%if ~isequal(plot_fig,'new fig...') & ~isequal(plot_fig,'uvmat') |
---|
| 1195 | sep=regexp(plot_fig,'_'); |
---|
| 1196 | if ~isempty(sep) |
---|
| 1197 | plot_fig=plot_fig([1:sep-1]); |
---|
| 1198 | end |
---|
| 1199 | if ishandle(str2num(plot_fig)) |
---|
| 1200 | figure(str2num(plot_fig))% display existing figure |
---|
| 1201 | else |
---|
| 1202 | browse_fig(handles.list_fig); %reset the current list of figures |
---|
| 1203 | end |
---|
| 1204 | end |
---|
| 1205 | |
---|
| 1206 | |
---|
| 1207 | %------------------------------------------------- |
---|
| 1208 | % give index numbers of the strings str in the list ListvarName |
---|
| 1209 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
| 1210 | VarIndex_y=[]; |
---|
| 1211 | if ischar(cell_str) |
---|
| 1212 | for ivar=1:length(ListVarName) |
---|
| 1213 | varlist=ListVarName{ivar}; |
---|
| 1214 | if isequal(varlist,cell_str) |
---|
| 1215 | VarIndex_y= ivar; |
---|
| 1216 | break |
---|
| 1217 | end |
---|
| 1218 | end |
---|
| 1219 | elseif iscell(cell_str) |
---|
| 1220 | for isel=1:length(cell_str) |
---|
| 1221 | varsel=cell_str{isel}; |
---|
| 1222 | for ivar=1:length(ListVarName) |
---|
| 1223 | varlist=ListVarName{ivar}; |
---|
| 1224 | if isequal(varlist,varsel) |
---|
| 1225 | VarIndex_y=[VarIndex_y ivar]; |
---|
| 1226 | end |
---|
| 1227 | end |
---|
| 1228 | end |
---|
| 1229 | end |
---|
| 1230 | |
---|
| 1231 | % -------------------------------------------------------------------- |
---|
| 1232 | function MenuOpen_Callback(hObject, eventdata, handles) |
---|
| 1233 | % hObject handle to MenuOpen (see GCBO) |
---|
| 1234 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1235 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1236 | |
---|
| 1237 | |
---|
| 1238 | % -------------------------------------------------------------------- |
---|
| 1239 | function MenuExport_Callback(hObject, eventdata, handles) |
---|
| 1240 | % hObject handle to MenuExport (see GCBO) |
---|
| 1241 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1242 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1243 | |
---|
| 1244 | |
---|
| 1245 | % -------------------------------------------------------------------- |
---|
| 1246 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 1247 | |
---|
| 1248 | oldfile=get(handles.inputfile,'String'); |
---|
| 1249 | testrootfile=0; |
---|
| 1250 | testsubdir=0; |
---|
| 1251 | if isempty(oldfile)|isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
| 1252 | oldfile=''; |
---|
| 1253 | dir_perso=prefdir; |
---|
| 1254 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1255 | if exist(profil_perso,'file') |
---|
| 1256 | h=load (profil_perso); |
---|
| 1257 | if isfield(h,'RootPath') |
---|
| 1258 | RootPath=h.RootPath; |
---|
| 1259 | end |
---|
| 1260 | if isfield(h,'SubDir') |
---|
| 1261 | SubDir=h.SubDir; |
---|
| 1262 | if ~isempty(SubDir) |
---|
| 1263 | testsubdir=1; |
---|
| 1264 | end |
---|
| 1265 | end |
---|
| 1266 | if isfield(h,'RootFile') |
---|
| 1267 | RootFile=h.RootFile; |
---|
| 1268 | if ~isempty(RootFile) |
---|
| 1269 | testrootfile=1; |
---|
| 1270 | end |
---|
| 1271 | end |
---|
| 1272 | end |
---|
| 1273 | end |
---|
| 1274 | if testrootfile |
---|
| 1275 | if ~testsubdir |
---|
| 1276 | oldfile=fullfile(RootPath,RootFile); |
---|
| 1277 | else |
---|
| 1278 | oldfile=fullfile(RootPath,SubDir,RootFile); |
---|
| 1279 | end |
---|
| 1280 | end |
---|
| 1281 | [FileName, PathName] = uigetfile( ... |
---|
| 1282 | {'*.nc', ' *.nc';... |
---|
| 1283 | '*.cdf', ' *.cdf';... |
---|
| 1284 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1285 | 'Pick a file',oldfile); |
---|
| 1286 | |
---|
| 1287 | %global inputfile |
---|
| 1288 | fileinput=[PathName FileName];%complete file name |
---|
| 1289 | sizf=size(fileinput); |
---|
[227] | 1290 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
[204] | 1291 | set(handles.inputfile,'String',fileinput) |
---|
| 1292 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1293 | |
---|
| 1294 | %update list of recent files in the menubar |
---|
| 1295 | MenuFile_1=fileinput; |
---|
| 1296 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 1297 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 1298 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 1299 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 1300 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 1301 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 1302 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 1303 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 1304 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 1305 | dir_perso=prefdir; |
---|
| 1306 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1307 | display(profil_perso) |
---|
| 1308 | if exist(profil_perso,'file') |
---|
| 1309 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 1310 | else |
---|
| 1311 | txt=ver('MATLAB'); |
---|
| 1312 | Release=txt.Release; |
---|
| 1313 | relnumb=str2double(Release(3:4)); |
---|
| 1314 | if relnumb >= 14 |
---|
| 1315 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 1316 | else |
---|
| 1317 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 1318 | end |
---|
| 1319 | end |
---|
| 1320 | |
---|
| 1321 | % -------------------------------------------------------------------- |
---|
| 1322 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 1323 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
| 1324 | set(handles.inputfile,'String',fileinput) |
---|
| 1325 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1326 | |
---|
| 1327 | % -------------------------------------------------------------------- |
---|
| 1328 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 1329 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
| 1330 | set(handles.inputfile,'String',fileinput) |
---|
| 1331 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1332 | |
---|
[227] | 1333 | % ----------------------------------------------------------------------- |
---|
[204] | 1334 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
[227] | 1335 | % ----------------------------------------------------------------------- |
---|
[204] | 1336 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
| 1337 | set(handles.inputfile,'String',fileinput) |
---|
| 1338 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1339 | |
---|
[227] | 1340 | % ----------------------------------------------------------------------- |
---|
[204] | 1341 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
[227] | 1342 | % ----------------------------------------------------------------------- |
---|
[204] | 1343 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
| 1344 | set(handles.inputfile,'String',fileinput) |
---|
| 1345 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1346 | |
---|
[227] | 1347 | % ----------------------------------------------------------------------- |
---|
[204] | 1348 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
[227] | 1349 | % ----------------------------------------------------------------------- |
---|
[204] | 1350 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
| 1351 | set(handles.inputfile,'String',fileinput) |
---|
| 1352 | inputfile_Callback(hObject, eventdata, handles) |
---|
| 1353 | |
---|
[227] | 1354 | %------------------------------------------------------------------------ |
---|
[204] | 1355 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[227] | 1356 | %------------------------------------------------------------------------ |
---|
[204] | 1357 | global Data_get_field |
---|
| 1358 | % huvmat=findobj(allchild(0),'Name','uvmat'); |
---|
| 1359 | inputfile=get(handles.inputfile,'String'); |
---|
| 1360 | Data_get_field=nc2struct(inputfile); |
---|
| 1361 | % Data_view_field=UvData.ProjField_2; |
---|
| 1362 | evalin('base','global Data_get_field')%make CurData global in the workspace |
---|
| 1363 | display(['content of ' inputfile ':']) |
---|
| 1364 | evalin('base','Data_get_field') %display CurData in the workspace |
---|
| 1365 | commandwindow; |
---|
| 1366 | |
---|
[227] | 1367 | %------------------------------------------------------------------------ |
---|
[204] | 1368 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[227] | 1369 | %------------------------------------------------------------------------ |
---|
[204] | 1370 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 1371 | pathelp=fileparts(path_to_uvmat); |
---|
| 1372 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 1373 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 1374 | else |
---|
| 1375 | web([helpfile '#get_field']) |
---|
| 1376 | end |
---|
| 1377 | |
---|
[227] | 1378 | % ----------------------------------------------------------------------- |
---|
| 1379 | function TimeName_Callback(hObject, eventdata, handles) |
---|
| 1380 | |
---|
| 1381 | scalar_Callback(hObject, eventdata, handles)% suppress time variable from possible spatial coordinates |
---|
| 1382 | vector_x_Callback(hObject, eventdata, handles) |
---|
| 1383 | |
---|
| 1384 | %------------------------------------------------------------------------ |
---|
| 1385 | % --- Executes on button press in TimeAttribute. |
---|
| 1386 | function TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1387 | %------------------------------------------------------------------------ |
---|
| 1388 | val=get(handles.TimeAttribute,'Value'); |
---|
| 1389 | if val |
---|
| 1390 | set(handles.TimeAttributeMenu,'Visible','on') |
---|
| 1391 | Field=get(handles.get_field,'UserData'); |
---|
| 1392 | time_value=zeros(size(Field.ListGlobalAttribute)); |
---|
| 1393 | test_time=zeros(size(Field.ListGlobalAttribute)); |
---|
| 1394 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 1395 | if isnumeric(eval(['Field.' Field.ListGlobalAttribute{ilist}])) |
---|
| 1396 | eval(['time_val=Field.' Field.ListGlobalAttribute{ilist} ';']) |
---|
| 1397 | if ~isempty(time_val) |
---|
| 1398 | time_value(ilist)=time_val; |
---|
| 1399 | test_time(ilist)=1; |
---|
| 1400 | end |
---|
| 1401 | end |
---|
| 1402 | end |
---|
| 1403 | ListTimeAttribute=Field.ListGlobalAttribute(test_time==1); |
---|
| 1404 | attr_index=get(handles.TimeAttributeMenu,'Value'); |
---|
| 1405 | if attr_index>numel(ListTimeAttribute) |
---|
| 1406 | attr_index=1; |
---|
| 1407 | set(handles.TimeAttributeMenu,'Value',1); |
---|
| 1408 | end |
---|
| 1409 | if isempty(ListTimeAttribute) |
---|
| 1410 | set(handles.TimeAttributeMenu,'String',{''}) |
---|
| 1411 | set(handles.TimeValue,'Visible','off') |
---|
| 1412 | else |
---|
| 1413 | set(handles.TimeValue,'Visible','on') |
---|
| 1414 | set(handles.TimeAttributeMenu,'String',ListTimeAttribute) |
---|
| 1415 | set(handles.TimeValue,'String',num2str(time_value(attr_index))) |
---|
| 1416 | end |
---|
| 1417 | set(handles.TimeDimension,'Value',0) |
---|
| 1418 | TimeDimension_Callback(hObject, eventdata, handles) |
---|
| 1419 | set(handles.TimeVariable,'Value',0) |
---|
| 1420 | TimeVariable_Callback(hObject, eventdata, handles) |
---|
| 1421 | else |
---|
| 1422 | set(handles.TimeAttributeMenu,'Visible','off') |
---|
| 1423 | set(handles.TimeValue,'Visible','off') |
---|
| 1424 | end |
---|
| 1425 | |
---|
| 1426 | %------------------------------------------------------------------------ |
---|
| 1427 | % --- Executes on selection change in TimeAttributeMenu. |
---|
| 1428 | function TimeAttributeMenu_Callback(hObject, eventdata, handles) |
---|
| 1429 | ListTimeAttribute=get(handles.TimeAttributeMenu,'String'); |
---|
| 1430 | index=get(handles.TimeAttributeMenu,'Value'); |
---|
| 1431 | AttrName=ListTimeAttribute{index}; |
---|
| 1432 | Field=get(handles.get_field,'UserData'); |
---|
| 1433 | eval(['time_val=Field.' AttrName ';']) |
---|
| 1434 | set(handles.TimeValue,'String',num2str(time_val)) |
---|
| 1435 | %------------------------------------------------------------------------ |
---|
| 1436 | |
---|
| 1437 | %------------------------------------------------------------------------ |
---|
| 1438 | % --- Executes on button press in TimeVariable. |
---|
| 1439 | function TimeDimension_Callback(hObject, eventdata, handles) |
---|
| 1440 | %------------------------------------------------------------------------ |
---|
| 1441 | val=get(handles.TimeDimension,'Value');%=1 if check box TimeDimension is selected |
---|
| 1442 | if val %if check box TimeDimension is selected |
---|
| 1443 | Field=get(handles.get_field,'UserData');% structure describing the currently opened field |
---|
| 1444 | previous_menu=get(handles.TimeDimensionMenu,'String'); |
---|
| 1445 | if ~isequal(previous_menu,Field.ListDimName)%update the list of available dimensions in the menu |
---|
| 1446 | ind_select=find(strcmpi('time',Field.ListDimName),1);% look for a dimension named 'time' or 'Time' |
---|
| 1447 | if isempty(ind_select) |
---|
| 1448 | ind_select=1;% select the first item in the list if 'time' is not found |
---|
| 1449 | end |
---|
| 1450 | set(handles.TimeDimensionMenu,'Value',ind_select); |
---|
| 1451 | set(handles.TimeDimensionMenu,'String',Field.ListDimName)% put the list of available dimensions in the menu |
---|
| 1452 | end |
---|
| 1453 | set(handles.TimeDimensionMenu,'Visible','on')% the menu is made visible |
---|
| 1454 | set(handles.TimeIndexValue,'Visible','on')% the time matrix index value selected is made visible |
---|
| 1455 | TimeDimensionMenu_Callback(hObject, eventdata, handles) |
---|
| 1456 | set(handles.TimeAttribute,'Value',0) %deselect alternative options for time |
---|
| 1457 | set(handles.TimeVariable,'Value',0) |
---|
| 1458 | TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1459 | else |
---|
| 1460 | set(handles.TimeDimensionMenu,'Visible','off') |
---|
| 1461 | set(handles.TimeIndexValue,'Visible','off') |
---|
| 1462 | end |
---|
[581] | 1463 | % |
---|
| 1464 | % %------------------------------------------------------------------------ |
---|
| 1465 | % % --- Executes on selection change in TimeDimensionMenu. |
---|
| 1466 | % function TimeDimensionMenu_Callback(hObject, eventdata, handles) |
---|
| 1467 | % %------------------------------------------------------------------------ |
---|
| 1468 | % index=get(handles.TimeDimensionMenu,'Value'); |
---|
| 1469 | % DimList=get(handles.TimeDimensionMenu,'String'); |
---|
| 1470 | % DimName=DimList{index}; |
---|
| 1471 | % Field=get(handles.get_field,'UserData'); |
---|
| 1472 | % DimIndex=find(strcmp(DimName,Field.ListDimName),1); |
---|
| 1473 | % ref_index=round(Field.DimValue(DimIndex)/2); |
---|
| 1474 | % set(handles.TimeIndexValue,'String',num2str(ref_index)) |
---|
| 1475 | % scalar_Callback(hObject, eventdata, handles) |
---|
| 1476 | % vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) |
---|
| 1477 | % % look for a corresponding time variable and value |
---|
| 1478 | % time_test=zeros(size(Field.VarDimName)); |
---|
| 1479 | % for ilist=1:numel(Field.VarDimName) |
---|
| 1480 | % if isequal(Field.VarDimName{ilist},{DimName}) |
---|
| 1481 | % time_test(ilist)=1; |
---|
| 1482 | % end |
---|
| 1483 | % end |
---|
| 1484 | % ListVariable=Field.ListVarName(time_test==1); |
---|
| 1485 | % set(handles.TimeVariableMenu,'Value',1) |
---|
| 1486 | % if isempty(ListVariable) |
---|
| 1487 | % set(handles.TimeVariableMenu,'String',{''}) |
---|
| 1488 | % set(handles.TimeVarValue,'String','') |
---|
| 1489 | % else |
---|
| 1490 | % set(handles.TimeVariableMenu,'String',ListVariable) |
---|
| 1491 | % TimeVarName=ListVariable{1}; |
---|
| 1492 | % VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables |
---|
| 1493 | % inputfile=get(handles.inputfile,'String');% read the input file |
---|
| 1494 | % SubField=nc2struct(inputfile,{TimeVarName}); |
---|
| 1495 | % eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) |
---|
| 1496 | % set(handles.TimeVarValue,'Visible','on') |
---|
| 1497 | % set(handles.TimeVariableMenu,'Visible','on') |
---|
| 1498 | % set(handles.TimeVarValue,'String',num2str(TimeValue)) |
---|
| 1499 | % end |
---|
| 1500 | % |
---|
| 1501 | % |
---|
| 1502 | % % % ----------------------------------------------------------------------- |
---|
| 1503 | % % % --- Executes on button press in TimeVariable. |
---|
| 1504 | % % function TimeVariable_Callback(hObject, eventdata, handles) |
---|
| 1505 | % % % ----------------------------------------------------------------------- |
---|
| 1506 | % % val=get(handles.TimeVariable,'Value'); |
---|
| 1507 | % % if val |
---|
| 1508 | % % Field=get(handles.get_field,'UserData'); |
---|
| 1509 | % % time_test=zeros(size(Field.VarDimName)); |
---|
| 1510 | % % for ilist=1:numel(Field.VarDimName) |
---|
| 1511 | % % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension |
---|
| 1512 | % % time_test(ilist)=1; |
---|
| 1513 | % % end |
---|
| 1514 | % % end |
---|
| 1515 | % % ind_test=find(time_test); |
---|
| 1516 | % % if isempty(time_test) |
---|
| 1517 | % % set(handles.TimeVariable,'Value',0) |
---|
| 1518 | % % set(handles.TimeVariableMenu,'Visible','off') |
---|
| 1519 | % % set(handles.TimeVarValue,'Visible','off') |
---|
| 1520 | % % else |
---|
| 1521 | % % set(handles.TimeVariableMenu,'Visible','on') |
---|
| 1522 | % % set(handles.TimeVarValue,'Visible','on') |
---|
| 1523 | % % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) |
---|
| 1524 | % % set(handles.TimeVariableMenu,'Value',1) |
---|
| 1525 | % % end |
---|
| 1526 | % % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) |
---|
| 1527 | % % TimeVariableMenu_Callback(hObject, eventdata, handles) |
---|
| 1528 | % % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time |
---|
| 1529 | % % set(handles.TimeAttribute,'Value',0) |
---|
| 1530 | % % TimeAttribute_Callback(hObject, eventdata, handles) |
---|
| 1531 | % % end |
---|
| 1532 | % % else |
---|
| 1533 | % % set(handles.TimeVariableMenu,'Visible','off') |
---|
| 1534 | % % set(handles.TimeVarValue,'Visible','off') |
---|
| 1535 | % % end |
---|
| 1536 | % |
---|
[227] | 1537 | % % ----------------------------------------------------------------------- |
---|
[581] | 1538 | % % --- Executes on selection change in TimeVariableMenu. |
---|
| 1539 | % function TimeVariableMenu_Callback(hObject, eventdata, handles) |
---|
[227] | 1540 | % % ----------------------------------------------------------------------- |
---|
[581] | 1541 | % ListVar=get(handles.TimeVariableMenu,'String'); |
---|
| 1542 | % index=get(handles.TimeVariableMenu,'Value'); |
---|
| 1543 | % TimeVariable=ListVar{index};% name of the selected variable |
---|
| 1544 | % if isempty(TimeVariable)% case of blank selection |
---|
| 1545 | % return |
---|
[227] | 1546 | % end |
---|
[581] | 1547 | % Field=get(handles.get_field,'UserData'); %index of |
---|
| 1548 | % VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables |
---|
| 1549 | % DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable |
---|
| 1550 | % set(handles.TimeDimensionMenu,'Value',1) |
---|
| 1551 | % set(handles.TimeDimensionMenu,'String',DimName) |
---|
| 1552 | % inputfile=get(handles.inputfile,'String');% read the input file |
---|
| 1553 | % SubField=nc2struct(inputfile,{TimeVariable}); |
---|
| 1554 | % eval(['TimeDimension=numel(SubField.' TimeVariable ');']) |
---|
| 1555 | % ref_index=round(TimeDimension/2); |
---|
| 1556 | % eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) |
---|
| 1557 | % set(handles.TimeIndexValue,'String',num2str(ref_index)) |
---|
| 1558 | % set(handles.TimeVarValue,'String',num2str(TimeValue)) |
---|
[227] | 1559 | |
---|
| 1560 | |
---|
[581] | 1561 | % --- Executes on button press in check_rgb. |
---|
| 1562 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[227] | 1563 | |
---|
| 1564 | |
---|
[581] | 1565 | % --- Executes when user attempts to close get_field. |
---|
| 1566 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
---|
| 1567 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 1568 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 1569 | uiresume(handles.get_field); |
---|
[227] | 1570 | else |
---|
[581] | 1571 | % The GUI is no longer waiting, just close it |
---|
| 1572 | delete(handles.get_field); |
---|
[227] | 1573 | end |
---|
| 1574 | |
---|
| 1575 | |
---|
| 1576 | |
---|
| 1577 | |
---|
| 1578 | |
---|
[581] | 1579 | % --- Executes on selection change in listbox30. |
---|
| 1580 | function listbox30_Callback(hObject, eventdata, handles) |
---|
| 1581 | % hObject handle to listbox30 (see GCBO) |
---|
| 1582 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1583 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1584 | |
---|
| 1585 | % Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array |
---|
| 1586 | % contents{get(hObject,'Value')} returns selected item from listbox30 |
---|
| 1587 | |
---|
| 1588 | |
---|
| 1589 | % --- Executes on selection change in SwitchVarIndexX. |
---|
| 1590 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
| 1591 | % hObject handle to SwitchVarIndexX (see GCBO) |
---|
| 1592 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 1593 | % handles structure with handles and user data (see GUIDATA) |
---|
| 1594 | |
---|
| 1595 | % Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array |
---|
| 1596 | % contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX |
---|
| 1597 | |
---|
| 1598 | |
---|
| 1599 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
| 1600 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
| 1601 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 1602 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[582] | 1603 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 1604 | switch option |
---|
| 1605 | case 'file index' |
---|
| 1606 | set(handles.TimeVarName, 'Visible','off') |
---|
| 1607 | case 'attribute' |
---|
| 1608 | set(handles.TimeVarName, 'Visible','on') |
---|
| 1609 | time_index=[]; |
---|
[582] | 1610 | PreviousList=get(handles.TimeVarName, 'String'); |
---|
| 1611 | index=[]; |
---|
| 1612 | if ~isempty(PreviousList) |
---|
| 1613 | PreviousAttr=PreviousList{get(handles.TimeVarName, 'Value')}; |
---|
| 1614 | index=find(strcmp(PreviousAttr,Field.ListNumAttributes)); |
---|
[581] | 1615 | end |
---|
[582] | 1616 | if isempty(index) |
---|
| 1617 | time_index=find(~cellfun('isempty',regexp(Field.ListNumAttributes,'Time')));% index of the attributes containing the string 'Time' |
---|
| 1618 | end |
---|
[581] | 1619 | if ~isempty(time_index) |
---|
| 1620 | set(handles.TimeVarName,'Value',time_index(1)) |
---|
| 1621 | else |
---|
| 1622 | set(handles.TimeVarName,'Value',1) |
---|
| 1623 | end |
---|
[582] | 1624 | set(handles.TimeVarName, 'String',Field.ListNumAttributes) |
---|
[581] | 1625 | case 'variable' |
---|
| 1626 | set(handles.TimeVarName, 'Visible','on') |
---|
[582] | 1627 | TimeVarName=Field.SingleVarName; |
---|
[581] | 1628 | List=get(handles.TimeVarName,'String'); |
---|
| 1629 | option=List{get(handles.TimeVarName,'Value')}; |
---|
[582] | 1630 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 1631 | if isempty(ind) |
---|
| 1632 | set(handles.TimeVarName, 'Value',1); |
---|
| 1633 | else |
---|
| 1634 | set(handles.TimeVarName, 'Value',ind); |
---|
| 1635 | end |
---|
| 1636 | set(handles.TimeVarName, 'String',TimeVarName) |
---|
| 1637 | case 'dim index' |
---|
| 1638 | set(handles.TimeVarName, 'Visible','on') |
---|
[582] | 1639 | TimeVarName=Field.SingleDimName; |
---|
[581] | 1640 | List=get(handles.TimeVarName,'String'); |
---|
| 1641 | option=List{get(handles.TimeVarName,'Value')}; |
---|
[582] | 1642 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 1643 | if isempty(ind) |
---|
| 1644 | set(handles.TimeVarName, 'Value',1); |
---|
| 1645 | else |
---|
| 1646 | set(handles.TimeVarName, 'Value',ind); |
---|
| 1647 | end |
---|
[582] | 1648 | set(handles.TimeVarName, 'String',TimeVarName) |
---|
[581] | 1649 | end |
---|
| 1650 | |
---|
[582] | 1651 | |
---|