[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 | % |
---|
[674] | 6 | % OUPUT: |
---|
| 7 | % GetFieldData: structure containing the information on the selected |
---|
| 8 | % fields, obtained by applying the fct red_GUI to the GUI get_field |
---|
| 9 | % .FieldOption='vectors': variables are used for vector plot |
---|
| 10 | % 'scalar': variables are used for scalar plot, |
---|
| 11 | % '1Dplot': variables are used for usual x-y plot, |
---|
| 12 | % 'civdata...': go back to automatic reading of civ data |
---|
| 13 | % .PanelVectors: sub-structure variables used as vector components |
---|
| 14 | % .PanelScalar: |
---|
| 15 | % INPUT: |
---|
| 16 | % FileName: name (including path) of the netcdf file to open |
---|
| 17 | % |
---|
[204] | 18 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 19 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | % This file is part of the toolbox UVMAT. |
---|
| 22 | % |
---|
| 23 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 24 | % it under the terms of the GNU General Public License as published by |
---|
| 25 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 26 | % (at your option) any later version. |
---|
| 27 | % |
---|
| 28 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 31 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 32 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 33 | |
---|
| 34 | function varargout = get_field(varargin) |
---|
| 35 | |
---|
[648] | 36 | % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54 |
---|
[204] | 37 | |
---|
| 38 | % Begin initialization code - DO NOT EDIT |
---|
[581] | 39 | gui_Singleton = 1; |
---|
[204] | 40 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 41 | 'gui_Singleton', gui_Singleton, ... |
---|
| 42 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
---|
| 43 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
---|
| 44 | 'gui_LayoutFcn', [] , ... |
---|
| 45 | 'gui_Callback', []); |
---|
| 46 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 47 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | if nargout |
---|
| 51 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 52 | else |
---|
| 53 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 54 | end |
---|
| 55 | % End initialization code - DO NOT EDIT |
---|
[674] | 56 | |
---|
[204] | 57 | %------------------------------------------------------------------------ |
---|
| 58 | % --- Executes just before get_field is made visible. |
---|
[648] | 59 | %------------------------------------------------------------------------ |
---|
[581] | 60 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
---|
[204] | 61 | |
---|
[648] | 62 | %% GUI settings |
---|
[581] | 63 | handles.output = 'Cancel'; |
---|
[204] | 64 | guidata(hObject, handles); |
---|
[434] | 65 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[204] | 66 | |
---|
[648] | 67 | %% enter input data |
---|
[674] | 68 | if ischar(filename)% input file name |
---|
| 69 | set(handles.inputfile,'String',filename)% fill the input file name |
---|
| 70 | Field=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
| 71 | else |
---|
| 72 | 'bad input to get_field' |
---|
| 73 | end |
---|
| 74 | if ~exist('ParamIn','var') |
---|
| 75 | ParamIn=[]; |
---|
| 76 | end |
---|
[648] | 77 | if isfield(Field,'Txt') |
---|
[674] | 78 | msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading |
---|
[648] | 79 | return |
---|
[227] | 80 | end |
---|
[204] | 81 | if ~isfield(Field,'ListVarName') |
---|
| 82 | return |
---|
| 83 | end |
---|
[582] | 84 | |
---|
[648] | 85 | %% look at singletons and variables with a single dimension |
---|
| 86 | Field.Display=Field; |
---|
| 87 | Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value |
---|
| 88 | NbVar=numel(Field.VarDimName); |
---|
| 89 | for ilist=1:NbVar |
---|
[582] | 90 | if ischar(Field.VarDimName{ilist}) |
---|
| 91 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 92 | end |
---|
[648] | 93 | NbDim=numel(Field.VarDimName{ilist}); |
---|
[582] | 94 | check_singleton=false(1,NbDim); |
---|
| 95 | for idim=1:NbDim |
---|
[648] | 96 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions |
---|
| 97 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton |
---|
[582] | 98 | end |
---|
[648] | 99 | Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)));% =1 if the variable reduces to a single value |
---|
| 100 | if ~Field.Check0D(ilist) |
---|
| 101 | Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions |
---|
[582] | 102 | end |
---|
[648] | 103 | %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons |
---|
[582] | 104 | end |
---|
[669] | 105 | if ~isfield(Field,'VarAttribute') |
---|
| 106 | Field.VarAttribute={}; |
---|
| 107 | end |
---|
[648] | 108 | if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded |
---|
| 109 | Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); |
---|
[582] | 110 | end |
---|
[672] | 111 | % Field.Display = list of variables and corresponding properties obtained after removal of singletons |
---|
[648] | 112 | Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); |
---|
| 113 | Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); |
---|
| 114 | Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); |
---|
| 115 | Field.Display.DimValue=Field.DimValue(Field.DimValue~=1); |
---|
| 116 | Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1); |
---|
[581] | 117 | |
---|
[648] | 118 | %% analyse the input field cells |
---|
| 119 | [CellInfo,NbDim,errormsg]=find_field_cells(Field.Display); |
---|
| 120 | if ~isempty(errormsg) |
---|
| 121 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
---|
| 122 | return |
---|
| 123 | end |
---|
| 124 | [Field.MaxDim,imax]=max(NbDim); |
---|
| 125 | |
---|
[581] | 126 | %% set time mode |
---|
[646] | 127 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
---|
[582] | 128 | % look at global attributes with numerical values |
---|
[674] | 129 | check_numvalue=false(1,numel(Field.ListGlobalAttribute)); |
---|
[646] | 130 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 131 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 132 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 133 | end |
---|
[648] | 134 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 135 | if ~isempty(Field.Display.ListGlobalAttribute) |
---|
[646] | 136 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
---|
[582] | 137 | end |
---|
| 138 | if Field.MaxDim>=2 |
---|
[646] | 139 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index |
---|
[582] | 140 | end |
---|
[674] | 141 | |
---|
| 142 | %% select the Time attribute from input |
---|
| 143 | if isfield(ParamIn,'TimeAttrName') |
---|
| 144 | time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); |
---|
| 145 | else |
---|
| 146 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1); |
---|
| 147 | end |
---|
| 148 | if ~isempty(time_index) |
---|
[648] | 149 | set(handles.SwitchVarIndexTime,'Value',2); |
---|
[674] | 150 | set(handles.TimeName,'UserData',time_index) |
---|
[581] | 151 | else |
---|
[648] | 152 | set(handles.SwitchVarIndexTime,'Value',1); |
---|
[581] | 153 | end |
---|
[646] | 154 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
[582] | 155 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[648] | 156 | SwitchVarIndexTime_Callback([], [], handles) |
---|
[581] | 157 | |
---|
[582] | 158 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
[648] | 159 | set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components |
---|
| 160 | set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components |
---|
[672] | 161 | set(handles.vector_z,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
---|
| 162 | set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components |
---|
[648] | 163 | set(handles.scalar,'Value',1)% fill the menu of y vector components |
---|
[672] | 164 | set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components |
---|
[648] | 165 | set(handles.ordinate,'Value',1)% fill the menu of y vector components |
---|
[672] | 166 | set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components |
---|
[654] | 167 | if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') |
---|
[672] | 168 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'}) |
---|
[654] | 169 | else |
---|
[672] | 170 | set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) |
---|
[654] | 171 | end |
---|
[582] | 172 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
---|
[674] | 173 | check_vec_input=0; |
---|
| 174 | if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y') |
---|
| 175 | ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1); |
---|
| 176 | ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1); |
---|
| 177 | if ~isempty(ichoice_x)&&~isempty(ichoice_y) |
---|
| 178 | set(handles.vector_x,'UserData',ichoice_x) |
---|
| 179 | set(handles.vector_y,'UserData',ichoice_y) |
---|
| 180 | check_vec_input=1; |
---|
| 181 | end |
---|
| 182 | end |
---|
| 183 | if ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
---|
| 184 | set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1)) |
---|
| 185 | set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1)) |
---|
| 186 | check_vec_input=1; |
---|
| 187 | end |
---|
| 188 | if check_vec_input |
---|
[646] | 189 | set(handles.FieldOption,'Value',3)% set vector selection option |
---|
[204] | 190 | else |
---|
[674] | 191 | set(handles.FieldOption,'Value',2)% set scalar selection option |
---|
[204] | 192 | end |
---|
[582] | 193 | else % case of 1D fields |
---|
[644] | 194 | set(handles.FieldOption,'Value',1) |
---|
[204] | 195 | end |
---|
[582] | 196 | |
---|
[648] | 197 | %% fill the general list of dimensions, variables, attributes |
---|
| 198 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
| 199 | Tabcell(:,1)=Field.ListDimName; |
---|
| 200 | for iline=1:length(Field.ListDimName) |
---|
| 201 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
| 202 | end |
---|
| 203 | Tabchar=cell2tab(Tabcell,' = '); |
---|
| 204 | set(handles.dimensions,'String',Tabchar) |
---|
| 205 | end |
---|
| 206 | set(handles.variables,'Value',1) |
---|
| 207 | set(handles.variables,'String',[{'*'} Field.ListVarName]) |
---|
| 208 | variables_Callback(handles.variables,[], handles)% list the global attributes |
---|
[644] | 209 | |
---|
[648] | 210 | %% fill menus for coordinates and time |
---|
| 211 | FieldOption_Callback(handles.variables,[], handles)% list the global attributes |
---|
| 212 | |
---|
[672] | 213 | %% Make choices of coordinates from input |
---|
| 214 | if isfield(CellInfo{imax},'CoordIndex') |
---|
| 215 | CoordIndex=CellInfo{imax}.CoordIndex; |
---|
| 216 | if numel(CoordIndex)==2 |
---|
| 217 | YName=Field.ListVarName{CoordIndex(1)}; |
---|
| 218 | XName=Field.ListVarName{CoordIndex(2)}; |
---|
| 219 | ListCoord=get(handles.Coord_x,'String'); |
---|
| 220 | XIndex=find(strcmp(XName,ListCoord)); |
---|
| 221 | if ~isempty(XIndex) |
---|
| 222 | set(handles.Coord_x,'Value',XIndex) |
---|
| 223 | end |
---|
| 224 | YIndex=find(strcmp(YName,ListCoord)); |
---|
| 225 | if ~isempty(YIndex) |
---|
| 226 | set(handles.Coord_y,'Value',YIndex) |
---|
| 227 | end |
---|
| 228 | end |
---|
| 229 | end |
---|
[648] | 230 | |
---|
| 231 | %% put the GUI on the lower right of the sceen |
---|
| 232 | set(hObject,'Unit','pixel') |
---|
| 233 | pos_view_field=get(hObject,'Position'); |
---|
| 234 | set(0,'Unit','pixels') |
---|
| 235 | ScreenSize=get(0,'ScreenSize'); |
---|
| 236 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
---|
| 237 | pos_view_field(2)=ScreenSize(2); |
---|
| 238 | set(hObject,'Position',pos_view_field) |
---|
| 239 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
---|
| 240 | drawnow |
---|
| 241 | uiwait(handles.get_field); |
---|
| 242 | |
---|
| 243 | return |
---|
| 244 | |
---|
| 245 | %% set z coordinate menu if relevant |
---|
| 246 | if Field.MaxDim>=3 |
---|
| 247 | set(handles.vector_z,'Visible','on') |
---|
| 248 | set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D)) |
---|
| 249 | set(handles.Coord_z,'Visible','on') |
---|
| 250 | set(handles.SwitchVarIndexZ,'Visible','on') |
---|
| 251 | set(handles.Z_title,'Visible','on') |
---|
| 252 | else |
---|
| 253 | set(handles.vector_z,'Visible','off') |
---|
| 254 | set(handles.Coord_z,'Visible','off') |
---|
| 255 | set(handles.Z_title,'Visible','off') |
---|
[581] | 256 | end |
---|
[204] | 257 | |
---|
[674] | 258 | %% make selections according to ParamIn |
---|
| 259 | if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y') |
---|
| 260 | |
---|
| 261 | end |
---|
| 262 | |
---|
[204] | 263 | %------------------------------------------------------------------------ |
---|
[672] | 264 | % --- Outputs from this function are returned to the command line. |
---|
[648] | 265 | %------------------------------------------------------------------------ |
---|
[582] | 266 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
[672] | 267 | |
---|
[582] | 268 | varargout{1} = handles.output; |
---|
| 269 | delete(handles.get_field) |
---|
| 270 | |
---|
[648] | 271 | %------------------------------------------------------------------------ |
---|
| 272 | % --- Executes when user attempts to close get_field. |
---|
| 273 | %------------------------------------------------------------------------ |
---|
| 274 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
---|
[582] | 275 | |
---|
[648] | 276 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 277 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 278 | uiresume(handles.get_field); |
---|
| 279 | else |
---|
| 280 | % The GUI is no longer waiting, just close it |
---|
| 281 | delete(handles.get_field); |
---|
| 282 | end |
---|
| 283 | |
---|
[672] | 284 | %------------------------------------------------------------------------ |
---|
[648] | 285 | % --- Executes on button press in OK. |
---|
| 286 | %------------------------------------------------------------------------ |
---|
| 287 | function OK_Callback(hObject, eventdata, handles) |
---|
| 288 | |
---|
| 289 | handles.output=read_GUI(handles.get_field); |
---|
| 290 | guidata(hObject, handles);% Update handles structure |
---|
| 291 | uiresume(handles.get_field); |
---|
| 292 | drawnow |
---|
| 293 | |
---|
[582] | 294 | % ----------------------------------------------------------------------- |
---|
| 295 | % --- Activated by selection in the list of variables |
---|
[672] | 296 | % ---------------------------------------------------------------------- |
---|
[582] | 297 | function variables_Callback(hObject, eventdata, handles) |
---|
[672] | 298 | |
---|
[582] | 299 | Tabchar={''};%default |
---|
| 300 | Tabcell=[]; |
---|
| 301 | hselect_field=get(handles.variables,'parent'); |
---|
| 302 | Field=get(handles.get_field,'UserData'); |
---|
| 303 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
| 304 | |
---|
| 305 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
---|
[672] | 306 | if isequal(index,1) |
---|
[582] | 307 | set(handles.attributes_txt,'String','global attributes') |
---|
| 308 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 309 | for iline=1:length(Field.ListGlobalAttribute) |
---|
[672] | 310 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
[582] | 311 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
[648] | 312 | val=Field.(Field.ListGlobalAttribute{iline}); |
---|
[582] | 313 | if ischar(val);% attribute value is char string |
---|
| 314 | Tabcell{iline,2}=val; |
---|
| 315 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
| 316 | Tabcell{iline,2}=num2str(val); |
---|
| 317 | end |
---|
| 318 | end |
---|
| 319 | end |
---|
| 320 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 321 | end |
---|
[672] | 322 | %% list Attribute names and values associated to the Variable # index-1 |
---|
[582] | 323 | else |
---|
| 324 | list_var=get(handles.variables,'String'); |
---|
| 325 | var_select=list_var{index}; |
---|
| 326 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
| 327 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
[672] | 328 | % nbline=0; |
---|
[582] | 329 | VarAttr=Field.VarAttribute{index-1}; |
---|
| 330 | if isstruct(VarAttr) |
---|
| 331 | attr_list=fieldnames(VarAttr); |
---|
| 332 | for iline=1:length(attr_list) |
---|
| 333 | Tabcell{iline,1}=attr_list{iline}; |
---|
[674] | 334 | val=VarAttr.(attr_list{iline}) ; |
---|
[582] | 335 | if ischar(val); |
---|
| 336 | Tabcell{iline,2}=val; |
---|
| 337 | else |
---|
[672] | 338 | Tabcell{iline,2}=num2str(val); |
---|
[582] | 339 | end |
---|
| 340 | end |
---|
| 341 | end |
---|
| 342 | end |
---|
[672] | 343 | |
---|
[582] | 344 | end |
---|
| 345 | if ~isempty(Tabcell) |
---|
| 346 | Tabchar=cell2tab(Tabcell,'='); |
---|
[672] | 347 | % Tabchar=[{''};Tabchar]; |
---|
[582] | 348 | end |
---|
| 349 | set(handles.attributes,'Value',1);% select the first item |
---|
| 350 | set(handles.attributes,'String',Tabchar); |
---|
| 351 | |
---|
| 352 | %% update dimensions; |
---|
| 353 | if isfield(Field,'ListDimName') |
---|
| 354 | Tabdim={};%default |
---|
| 355 | if isequal(index,1)%list all dimensions |
---|
| 356 | dim_indices=1:length(Field.ListDimName); |
---|
| 357 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
| 358 | else |
---|
| 359 | DimCell=Field.VarDimName{index-1}; |
---|
| 360 | if ischar(DimCell) |
---|
| 361 | DimCell={DimCell}; |
---|
[672] | 362 | end |
---|
[582] | 363 | dim_indices=[]; |
---|
| 364 | for idim=1:length(DimCell) |
---|
[672] | 365 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
[582] | 366 | dim_index=find(dim_index,1); |
---|
| 367 | dim_indices=[dim_indices dim_index]; |
---|
| 368 | end |
---|
| 369 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
| 370 | end |
---|
| 371 | for iline=1:length(dim_indices) |
---|
| 372 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
| 373 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
| 374 | end |
---|
| 375 | Tabchar=cell2tab(Tabdim,' = '); |
---|
| 376 | Tabchar=[{''} ;Tabchar]; |
---|
| 377 | set(handles.dimensions,'Value',1) |
---|
[672] | 378 | set(handles.dimensions,'String',Tabchar) |
---|
| 379 | end |
---|
[582] | 380 | |
---|
| 381 | %------------------------------------------------------------------------ |
---|
[648] | 382 | % --- Executes on selection change in FieldOption. |
---|
[582] | 383 | %------------------------------------------------------------------------ |
---|
[648] | 384 | function FieldOption_Callback(hObject, eventdata, handles) |
---|
| 385 | |
---|
[672] | 386 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 387 | FieldList=get(handles.FieldOption,'String'); |
---|
| 388 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
---|
| 389 | switch FieldOption |
---|
[672] | 390 | |
---|
[648] | 391 | case '1D plot' |
---|
[654] | 392 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 393 | set(handles.PanelOrdinate,'Visible','on') |
---|
| 394 | pos=get(handles.PanelOrdinate,'Position'); |
---|
| 395 | pos(1)=2; |
---|
| 396 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 397 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 398 | set(handles.PanelOrdinate,'Position',pos) |
---|
| 399 | set(handles.PanelScalar,'Visible','off') |
---|
| 400 | set(handles.PanelVectors,'Visible','off') |
---|
| 401 | set(handles.Coord_y,'Visible','off') |
---|
| 402 | set(handles.Y_title,'Visible','off') |
---|
| 403 | set(handles.Coord_z,'Visible','off') |
---|
| 404 | set(handles.Z_title,'Visible','off') |
---|
| 405 | ordinate_Callback(hObject, eventdata, handles) |
---|
[672] | 406 | |
---|
[648] | 407 | case 'scalar' |
---|
[654] | 408 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 409 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 410 | set(handles.PanelScalar,'Visible','on') |
---|
| 411 | set(handles.PanelVectors,'Visible','off') |
---|
| 412 | pos=get(handles.PanelScalar,'Position'); |
---|
| 413 | pos(1)=2; |
---|
| 414 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 415 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 416 | set(handles.PanelScalar,'Position',pos) |
---|
| 417 | set(handles.Coord_y,'Visible','on') |
---|
| 418 | set(handles.Y_title,'Visible','on') |
---|
[672] | 419 | %default scalar selection |
---|
| 420 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 421 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 422 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') |
---|
| 423 | Role=Field.Display.VarAttribute{ilist}.Role; |
---|
| 424 | if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') |
---|
| 425 | test_coord(ilist)=1; |
---|
| 426 | end |
---|
| 427 | end |
---|
| 428 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 429 | if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable |
---|
| 430 | test_coord(ilist)=1; |
---|
| 431 | end |
---|
| 432 | end |
---|
| 433 | scalar_index=find(~test_coord,1);%get the first variable not a coordiante |
---|
| 434 | if isempty(scalar_index) |
---|
| 435 | set(handles.scalar,'Value',1) |
---|
| 436 | else |
---|
| 437 | set(handles.scalar,'Value',scalar_index) |
---|
| 438 | end |
---|
[648] | 439 | scalar_Callback(hObject, eventdata, handles) |
---|
[674] | 440 | |
---|
[648] | 441 | case 'vectors' |
---|
[674] | 442 | set(handles.PanelVectors,'Visible','on') |
---|
[654] | 443 | set(handles.Coordinates,'Visible','on') |
---|
[648] | 444 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 445 | set(handles.PanelScalar,'Visible','off') |
---|
| 446 | pos=get(handles.PanelVectors,'Position'); |
---|
| 447 | pos(1)=2; |
---|
| 448 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 449 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 450 | set(handles.PanelVectors,'Position',pos) |
---|
| 451 | set(handles.Coord_y,'Visible','on') |
---|
[672] | 452 | set(handles.Y_title,'Visible','on') |
---|
| 453 | %default vector selection |
---|
[674] | 454 | vector_x_value=get(handles.vector_x,'UserData'); |
---|
| 455 | vector_y_value=get(handles.vector_y,'UserData'); |
---|
| 456 | if ~isempty(vector_x_value)&&~isempty(vector_y_value) |
---|
| 457 | set(handles.vector_x,'Value',vector_x_value) |
---|
| 458 | set(handles.vector_y,'Value',vector_y_value) |
---|
| 459 | else |
---|
| 460 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate |
---|
| 461 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 462 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') |
---|
| 463 | Role=Field.Display.VarAttribute{ilist}.Role; |
---|
| 464 | if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') |
---|
| 465 | test_coord(ilist)=1; |
---|
| 466 | end |
---|
| 467 | end |
---|
| 468 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 469 | if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable |
---|
[672] | 470 | test_coord(ilist)=1; |
---|
| 471 | end |
---|
| 472 | end |
---|
[674] | 473 | vector_index=find(~test_coord,2);%get the two first variables not a coordinate |
---|
| 474 | if isempty(vector_index) |
---|
| 475 | set(handles.vector_x,'Value',1) |
---|
| 476 | set(handles.vector_y,'Value',2) |
---|
| 477 | else |
---|
| 478 | set(handles.vector_x,'Value',vector_index(1)) |
---|
| 479 | set(handles.vector_y,'Value',vector_index(2)) |
---|
[672] | 480 | end |
---|
| 481 | end |
---|
[648] | 482 | vector_Callback(handles) |
---|
[672] | 483 | |
---|
[654] | 484 | case 'civdata...' |
---|
| 485 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 486 | set(handles.PanelScalar,'Visible','off') |
---|
| 487 | set(handles.PanelVectors,'Visible','off') |
---|
| 488 | set(handles.Coordinates,'Visible','off') |
---|
[582] | 489 | end |
---|
| 490 | |
---|
| 491 | %------------------------------------------------------------------------ |
---|
[204] | 492 | function ordinate_Callback(hObject, eventdata, handles) |
---|
| 493 | %------------------------------------------------------------------------ |
---|
[582] | 494 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 495 | y_index=get(handles.ordinate,'Value'); |
---|
| 496 | y_menu=get(handles.ordinate,'String'); |
---|
| 497 | YName=y_menu{y_index}; |
---|
| 498 | |
---|
| 499 | %% set list of possible coordinates |
---|
| 500 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 501 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 502 | ListCoord={''}; |
---|
| 503 | dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable |
---|
| 504 | |
---|
| 505 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 506 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 507 | if isequal(dimnames,dim_var) |
---|
| 508 | test_component(ilist)=1; |
---|
| 509 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 510 | test_coord(ilist)=1; |
---|
[582] | 511 | end |
---|
| 512 | end |
---|
[648] | 513 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
| 514 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 515 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[204] | 516 | |
---|
[648] | 517 | %% set default coord selection |
---|
| 518 | if numel(find(test_coord))>3 |
---|
| 519 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[582] | 520 | end |
---|
[648] | 521 | if numel(var_component)<2 |
---|
| 522 | if numel(test_coord)<2 |
---|
| 523 | ListCoord={''}; |
---|
| 524 | else |
---|
| 525 | set(handles.Coord_x,'Value',2) |
---|
| 526 | set(handles.Coord_y,'Value',1) |
---|
| 527 | end |
---|
[582] | 528 | else |
---|
[648] | 529 | coord_val=1; |
---|
| 530 | for ilist=1:numel(var_component) |
---|
| 531 | ivar=var_component(ilist); |
---|
| 532 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 533 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 534 | if strcmp(Role,'coord_x') |
---|
| 535 | coord_val=ilist; |
---|
| 536 | end |
---|
| 537 | end |
---|
| 538 | end |
---|
| 539 | set(handles.Coord_x,'Value',coord_val) |
---|
[582] | 540 | end |
---|
[648] | 541 | set(handles.Coord_x,'String',ListCoord) |
---|
[582] | 542 | |
---|
| 543 | |
---|
[648] | 544 | %% set list of time coordinates |
---|
| 545 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 546 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 547 | switch TimeOption |
---|
| 548 | case 'variable' |
---|
| 549 | if numel(find(test_coord))<3 |
---|
| 550 | ListTime={''}; |
---|
| 551 | else |
---|
| 552 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 553 | end |
---|
| 554 | set(handles.TimeName,'Value',1) |
---|
| 555 | set(handles.TimeName,'String',ListTime) |
---|
| 556 | case 'dim index' |
---|
| 557 | if numel(find(test_coord))<3 |
---|
| 558 | ListTime={''}; |
---|
| 559 | else |
---|
| 560 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 561 | end |
---|
| 562 | set(handles.TimeName,'Value',1) |
---|
| 563 | set(handles.TimeName,'String',ListTime) |
---|
| 564 | end |
---|
| 565 | update_field(handles,YName) |
---|
[674] | 566 | |
---|
[582] | 567 | %------------------------------------------------------------------------ |
---|
[204] | 568 | % --- Executes on selection change in scalar menu. |
---|
[648] | 569 | %------------------------------------------------------------------------ |
---|
[204] | 570 | function scalar_Callback(hObject, eventdata, handles) |
---|
[648] | 571 | |
---|
[586] | 572 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 573 | scalar_index=get(handles.scalar,'Value'); |
---|
| 574 | scalar_menu=get(handles.scalar,'String'); |
---|
| 575 | ScalarName=scalar_menu{scalar_index}; |
---|
[204] | 576 | |
---|
[648] | 577 | %% set list of possible coordinates |
---|
| 578 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 579 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 580 | dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable |
---|
| 581 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 582 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 583 | if isequal(dimnames,dim_var) |
---|
| 584 | test_component(ilist)=1; |
---|
| 585 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 586 | test_coord(ilist)=1; |
---|
| 587 | end |
---|
[227] | 588 | end |
---|
[672] | 589 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
[648] | 590 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 591 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[227] | 592 | |
---|
[648] | 593 | %% set default coord selection |
---|
| 594 | if numel(find(test_coord))>3 |
---|
| 595 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
| 596 | end |
---|
[672] | 597 | % if numel(var_component)<2 |
---|
| 598 | % if numel(test_coord)<2 |
---|
| 599 | % ListCoord={''}; |
---|
| 600 | % else |
---|
| 601 | % set(handles.Coord_x,'Value',2) |
---|
| 602 | % set(handles.Coord_y,'Value',1) |
---|
| 603 | % end |
---|
| 604 | % else |
---|
| 605 | coord_val=[0 0]; |
---|
| 606 | % look for labelled unstructured coordinates |
---|
| 607 | for ilist=1:numel(var_component) |
---|
| 608 | ivar=var_component(ilist); |
---|
| 609 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 610 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 611 | if strcmp(Role,'coord_x') |
---|
| 612 | coord_val(1)=ilist; |
---|
| 613 | elseif strcmp(Role,'coord_y') |
---|
| 614 | coord_val(2)=ilist; |
---|
[227] | 615 | end |
---|
| 616 | end |
---|
| 617 | end |
---|
[672] | 618 | if numel(find(coord_val))<2 |
---|
| 619 | if numel(var_coord)>=2 |
---|
| 620 | coord_val=[numel(var_component)+2 numel(var_component)+1]; |
---|
| 621 | else |
---|
| 622 | coord_val=[1 2]; |
---|
| 623 | end |
---|
| 624 | end |
---|
| 625 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 626 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[648] | 627 | set(handles.Coord_y,'String',ListCoord) |
---|
| 628 | set(handles.Coord_x,'String',ListCoord) |
---|
[227] | 629 | |
---|
| 630 | |
---|
[648] | 631 | %% set list of time coordinates |
---|
| 632 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 633 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 634 | switch TimeOption |
---|
| 635 | case 'variable' |
---|
| 636 | if numel(find(test_coord))<3 |
---|
| 637 | ListTime={''}; |
---|
| 638 | else |
---|
| 639 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 640 | end |
---|
| 641 | set(handles.TimeName,'Value',1) |
---|
| 642 | set(handles.TimeName,'String',ListTime) |
---|
| 643 | case 'dim index' |
---|
| 644 | if numel(find(test_coord))<3 |
---|
| 645 | ListTime={''}; |
---|
| 646 | else |
---|
| 647 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 648 | end |
---|
| 649 | set(handles.TimeName,'Value',1) |
---|
| 650 | set(handles.TimeName,'String',ListTime) |
---|
| 651 | end |
---|
| 652 | update_field(handles,ScalarName) |
---|
[582] | 653 | |
---|
[648] | 654 | % --- Executes on button press in check_rgb. |
---|
| 655 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[582] | 656 | |
---|
| 657 | |
---|
| 658 | %------------------------------------------------------------------------ |
---|
[204] | 659 | % --- Executes on selection change in vector_x. |
---|
[672] | 660 | %------------------------------------------------------------------------ |
---|
[204] | 661 | function vector_x_Callback(hObject, eventdata, handles) |
---|
[672] | 662 | |
---|
[648] | 663 | vector_x_menu=get(handles.vector_x,'String'); |
---|
| 664 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 665 | vector_x=vector_x_menu{vector_x_index}; |
---|
| 666 | vector_Callback(handles) |
---|
| 667 | update_field(handles,vector_x) |
---|
[227] | 668 | |
---|
[204] | 669 | %------------------------------------------------------------------------ |
---|
[648] | 670 | % --- Executes on selection change in vector_x. |
---|
[204] | 671 | function vector_y_Callback(hObject, eventdata, handles) |
---|
| 672 | %------------------------------------------------------------------------ |
---|
[648] | 673 | vector_y_menu=get(handles.vector_x,'String'); |
---|
| 674 | vector_y_index=get(handles.vector_x,'Value'); |
---|
| 675 | vector_y=vector_y_menu{vector_y_index}; |
---|
| 676 | vector_Callback(handles) |
---|
| 677 | update_field(handles,vector_y) |
---|
[204] | 678 | |
---|
| 679 | %------------------------------------------------------------------------ |
---|
| 680 | % --- Executes on selection change in vector_z. |
---|
| 681 | function vector_z_Callback(hObject, eventdata, handles) |
---|
| 682 | %------------------------------------------------------------------------ |
---|
[648] | 683 | vector_z_menu=get(handles.vector_z,'String'); |
---|
| 684 | vector_z_index=get(handles.vector_z,'Value'); |
---|
| 685 | vector_z=vector_z_menu{vector_z_index}; |
---|
| 686 | vector_Callback(handles) |
---|
| 687 | update_field(handles,vector_z) |
---|
[204] | 688 | |
---|
| 689 | %------------------------------------------------------------------------ |
---|
| 690 | % --- Executes on selection change in vec_color. |
---|
| 691 | function vec_color_Callback(hObject, eventdata, handles) |
---|
[227] | 692 | %------------------------------------------------------------------------ |
---|
[204] | 693 | index=get(handles.vec_color,'Value'); |
---|
| 694 | string=get(handles.vec_color,'String'); |
---|
| 695 | VarName=string{index}; |
---|
[648] | 696 | vector_Callback(handles) |
---|
| 697 | update_field(handles,VarName) |
---|
[204] | 698 | |
---|
[227] | 699 | %------------------------------------------------------------------------ |
---|
[648] | 700 | % --- Executes on selection change in vector_x or vector_y |
---|
| 701 | function vector_Callback( handles) |
---|
[227] | 702 | %------------------------------------------------------------------------ |
---|
[648] | 703 | Field=get(handles.get_field,'UserData'); |
---|
| 704 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 705 | vector_y_index=get(handles.vector_y,'Value'); |
---|
| 706 | vec_color_index=get(handles.vec_color,'Value'); |
---|
[204] | 707 | |
---|
[648] | 708 | %% set list of possible coordinates |
---|
| 709 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 710 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 711 | check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn |
---|
| 712 | ListCoord={''}; |
---|
| 713 | dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable |
---|
| 714 | if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index}) |
---|
| 715 | check_consistent=0; |
---|
| 716 | elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index}) |
---|
| 717 | check_consistent=0; |
---|
[204] | 718 | end |
---|
[672] | 719 | % the two vector components have consistent dimensions |
---|
[648] | 720 | if check_consistent |
---|
| 721 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 722 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 723 | if isequal(dimnames,dim_var) |
---|
| 724 | test_component(ilist)=1; |
---|
| 725 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 726 | test_coord(ilist)=1; |
---|
[204] | 727 | end |
---|
| 728 | end |
---|
[675] | 729 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
[648] | 730 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 731 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
| 732 | |
---|
| 733 | %% set default coord selection |
---|
| 734 | if numel(find(test_coord))>3 |
---|
| 735 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[204] | 736 | end |
---|
[648] | 737 | if numel(var_component)<2 |
---|
| 738 | if numel(test_coord)<2 |
---|
| 739 | ListCoord={''}; |
---|
| 740 | else |
---|
| 741 | set(handles.Coord_x,'Value',2) |
---|
| 742 | set(handles.Coord_y,'Value',1) |
---|
[204] | 743 | end |
---|
| 744 | else |
---|
[672] | 745 | coord_val=[0 0]; |
---|
[648] | 746 | for ilist=1:numel(var_component) |
---|
| 747 | ivar=var_component(ilist); |
---|
| 748 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 749 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 750 | if strcmp(Role,'coord_x') |
---|
| 751 | coord_val(1)=ilist; |
---|
| 752 | elseif strcmp(Role,'coord_y') |
---|
| 753 | coord_val(2)=ilist; |
---|
| 754 | end |
---|
[526] | 755 | end |
---|
| 756 | end |
---|
[675] | 757 | if isempty(find(coord_val)) |
---|
[672] | 758 | coord_val=var_coord;% case of dimension coordinates |
---|
| 759 | end |
---|
| 760 | if numel(find(coord_val))<2 |
---|
[675] | 761 | %coord_val=[numel(var_component)+2 numel(var_component)+1]; |
---|
| 762 | coord_val=[1 2]; |
---|
[672] | 763 | end |
---|
[648] | 764 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 765 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[526] | 766 | end |
---|
[204] | 767 | end |
---|
[648] | 768 | set(handles.Coord_y,'String',ListCoord) |
---|
| 769 | set(handles.Coord_x,'String',ListCoord) |
---|
[204] | 770 | |
---|
| 771 | |
---|
[648] | 772 | %% set list of time coordinates |
---|
| 773 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 774 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 775 | switch TimeOption |
---|
| 776 | case 'variable' |
---|
| 777 | if numel(find(test_coord))<3 |
---|
| 778 | ListTime={''}; |
---|
| 779 | else |
---|
| 780 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
[204] | 781 | end |
---|
[648] | 782 | set(handles.TimeName,'Value',1) |
---|
| 783 | set(handles.TimeName,'String',ListTime) |
---|
| 784 | case 'dim index' |
---|
| 785 | if numel(find(test_coord))<3 |
---|
| 786 | ListTime={''}; |
---|
| 787 | else |
---|
| 788 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
[204] | 789 | end |
---|
[648] | 790 | set(handles.TimeName,'Value',1) |
---|
| 791 | set(handles.TimeName,'String',ListTime) |
---|
| 792 | end |
---|
[204] | 793 | |
---|
[227] | 794 | %------------------------------------------------------------------------ |
---|
[648] | 795 | % --- Executes on selection change in SwitchVarIndexX. |
---|
[227] | 796 | %------------------------------------------------------------------------ |
---|
[648] | 797 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
[227] | 798 | |
---|
| 799 | %------------------------------------------------------------------------ |
---|
[648] | 800 | % --- Executes on selection change in Coord_x. |
---|
[672] | 801 | %------------------------------------------------------------------------ |
---|
[648] | 802 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[672] | 803 | |
---|
[648] | 804 | index=get(handles.Coord_x,'Value'); |
---|
| 805 | string=get(handles.Coord_x,'String'); |
---|
| 806 | VarName=string{index}; |
---|
| 807 | update_field(handles,VarName) |
---|
[227] | 808 | |
---|
| 809 | %------------------------------------------------------------------------ |
---|
[648] | 810 | % --- Executes on selection change in Coord_y. |
---|
[672] | 811 | %------------------------------------------------------------------------ |
---|
[648] | 812 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
[672] | 813 | |
---|
[648] | 814 | index=get(handles.Coord_y,'Value'); |
---|
| 815 | string=get(handles.Coord_y,'String'); |
---|
| 816 | VarName=string{index}; |
---|
| 817 | update_field(handles,VarName) |
---|
[227] | 818 | |
---|
[646] | 819 | %------------------------------------------------------------------------ |
---|
[648] | 820 | % --- Executes on selection change in Coord_z. |
---|
[672] | 821 | %------------------------------------------------------------------------ |
---|
[648] | 822 | function Coord_z_Callback(hObject, eventdata, handles) |
---|
[672] | 823 | |
---|
[648] | 824 | index=get(handles.Coord_z,'Value'); |
---|
| 825 | string=get(handles.Coord_z,'String'); |
---|
| 826 | VarName=string{index}; |
---|
| 827 | update_field(handles,VarName) |
---|
[581] | 828 | |
---|
[646] | 829 | %------------------------------------------------------------------------ |
---|
[581] | 830 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
[646] | 831 | %------------------------------------------------------------------------ |
---|
[581] | 832 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
[672] | 833 | |
---|
[648] | 834 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 835 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 836 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[648] | 837 | |
---|
[581] | 838 | switch option |
---|
| 839 | case 'file index' |
---|
[648] | 840 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
---|
[581] | 841 | case 'attribute' |
---|
[648] | 842 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
---|
[674] | 843 | time_index=get(handles.TimeName,'UserData'); %select the input data |
---|
| 844 | if isempty(time_index) |
---|
| 845 | PreviousList=get(handles.TimeName, 'String'); |
---|
| 846 | if ~isempty(PreviousList) |
---|
| 847 | PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; |
---|
| 848 | index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1); |
---|
| 849 | end |
---|
[581] | 850 | end |
---|
[674] | 851 | if isempty(time_index) |
---|
| 852 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time' |
---|
| 853 | end |
---|
[581] | 854 | if ~isempty(time_index) |
---|
[674] | 855 | set(handles.TimeName,'Value',time_index) |
---|
[581] | 856 | else |
---|
[648] | 857 | set(handles.TimeName,'Value',1) |
---|
[581] | 858 | end |
---|
[648] | 859 | set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) |
---|
[674] | 860 | |
---|
[648] | 861 | case 'variable'% TimeName menu represents the available variables |
---|
| 862 | set(handles.TimeName, 'Visible','on') |
---|
| 863 | TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time) |
---|
| 864 | List=get(handles.TimeName,'String'); |
---|
| 865 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 866 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 867 | if isempty(ind) |
---|
[648] | 868 | set(handles.TimeName, 'Value',1); |
---|
[581] | 869 | else |
---|
[648] | 870 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 871 | end |
---|
[648] | 872 | set(handles.TimeName, 'String',TimeVarName) |
---|
| 873 | case 'dim index'% TimeName menu represents the available dimensions |
---|
| 874 | set(handles.TimeName, 'Visible','on') |
---|
| 875 | TimeVarName=Field.Display.SingleDimName; |
---|
| 876 | List=get(handles.TimeName,'String'); |
---|
| 877 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 878 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 879 | if isempty(ind) |
---|
[648] | 880 | set(handles.TimeName, 'Value',1); |
---|
[581] | 881 | else |
---|
[648] | 882 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 883 | end |
---|
[648] | 884 | set(handles.TimeName, 'String',TimeVarName) |
---|
[581] | 885 | end |
---|
| 886 | |
---|
[648] | 887 | %----------------------------------------------------------------------- |
---|
| 888 | function update_field(handles,VarName) |
---|
| 889 | %----------------------------------------------------------------------- |
---|
| 890 | Field=get(handles.get_field,'UserData'); |
---|
| 891 | index=name2index(VarName,Field.ListVarName); |
---|
| 892 | if ~isempty(index) |
---|
| 893 | set(handles.variables,'Value',index+1) |
---|
| 894 | variables_Callback(handles.variables, [], handles) |
---|
[644] | 895 | end |
---|
[648] | 896 | |
---|
[672] | 897 | %------------------------------------------------------------------------ |
---|
| 898 | % --- give index numbers of the strings str in the list ListvarName |
---|
| 899 | % ----------------------------------------------------------------------- |
---|
[648] | 900 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
[672] | 901 | |
---|
[648] | 902 | VarIndex_y=[]; |
---|
| 903 | if ischar(cell_str) |
---|
| 904 | for ivar=1:length(ListVarName) |
---|
| 905 | varlist=ListVarName{ivar}; |
---|
| 906 | if isequal(varlist,cell_str) |
---|
| 907 | VarIndex_y= ivar; |
---|
| 908 | break |
---|
| 909 | end |
---|
| 910 | end |
---|
| 911 | elseif iscell(cell_str) |
---|
| 912 | for isel=1:length(cell_str) |
---|
| 913 | varsel=cell_str{isel}; |
---|
| 914 | for ivar=1:length(ListVarName) |
---|
| 915 | varlist=ListVarName{ivar}; |
---|
| 916 | if isequal(varlist,varsel) |
---|
| 917 | VarIndex_y=[VarIndex_y ivar]; |
---|
| 918 | end |
---|
| 919 | end |
---|
| 920 | end |
---|
| 921 | end |
---|