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