Changeset 674
- Timestamp:
- Aug 23, 2013, 2:56:17 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r648 r674 107 107 108 108 %% find scattered (unstructured) coordinates 109 ivar_coord_x=find(strcmp('coord_x',Role)); 110 % VarDimCell=cell(numel(ivar_coord_x)); 109 ivar_coord_x=find(strcmp('coord_x',Role));%find variables with Role='coord_x' 111 110 check_select=false(1,nbvar); 112 111 check_coord=false(1,nbvar); 113 112 CellInfo=cell(1,numel(ivar_coord_x)); 114 113 NbDim=zeros(1,numel(ivar_coord_x)); 114 % loop on unstructured coordinate x -> different field cells 115 115 for icell=1:numel(ivar_coord_x) 116 DimCell=Data.VarDimName{ivar_coord_x(icell)}; 117 if ischar(DimCell),DimCell={DimCell};end 116 DimCell=Data.VarDimName{ivar_coord_x(icell)};% cell of dimension names for ivar_coord_x(icell) 117 if ischar(DimCell),DimCell={DimCell};end % transform char to cell for a single dimension 118 % look for variables sharing dimension(s) with ivar_coord_x(icell) 118 119 check_cell=zeros(numel(DimCell),nbvar); 119 120 for idim=1:numel(DimCell) … … 123 124 end 124 125 check_cell=sum(check_cell,1)==numel(DimCell);%logical array=1 for variables belonging to the current cell 125 VarIndex=find(check_cell); 126 VarIndex=find(check_cell);% list of detected variable indices 126 127 if ~(numel(VarIndex)==1 && numel(DimCell)==1)% exclude case of isolated coord_x variable (treated later) 127 128 if ~(numel(VarIndex)==1 && numel(DimCell)>1)% a variable is associated to coordinate … … 132 133 else 133 134 for idim=1:numel(DimCell) 134 check_index= strcmp(DimCell{idim},Data.ListDimName);135 CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);135 check_index= strcmp(DimCell{idim},Data.ListDimName); 136 CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index); 136 137 end 137 138 CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize); … … 291 292 NbDim=[NbDim NewNbDim]; 292 293 CellInfo=[CellInfo NewCellInfo]; 293 %294 % %% suppress empty cells295 % check_empty=cellfun(@isempty,CellInfo);296 % CellInfo(check_empty)=[];297 % NbDim(check_empty)=[];298 294 299 295 %% suppress empty cells or cells with a single coordinate variable … … 308 304 309 305 %% document roles of non-coordinate variables 310 % ListRole={'vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...311 % 'ancillary','image','color','discrete','scalar'};% except coord,coord_x,_y,_z,Coord_tps already taken, into account312 306 for icell=1:numel(CellInfo) 313 307 VarIndex=CellInfo{icell}.VarIndex; -
trunk/src/find_imadoc.m
r672 r674 15 15 dotchar=regexp(SubDir,'\.'); 16 16 for idot=1:numel(dotchar) 17 XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1) ) '.xml']);17 XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']); 18 18 if exist(XmlFileName,'file') 19 19 SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1))); -
trunk/src/geometry_calib.m
r672 r674 97 97 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 98 98 Left=ScreenSize(3)- 460; %right edge close to the right, with margin=40 (GUI width=420 px) 99 if ScreenSize(4)> 88099 if ScreenSize(4)>920 100 100 Height=840;%default height of the GUI 101 101 Bottom=ScreenSize(4)-Height-40; %put fig at top right 102 102 else 103 Height=ScreenSize(4)- 40;104 Bottom= 0; % GUI lies o the screen bottom105 end 106 set(handles.calib_type,'Position',[1 Height- 30 194 30])% rank 1107 set(handles.APPLY,'Position',[197 Height- 30 110 30])% rank 1108 set(handles.REPLICATE,'Position',[309 Height- 30 110 30])% rank 1109 set(handles.Intrinsic,'Position',[1 Height- 30-2-92 418 92])% rank 2110 set(handles.Extrinsic,'Position',[1 Height- 30-4-92-75 418 75])% rank 3111 set(handles.PointLists,'Position',[1 Height- 30-6-92-75-117 418 117]) % rank 4112 set(handles.CheckEnableMouse,'Position',[3 Height- 30-8-92-75-117-30 203 30])% rank 5113 set(handles.PLOT,'Position',[3 Height-3 84 120 30])% rank 6114 set(handles.Copy,'Position',[151 Height-3 84 120 30])% rank 6115 set(handles.CLEAR_PTS,'Position',[297 Height-3 84 120 30])% rank 6116 set(handles.phys_title,'Position',[38 Height-4 16 125 20])% rank 7117 set(handles.CoordUnit,'Position',[151 Height-4 16 120 30])% rank 7118 set(handles.px_title,'Position',[272 Height-4 16 125 20])% rank 7119 set(handles.ListCoord,'Position',[1 20 418 Height-4 36])% rank 8103 Height=ScreenSize(4)-80; 104 Bottom=40; % GUI lies o the screen bottom (with margin =40) 105 end 106 set(handles.calib_type,'Position',[1 Height-40 194 30])% rank 1 107 set(handles.APPLY,'Position',[197 Height-40 110 30])% rank 1 108 set(handles.REPLICATE,'Position',[309 Height-40 110 30])% rank 1 109 set(handles.Intrinsic,'Position',[1 Height-40-2-92 418 92])% rank 2 110 set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])% rank 3 111 set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) % rank 4 112 set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 203 30])% rank 5 113 set(handles.PLOT,'Position',[3 Height-394 120 30])% rank 6 114 set(handles.Copy,'Position',[151 Height-394 120 30])% rank 6 115 set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])% rank 6 116 set(handles.phys_title,'Position',[38 Height-426 125 20])% rank 7 117 set(handles.CoordUnit,'Position',[151 Height-426 120 30])% rank 7 118 set(handles.px_title,'Position',[272 Height-426 125 20])% rank 7 119 set(handles.ListCoord,'Position',[1 20 418 Height-446])% rank 8 120 120 set(handles.geometry_calib,'Position',[Left Bottom 420 Height]) 121 121 … … 1149 1149 set(handles.ListCoordFiles,'string',listfile); 1150 1150 1151 %------------------------------------------------------------------------1152 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard1153 function key_press_fcn(hObject,eventdata,handles)1154 %------------------------------------------------------------------------1155 xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character1156 %if ismember(xx,[8 127])%backspace or delete1157 if ismember(xx,[30 31 8 127])1158 Coord=get(handles.ListCoord,'Data');1159 ind=find(Coord(:,6));1160 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark1161 switch xx1162 case 30 % arrow upward1163 Coord(ind-1,6)=1;1164 case 31% arrow downward1165 Coord(ind+1,6)=1;1166 case {8 127}% remove line1167 Coord(ind,:)=[];1168 end1169 set(handles.ListCoord,'Data',Coord);1170 PLOT_Callback(hObject,eventdata,handles)1171 end1172 1173 1174 1151 1175 1152 %------------------------------------------------------------------------ … … 1240 1217 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4)) 1241 1218 end 1219 if isfield(GeometryCalib,'SourceCalib') 1242 1220 calib=GeometryCalib.SourceCalib.PointCoord; 1243 1221 Coord=[calib zeros(size(calib,1),1)]; 1244 1222 set(handles.ListCoord,'Data',Coord) 1223 end 1245 1224 % CoordCell=reshape(CoordCell,[],5); 1246 1225 % Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display … … 1284 1263 % --- Executes when user attempts to close geometry_calib. 1285 1264 function geometry_calib_CloseRequestFcn(hObject, eventdata, handles) 1286 % hObject handle to geometry_calib (see GCBO) 1287 % eventdata reserved - to be defined in a future version of MATLAB 1288 % handles structure with handles and user data (see GUIDATA) 1289 1290 % Hint: delete(hObject) closes the figure 1291 delete(hObject); 1265 1266 delete(hObject); % closes the figure 1292 1267 1293 1268 %------------------------------------------------------------------------ … … 1331 1306 1332 1307 %------------------------------------------------------------------------ 1333 % --- Executes on button press in Copy .1308 % --- Executes on button press in Copy: display Coord on the Matlab work space 1334 1309 %------------------------------------------------------------------------ 1335 1310 function Copy_Callback(hObject, eventdata, handles) … … 1341 1316 commandwindow; %brings the Matlab command window to the front 1342 1317 1343 1318 %------------------------------------------------------------------------ 1344 1319 % --- Executes when selected cell(s) is changed in ListCoord. 1320 %------------------------------------------------------------------------ 1345 1321 function ListCoord_CellSelectionCallback(hObject, eventdata, handles) 1322 1346 1323 if ~isempty(eventdata.Indices) 1347 iline=eventdata.Indices(1);% selected line number 1348 Data=get(handles.ListCoord,'Data'); 1349 Data(:,6)=zeros(size(Data,1),1); 1350 Data(iline,6)=1;% mark the selected line 1351 set(handles.ListCoord,'Data',Data) 1352 update_calib_marker(Data(iline,:)) 1353 end 1354 1324 iline=eventdata.Indices(1);% selected line number 1325 Data=get(handles.ListCoord,'Data'); 1326 Data(:,6)=zeros(size(Data,1),1); 1327 Data(iline,6)=1;% mark the selected line 1328 set(handles.ListCoord,'Data',Data) 1329 update_calib_marker(Data(iline,:)) 1330 end 1331 1332 %------------------------------------------------------------------------ 1355 1333 % --- Executes when entered data in editable cell(s) in ListCoord. 1334 %------------------------------------------------------------------------ 1356 1335 function ListCoord_CellEditCallback(hObject, eventdata, handles) 1357 1336 … … 1366 1345 PLOT_Callback(hObject, eventdata, handles) 1367 1346 1347 %------------------------------------------------------------------------ 1348 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard 1349 %------------------------------------------------------------------------ 1350 function key_press_fcn(hObject,eventdata,handles) 1351 1352 xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character 1353 %if ismember(xx,[8 127])%backspace or delete 1354 if ismember(xx,[30 31 8 127])% arrow upward, downward, backspace or delete 1355 Coord=get(handles.ListCoord,'Data'); 1356 ind=find(Coord(:,6)); 1357 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark 1358 switch xx 1359 case 30 % arrow upward 1360 Coord(ind-1,6)=1; 1361 case 31% arrow downward 1362 Coord(ind+1,6)=1; 1363 case {8 127}% remove line 1364 Coord(ind,:)=[]; 1365 end 1366 set(handles.ListCoord,'Data',Coord); 1367 PLOT_Callback(hObject,eventdata,handles) 1368 end 1369 1370 1371 1372 %------------------------------------------------------------------------ 1373 % --- update the plot of calibration points 1374 %------------------------------------------------------------------------ 1368 1375 function update_calib_marker(Coord) 1369 1376 %% update the plot on uvmat -
trunk/src/get_field.m
r672 r674 1 1 %'get_field': display variables and attributes from a Netcdf file, and OK selected fields 2 2 %------------------------------------------------------------------------ 3 % function varargout = get_field(varargin)3 % GetFieldData=get_field(FileName,ParamIn) 4 4 % associated with the GUI get_field.fig 5 % 6 % OUPUT: 7 % GetFieldData: structure containing the information on the selected 8 % fields, obtained by applying the fct red_GUI to the GUI get_field 9 % .FieldOption='vectors': variables are used for vector plot 10 % 'scalar': variables are used for scalar plot, 11 % '1Dplot': variables are used for usual x-y plot, 12 % 'civdata...': go back to automatic reading of civ data 13 % .PanelVectors: sub-structure variables used as vector components 14 % .PanelScalar: 15 % INPUT: 16 % FileName: name (including path) of the netcdf file to open 5 17 % 6 18 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 42 54 end 43 55 % End initialization code - DO NOT EDIT 44 56 45 57 %------------------------------------------------------------------------ 46 58 % --- Executes just before get_field is made visible. … … 54 66 55 67 %% enter input data 56 set(handles.inputfile,'String',filename)% fill the input file name 57 Field=nc2struct(filename,[]);% reads the field structure, without the variables 68 if ischar(filename)% input file name 69 set(handles.inputfile,'String',filename)% fill the input file name 70 Field=nc2struct(filename,[]);% reads the field structure, without the variables 71 else 72 'bad input to get_field' 73 end 74 if ~exist('ParamIn','var') 75 ParamIn=[]; 76 end 58 77 if isfield(Field,'Txt') 59 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fi elreading78 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading 60 79 return 61 80 end 62 81 if ~isfield(Field,'ListVarName') 63 82 return 64 end65 if ~exist('ParamIn','var')66 ParamIn=[];67 83 end 68 84 … … 111 127 ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index 112 128 % look at global attributes with numerical values 113 check_numvalue=false; 114 check_time=false; 129 check_numvalue=false(1,numel(Field.ListGlobalAttribute)); 115 130 for ilist=1:numel(Field.ListGlobalAttribute) 116 131 Value=Field.(Field.ListGlobalAttribute{ilist}); 117 132 check_numvalue(ilist)=isnumeric(Value); 118 check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1));119 133 end 120 134 Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value … … 122 136 ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute 123 137 end 124 nboption=numel(ListSwitchVarIndexTime);125 138 if Field.MaxDim>=2 126 139 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index 127 140 end 128 if ~isempty(find(check_time, 1)) 141 142 %% select the Time attribute from input 143 if isfield(ParamIn,'TimeAttrName') 144 time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); 145 else 146 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1); 147 end 148 if ~isempty(time_index) 129 149 set(handles.SwitchVarIndexTime,'Value',2); 150 set(handles.TimeName,'UserData',time_index) 130 151 else 131 152 set(handles.SwitchVarIndexTime,'Value',1); … … 150 171 end 151 172 if Field.MaxDim>=2 % case of 2D (or 3D) fields 152 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 173 check_vec_input=0; 174 if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y') 175 ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1); 176 ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1); 177 if ~isempty(ichoice_x)&&~isempty(ichoice_y) 178 set(handles.vector_x,'UserData',ichoice_x) 179 set(handles.vector_y,'UserData',ichoice_y) 180 check_vec_input=1; 181 end 182 end 183 if ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 184 set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1)) 185 set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1)) 186 check_vec_input=1; 187 end 188 if check_vec_input 153 189 set(handles.FieldOption,'Value',3)% set vector selection option 154 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))155 set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))156 set(handles.FieldOption,'Value',3)157 190 else 158 set(handles.FieldOption,'Value',2) 191 set(handles.FieldOption,'Value',2)% set scalar selection option 159 192 end 160 193 else % case of 1D fields … … 177 210 %% fill menus for coordinates and time 178 211 FieldOption_Callback(handles.variables,[], handles)% list the global attributes 179 % if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y')180 % set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1))181 % set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1))182 % end183 212 184 213 %% Make choices of coordinates from input … … 214 243 return 215 244 216 SwitchVarIndexTime_Callback([],[], handles)217 218 245 %% set z coordinate menu if relevant 219 246 if Field.MaxDim>=3 … … 227 254 set(handles.Coord_z,'Visible','off') 228 255 set(handles.Z_title,'Visible','off') 256 end 257 258 %% make selections according to ParamIn 259 if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y') 260 229 261 end 230 262 … … 300 332 for iline=1:length(attr_list) 301 333 Tabcell{iline,1}=attr_list{iline}; 302 eval(['val=VarAttr.' attr_list{iline} ';'])334 val=VarAttr.(attr_list{iline}) ; 303 335 if ischar(val); 304 336 Tabcell{iline,2}=val; … … 406 438 end 407 439 scalar_Callback(hObject, eventdata, handles) 408 440 409 441 case 'vectors' 442 set(handles.PanelVectors,'Visible','on') 410 443 set(handles.Coordinates,'Visible','on') 411 444 set(handles.PanelOrdinate,'Visible','off') 412 445 set(handles.PanelScalar,'Visible','off') 413 set(handles.PanelVectors,'Visible','on')414 446 pos=get(handles.PanelVectors,'Position'); 415 447 pos(1)=2; … … 420 452 set(handles.Y_title,'Visible','on') 421 453 %default vector selection 422 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 423 for ilist=1:numel(Field.Display.VarDimName) 424 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') 425 Role=Field.Display.VarAttribute{ilist}.Role; 426 if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') 454 vector_x_value=get(handles.vector_x,'UserData'); 455 vector_y_value=get(handles.vector_y,'UserData'); 456 if ~isempty(vector_x_value)&&~isempty(vector_y_value) 457 set(handles.vector_x,'Value',vector_x_value) 458 set(handles.vector_y,'Value',vector_y_value) 459 else 460 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate 461 for ilist=1:numel(Field.Display.VarDimName) 462 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role') 463 Role=Field.Display.VarAttribute{ilist}.Role; 464 if strcmp(Role,'coord_x')||strcmp(Role,'coord_y') 465 test_coord(ilist)=1; 466 end 467 end 468 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 469 if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable 427 470 test_coord(ilist)=1; 428 471 end 429 472 end 430 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 431 if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable 432 test_coord(ilist)=1; 473 vector_index=find(~test_coord,2);%get the two first variables not a coordinate 474 if isempty(vector_index) 475 set(handles.vector_x,'Value',1) 476 set(handles.vector_y,'Value',2) 477 else 478 set(handles.vector_x,'Value',vector_index(1)) 479 set(handles.vector_y,'Value',vector_index(2)) 433 480 end 434 481 end 435 vector_index=find(~test_coord,2);%get the first variable not a coordiante436 if isempty(vector_index)437 set(handles.vector_x,'Value',1)438 set(handles.vector_y,'Value',2)439 else440 set(handles.vector_x,'Value',vector_index(1))441 set(handles.vector_y,'Value',vector_index(2))442 end443 482 vector_Callback(handles) 444 483 … … 525 564 end 526 565 update_field(handles,YName) 527 566 528 567 %------------------------------------------------------------------------ 529 568 % --- Executes on selection change in scalar menu. … … 801 840 case 'attribute' 802 841 set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes 803 time_index=[]; 804 PreviousList=get(handles.TimeName, 'String'); 805 index=[]; 806 if ~isempty(PreviousList) 807 PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; 808 index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes)); 809 end 810 if isempty(index) 811 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' 812 end 842 time_index=get(handles.TimeName,'UserData'); %select the input data 843 if isempty(time_index) 844 PreviousList=get(handles.TimeName, 'String'); 845 if ~isempty(PreviousList) 846 PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; 847 index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1); 848 end 849 end 850 if isempty(time_index) 851 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time' 852 end 813 853 if ~isempty(time_index) 814 set(handles.TimeName,'Value',time_index (1))854 set(handles.TimeName,'Value',time_index) 815 855 else 816 856 set(handles.TimeName,'Value',1) 817 857 end 818 858 set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) 859 819 860 case 'variable'% TimeName menu represents the available variables 820 861 set(handles.TimeName, 'Visible','on') -
trunk/src/plot_field.m
r652 r674 545 545 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam,PosColorbar) 546 546 %------------------------------------------------------------------- 547 547 PlotType='plane'; 548 548 grid(haxes, 'off')% remove grid (possibly remaining from other graphs) 549 549 550 %default plotting parameters 550 PlotType='plane';%default551 % if ~exist('PlotParam','var')552 % PlotParam=[];553 % end554 555 551 if ~isfield(PlotParam,'Scalar') 556 552 PlotParam.Scalar=[]; … … 559 555 PlotParam.Vectors=[]; 560 556 end 561 562 557 PlotParamOut=PlotParam;%default 563 hfig=get(haxes,'parent'); 558 errormsg='';%default 559 560 hfig=get(haxes,'parent');%handle of the figure containing the plot axes 564 561 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes 565 562 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes 566 errormsg='';%default567 563 test_ima=0; %default: test for image or map plot 568 564 test_vec=0; %default: test for vector plots … … 574 570 YName=''; 575 571 y_units=''; 576 for icell=1:numel(CellInfo) % length(CellVarIndex) =1 or 2 (from the calling function) 577 % VarRole=CellInfo{icell}; 572 573 % loop on the input field cells 574 for icell=1:numel(CellInfo) 578 575 if strcmp(CellInfo{icell}.CoordType,'tps') %do not plot directly tps data (used for projection only) 579 576 continue … … 600 597 ivar_F=[]; 601 598 if isfield(CellInfo{icell},'VarIndex_warnflag') 602 ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable 603 end 604 ivar_FF=[]; 605 if isfield(CellInfo{icell},'VarIndex_errorflag') 606 ivar_FF=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable 607 end 599 ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable 600 end 601 ivar_FF_vec=[]; 608 602 if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected 609 if test_vec 603 if test_vec% a vector field has been already detected 610 604 errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp'; 611 605 return 612 606 else 613 607 test_vec=1; 614 vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 608 if isfield(CellInfo{icell},'VarIndex_errorflag') 609 ivar_FF_vec=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable 610 end 611 vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 615 612 vec_V=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_y}); 616 if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 613 if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 617 614 XName=Data.ListVarName{CellInfo{icell}.CoordIndex(end)}; 618 615 YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 619 616 vec_X=reshape(Data.(XName),[],1); %transform vectors in column matlab vectors 620 617 vec_Y=reshape(Data.(YName),[],1); 621 elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 618 elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 622 619 y=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); 623 620 x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)}); … … 628 625 x=linspace(x(1),x(2),size(vec_U,2)); 629 626 end 630 [vec_X,vec_Y]=meshgrid(x,y); 627 [vec_X,vec_Y]=meshgrid(x,y); 631 628 end 632 629 if isfield(PlotParam.Vectors,'ColorScalar') && ~isempty(PlotParam.Vectors.ColorScalar) … … 637 634 end 638 635 end 639 if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 640 if test_vec 636 if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 637 % if test_vec 641 638 vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for dubious vectors 642 if ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1)) 639 if ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1)) 643 640 test_black=1; 644 641 end 645 end646 end 647 if ~isempty(ivar_FF ) %&& ~test_false648 if test_vec% TODO: deal with FF for structured coordinates649 vec_FF=Data.(Data.ListVarName{ivar_FF }); % flags for false vectors650 end642 % end 643 end 644 if ~isempty(ivar_FF_vec) %&& ~test_false 645 % if test_vec% TODO: deal with FF for structured coordinates 646 vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors 647 % end 651 648 end 652 649 end 653 650 elseif ~isempty(ivar_C) %scalar or image 654 651 if test_ima 655 652 errormsg='attempt to plot two scalar fields or images'; 656 653 return 657 654 end 658 655 A=squeeze(Data.(Data.ListVarName{ivar_C}));% scalar represented as color image 659 656 test_ima=1; 660 if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 657 if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 661 658 A=reshape(A,1,[]); 662 659 XName=Data.ListVarName{ivar_X}; 663 660 YName=Data.ListVarName{ivar_Y}; 664 eval(['AX=reshape(Data.' XName ',1,[]);']) 661 eval(['AX=reshape(Data.' XName ',1,[]);']) 665 662 eval(['AY=reshape(Data.' YName ',1,[]);']) 666 [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256'); % interpolate on a grid 663 [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256'); % interpolate on a grid 667 664 if isfield(Data,'VarAttribute') 668 665 if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units') … … 672 669 y_units=[' (' Data.VarAttribute{ivar_Y}.units ')']; 673 670 end 674 end 675 elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 671 end 672 elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 676 673 YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 677 AY=Data.(YName); 674 AY=Data.(YName); 678 675 AX=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)}); 679 676 test_interp_X=0; %default, regularly meshed X coordinate … … 686 683 y_units=Data.VarAttribute{CellInfo{icell}.CoordIndex(end-1)}.units; 687 684 end 688 end 685 end 689 686 if numel(AY)>2 690 687 DAY=diff(AY); … … 692 689 DAY_max=max(DAY); 693 690 if sign(DAY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise 694 695 696 end 691 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ]; 692 return 693 end 697 694 test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max); 698 695 end … … 702 699 DAX_max=max(DAX); 703 700 if sign(DAX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise 704 705 706 end 701 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ]; 702 return 703 end 707 704 test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max); 708 end 709 if test_interp_Y 705 end 706 if test_interp_Y 710 707 npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]); 711 708 yI=linspace(AY(1),AY(end),npxy(1)); 712 709 if ~test_interp_X 713 xI=linspace(AX(1),AX(end),size(A,2));%default 710 xI=linspace(AX(1),AX(end),size(A,2));%default 714 711 AX=xI; 715 712 end 716 713 end 717 if test_interp_X 714 if test_interp_X 718 715 npxy(2)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]); 719 xI=linspace(AX(1),AX(end),npxy(2)); 716 xI=linspace(AX(1),AX(end),npxy(2)); 720 717 if ~test_interp_Y 721 yI=linspace(AY(1),AY(end),size(A,1));722 AY=yI;723 end 724 end 725 if test_interp_X || test_interp_Y 718 yI=linspace(AY(1),AY(end),size(A,1)); 719 AY=yI; 720 end 721 end 722 if test_interp_X || test_interp_Y 726 723 [AX2D,AY2D]=meshgrid(AX,AY); 727 724 A=interp2(AX2D,AY2D,double(A),xI,yI'); 728 725 end 729 AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 726 AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 730 727 AY=[AY(1) AY(end)]; 731 % else732 % errormsg='error in plot_field: invalid coordinate definition ';733 % return734 728 end 735 729 end … … 742 736 y_units=Data.CoordUnit; 743 737 end 744 end 745 746 end 738 end 739 end 747 740 748 741 %% image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%% … … 1092 1085 vec_F=vec_F(ind_sel); 1093 1086 end 1094 if ~isempty(ivar_FF )1087 if ~isempty(ivar_FF_vec) 1095 1088 vec_FF=vec_FF(ind_sel); 1096 1089 end … … 1106 1099 nbcolor=nbcolor+1; 1107 1100 colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors 1108 if ~isempty(ivar_FF) 1109 % ind_flag=find(vec_F~=1 & vec_F~=0 & vec_FF==0); %flag warning but not false 1101 if ~isempty(ivar_FF_vec) 1110 1102 col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor; 1111 1103 else … … 1114 1106 end 1115 1107 nbcolor=nbcolor+1; 1116 if ~isempty(ivar_FF )1108 if ~isempty(ivar_FF_vec) 1117 1109 if isfield(PlotParam.Vectors,'CheckHideFalse') && PlotParam.Vectors.CheckHideFalse==1 1118 1110 colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors -
trunk/src/read_civdata.m
r654 r674 133 133 for ivar=1:numel(var_ind) 134 134 Field.VarAttribute{ivar}.Role=role{var_ind(ivar)}; 135 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel 136 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 135 137 if strcmp(role{var_ind(ivar)},'vector_x') 136 138 Field.VarAttribute{ivar}.FieldName=FieldNames; 137 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;139 % Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 138 140 ivar_U=ivar; 139 141 end 140 142 if strcmp(role{var_ind(ivar)},'vector_x_tps') 141 143 Field.VarAttribute{ivar}.FieldName=FieldNames; 142 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;144 % Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 143 145 ivar_U_tps=ivar; 144 146 end 145 147 if strcmp(role{var_ind(ivar)},'vector_y') 146 148 Field.VarAttribute{ivar}.FieldName=FieldNames; 147 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;149 % Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 148 150 ivar_V=ivar; 149 151 end 150 152 if strcmp(role{var_ind(ivar)},'vector_y_tps') 151 153 Field.VarAttribute{ivar}.FieldName=FieldNames; 152 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;154 % Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 153 155 ivar_V_tps=ivar; 154 156 end 155 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel156 157 end 157 158 if ~isempty(ivar_U_tps) -
trunk/src/set_object.m
r667 r674 93 93 ZBounds=0; %default 94 94 end 95 set(h Object,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)95 set(handles.Coord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front) 96 96 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 97 97 set(hObject,'DeleteFcn',{@closefcn}) … … 722 722 % add lines if multi line input needed 723 723 case{'points','polyline','polygon'} 724 Input=str2num(eventdata.EditData);%pasted input 724 725 Coord=get(handles.Coord,'Data'); 725 if ~isnan(Coord(end,1)) 726 if isequal(size(Coord,2),3) 727 %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case) 728 Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case) 726 iline=eventdata.Indices(1);% selected line number 727 if size(Coord,1)<iline+numel(Input) 728 Coord=[Coord ; zeros(iline+numel(Input)-size(Coord,1),size(Coord,2))];% append zeros to fit the new column 729 end 730 Coord(iline:iline+numel(Input)-1,eventdata.Indices(2))=Input'; 731 set(handles.Coord,'Data',Coord) 732 end 733 734 % --- Executes when selected cell(s) is changed in ListCoord. 735 function Coord_CellSelectionCallback(hObject, eventdata, handles) 736 737 if ~isempty(eventdata.Indices) 738 iline=eventdata.Indices(1);% selected line number 739 set(handles.Coord,'UserData',iline) 740 end 741 742 %------------------------------------------------------------------------ 743 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard 744 %------------------------------------------------------------------------ 745 function key_press_fcn(hObject,eventdata,handles) 746 747 xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character 748 if ismember(xx,[8 127 31])%backspace or delete, or downward 749 Coord=get(handles.Coord,'Data'); 750 iline=get(handles.Coord,'UserData'); 751 if isequal(xx, 31) 752 if isequal(iline,size(Coord,1))% arrow downward 753 Coord=[Coord;zeros(1,size(Coord,2))]; 754 end 729 755 else 730 Coord=[Coord;NaN NaN]; %add a line for edition (2D case)756 Coord(iline,:)=[];% suppress the current line 731 757 end 732 set(handles.Coord,'Data',Coord) 733 end 734 end 735 736 758 set(handles.Coord,'Data',Coord); 759 end 737 760 738 761 function num_Angle_3_Callback(hObject, eventdata, handles) -
trunk/src/struct2nc.m
r530 r674 47 47 return 48 48 end 49 % [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure49 %check the validity of the input field structure 50 50 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data); 51 51 if ~isempty(errormsg) … … 139 139 %'check_field_structure': check the validity of the field struture representation consistant with the netcdf format 140 140 %------------------------------------------------------------------------ 141 % function [DataOut,errormsg]=check_field_structure(Data)141 % [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data) 142 142 % 143 143 % OUTPUT: 144 % DataOut: structure reproducing the input structure Data (TODO: suppress this output)145 144 % errormsg: error message which is not empty when the input structure does not have the right form 145 % ListDimName: list of dimension names (cell array of cahr strings) 146 % DimValue: list of dimension values (numerical array with the same dimension as ListDimName) 147 % VarDimIndex: cell array of dimension index (in the list ListDimName) for each element of Data.ListVarName 146 148 % 147 149 % INPUT: … … 179 181 return 180 182 end 181 % if isfield(Data,'DimValue')182 % Data=rmfield(Data,'DimValue');183 % end184 183 nbdim=0; 185 184 ListDimName={}; 186 185 187 186 %% main loop on the list of variables 187 VarDimIndex=cell(1,nbfield); 188 188 for ivar=1:nbfield 189 189 VarName=Data.ListVarName{ivar}; … … 198 198 elseif ~iscell(DimCell) 199 199 errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName]; 200 return 201 200 return 202 201 end 203 202 nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName … … 209 208 if nbcoord==2 210 209 if sizvar(1)==1 211 nbcoord=1;212 210 sizvar(1)=sizvar(2); 213 211 elseif sizvar(2)==1 214 nbcoord=1;215 212 else 216 213 errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName]; … … 227 224 if numel(DimCell)>nbcoord 228 225 sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size) 229 % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,230 226 elseif nbcoord > numel(DimCell) 231 227 errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName]; … … 234 230 end 235 231 DimIndex=[]; 236 %for idim=1:nbcoord237 232 for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar 238 233 DimName=DimCell{idim}; … … 261 256 VarDimIndex{ivar}=DimIndex; 262 257 end 263 DataOut=Data; -
trunk/src/sub_field.m
r581 r674 26 26 return 27 27 end 28 28 29 %% global attributes 29 30 SubData.ListGlobalAttribute={};%default … … 107 108 %% look for coordinates common to Field in Field_1 108 109 ind_remove=zeros(size(Field_1.ListVarName)); 110 % loop on the variables of the second field Field_1 109 111 for ilist=1:numel(Field_1.ListVarName) 110 if ischar(Field_1.VarDimName{ilist})||numel(Field_1.VarDimName{ilist})==1111 OldDim=Field_1.VarDimName{ilist};112 if ischar(OldDim)113 OldDim=Field_1.VarDimName(ilist);114 end115 VarVal=Field_1.(Field_1.ListVarName{ilist});112 % case of variable with a single dimension 113 OldDimName=Field_1.VarDimName{ilist}; 114 if ischar(OldDimName), OldDimName={OldDimName}; end% transform char string to cell if relevant 115 if numel(OldDimName)==1 116 OldDim=Field_1.(Field_1.ListVarName{ilist});% get variable 117 %look for the existence of the variable OldDim in the first field Field 116 118 for i1=1:numel(Field.ListVarName) 117 if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal) 119 if isequal(Field.(Field.ListVarName{i1}),OldDim) &&... 120 ((isempty(ProjModeRequest{i1}) && isempty(ProjModeRequest_1{ilist})) || strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) 118 121 ind_remove(ilist)=1; 119 NewDim=Field.VarDimName{i1}; 120 if ischar(NewDim) 121 NewDim={NewDim}; 122 end 123 Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDim{1} '$'],NewDim{1}); 122 NewDimName=Field.VarDimName{i1}; 123 if ischar(NewDimName), NewDimName={NewDimName}; end %transform char chain to cell if needed 124 Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDimName{1} '$'],NewDimName{1});% change the var name of Field_1 to the corresponding var name of Field 124 125 end 125 126 end 126 127 end 127 128 end 128 Field_1.ListVarName(find(ind_remove))=[];%removes the se redondent coordinates129 Field_1.ListVarName(find(ind_remove))=[];%removes the redondent coordinate 129 130 Field_1.VarDimName(find(ind_remove))=[]; 130 131 Field_1.VarAttribute(find(ind_remove))=[]; … … 150 151 151 152 %% substrat fields when possible 152 %[CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(SubData);153 153 [CellInfo,NbDim,errormsg]=find_field_cells(SubData); 154 154 ind_remove=zeros(size(SubData.ListVarName)); … … 180 180 SubData.VarDimName(find(ind_remove))=[]; 181 181 SubData.VarAttribute(find(ind_remove))=[]; 182 %end 182 'end' 183 183 184 184 function OutputCell=regexprep_r(InputCell,search_string,new_string) 185 OutputCell=InputCell;%default 185 186 for icell=1:numel(InputCell) 186 187 OutputCell{icell}=regexprep(InputCell{icell},search_string,new_string); -
trunk/src/tps_coeff_field.m
r651 r674 40 40 X=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end)});% value of x coordinate 41 41 Y=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end-1)});% value of x coordinate 42 check_interp_tps=false(numel( CellInfo{icell}.VarIndex),1);42 check_interp_tps=false(numel(DataIn.ListVarName),1); 43 43 %for ivar=1:numel(CellInfo{icell}.VarIndex) 44 44 Index_interp=[]; … … 52 52 Index_interp=[Index_interp CellInfo{icell}.VarIndex_vector_y]; 53 53 end 54 for i var=Index_interp55 Attr=DataIn.VarAttribute{ CellInfo{icell}.VarIndex(ivar)};54 for iselect=1:numel(Index_interp) 55 Attr=DataIn.VarAttribute{Index_interp(iselect)}; 56 56 if ~isfield(Attr,'VarIndex_tps')&& (checkall || (isfield(Attr,'ProjModeRequest')&&strcmp(Attr.ProjModeRequest,'interp_tps'))) 57 check_interp_tps( ivar)=1;57 check_interp_tps(Index_interp(iselect))=1; 58 58 end 59 59 end 60 VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps 61 if ~isempty(VarIndexInterp) 62 ListVarInterp=DataIn.ListVarName(VarIndexInterp); 60 61 %VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps 62 % if ~isempty(VarIndexInterp) 63 ListVarInterp=DataIn.ListVarName(check_interp_tps); 64 VarIndexInterp=find(check_interp_tps); 65 if ~isempty(ListVarInterp) 63 66 % exclude data points marked 'false' for interpolation 64 67 if isfield(CellInfo{icell},'VarIndex_errorflag') … … 66 69 X=X(FF==0); 67 70 Y=Y(FF==0); 68 for ilist=1:numel( VarIndexInterp)71 for ilist=1:numel(ListVarInterp) 69 72 DataIn.(ListVarInterp{ilist})=DataIn.(ListVarInterp{ilist})(FF==0); 70 73 end … … 74 77 term=['_' num2str(nbtps-1)]; 75 78 end 76 ListNewVar=cell(1,numel( VarIndexInterp)+3);79 ListNewVar=cell(1,numel(ListVarInterp)+3); 77 80 ListNewVar(1:3)={['SubRange' term],['NbCentre' term],['Coord_tps' term]}; 78 for ilist=1:numel( VarIndexInterp)81 for ilist=1:numel(ListVarInterp) 79 82 ListNewVar{ilist+3}=[ListVarInterp{ilist} '_tps' term]; 80 83 end 81 84 nbvar=numel(DataIn.ListVarName); 82 85 DataOut.ListVarName=[DataIn.ListVarName ListNewVar]; 83 %ListNewDim={['nb_tps' term],['nb_subdomain' term]};84 86 DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds',['nb_subdomain' term]}} {['nb_subdomain' term]} ... 85 87 {{['nb_tps' term],'nb_coord',['nb_subdomain' term]}}]; … … 91 93 DataOut.(['Coord_tps' term])(NbCentre(isub)+1:NbCentre(isub)+3,1:2,isub)=0;%matrix of zeros to complement the matrix Coord_tps (conveninent for file storage) 92 94 %fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 93 % fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)94 % Coord_tps=cat(1,Coord_tps,fill);95 end 96 for ivar=1:numel( VarIndexInterp)95 % fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 96 % Coord_tps=cat(1,Coord_tps,fill); 97 end 98 for ivar=1:numel(ListVarInterp) 97 99 DataOut.VarDimName{nbvar+3+ivar}={['nb_tps' term],['nb_subdomain' term]}; 98 100 DataOut.VarAttribute{nbvar+3+ivar}=DataIn.VarAttribute{CellInfo{icell}.VarIndex_vector_x};%reproduce attributes of velocity … … 112 114 DataOut.(['SubRange' term])=SubRange; 113 115 DataOut.(['NbCentre' term])=NbCentre; 114 % DataOut.(['Coord_tps' term])=Coord_tps;116 % DataOut.(['Coord_tps' term])=Coord_tps; 115 117 for ilist=1:numel(VarIndexInterp) 116 % Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline118 % Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline 117 119 for isub=1:size(SubRange,3) 118 120 ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain -
trunk/src/uvmat.m
r672 r674 442 442 %% display the selected field and related information 443 443 if ~isempty(fileinput) 444 set(handles.SubField,'Value',0) 445 desable_subfield(handles) 444 446 display_file_name(handles,fileinput) 445 447 end … … 450 452 %------------------------------------------------------------------------ 451 453 fileinput=get(hObject,'Label'); 454 set(handles.SubField,'Value',0) 455 desable_subfield(handles) 452 456 display_file_name( handles,fileinput) 453 %454 % % -----------------------------------------------------------------------455 % % --- Open again the file whose name has been recorded in MenuFile_2456 % function MenuFile_2_Callback(hObject, eventdata, handles)457 % %------------------------------------------------------------------------458 % fileinput=get(handles.MenuFile_2,'Label');459 % display_file_name(handles,fileinput)460 %461 % % -----------------------------------------------------------------------462 % % --- Open again the file whose name has been recorded in MenuFile_3463 % function MenuFile_3_Callback(hObject, eventdata, handles)464 % %------------------------------------------------------------------------465 % fileinput=get(handles.MenuFile_3,'Label');466 % display_file_name(handles,fileinput)467 %468 % % -----------------------------------------------------------------------469 % % --- Open again the file whose name has been recorded in MenuFile_4470 % function MenuFile_4_Callback(hObject, eventdata, handles)471 % %------------------------------------------------------------------------472 % fileinput=get(handles.MenuFile_4,'Label');473 % display_file_name(handles,fileinput)474 %475 % % -----------------------------------------------------------------------476 % % --- Open again the file whose name has been recorded in MenuFile_5477 % function MenuFile_5_Callback(hObject, eventdata, handles)478 % %------------------------------------------------------------------------479 % fileinput=get(handles.MenuFile_5,'Label');480 % display_file_name(handles,fileinput)481 457 482 458 … … 681 657 return 682 658 end 683 684 %% detect root name, nomenclature and indices in the input file name:685 [FilePath,FileName,FileExt]=fileparts(fileinput);686 % detect the file type, get the movie object if relevant, and look for the corresponding file series:687 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists688 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);689 690 if strcmp(FileType,'txt')691 edit(fileinput)692 return693 elseif strcmp(FileType,'xml')694 editxml(fileinput)695 return696 elseif strcmp(FileType,'figure')697 open(fileinput)698 return699 end700 701 %% set the mouse pointer to 'watch'702 set(handles.uvmat,'Pointer','watch')703 set(handles.RootPath,'BackgroundColor',[1 1 0])704 drawnow705 659 706 660 %% define the relevant handles for the first field series (index=1) or the second file series (index=2) … … 728 682 set(handles.FileExt_1,'Visible','on'); 729 683 set(handles.NomType_1,'Visible','on'); 684 set(handles.TimeName_1,'Visible','on') 685 set(handles.TimeValue_1,'Visible','on') 686 end 687 set(handles_RootPath,'BackgroundColor',[1 1 0])% paint edit box to yellow to visualise root file input 688 set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' 689 drawnow 690 691 %% detect root name, nomenclature and indices in the input file name: 692 [FilePath,FileName,FileExt]=fileparts(fileinput); 693 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 694 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 695 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); 696 697 if strcmp(FileType,'txt') 698 edit(fileinput) 699 return 700 elseif strcmp(FileType,'xml') 701 editxml(fileinput) 702 return 703 elseif strcmp(FileType,'figure') 704 open(fileinput) 705 return 730 706 end 731 707 … … 820 796 %enable other menus 821 797 set(handles.MenuOpenCampaign,'Enable','on') 822 % set(handles.MenuCampaign_1,'Enable','on')823 % set(handles.MenuCampaign_2,'Enable','on')824 % set(handles.MenuCampaign_3,'Enable','on')825 % set(handles.MenuCampaign_4,'Enable','on')826 % set(handles.MenuCampaign_5,'Enable','on')827 798 set(handles.MenuExport,'Enable','on') 828 799 set(handles.MenuExportFigure,'Enable','on') … … 854 825 end 855 826 856 %% set back the mouse pointer to arrow 857 set(handles.uvmat,'Pointer','arrow') 827 set(handles_RootPath,'BackgroundColor',[1 1 1])% paint back edit box to white to visualise end of root file input 828 set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow 858 829 859 830 … … 869 840 end 870 841 if index==1 871 handles_RootPath=handles.RootPath;872 842 handles_Fields=handles.FieldName; 873 843 elseif index==2 874 handles_RootPath=handles.RootPath_1;875 844 handles_Fields=handles.FieldName_1; 876 845 end 877 846 878 set(handles_RootPath,'BackgroundColor',[1 1 0])879 drawnow880 847 set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening 881 848 UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface … … 901 868 902 869 %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file 870 TimeUnit='';%default 871 TimeName='';%default 903 872 XmlData.Time=[];%default 904 XmlData.GeometryCalib=[];%default905 TimeUnit='';%default906 Time=[];907 873 imainfo=[]; 908 874 ColorType='falsecolor'; %default … … 912 878 TimeUnit='s'; 913 879 if isempty(j1_series); %frame index along i 914 Time=zeros(imainfo.NumberOfFrames+1,2);915 Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';880 XmlData.Time=zeros(imainfo.NumberOfFrames+1,2); 881 XmlData.Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; 916 882 else 917 Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);883 XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); 918 884 end 919 885 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 920 if index==1 921 set(handles.TimeName,'String','video') 922 else 923 set(handles.TimeName_1,'String','video') 924 end 886 TimeName='video'; 925 887 ColorType='truecolor'; 926 888 elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image 927 % testima=1;928 889 if ~isequal(SubDir,'') 929 890 imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); … … 948 909 949 910 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) 911 XmlData.GeometryCalib=[];%default 950 912 XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); 951 913 [tild,tild,DocExt]=fileparts(XmlFileName); … … 964 926 end 965 927 if ~isempty(XmlDataRead) 966 ImaDoc_str=['view ' DocExt]; 928 ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) 967 929 XmlData=XmlDataRead; 968 930 if isfield(XmlData,'TimeUnit') … … 990 952 end 991 953 end 992 if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))993 if index==1994 set(handles.TimeName,'String','xml')995 else996 set(handles.TimeName_1,'String','xml')997 end998 else999 XmlData.Time=Time; %time set by video1000 end1001 954 if isempty(ImaDoc_str) 1002 set(handles.view_xml,'Visible','off') 1003 else 1004 set(handles.view_xml,'String',ImaDoc_str) 955 set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected 956 else 957 set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected 958 end 959 960 %% Define timing 961 % time not set by the input file: images or civ data: indicate that time is read from the xml file 962 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... 963 (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) 964 TimeName='xml'; 965 end 966 if index==1 967 set(handles.TimeName,'String',TimeName) 968 else 969 set(handles.TimeName_1,'String',TimeName) 970 set(handles.TimeName_1,'Visible','on') 1005 971 end 1006 972 … … 1014 980 nbfield_j=max(max(max(j1_series))); 1015 981 end 1016 if ~isempty(XmlData.Time)982 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) 1017 983 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 1018 984 if isequal(size(XmlData.Time,1),1) … … 1075 1041 1076 1042 %% update the data attached to the uvmat interface 1077 if ~isempty(TimeUnit)1078 set(handles.TimeName,'String',['time (' TimeUnit ')'])1079 end1080 1043 UvData.TimeUnit=TimeUnit; 1081 1044 UvData.XmlData{index}=XmlData; … … 1311 1274 %------------------------------------------------------------------------ 1312 1275 % --- Executes on button press in view_xml. 1276 %------------------------------------------------------------------------ 1313 1277 function view_xml_Callback(hObject, eventdata, handles) 1314 %------------------------------------------------------------------------ 1315 %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); 1316 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1317 FileBase=fullfile(RootPath,RootFile); 1278 1279 % if TimeName defined, open the xml file corresponding to the first file 1280 % series, else open the xml file corresponding to the second series 1281 if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series 1282 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); 1283 else 1284 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1285 end 1318 1286 option=get(handles.view_xml,'String'); 1319 if isequal(option,'view .xml') 1287 if isequal(option,'view .xml') 1320 1288 FileXml=fullfile(RootPath,[SubDir '.xml']); 1321 1289 if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir … … 1616 1584 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); 1617 1585 1586 % i1_1=i1; 1587 % i2_1=i2; 1588 % j1_1=j1; 1589 % j2_1=j2; 1618 1590 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) 1619 i1_1=i1;1620 i2_1=i2;1621 j1_1=j1;1622 j2_1=j2;1623 1591 if CheckFixPair && isnumeric(increment) 1624 1592 if get(handles.scan_i,'Value')==1% case of scanning along index i … … 2214 2182 ParamIn_1.FieldName=FieldName_1; 2215 2183 ParamIn_1.VelType=VelType_1; 2216 ParamIn_1.GUIName='get_field_1';2184 %ParamIn_1.GUIName='get_field_1'; 2217 2185 end 2218 2186 [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); … … 2320 2288 end 2321 2289 2322 %% display time 2290 %% display time value of the current file 2323 2291 abstime=[];%default inputs 2324 2292 dt=[]; 2325 2293 TimeUnit=''; 2294 if isfield(UvData,'TimeUnit') 2295 TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo 2296 end 2326 2297 % time from xml file or video movie 2327 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') 2298 TimeName=get(handles.TimeName,'String');% indicate that time is from xml 2299 if strcmp(TimeName,'xml')||strcmp(TimeName,'video') 2328 2300 if isempty(num_i2)||isnan(num_i2) 2329 2301 num_i2=num_i1; … … 2337 2309 siz=size(UvData.XmlData{1}.Time); 2338 2310 if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1) 2339 set(handles.TimeName,'String','xml')% indicate that time is from xml2340 2311 abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files 2341 2312 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); … … 2345 2316 end 2346 2317 end 2347 if numel(UvData.XmlData)==2 2348 if isempty(i2_1) 2349 i2_1=num_i1; 2350 end 2351 if isempty(j1_1) 2352 j1_1=1; 2353 end 2354 if isempty(j2_1) 2355 j2_1=j1_1; 2356 end 2357 siz=size(UvData.XmlData{2}.Time); 2358 if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1) 2359 abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files 2360 Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1)); 2361 end 2362 end 2363 end 2364 2365 %% look for timing in the input file if not defined in a xml file or movie 2318 end 2319 2320 % get time in the input file, not defined in a xml file or movie 2366 2321 if isempty(abstime) 2367 TimeName=get(handles.TimeName,'String');2368 2322 if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2369 2323 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file … … 2382 2336 end 2383 2337 set(handles.TimeValue,'String',num2str(abstime)) 2338 2339 %% display time value of the second current file if relevant 2384 2340 abstime_1=[]; 2385 TimeName_1=get(handles.TimeName_1,'String'); 2386 if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2341 if ~isempty(FileName_1) 2342 TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video 2343 % time from xml file or video movie as a second file series 2344 if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video') 2345 if numel(UvData.XmlData)==2 2346 if isempty(i2_1) 2347 i2_1=num_i1; 2348 end 2349 if isempty(j1_1) 2350 j1_1=1; 2351 end 2352 if isempty(j2_1) 2353 j2_1=j1_1; 2354 end 2355 siz=size(UvData.XmlData{2}.Time); 2356 if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1) 2357 abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files 2358 Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1)); 2359 end 2360 end 2361 end 2362 2363 % get time in the input file of the second series, not defined in a xml file or movie 2364 if isempty(abstime_1) && numel(Field)==2 &&... 2365 ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2387 2366 abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file 2388 end 2389 set(handles.TimeValue_1,'String',num2str(abstime_1,5)) 2367 end 2368 set(handles.TimeValue_1,'String',num2str(abstime_1,5)) 2369 end 2370 2390 2371 if isempty(dt)||isequal(dt,0) 2391 2372 set(handles.Dt_txt,'String','') … … 2397 2378 end 2398 2379 end 2380 2381 %% Time title with unit 2382 if isempty(abstime)&&isempty(abstime_1) 2383 Time_title=''; 2384 else 2385 Time_title='Time'; 2386 if ~isempty(TimeUnit) 2387 Time_title=['Time (' TimeUnit ')']; 2388 end 2389 end 2390 set(handles.Time_title,'String',Time_title) 2399 2391 2400 2392 %% store the current open names, fieldname and vel types in uvmat interface … … 2418 2410 end 2419 2411 end 2420 transform=get(handles.TransformPath,'UserData');2421 2412 switch nargin(transform) 2422 2413 case 4 … … 2538 2529 set(handles.ListObject_1,'String',{'plane'}) 2539 2530 end 2540 IndexObj (1)=get(handles.ListObject_1,'Value');%selected projection object for main view2541 if IndexObj (1)> numel(UvData.ProjObject)2542 IndexObj (1)=1;%select the first object if the selected one does not exist2531 IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view 2532 if IndexObj> numel(UvData.ProjObject) 2533 IndexObj=1;%select the first object if the selected one does not exist 2543 2534 set(handles.ListObject_1,'Value',1) 2544 2535 end 2545 IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view 2546 if isequal(IndexObj(2),IndexObj(1)) 2547 IndexObj(2)=[]; 2536 if get(handles.CheckViewField,'Value') 2537 IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field 2538 if ~isequal(IndexObj_2,IndexObj(1)) 2539 IndexObj(2)=IndexObj_2; 2540 end 2548 2541 end 2549 2542 plot_handles{1}=handles; … … 2894 2887 fin=close(nc); 2895 2888 2896 %------------------------------------------------------------------- 2889 %----------------------------------------------------------------------- 2897 2890 % --- Executes on button press in SubField 2891 %----------------------------------------------------------------------- 2898 2892 function SubField_Callback(hObject, eventdata, handles) 2899 %------------------------------------------------------------------- 2900 UvData=get(handles.uvmat,'UserData'); 2901 if get(handles.SubField,'Value')==0% if the subfield button is desactivated 2902 set(handles.RootPath_1,'String','') 2903 set(handles.RootFile_1,'String','') 2904 set(handles.SubDir_1,'String',''); 2905 set(handles.FileIndex_1,'String',''); 2906 set(handles.FileExt_1,'String',''); 2907 set(handles.RootPath_1,'Visible','off') 2908 set(handles.RootFile_1,'Visible','off') 2909 set(handles.SubDir_1,'Visible','off'); 2910 set(handles.NomType_1,'Visible','off'); 2911 set(handles.TimeValue_1,'Visible','off') 2912 set(handles.FileIndex_1,'Visible','off'); 2913 set(handles.FileExt_1,'Visible','off'); 2914 set(handles.FieldName_1,'Value',1);%set to blank state 2915 set(handles.VelType_1,'Value',1);%set to blank state 2916 set(handles.num_Opacity,'String','')% desactivate opacity setting 2917 FieldList=get(handles.FieldName,'String'); 2918 if numel(FieldList)>1 % if a choice of fields exists 2919 set(handles.FieldName_1,'Value',1)% set second field choice to blank 2920 set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option 2921 else 2922 set(handles.FieldName_1,'String',{''})% set second field choice to blank 2923 end 2924 if ~strcmp(get(handles.VelType,'Visible'),'on') 2925 set(handles.VelType_1,'Visible','off') 2926 end 2927 if isfield(UvData,'XmlData_1') 2928 UvData=rmfield(UvData,'XmlData_1'); 2929 end 2930 set(handles.uvmat,'UserData',UvData); 2893 2894 if get(handles.SubField,'Value')==0% if the subfield button is desactivated 2895 desable_subfield(handles) 2931 2896 transform_fct_list=get(handles.TransformName,'String'); 2932 2897 transform_fct=transform_fct_list(get(handles.TransformName,'Value')); … … 2938 2903 end 2939 2904 else 2940 %RootPath=get(handles.RootPath,'String');2941 %SubDir=get(handles.SubDir,'String');2942 2905 fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String')); 2943 2906 if isempty(fileinput_1) 2944 2907 set(handles.SubField,'Value',0) 2945 else 2946 2908 else 2947 2909 % refresh the current displayed field 2948 set(handles.SubField,'Value',1)2949 2910 display_file_name(handles,fileinput_1,2) 2950 2911 … … 2961 2922 set(handles.MenuFile_5,'Label',MenuFile_5) 2962 2923 end 2963 % MenuBrowse_1_Callback(hObject, eventdata, handles) 2964 end 2924 end 2925 2926 %----------------------------------------------------------------------- 2927 % --- desactivate display used for a second file series 2928 %----------------------------------------------------------------------- 2929 function desable_subfield(handles) 2930 2931 set(handles.RootPath_1,'String','') 2932 set(handles.RootFile_1,'String','') 2933 set(handles.SubDir_1,'String',''); 2934 set(handles.FileIndex_1,'String',''); 2935 set(handles.FileExt_1,'String',''); 2936 set(handles.RootPath_1,'Visible','off') 2937 set(handles.RootFile_1,'Visible','off') 2938 set(handles.SubDir_1,'Visible','off'); 2939 set(handles.NomType_1,'Visible','off'); 2940 set(handles.FileIndex_1,'Visible','off'); 2941 set(handles.FileExt_1,'Visible','off'); 2942 set(handles.TimeName_1,'String',''); 2943 set(handles.TimeName_1,'Visible','off'); 2944 set(handles.TimeValue_1,'String',''); 2945 set(handles.TimeValue_1,'Visible','off'); 2946 set(handles.FieldName_1,'Value',1);%set to blank state 2947 set(handles.VelType_1,'Value',1);%set to blank state 2948 set(handles.num_Opacity,'String','')% desactivate opacity setting 2949 FieldList=get(handles.FieldName,'String'); 2950 if numel(FieldList)>1 % if a choice of fields exists 2951 set(handles.FieldName_1,'Value',1)% set second field choice to blank 2952 set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option 2953 else 2954 set(handles.FieldName_1,'String',{''})% set second field choice to blank 2955 end 2956 if ~strcmp(get(handles.VelType,'Visible'),'on') 2957 set(handles.VelType_1,'Visible','off') 2958 end 2959 UvData=get(handles.uvmat,'UserData'); 2960 if isfield(UvData,'XmlData_1') 2961 UvData=rmfield(UvData,'XmlData_1'); 2962 end 2963 set(handles.uvmat,'UserData',UvData); 2965 2964 2966 2965 %------------------------------------------------------------------------ 2967 2966 % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI 2968 2967 %------------------------------------------------------------------------ 2969 2968 function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) 2970 %------------------------------------------------------------------------ 2969 2971 2970 InputFile=read_GUI(handles.InputFile); 2972 2971 RootPath=InputFile.RootPath; … … 2979 2978 %------------------------------------------------------------------------ 2980 2979 % ---- read the data displayed for the second input rootfile windows 2980 %------------------------------------------------------------------------ 2981 2981 function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) 2982 %------------------------------------------------------------------------ 2982 2983 2983 RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window 2984 2984 if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') … … 3021 3021 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3022 3022 3023 switch field 3023 switch field 3024 3024 3025 3025 case 'get_field...' 3026 %% fill the coordinates and variables from selections in get_field3026 %% fill the coordinates and variables from selections in get_field 3027 3027 ParamIn=[]; 3028 3028 % in case of civ data, we use the civ choice as default input for the GUI get_field … … 3033 3033 switch VelType 3034 3034 case 'civ1' 3035 ParamIn.Time VarName='Civ1_Time';3035 ParamIn.TimeAttrName='Civ1_Time'; 3036 3036 ParamIn.vector_x='Civ1_U'; 3037 3037 ParamIn.vector_y='Civ1_V'; 3038 3038 ParamIn.vec_color='Civ1_C'; 3039 3039 case 'filter1' 3040 ParamIn.Time VarName='Civ1_Time';3040 ParamIn.TimeAttrName='Civ1_Time'; 3041 3041 ParamIn.vector_x='Civ1_U_smooth'; 3042 3042 ParamIn.vector_y='Civ1_V_smooth'; 3043 3043 case 'civ2' 3044 ParamIn.Time VarName='Civ2_Time';3044 ParamIn.TimeAttrName='Civ2_Time'; 3045 3045 ParamIn.vector_x='Civ2_U'; 3046 3046 ParamIn.vector_y='Civ2_V'; 3047 3047 case 'filter2' 3048 ParamIn.Time VarName='Civ2_Time';3048 ParamIn.TimeAttrName='Civ2_Time'; 3049 3049 ParamIn.vector_x='Civ2_U_smooth'; 3050 3050 ParamIn.vector_y='Civ2_V_smooth'; … … 3056 3056 set(handles.FixVelType,'visible','off') 3057 3057 set(handles.VelType,'Visible','off') 3058 %set(handles.VelType_1,'Visible','off')3059 3058 3060 3059 %read selection from get_field … … 3077 3076 case '1D plot' 3078 3077 YName=GetFieldData.PanelOrdinate.ordinate; 3079 case 'civdata...'%return to civdata from get_field 3080 % [FieldList,VecColorList]=set_field_list('U','V','C'); 3081 set(handles.FieldName,'Value',2) 3082 set(handles.FixVelType,'visible','on') 3083 set(handles.VelType,'Visible','on') 3078 case 'civdata...'%reinitiate input, return to automatic civ data reading 3079 display_file_name(handles,FileName,1) 3084 3080 end 3085 3081 if ~strcmp(GetFieldData.FieldOption,'civdata...') 3086 3082 XName=GetFieldData.Coordinates.Coord_x; 3087 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;3088 if strcmp(TimeNameStr,'file index')3089 set(handles.TimeName,'String','');3090 else3091 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);3092 end3093 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index3094 set(handles.NomType,'String','*')3095 set(handles.RootFile,FileName)3096 end3097 % set(handles.TimeValue,'String' SwitchVarIndexTime3098 set(handles.Coord_x,'String',XName)3099 if ischar(YName)3100 YName={YName};3101 end3102 set(handles.Coord_y,'Data',YName)3103 set(handles.FieldName,'Value',1)3104 set(handles.FieldName,'String',[FieldList; {'get_field...'}]);3105 set(handles.ColorScalar,'Value',1)3106 set(handles.ColorScalar,'String',VecColorList);3107 UvData.FileType{1}='netcdf';3108 set(handles.uvmat,'UserData',UvData)3109 end3110 run0_Callback(hObject, eventdata, handles)3111 3083 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 3084 if strcmp(TimeNameStr,'file index') 3085 set(handles.TimeName,'String',''); 3086 else 3087 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]); 3088 end 3089 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index 3090 set(handles.NomType,'String','*') 3091 set(handles.RootFile,FileName) 3092 end 3093 % set(handles.TimeValue,'String' SwitchVarIndexTime 3094 set(handles.Coord_x,'String',XName) 3095 if ischar(YName) 3096 YName={YName}; 3097 end 3098 set(handles.Coord_y,'Data',YName) 3099 set(handles.FieldName,'Value',1) 3100 set(handles.FieldName,'String',[FieldList; {'get_field...'}]); 3101 set(handles.ColorScalar,'Value',1) 3102 set(handles.ColorScalar,'String',VecColorList); 3103 UvData.FileType{1}='netcdf'; 3104 set(handles.uvmat,'UserData',UvData) 3105 run0_Callback(hObject, eventdata, handles) 3106 end 3107 3112 3108 case 'image' 3113 %% look for image corresponding to civ data3109 %% look for image corresponding to civ data 3114 3110 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3115 3111 imagename=UvData.Field.Civ2_ImageA; … … 3128 3124 % display the selected field and related information 3129 3125 display_file_name(handles,imagename)%display the image 3130 otherwise 3131 % ext=get(handles.FileExt,'String'); 3132 % if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file 3133 % [FileName,PathName] = uigetfile( ... 3134 % {'*.nc', ' (*.nc)'; 3135 % '*.nc',' netcdf files'; ... 3136 % '*.*', 'All Files (*.*)'}, ... 3137 % 'Pick a netcdf file',FileBase); 3138 % if ~ischar(FileName),return,end %abandon if the browser is cancelled 3139 % FullFileName=[PathName FileName]; 3140 % display the selected field and related information 3141 run0_Callback(hObject, eventdata, handles) 3126 otherwise 3127 run0_Callback(hObject, eventdata, handles) 3142 3128 end 3143 3129 … … 3192 3178 end 3193 3179 case 'image' 3194 % get the image name corresponding to the current netcdf name (no unique correspondance) 3180 %% look for image corresponding to civ data 3181 imagename=''; 3195 3182 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3196 3183 imagename=UvData.Field.Civ2_ImageA; … … 3198 3185 imagename=UvData.Field.Civ1_ImageA; 3199 3186 else 3200 SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' 3201 imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); 3202 end 3203 if ~exist(imagename,'file') % browse for images if it is not found 3204 [FileName,PathName] = uigetfile( ... 3205 {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; 3206 '*.jpg',' jpeg image files'; ... 3207 '*.png','.png image files'; ... 3208 '*.tif','.tif image files'; ... 3209 '*.avi;*.AVI','.avi movie files'; ... 3210 '*.vol','.volume images (png)'; ... 3211 '*.*', 'All Files (*.*)'}, ... 3212 'Pick an image',imagename); 3213 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3214 imagename=[PathName FileName]; 3215 end 3216 if ~ischar(imagename)% quit if the browser has been closed 3187 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3188 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3189 end 3190 if ~exist(imagename,'file') 3191 imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); 3192 3193 end 3194 if isempty(imagename) 3217 3195 set(handles.SubField,'Value',0) 3218 else %valid browser input: display the selected image 3219 set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons 3220 set(handles.num_Npx,'Visible','on') 3221 set(handles.num_Npy,'Visible','on') 3222 display_file_name(handles,imagename,2)%display the imag 3196 return 3197 else 3198 display_file_name(handles,imagename,2)%display the image as second field 3223 3199 end 3224 3200 otherwise … … 3234 3210 set(handles.uvmat,'UserData',UvData) 3235 3211 set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields 3236 transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot3212 TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot 3237 3213 check_refresh=0; 3238 3214 end … … 4575 4551 %------------------------------------------------------------------------ 4576 4552 function Menuline_x_Callback(hObject, eventdata, handles) 4577 msgbox_uvmat('ERROR','option not yet implemented, use line') 4578 return 4553 4579 4554 data.Type='line_x'; 4580 4555 data.ProjMode='projection';%default … … 4586 4561 % ----------------------------------------------------------------------- 4587 4562 function Menuline_y_Callback(hObject, eventdata, handles) 4588 msgbox_uvmat('ERROR','option not yet implemented, use line') 4589 return 4563 4590 4564 data.Type='line_y'; 4591 4565 data.ProjMode='projection';%default … … 4676 4650 data.Name=data.Type;% default name=type 4677 4651 data.Coord=[0 0]; %default 4652 check_plot=0; 4678 4653 if isfield(UvData,'Field') 4679 4654 Field=UvData.Field; 4655 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) 4656 data.Coord=[0 0 0]; %default 4657 end 4658 if isfield(Field,'CoordUnit') 4659 data.CoordUnit=Field.CoordUnit; 4660 end 4680 4661 if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) 4681 4662 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; … … 4684 4665 data.RangeY=UvData.Field.CoordMesh; 4685 4666 case 'line_x' 4686 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; 4667 check_plot=1; %plot the line directly when set_object is opened 4668 data.Type='line'; 4669 data.RangeX=UvData.Field.XMin ; 4687 4670 data.RangeY=UvData.Field.CoordMesh; 4688 data.Coord=[0 (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis 4671 data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;... 4672 UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis 4689 4673 case 'line_y' 4674 check_plot=1; %plot the line directly when set_object is opened 4675 data.Type='line'; 4676 data.RangeX=UvData.Field.YMin ; 4690 4677 data.RangeY=UvData.Field.CoordMesh; 4691 data.Coord=[(UvData.Field.XMin +UvData.Field.XMax)/2 0];% put line at the middle of the x axis 4678 data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;... 4679 (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis 4692 4680 case {'rectangle','ellipse'} 4693 4681 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; … … 4700 4688 data.DY=UvData.Field.CoordMesh; 4701 4689 end 4702 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) 4703 data.Coord=[0 0 0]; %default 4704 end 4705 if isfield(Field,'CoordUnit') 4706 data.CoordUnit=Field.CoordUnit; 4707 end 4708 end 4690 end 4691 4709 4692 hset_object=set_object(data,handles);% call the GUI set_object 4710 4693 hchild=get(hset_object,'children'); 4711 4694 set(hchild,'enable','on') 4712 4695 set(handles.DeleteObject,'Visible','on')% make the object delete button visible 4696 if check_plot 4697 hhset_object=guidata(hset_object); 4698 set_object('PLOT_Callback',1,[],hhset_object);% call the GUI set_object 4699 end 4713 4700 4714 4701 %------------------------------------------------------------------------ … … 4717 4704 %get the object file 4718 4705 fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml'); 4719 4720 4706 if ~isempty(fileinput) 4721 4707 %read the file
Note: See TracChangeset
for help on using the changeset viewer.