Changeset 646 for trunk/src/get_field.m
- Timestamp:
- Jun 2, 2013, 4:00:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r644 r646 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 28-May-2013 01:55:2524 % Last Modified by GUIDE v2.5 02-Jun-2013 14:00:39 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 75 75 set(hObject,'Unit','pixel') 76 76 pos_view_field=get(hObject,'Position'); 77 set(0,'Unit','pixels') 77 78 ScreenSize=get(0,'ScreenSize'); 78 79 pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); … … 106 107 set(handles.variables,'String',[{'*'} Txt]) 107 108 variables_Callback(handles.variables,[], handles) 108 109 % set(handles.abscissa,'String',[{''} Txt ])110 109 set(handles.ordinate,'String',Txt) 111 set(handles.vector_x,'String', [Txt ])112 set(handles.vector_y,'String', [Txt ])110 set(handles.vector_x,'String',Txt) 111 set(handles.vector_y,'String',Txt ) 113 112 set(handles.vector_z,'String',[{''} Txt ]) 114 113 set(handles.vec_color,'String',[{''} Txt ]) 115 set(handles.XVarName,'String',[{''} Txt ]) 116 set(handles.YVarName,'String',[{''} Txt ]) 117 set(handles.ZVarName,'String',[{''} Txt ]) 118 % set(handles.coord_x_vectors,'String',[{''} Txt ]) 119 % set(handles.coord_y_vectors,'String',[{''} Txt ]) 120 % set(handles.YVarName,'String',[{''} Txt ]) 121 % set(handles.TimeVarName,'String',[{''} Txt ]) 114 set(handles.XVarName,'String',Txt ) 115 set(handles.YVarName,'String',Txt ) 116 set(handles.ZVarName,'String',Txt ) 122 117 set(handles.scalar,'Value',1) 123 118 set(handles.scalar,'String', Txt ) 124 119 125 %% ana nlyse the input field cells120 %% analyse the input field cells 126 121 [CellInfo,NbDim,errormsg]=find_field_cells(Field); 127 122 if ~isempty(errormsg) … … 162 157 163 158 %% set time mode 164 ListSwitchVarIndexTime={'file index'}; 159 ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index 165 160 % look at global attributes with numerical values 166 161 check_numvalue=false; 167 162 check_time=false; 168 169 170 171 172 end 163 for ilist=1:numel(Field.ListGlobalAttribute) 164 Value=Field.(Field.ListGlobalAttribute{ilist}); 165 check_numvalue(ilist)=isnumeric(Value); 166 check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); 167 end 173 168 Field.ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value 174 169 if ~isempty(Field.ListNumAttributes) 175 ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}]; 170 ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute 176 171 end 177 172 nboption=numel(ListSwitchVarIndexTime); 178 173 if Field.MaxDim>=2 179 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}]; 180 end 181 if Field.MaxDim>=4 182 174 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index 175 end 176 if Field.MaxDim>=4% for dim >=4, one dim is proposed as time 177 option=nboption+1; 183 178 elseif ~isempty(find(check_time, 1)) 184 179 option=2; … … 186 181 option=1; 187 182 end 188 %set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime)189 %set(handles.SwitchVarIndexTime,'Value',option)183 set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) 184 set(handles.SwitchVarIndexTime,'Value',option) 190 185 set(handles.get_field,'UserData',Field);% record the finput field structure 191 %SwitchVarIndexTime_Callback([],[], handles)186 SwitchVarIndexTime_Callback([],[], handles) 192 187 193 188 %% set z coordinate menu if relevant … … 207 202 %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields 208 203 if Field.MaxDim>=2 % case of 2D (or 3D) fields 204 if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y') 205 set(handles.XVarName,'Value',CellInfo{imax}.VarIndex_coord_x(1)) 206 set(handles.YVarName,'Value',CellInfo{imax}.VarIndex_coord_y(1)) 207 end 209 208 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 210 set(handles.CheckVector,'Value',1) 211 set(handles.CheckScalar,'Value',0) 209 set(handles.FieldOption,'Value',3)% set vector selection option 212 210 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) 213 211 set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) … … 354 352 end 355 353 end 356 val=get(handles.abscissa,'Value');357 set(handles.abscissa,'Value',min(val,2));354 %val=get(handles.abscissa,'Value'); 355 %set(handles.abscissa,'Value',min(val,2)); 358 356 coord_x_index=CellInfo{cell_select}.VarIndex_coord_x; 359 357 coord_x_index=coord_x_index(coord_x_index~=0); 360 set(handles.XVarName,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) 358 %set(handles.XVarName,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) 359 set(handles.XVarName,'String',[(Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) 361 360 362 361 %------------------------------------------------------------------------ … … 395 394 %eliminate time 396 395 TimeDimName='';%default 396 397 397 % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); 398 398 % TimeVarOption=SwitchVarIndexTime{get(handles.SwitchVarIndexTime,'Value')}; 399 if strcmp(TimeVarOption,'variable') 400 List=get(handles.TimeVarName,'String'); 399 List=get(handles.TimeVarName,'String'); 400 if get(handles.CheckDimensionTime) 401 TimeDimName=List{get(handles.TimeVarName,'Value')}; 402 elseif ~get(handles.CheckAttributeTime) 401 403 TimeVarName=List{get(handles.TimeVarName,'Value')}; 402 elseif strcmp(TimeVarOption,'dim index')403 List=get(handles.TimeVarName,'String');404 TimeDimName=List{get(handles.TimeVarName,'Value')};405 404 end 406 405 % A completer … … 1038 1037 end 1039 1038 1040 % --------------------------------------------------------------------1041 function MenuOpen_Callback(hObject, eventdata, handles)1042 % hObject handle to MenuOpen (see GCBO)1043 % eventdata reserved - to be defined in a future version of MATLAB1044 % handles structure with handles and user data (see GUIDATA)1045 1046 1047 % --------------------------------------------------------------------1048 function MenuExport_Callback(hObject, eventdata, handles)1049 % hObject handle to MenuExport (see GCBO)1050 % eventdata reserved - to be defined in a future version of MATLAB1051 % handles structure with handles and user data (see GUIDATA)1052 1053 1054 % --------------------------------------------------------------------1055 function MenuBrowse_Callback(hObject, eventdata, handles)1056 1057 oldfile=get(handles.inputfile,'String');1058 testrootfile=0;1059 testsubdir=0;1060 if isempty(oldfile)|isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box1061 oldfile='';1062 dir_perso=prefdir;1063 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');1064 if exist(profil_perso,'file')1065 h=load (profil_perso);1066 if isfield(h,'RootPath')1067 RootPath=h.RootPath;1068 end1069 if isfield(h,'SubDir')1070 SubDir=h.SubDir;1071 if ~isempty(SubDir)1072 testsubdir=1;1073 end1074 end1075 if isfield(h,'RootFile')1076 RootFile=h.RootFile;1077 if ~isempty(RootFile)1078 testrootfile=1;1079 end1080 end1081 end1082 end1083 if testrootfile1084 if ~testsubdir1085 oldfile=fullfile(RootPath,RootFile);1086 else1087 oldfile=fullfile(RootPath,SubDir,RootFile);1088 end1089 end1090 [FileName, PathName] = uigetfile( ...1091 {'*.nc', ' *.nc';...1092 '*.cdf', ' *.cdf';...1093 '*.*', 'All Files (*.*)'}, ...1094 'Pick a file',oldfile);1095 1096 %global inputfile1097 fileinput=[PathName FileName];%complete file name1098 sizf=size(fileinput);1099 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end1100 set(handles.inputfile,'String',fileinput)1101 inputfile_Callback(hObject, eventdata, handles)1102 1103 %update list of recent files in the menubar1104 MenuFile_1=fileinput;1105 MenuFile_2=get(handles.MenuFile_1,'Label');1106 MenuFile_3=get(handles.MenuFile_2,'Label');1107 MenuFile_4=get(handles.MenuFile_3,'Label');1108 MenuFile_5=get(handles.MenuFile_4,'Label');1109 set(handles.MenuFile_1,'Label',MenuFile_1)1110 set(handles.MenuFile_2,'Label',MenuFile_2)1111 set(handles.MenuFile_3,'Label',MenuFile_3)1112 set(handles.MenuFile_4,'Label',MenuFile_4)1113 set(handles.MenuFile_5,'Label',MenuFile_5)1114 dir_perso=prefdir;1115 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');1116 display(profil_perso)1117 if exist(profil_perso,'file')1118 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat1119 else1120 txt=ver('MATLAB');1121 Release=txt.Release;1122 relnumb=str2double(Release(3:4));1123 if relnumb >= 141124 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat1125 else1126 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat1127 end1128 end1129 1130 % --------------------------------------------------------------------1131 function MenuFile_1_Callback(hObject, eventdata, handles)1132 fileinput=get(handles.MenuFile_1,'Label');1133 set(handles.inputfile,'String',fileinput)1134 inputfile_Callback(hObject, eventdata, handles)1135 1136 % --------------------------------------------------------------------1137 function MenuFile_2_Callback(hObject, eventdata, handles)1138 fileinput=get(handles.MenuFile_2,'Label');1139 set(handles.inputfile,'String',fileinput)1140 inputfile_Callback(hObject, eventdata, handles)1141 1142 % -----------------------------------------------------------------------1143 function MenuFile_3_Callback(hObject, eventdata, handles)1144 % -----------------------------------------------------------------------1145 fileinput=get(handles.MenuFile_3,'Label');1146 set(handles.inputfile,'String',fileinput)1147 inputfile_Callback(hObject, eventdata, handles)1148 1149 % -----------------------------------------------------------------------1150 function MenuFile_4_Callback(hObject, eventdata, handles)1151 % -----------------------------------------------------------------------1152 fileinput=get(handles.MenuFile_4,'Label');1153 set(handles.inputfile,'String',fileinput)1154 inputfile_Callback(hObject, eventdata, handles)1155 1156 % -----------------------------------------------------------------------1157 function MenuFile_5_Callback(hObject, eventdata, handles)1158 % -----------------------------------------------------------------------1159 fileinput=get(handles.MenuFile_5,'Label');1160 set(handles.inputfile,'String',fileinput)1161 inputfile_Callback(hObject, eventdata, handles)1162 1163 %------------------------------------------------------------------------1164 function MenuExportField_Callback(hObject, eventdata, handles)1165 %------------------------------------------------------------------------1166 global Data_get_field1167 % huvmat=findobj(allchild(0),'Name','uvmat');1168 inputfile=get(handles.inputfile,'String');1169 Data_get_field=nc2struct(inputfile);1170 % Data_view_field=UvData.ProjField_2;1171 evalin('base','global Data_get_field')%make CurData global in the workspace1172 display(['content of ' inputfile ':'])1173 evalin('base','Data_get_field') %display CurData in the workspace1174 commandwindow;1175 1176 %------------------------------------------------------------------------1177 function MenuHelp_Callback(hObject, eventdata, handles)1178 %------------------------------------------------------------------------1179 path_to_uvmat=which ('uvmat');% check the path of uvmat1180 pathelp=fileparts(path_to_uvmat);1181 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');1182 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')1183 else1184 web([helpfile '#get_field'])1185 end1186 1039 1187 1040 % ----------------------------------------------------------------------- … … 1384 1237 1385 1238 1386 1239 %------------------------------------------------------------------------ 1387 1240 % --- Executes on selection change in SwitchVarIndexX. 1241 %------------------------------------------------------------------------ 1388 1242 function SwitchVarIndexX_Callback(hObject, eventdata, handles) 1389 % hObject handle to SwitchVarIndexX (see GCBO) 1390 % eventdata reserved - to be defined in a future version of MATLAB 1391 % handles structure with handles and user data (see GUIDATA) 1392 1393 % Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array 1394 % contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX 1395 1396 1243 1244 %------------------------------------------------------------------------ 1397 1245 % --- Executes on selection change in SwitchVarIndexTime. 1246 %------------------------------------------------------------------------ 1398 1247 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 1248 1399 1249 menu=get(handles.SwitchVarIndexTime,'String'); 1400 1250 option=menu{get(handles.SwitchVarIndexTime,'Value')}; … … 1453 1303 switch FieldOption 1454 1304 case '1D plot' 1455 set(handles.Panel1Dplot,'Visible','on') 1456 pos=get(handles.Panel1Dplot,'Position'); 1457 pos(1)=2; 1458 pos_coord=get(handles.Coordinates,'Position'); 1459 pos(2)=pos_coord(2)-pos(4)-2; 1460 set(handles.Panel1Dplot,'Position',pos) 1461 set(handles.PanelScalar,'Visible','off') 1462 set(handles.PanelVectors,'Visible','off') 1463 set(handles.YVarName,'Visible','off') 1464 % set(handles.SwitchVarIndexY,'Visible','off') 1465 set(handles.Y_title,'Visible','off') 1466 set(handles.ZVarName,'Visible','off') 1467 % set(handles.SwitchVarIndexZ,'Visible','off') 1468 set(handles.Z_title,'Visible','off') 1469 % ordinate_Callback(hObject, eventdata, handles) 1470 % set(handles.get_field,'Units','pixels') 1471 % size_fig=get(handles.get_field,'Position'); 1472 % Data=get(handles.view_field,'UserData'); 1473 % Data.GUISize=size_fig; 1474 % set(handles.view_field,'UserData',Data) 1475 % 1476 % %% reset position of text_display or TableDisplay 1477 % if strcmp(get(handles.TableDisplay,'Visible'),'off') 1478 % pos_1=get(handles.text_display,'Position'); 1479 % pos_1(1)=size_fig(3)-pos_1(3); 1480 % pos_1(2)=size_fig(4)-pos_1(4); 1481 % set(handles.text_display,'Position',pos_1) 1482 % % reset position of TableDisplay 1483 % else 1484 % pos_1=get(handles.TableDisplay,'Position'); 1485 % pos_1(1)=size_fig(3)-pos_1(3); 1486 % pos_1(2)=size_fig(4)-pos_1(4); 1487 % set(handles.TableDisplay,'Position',pos_1) 1488 % end 1489 % 1490 % %% reset position of Coordinates 1491 % pos_2=get(handles.Coordinates,'Position'); 1492 % pos_2(1)=size_fig(3)-pos_1(3); 1493 % pos_2(2)=pos_1(2)-pos_2(4); 1494 % set(handles.Coordinates,'Position',pos_2) 1305 set(handles.Panel1Dplot,'Visible','on') 1306 pos=get(handles.Panel1Dplot,'Position'); 1307 pos(1)=2; 1308 pos_coord=get(handles.Coordinates,'Position'); 1309 pos(2)=pos_coord(2)-pos(4)-2; 1310 set(handles.Panel1Dplot,'Position',pos) 1311 set(handles.PanelScalar,'Visible','off') 1312 set(handles.PanelVectors,'Visible','off') 1313 set(handles.YVarName,'Visible','off') 1314 % set(handles.SwitchVarIndexY,'Visible','off') 1315 set(handles.Y_title,'Visible','off') 1316 set(handles.ZVarName,'Visible','off') 1317 % set(handles.SwitchVarIndexZ,'Visible','off') 1318 set(handles.Z_title,'Visible','off') 1495 1319 case 'scalar' 1496 1320 set(handles.Panel1Dplot,'Visible','off') 1497 set(handles.PanelScalar,'Visible','on')1498 set(handles.PanelVectors,'Visible','off')1499 1500 1501 1502 1503 1504 set(handles.YVarName,'Visible','on')1505 set(handles.Y_title,'Visible','on')1321 set(handles.PanelScalar,'Visible','on') 1322 set(handles.PanelVectors,'Visible','off') 1323 pos=get(handles.PanelScalar,'Position'); 1324 pos(1)=2; 1325 pos_coord=get(handles.Coordinates,'Position'); 1326 pos(2)=pos_coord(2)-pos(4)-2; 1327 set(handles.PanelScalar,'Position',pos) 1328 set(handles.YVarName,'Visible','on') 1329 set(handles.Y_title,'Visible','on') 1506 1330 case 'vectors' 1507 1331 set(handles.Panel1Dplot,'Visible','off') 1508 set(handles.PanelScalar,'Visible','off') 1509 set(handles.PanelVectors,'Visible','on') 1510 pos=get(handles.PanelVectors,'Position'); 1511 pos(1)=2; 1512 pos_coord=get(handles.Coordinates,'Position'); 1513 pos(2)=pos_coord(2)-pos(4)-2; 1514 set(handles.PanelVectors,'Position',pos) 1515 set(handles.YVarName,'Visible','on') 1516 set(handles.Y_title,'Visible','on') 1517 end 1518 % hObject handle to FieldOption (see GCBO) 1519 % eventdata reserved - to be defined in a future version of MATLAB 1520 % handles structure with handles and user data (see GUIDATA) 1521 1522 % Hints: contents = get(hObject,'String') returns FieldOption contents as cell array 1523 % contents{get(hObject,'Value')} returns selected item from FieldOption 1524 1525 1526 % --- Executes on button press in CheckDimensionX. 1527 function CheckDimensionX_Callback(hObject, eventdata, handles) 1528 % hObject handle to CheckDimensionX (see GCBO) 1529 % eventdata reserved - to be defined in a future version of MATLAB 1530 % handles structure with handles and user data (see GUIDATA) 1531 1532 % Hint: get(hObject,'Value') returns toggle state of CheckDimensionX 1533 1534 1535 % --- Executes on button press in checkbox25. 1536 function checkbox25_Callback(hObject, eventdata, handles) 1537 % hObject handle to checkbox25 (see GCBO) 1538 % eventdata reserved - to be defined in a future version of MATLAB 1539 % handles structure with handles and user data (see GUIDATA) 1540 1541 % Hint: get(hObject,'Value') returns toggle state of checkbox25 1542 1543 1544 % --- Executes on button press in checkbox26. 1545 function checkbox26_Callback(hObject, eventdata, handles) 1546 % hObject handle to checkbox26 (see GCBO) 1547 % eventdata reserved - to be defined in a future version of MATLAB 1548 % handles structure with handles and user data (see GUIDATA) 1549 1550 % Hint: get(hObject,'Value') returns toggle state of checkbox26 1551 1552 1553 % --- Executes on button press in checkbox27. 1554 function checkbox27_Callback(hObject, eventdata, handles) 1555 % hObject handle to checkbox27 (see GCBO) 1556 % eventdata reserved - to be defined in a future version of MATLAB 1557 % handles structure with handles and user data (see GUIDATA) 1558 1559 % Hint: get(hObject,'Value') returns toggle state of checkbox27 1560 1561 1562 % --- Executes on button press in checkbox29. 1563 function checkbox29_Callback(hObject, eventdata, handles) 1564 % hObject handle to checkbox29 (see GCBO) 1565 % eventdata reserved - to be defined in a future version of MATLAB 1566 % handles structure with handles and user data (see GUIDATA) 1567 1568 % Hint: get(hObject,'Value') returns toggle state of checkbox29 1332 set(handles.PanelScalar,'Visible','off') 1333 set(handles.PanelVectors,'Visible','on') 1334 pos=get(handles.PanelVectors,'Position'); 1335 pos(1)=2; 1336 pos_coord=get(handles.Coordinates,'Position'); 1337 pos(2)=pos_coord(2)-pos(4)-2; 1338 set(handles.PanelVectors,'Position',pos) 1339 set(handles.YVarName,'Visible','on') 1340 set(handles.Y_title,'Visible','on') 1341 end
Note: See TracChangeset
for help on using the changeset viewer.