Changeset 581 for trunk/src/get_field.m
- Timestamp:
- Mar 12, 2013, 12:52:13 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r538 r581 1 %'get_field': display variables and attributes from a Netcdf file, and RUNselected fields1 %'get_field': display variables and attributes from a Netcdf file, and OK selected fields 2 2 %------------------------------------------------------------------------ 3 3 %function varargout = get_field(varargin) … … 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 26-Jul-2012 09:11:2324 % Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52 25 25 26 26 % Begin initialization code - DO NOT EDIT 27 gui_Singleton = 0;27 gui_Singleton = 1; 28 28 gui_State = struct('gui_Name', mfilename, ... 29 29 'gui_Singleton', gui_Singleton, ... … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before get_field is made visible. 47 function get_field_OpeningFcn(hObject, eventdata, handles,filename, multiple)47 function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) 48 48 %------------------------------------------------------------------------ 49 49 global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN 50 50 51 52 53 51 %% Choose default command line output for get_field 54 handles.output = hObject;52 handles.output = 'Cancel'; 55 53 56 54 %% Update handles structure … … 58 56 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 59 57 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 58 %% settings for 'slave' mode, called by uvmat, or 'master' mode 110 59 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 111 60 set(handles.inputfile,'String',filename)% prefill the input file name 112 Field=nc2struct(filename,[]);% reads the field structure, without variables61 Field=nc2struct(filename,[]);% reads the field structure, without the variables 113 62 if isfield(Field,'Txt') 114 msgbox_uvmat('ERROR', Field.Txt)63 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt]) 115 64 else 116 65 set(handles.get_field,'UserData',Field); 117 Field_input(handles,Field); 66 if ~exist('ParamIn','var') 67 ParamIn=[]; 68 end 69 Field_input(handles,Field,ParamIn); 118 70 end 119 71 else %master mode … … 121 73 end 122 74 123 %% load the list of previously browsed files for the upper bar menu Open124 % 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 % end131 % if isfield(h,'MenuFile_1')132 % set(handles.MenuFile_2,'Label',h.MenuFile_2);133 % end134 % if isfield(h,'MenuFile_1')135 % set(handles.MenuFile_3,'Label',h.MenuFile_3);136 % end137 % if isfield(h,'MenuFile_1')138 % set(handles.MenuFile_4,'Label',h.MenuFile_4);139 % end140 % if isfield(h,'MenuFile_1')141 % set(handles.MenuFile_5,'Label',h.MenuFile_5);142 % end143 % end144 145 75 %% put the GUI on the lower right of the sceen 76 set(hObject,'Unit','pixel') 146 77 pos_view_field=get(hObject,'Position'); 147 78 ScreenSize=get(0,'ScreenSize'); … … 150 81 set(hObject,'Position',pos_view_field) 151 82 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 83 % if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence 84 % hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI 85 % if length(hget_field)>1 86 % delete(hget_field(2)) 87 % end 88 % else 89 % set(hObject,'name','get_field_1') 90 % end 91 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 92 drawnow 93 uiwait(handles.get_field); 162 94 163 95 %------------------------------------------------------------------------ … … 166 98 %------------------------------------------------------------------------ 167 99 varargout{1} = handles.output; 100 delete(handles.get_field) 168 101 169 102 %------------------------------------------------------------------------ … … 186 119 %------------------------------------------------------------------------ 187 120 % --- update the display when a new field is introduced. 188 function Field_input(handles,Field )121 function Field_input(handles,Field,ParamInput) 189 122 %------------------------------------------------------------------------ 190 123 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) … … 203 136 set(handles.variables,'String',[{'*'} Txt]) 204 137 variables_Callback(handles.variables,[], handles) 138 139 if exist('ParamInput','var') 140 fill_GUI(ParamInput,handles); 141 return 142 else 205 143 set(handles.abscissa,'String',[{''} Txt ]) 206 144 set(handles.ordinate,'String',Txt) … … 209 147 set(handles.vector_z,'String',[{''} Txt ]) 210 148 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 ])149 % set(handles.XVarName,'String',[{''} Txt ]) 150 % set(handles.ZVarName,'String',[{''} Txt ]) 151 % set(handles.coord_x_vectors,'String',[{''} Txt ]) 152 % set(handles.coord_y_vectors,'String',[{''} Txt ]) 153 % set(handles.YVarName,'String',[{''} Txt ]) 154 % set(handles.TimeVarName,'String',[{''} Txt ]) 217 155 set(handles.scalar,'Value',1) 218 156 219 157 set(handles.scalar,'String', Txt ) 220 158 [CellInfo,NbDim,errormsg]=find_field_cells(Field); 221 % [CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Field);222 159 if ~isempty(errormsg) 223 160 msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) 224 161 return 225 162 end 226 % for icell=1:numel(CellInfo)227 % NbDim(icell)=max(NbDim(icell),numel(CellInfo{icell}.VarIndex));228 % end229 163 [maxdim,imax]=max(NbDim); 230 164 165 %% set time mode 166 if maxdim>=4 167 set(handles.SwitchVarIndexTime,'Value',4) 168 else 169 time_index=[]; 170 if isfield(Field,'ListGlobalAttribute') 171 time_index=find(~cellfun('isempty',regexp(Field.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' 172 end 173 if isempty(time_index) 174 set(handles.SwitchVarIndexTime,'Value',1) 175 else 176 set(handles.SwitchVarIndexTime,'Value',2) 177 end 178 end 179 SwitchVarIndexTime_Callback([],[], handles) 180 231 181 if maxdim>=3 232 182 set(handles.vector_z,'Visible','on') 233 183 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 ]) 184 set(handles.ZVarName,'Visible','on') 185 set(handles.SwitchVarIndexZ,'Visible','on') 186 set(handles.Z_title,'Visible','on') 187 % set(handles.TimeVarName,'Visible','on') 188 % set(handles.TimeVarName,'String',[{''} Txt ]) 189 % set(handles.YVarName,'Visible','on') 190 % set(handles.YVarName,'String',[{''} Txt ]) 238 191 else 239 192 set(handles.vector_z,'Visible','off') 240 set(handles.coord_z_vectors,'Visible','off') 241 set(handles.coord_z_scalar,'Visible','off') 193 set(handles.ZVarName,'Visible','off') 194 set(handles.SwitchVarIndexZ,'Visible','off') 195 set(handles.Z_title,'Visible','off') 242 196 end 243 197 if maxdim>=2 … … 248 202 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) 249 203 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 end204 % if strcmp(CellInfo{imax}.CoordType,'scattered') 205 % set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)) 206 % set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)) 207 % elseif strcmp(CellInfo{imax}.CoordType,'grid') 208 % set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1) 209 % set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1) 210 % end 257 211 else 258 212 set(handles.CheckScalar,'Value',1) 259 213 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 214 % if isfield(CellInfo{imax},'VarIndex_scalar') 215 % set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1)) 216 % set(handles.XVarName,'Value',CellInfo{imax}.CoordIndex(end)+1) 217 % set(handles.ZVarName,'Value',CellInfo{imax}.CoordIndex(end-1)+1) 218 % if numel(CellInfo{imax}.CoordIndex)==3 219 % set(handles.YVarName,'Value',CellInfo{imax}.CoordIndex(1)+1) 220 % end 221 % end 222 end 223 else 224 set(handles.CheckPlot1D,'Value',1) 225 set(handles.CheckScalar,'Value',0) 226 set(handles.CheckVector,'Value',0) 227 end 228 end 229 CheckPlot1D_Callback(handles.CheckPlot1D, [], handles) 230 CheckScalar_Callback(handles.CheckScalar, [], handles) 231 CheckVector_Callback(handles.CheckVector, [], handles) 273 232 274 233 %------------------------------------------------------------------------ … … 324 283 % set(handles.variables,'Value',xindex+1)%outline in the list of variables 325 284 % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) 326 % if ~test_2D & ~test_scalar% look for possible varaibles to RUNin ordinate285 % if ~test_2D & ~test_scalar% look for possible varaibles to OK in ordinate 327 286 % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa 328 287 % VarIndex=[]; … … 330 289 % index_i=Field.VarDimIndex{ilist}; 331 290 % if ~isempty(index_i) 332 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, RUNis possible291 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible 333 292 % VarIndex=[VarIndex ilist]; 334 293 % end … … 378 337 379 338 string_coord=[{''};string(test_coord==1)]; 380 val=get(handles. coord_x_scalar,'Value');339 val=get(handles.XVarName,'Value'); 381 340 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');341 set(handles.XVarName,'Value',1) 342 end 343 set(handles.XVarName,'String',string_coord); 344 val=get(handles.ZVarName,'Value'); 386 345 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');346 set(handles.ZVarName,'Value',1) 347 end 348 set(handles.ZVarName,'String',string_coord); 349 val=get(handles.ZVarName,'Value'); 391 350 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');351 set(handles.ZVarName,'Value',1) 352 end 353 set(handles.YVarName,'String',string_coord); 354 355 356 %------------------------------------------------------------------------ 357 % --- Executes on selection change in XVarName. 358 function XVarName_Callback(hObject, eventdata, handles) 359 %------------------------------------------------------------------------ 360 index=get(handles.XVarName,'Value'); 361 string=get(handles.XVarName,'String'); 403 362 VarName=string{index}; 404 363 update_field(hObject, eventdata, handles,VarName) 405 364 406 365 %------------------------------------------------------------------------ 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');366 % --- Executes on selection change in ZVarName. 367 function ZVarName_Callback(hObject, eventdata, handles) 368 %------------------------------------------------------------------------ 369 index=get(handles.ZVarName,'Value'); 370 string=get(handles.ZVarName,'String'); 412 371 VarName=string{index}; 413 372 update_field(hObject, eventdata, handles,VarName) 414 373 415 374 %------------------------------------------------------------------------ 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');375 % --- Executes on selection change in YVarName. 376 function YVarName_Callback(hObject, eventdata, handles) 377 %------------------------------------------------------------------------ 378 index=get(handles.YVarName,'Value'); 379 string=get(handles.YVarName,'String'); 421 380 VarName=string{index}; 422 381 update_field(hObject, eventdata, handles,VarName) … … 480 439 end 481 440 set(handles.coord_y_vectors,'String',string_coord); 482 val=get(handles. coord_z_vectors,'Value');441 val=get(handles.TimeVarName,'Value'); 483 442 if val>numel(string_coord) 484 set(handles. coord_z_vectors,'Value',1)485 end 486 set(handles. coord_z_vectors,'String',string_coord);443 set(handles.TimeVarName,'Value',1) 444 end 445 set(handles.TimeVarName,'String',string_coord); 487 446 488 447 update_field(hObject, eventdata, handles,VarName) … … 525 484 526 485 %------------------------------------------------------------------------ 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');486 % --- Executes on selection change in YVarName. 487 function TimeVarName_Callback(hObject, eventdata, handles) 488 %------------------------------------------------------------------------ 489 index=get(handles.TimeVarName,'Value'); 490 string=get(handles.TimeVarName,'String'); 532 491 VarName=string{index}; 533 492 update_field(hObject, eventdata, handles,VarName) … … 689 648 VarIndex.y=name2index(list_var,Field.ListVarName); 690 649 if isequal(VarIndex.A,VarIndex.y) 691 set(handles. coord_y_scalar,'Value',1)650 set(handles.ZVarName,'Value',1) 692 651 elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) 693 652 set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components … … 811 770 812 771 %--------------------------------------------------------- 813 % --- Executes on button press in RUN.814 815 function RUN_Callback(hObject, eventdata, handles)772 % --- Executes on button press in OK. 773 774 function OK_Callback(hObject, eventdata, handles) 816 775 %--------------------------------------------------------- 776 777 handles.output=read_GUI(handles.get_field); 778 guidata(hObject, handles);% Update handles structure 779 uiresume(handles.get_field); 780 drawnow 781 return 782 783 %%%% SKIPPED %%%% 817 784 hfield=[]; 818 785 huvmat=findobj(allchild(0),'tag','uvmat'); … … 911 878 if strcmp(list_fig{val},'uvmat') 912 879 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)880 set(handles.OK,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt) 914 881 set(handles.MenuOpen,'Visible','off') 915 882 set(handles.MenuExport,'Visible','off') … … 933 900 % %------------------------------------------------ 934 901 % % --- Executes on button press in Plot_histo. 935 % % RUNglobal histograms902 % %OK global histograms 936 903 % %------------------------------------------------- 937 904 % function RUN_histo_Callback(hObject, eventdata, handles) 938 % % hObject handle to RUN(see GCBO)905 % % hObject handle to OK (see GCBO) 939 906 % % eventdata reserved - to be defined in a future version of MATLAB 940 907 % % handles structure with handles and user data (see GUIDATA) … … 1672 1639 set(handles.TimeIndexValue,'Visible','off') 1673 1640 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 1641 % 1642 % %------------------------------------------------------------------------ 1643 % % --- Executes on selection change in TimeDimensionMenu. 1644 % function TimeDimensionMenu_Callback(hObject, eventdata, handles) 1645 % %------------------------------------------------------------------------ 1646 % index=get(handles.TimeDimensionMenu,'Value'); 1647 % DimList=get(handles.TimeDimensionMenu,'String'); 1648 % DimName=DimList{index}; 1649 % Field=get(handles.get_field,'UserData'); 1650 % DimIndex=find(strcmp(DimName,Field.ListDimName),1); 1651 % ref_index=round(Field.DimValue(DimIndex)/2); 1652 % set(handles.TimeIndexValue,'String',num2str(ref_index)) 1653 % scalar_Callback(hObject, eventdata, handles) 1654 % vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time) 1655 % % look for a corresponding time variable and value 1656 % time_test=zeros(size(Field.VarDimName)); 1657 % for ilist=1:numel(Field.VarDimName) 1658 % if isequal(Field.VarDimName{ilist},{DimName}) 1659 % time_test(ilist)=1; 1660 % end 1661 % end 1662 % ListVariable=Field.ListVarName(time_test==1); 1663 % set(handles.TimeVariableMenu,'Value',1) 1664 % if isempty(ListVariable) 1665 % set(handles.TimeVariableMenu,'String',{''}) 1666 % set(handles.TimeVarValue,'String','') 1667 % else 1668 % set(handles.TimeVariableMenu,'String',ListVariable) 1669 % TimeVarName=ListVariable{1}; 1670 % VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables 1671 % inputfile=get(handles.inputfile,'String');% read the input file 1672 % SubField=nc2struct(inputfile,{TimeVarName}); 1673 % eval(['TimeValue=SubField.' TimeVarName '(ref_index);']) 1674 % set(handles.TimeVarValue,'Visible','on') 1675 % set(handles.TimeVariableMenu,'Visible','on') 1676 % set(handles.TimeVarValue,'String',num2str(TimeValue)) 1677 % end 1678 % 1679 % 1680 % % % ----------------------------------------------------------------------- 1681 % % % --- Executes on button press in TimeVariable. 1682 % % function TimeVariable_Callback(hObject, eventdata, handles) 1683 % % % ----------------------------------------------------------------------- 1684 % % val=get(handles.TimeVariable,'Value'); 1685 % % if val 1686 % % Field=get(handles.get_field,'UserData'); 1687 % % time_test=zeros(size(Field.VarDimName)); 1688 % % for ilist=1:numel(Field.VarDimName) 1689 % % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension 1690 % % time_test(ilist)=1; 1691 % % end 1692 % % end 1693 % % ind_test=find(time_test); 1694 % % if isempty(time_test) 1695 % % set(handles.TimeVariable,'Value',0) 1696 % % set(handles.TimeVariableMenu,'Visible','off') 1697 % % set(handles.TimeVarValue,'Visible','off') 1698 % % else 1699 % % set(handles.TimeVariableMenu,'Visible','on') 1700 % % set(handles.TimeVarValue,'Visible','on') 1701 % % if get(handles.TimeVariableMenu,'Value')>numel(ind_test) 1702 % % set(handles.TimeVariableMenu,'Value',1) 1703 % % end 1704 % % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test)) 1705 % % TimeVariableMenu_Callback(hObject, eventdata, handles) 1706 % % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time 1707 % % set(handles.TimeAttribute,'Value',0) 1708 % % TimeAttribute_Callback(hObject, eventdata, handles) 1709 % % end 1710 % % else 1711 % % set(handles.TimeVariableMenu,'Visible','off') 1712 % % set(handles.TimeVarValue,'Visible','off') 1713 % % end 1714 % 1713 1715 % % ----------------------------------------------------------------------- 1714 % % --- Executes on button press in TimeVariable.1715 % function TimeVariable _Callback(hObject, eventdata, handles)1716 % % --- Executes on selection change in TimeVariableMenu. 1717 % function TimeVariableMenu_Callback(hObject, eventdata, handles) 1716 1718 % % ----------------------------------------------------------------------- 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') 1719 % ListVar=get(handles.TimeVariableMenu,'String'); 1720 % index=get(handles.TimeVariableMenu,'Value'); 1721 % TimeVariable=ListVar{index};% name of the selected variable 1722 % if isempty(TimeVariable)% case of blank selection 1723 % return 1746 1724 % 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 1725 % Field=get(handles.get_field,'UserData'); %index of 1726 % VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables 1727 % DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable 1728 % set(handles.TimeDimensionMenu,'Value',1) 1729 % set(handles.TimeDimensionMenu,'String',DimName) 1730 % inputfile=get(handles.inputfile,'String');% read the input file 1731 % SubField=nc2struct(inputfile,{TimeVariable}); 1732 % eval(['TimeDimension=numel(SubField.' TimeVariable ');']) 1733 % ref_index=round(TimeDimension/2); 1734 % eval(['TimeValue=SubField.' TimeVariable '(ref_index);']) 1735 % set(handles.TimeIndexValue,'String',num2str(ref_index)) 1736 % set(handles.TimeVarValue,'String',num2str(TimeValue)) 1803 1737 1804 1738 1805 1739 % --- Executes on button press in check_rgb. 1806 1740 function check_rgb_Callback(hObject, eventdata, handles) 1741 1742 1743 % --- Executes when user attempts to close get_field. 1744 function get_field_CloseRequestFcn(hObject, eventdata, handles) 1745 if isequal(get(handles.get_field, 'waitstatus'), 'waiting') 1746 % The GUI is still in UIWAIT, us UIRESUME 1747 uiresume(handles.get_field); 1748 else 1749 % The GUI is no longer waiting, just close it 1750 delete(handles.get_field); 1751 end 1752 1753 1754 1755 1756 1757 % --- Executes on selection change in listbox30. 1758 function listbox30_Callback(hObject, eventdata, handles) 1759 % hObject handle to listbox30 (see GCBO) 1760 % eventdata reserved - to be defined in a future version of MATLAB 1761 % handles structure with handles and user data (see GUIDATA) 1762 1763 % Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array 1764 % contents{get(hObject,'Value')} returns selected item from listbox30 1765 1766 1767 % --- Executes on selection change in SwitchVarIndexX. 1768 function SwitchVarIndexX_Callback(hObject, eventdata, handles) 1769 % hObject handle to SwitchVarIndexX (see GCBO) 1770 % eventdata reserved - to be defined in a future version of MATLAB 1771 % handles structure with handles and user data (see GUIDATA) 1772 1773 % Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array 1774 % contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX 1775 1776 1777 % --- Executes on selection change in SwitchVarIndexTime. 1778 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 1779 menu=get(handles.SwitchVarIndexTime,'String'); 1780 option=menu{get(handles.SwitchVarIndexTime,'Value')}; 1781 switch option 1782 case 'file index' 1783 set(handles.TimeVarName, 'Visible','off') 1784 case 'attribute' 1785 set(handles.TimeVarName, 'Visible','on') 1786 time_index=[]; 1787 ListAttributes=get(handles.attributes,'String'); 1788 if ~isempty(ListAttributes) 1789 time_index=find(~cellfun('isempty',regexp(ListAttributes,'Time')));% index of the attributes containing the string 'Time' 1790 end 1791 if ~isempty(time_index) 1792 set(handles.TimeVarName,'Value',time_index(1)) 1793 else 1794 set(handles.TimeVarName,'Value',1) 1795 end 1796 set(handles.TimeVarName, 'String',ListAttributes) 1797 case 'variable' 1798 ListDim=get(handles.dimensions,'String'); 1799 Field=get(handles.get_field,'UserData'); 1800 for idim=1:numel(ListDim) 1801 var_count=[]; 1802 for ilist=1:numel(Field.VarDimName) 1803 DimName=Field.VarDimName{ilist}; 1804 if strcmp(DimName,ListDim{idim})||strcmp(DimName,{ListDim{idim}}) %if the variable has a single dim ( 1D array) 1805 var_count=[var_count ilist]; 1806 end 1807 end 1808 if numel(var_count)==1 1809 TimeVarName=[TimeVarName;Field.ListVarName{var_count}]; 1810 end 1811 end 1812 set(handles.TimeVarName, 'Visible','on') 1813 List=get(handles.TimeVarName,'String'); 1814 option=List{get(handles.TimeVarName,'Value')}; 1815 ind=find(strcmp(option,get(handles.dimensions,'String'))); 1816 if isempty(ind) 1817 set(handles.TimeVarName, 'Value',1); 1818 else 1819 set(handles.TimeVarName, 'Value',ind); 1820 end 1821 set(handles.TimeVarName, 'String',TimeVarName) 1822 case 'dim index' 1823 set(handles.TimeVarName, 'Visible','on') 1824 List=get(handles.TimeVarName,'String'); 1825 option=List{get(handles.TimeVarName,'Value')}; 1826 ind=find(strcmp(option,get(handles.dimensions,'String'))); 1827 if isempty(ind) 1828 set(handles.TimeVarName, 'Value',1); 1829 else 1830 set(handles.TimeVarName, 'Value',ind); 1831 end 1832 set(handles.TimeVarName, 'String',get(handles.dimensions,'String')) 1833 end 1834 1835
Note: See TracChangeset
for help on using the changeset viewer.