- Timestamp:
- Jun 9, 2013, 10:31:58 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r644 r648 32 32 r=regexp(FieldName{ilist},'(?<Operator>(^vec|^norm|^curl|^div|^strain))\((?<UName>.+),(?<VName>.+)\)$','names');% analyse the field name 33 33 if isempty(r) % the field name is a variable itself 34 if ~isfield(Data,FieldName{ilist}) 34 ivar=strcmp(FieldName{ilist},Data.ListVarName); 35 if isempty(ivar) 35 36 check_skipped(ilist)=1; %variable not found 36 37 else 37 if isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 38 if isfield(Data.VarAttribute{ivar},'Role')&&strcmp(Data.VarAttribute{ivar}.Role,'ancillary') 39 check_skipped(ilist)=1; % ancillary variable, not found interpolated 40 elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1)); 38 41 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list 39 42 end -
trunk/src/check_files.m
r646 r648 78 78 'nc2struct';...% transform a netcdf file in a corresponding matlab structure 79 79 'num2stra';...% transform number to the corresponding character string depending on the nomenclature 80 'open_uvmat';...% open with uvmat the field selected in the list of 'civ/status' or 'series/check_data_files'81 80 'phys_XYZ';...% transform coordiantes from pixels to phys 82 81 'px_XYZ';...% transform coordiantes from phys to pixels -
trunk/src/civ.m
r623 r648 4563 4563 civ2.convectFlow='n'; 4564 4564 4565 4566 % --- Executes on selection change in RunMode. 4567 function RunMode_Callback(hObject, eventdata, handles) 4568 4569 4570 function nb_field2_Callback(hObject, eventdata, handles) 4571 4572 4573 function last_j_Callback(hObject, eventdata, handles) 4574 4575 4576 function last_i_Callback(hObject, eventdata, handles) 4565 % 'open_uvmat': open with uvmat the field selected in the list of 'civ/status' 4566 %------------------------------------------------------------------------ 4567 %function open_uvmat(hObject, eventdata) 4568 % 4569 % INPUT: 4570 % hObject: handle of uicontrol object containing the list 4571 % eventdata: not used 4572 function open_uvmat(hObject, eventdata) 4573 %------------------------------------------------------------------------ 4574 list=get(hObject,'String'); 4575 index=get(hObject,'Value'); 4576 rootroot=get(hObject,'UserData'); 4577 filename=list{index}; 4578 ind_dot=strfind(filename,'...'); 4579 if ~isempty(ind_dot) 4580 filename=filename(1:ind_dot-1); 4581 end 4582 filename=fullfile(rootroot,filename); 4583 if exist(filename,'file')%visualise the vel field if it exists 4584 uvmat(filename) 4585 set(gcbo,'Value',1) 4586 end 4587 4588 % 4589 % % --- Executes on selection change in RunMode. 4590 % function RunMode_Callback(hObject, eventdata, handles) 4591 % 4592 % 4593 % function nb_field2_Callback(hObject, eventdata, handles) 4594 % 4595 % 4596 % function last_j_Callback(hObject, eventdata, handles) 4597 % 4598 % 4599 % function last_i_Callback(hObject, eventdata, handles) -
trunk/src/find_field_cells.m
r582 r648 191 191 check_index_1= strcmp(DimCell{1},Data.ListDimName); 192 192 check_index_2= strcmp(DimCell{2},Data.ListDimName); 193 check_index_3= strcmp(DimCell{3},Data.ListDimName);194 193 NbDim(icell)=Data.DimValue(check_index_2); 194 if numel(DimCell)>=3 195 check_index_3= strcmp(DimCell{3},Data.ListDimName); 195 196 CellInfo{icell}.CoordSize=Data.DimValue(check_index_1)*Data.DimValue(check_index_3); 197 end 196 198 end 197 199 check_select=check_select|check_cell; -
trunk/src/get_field.m
r646 r648 22 22 function varargout = get_field(varargin) 23 23 24 % Last Modified by GUIDE v2.5 0 2-Jun-2013 14:00:3924 % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before get_field is made visible. 47 %------------------------------------------------------------------------ 47 48 function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) 48 %------------------------------------------------------------------------ 49 global nb_builtin % nbre of functions to include by default in the menu of functions called by RUN 50 51 %% Choose default command line output for get_field 49 50 %% GUI settings 52 51 handles.output = 'Cancel'; 53 54 %% Update handles structure55 52 guidata(hObject, handles); 56 53 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) 57 54 58 %% settings for 'slave' mode, called by uvmat, or 'master' mode 59 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 60 set(handles.inputfile,'String',filename)% prefill the input file name 61 Field=nc2struct(filename,[]);% reads the field structure, without the variables 62 if isfield(Field,'Txt') 63 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt]) 64 else 65 if ~exist('ParamIn','var') 66 ParamIn=[]; 67 end 68 Field_input(handles,Field,ParamIn); 69 end 70 else %master mode 71 set(handles.inputfile,'String','') 72 end 73 74 %% put the GUI on the lower right of the sceen 75 set(hObject,'Unit','pixel') 76 pos_view_field=get(hObject,'Position'); 77 set(0,'Unit','pixels') 78 ScreenSize=get(0,'ScreenSize'); 79 pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); 80 pos_view_field(2)=ScreenSize(2); 81 set(hObject,'Position',pos_view_field) 82 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 83 drawnow 84 uiwait(handles.get_field); 85 86 %------------------------------------------------------------------------ 87 % --- update the display when a new field is introduced. 88 function Field_input(handles,Field,ParamIn) 89 %------------------------------------------------------------------------ 90 91 %% fill the list and values of dimensions 92 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) 93 Tabcell(:,1)=Field.ListDimName; 94 for iline=1:length(Field.ListDimName) 95 Tabcell{iline,2}=num2str(Field.DimValue(iline)); 96 end 97 Tabchar=cell2tab(Tabcell,' = '); 98 set(handles.dimensions,'String',Tabchar) 55 %% 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 58 if isfield(Field,'Txt') 59 msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fiel reading 60 return 99 61 end 100 62 if ~isfield(Field,'ListVarName') 101 63 return 102 64 end 103 104 %% fill the list of variables 105 Txt=Field.ListVarName; 106 set(handles.variables,'Value',1) 107 set(handles.variables,'String',[{'*'} Txt]) 108 variables_Callback(handles.variables,[], handles) 109 set(handles.ordinate,'String',Txt) 110 set(handles.vector_x,'String',Txt) 111 set(handles.vector_y,'String',Txt ) 112 set(handles.vector_z,'String',[{''} Txt ]) 113 set(handles.vec_color,'String',[{''} Txt ]) 114 set(handles.XVarName,'String',Txt ) 115 set(handles.YVarName,'String',Txt ) 116 set(handles.ZVarName,'String',Txt ) 117 set(handles.scalar,'Value',1) 118 set(handles.scalar,'String', Txt ) 65 if ~exist('ParamIn','var') 66 ParamIn=[]; 67 end 68 69 %% look at singletons and variables with a single dimension 70 Field.Display=Field; 71 Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value 72 NbVar=numel(Field.VarDimName); 73 for ilist=1:NbVar 74 if ischar(Field.VarDimName{ilist}) 75 Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell 76 end 77 NbDim=numel(Field.VarDimName{ilist}); 78 check_singleton=false(1,NbDim); 79 for idim=1:NbDim 80 dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions 81 check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton 82 end 83 Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)));% =1 if the variable reduces to a single value 84 if ~Field.Check0D(ilist) 85 Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions 86 end 87 %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons 88 end 89 if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded 90 Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); 91 end 92 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); 93 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); 94 Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); 95 Field.Display.DimValue=Field.DimValue(Field.DimValue~=1); 96 Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1); 119 97 120 98 %% analyse the input field cells 121 [CellInfo,NbDim,errormsg]=find_field_cells(Field );122 if ~isempty(errormsg) 99 [CellInfo,NbDim,errormsg]=find_field_cells(Field.Display); 100 if ~isempty(errormsg) 123 101 msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) 124 102 return 125 end 103 end 126 104 [Field.MaxDim,imax]=max(NbDim); 127 % look at variables with a single dimension128 for ilist=1:numel(Field.VarDimName)129 if ischar(Field.VarDimName{ilist})130 Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell131 end132 NbDim=numel(Field.VarDimName{ilist});% TODO eliminate singleton dimensions133 check_singleton=false(1,NbDim);134 for idim=1:NbDim135 dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);136 check_singleton(idim)=isequal(Field.DimValue(dim_index),1);137 end138 Field.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);139 Field.NbDim(ilist)=numel(Field.VarDimName{ilist});140 if Field.NbDim(ilist)==1141 Field.VarDimName{ilist}=cell2mat(Field.VarDimName{ilist});142 end143 end144 SingleVarName=Field.ListVarName(Field.NbDim==1);%list of variables with a single dim145 MultiVarName=Field.ListVarName(Field.NbDim>1);146 check_dim=zeros(size(Field.VarDimName));147 for ilist=1:numel(Field.VarDimName);148 if iscell(Field.VarDimName{ilist})% exclude single dim149 for idim=1:numel(Field.VarDimName{ilist})150 check_dim=check_dim|strcmp(Field.VarDimName{ilist}{idim},Field.VarDimName);151 end152 end153 end154 Field.SingleVarName=Field.ListVarName(find(check_dim));%list of variables with a single dim155 Field.SingleDimName=Field.VarDimName(find(check_dim));% corresponding list of dimensions for variables with a single dim156 Field.MaxDim=max(Field.NbDim);157 105 158 106 %% set time mode … … 166 114 check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); 167 115 end 168 Field. ListNumAttributes=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value169 if ~isempty(Field. ListNumAttributes)116 Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value 117 if ~isempty(Field.Display.ListGlobalAttribute) 170 118 ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute 171 119 end … … 174 122 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index 175 123 end 176 if Field.MaxDim>=4% for dim >=4, one dim is proposed as time 177 option=nboption+1; 178 elseif ~isempty(find(check_time, 1)) 179 option=2; 124 if ~isempty(find(check_time, 1)) 125 set(handles.SwitchVarIndexTime,'Value',2); 180 126 else 181 option=1;127 set(handles.SwitchVarIndexTime,'Value',1); 182 128 end 183 129 set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) 184 set(handles.SwitchVarIndexTime,'Value',option)185 130 set(handles.get_field,'UserData',Field);% record the finput field structure 186 SwitchVarIndexTime_Callback([],[], handles) 187 188 %% set z coordinate menu if relevant 189 if Field.MaxDim>=3 190 set(handles.vector_z,'Visible','on') 191 set(handles.vector_z,'String',[{''} Txt ]) 192 set(handles.ZVarName,'Visible','on') 193 set(handles.SwitchVarIndexZ,'Visible','on') 194 set(handles.Z_title,'Visible','on') 195 else 196 set(handles.vector_z,'Visible','off') 197 set(handles.ZVarName,'Visible','off') 198 % set(handles.SwitchVarIndexZ,'Visible','off') 199 set(handles.Z_title,'Visible','off') 200 end 131 SwitchVarIndexTime_Callback([], [], handles) 201 132 202 133 %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields 134 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components 135 set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components 136 set(handles.vector_z,'String',[{''} Field.ListVarName])% fill the menu of y vector components 137 set(handles.vec_color,'String',[{''} Field.ListVarName])% fill the menu of y vector components 138 set(handles.scalar,'Value',1)% fill the menu of y vector components 139 set(handles.scalar,'String',Field.ListVarName)% fill the menu of y vector components 140 set(handles.ordinate,'Value',1)% fill the menu of y vector components 141 set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components 203 142 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 208 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 143 if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') 209 144 set(handles.FieldOption,'Value',3)% set vector selection option 210 145 set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) … … 218 153 end 219 154 155 %% fill the general list of dimensions, variables, attributes 156 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) 157 Tabcell(:,1)=Field.ListDimName; 158 for iline=1:length(Field.ListDimName) 159 Tabcell{iline,2}=num2str(Field.DimValue(iline)); 160 end 161 Tabchar=cell2tab(Tabcell,' = '); 162 set(handles.dimensions,'String',Tabchar) 163 end 164 set(handles.variables,'Value',1) 165 set(handles.variables,'String',[{'*'} Field.ListVarName]) 166 variables_Callback(handles.variables,[], handles)% list the global attributes 167 168 %% fill menus for coordinates and time 169 FieldOption_Callback(handles.variables,[], handles)% list the global attributes 170 % if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y') 171 % set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1)) 172 % set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1)) 173 % end 220 174 221 175 %% Make choices in menus from input 222 if exist('ParamIn','var')&&~isempty(ParamIn) 223 fill_GUI(ParamIn,handles.get_field); 224 end 225 FieldOption_Callback([],[],handles) 176 % if exist('ParamIn','var')&&~isempty(ParamIn) 177 % fill_GUI(ParamIn,handles.get_field); 178 % end 179 %FieldOption_Callback([],[],handles) 180 181 182 %% put the GUI on the lower right of the sceen 183 set(hObject,'Unit','pixel') 184 pos_view_field=get(hObject,'Position'); 185 set(0,'Unit','pixels') 186 ScreenSize=get(0,'ScreenSize'); 187 pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); 188 pos_view_field(2)=ScreenSize(2); 189 set(hObject,'Position',pos_view_field) 190 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 191 drawnow 192 uiwait(handles.get_field); 193 194 return 195 196 SwitchVarIndexTime_Callback([],[], handles) 197 198 %% set z coordinate menu if relevant 199 if Field.MaxDim>=3 200 set(handles.vector_z,'Visible','on') 201 set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D)) 202 set(handles.Coord_z,'Visible','on') 203 set(handles.SwitchVarIndexZ,'Visible','on') 204 set(handles.Z_title,'Visible','on') 205 else 206 set(handles.vector_z,'Visible','off') 207 set(handles.Coord_z,'Visible','off') 208 set(handles.Z_title,'Visible','off') 209 end 210 211 212 213 %------------------------------------------------------------------------ 226 214 227 215 %------------------------------------------------------------------------ … … 232 220 delete(handles.get_field) 233 221 222 %------------------------------------------------------------------------ 223 % --- Executes when user attempts to close get_field. 224 %------------------------------------------------------------------------ 225 function get_field_CloseRequestFcn(hObject, eventdata, handles) 226 227 if isequal(get(handles.get_field, 'waitstatus'), 'waiting') 228 % The GUI is still in UIWAIT, us UIRESUME 229 uiresume(handles.get_field); 230 else 231 % The GUI is no longer waiting, just close it 232 delete(handles.get_field); 233 end 234 235 %--------------------------------------------------------- 236 % --- Executes on button press in OK. 237 %------------------------------------------------------------------------ 238 function OK_Callback(hObject, eventdata, handles) 239 240 handles.output=read_GUI(handles.get_field); 241 guidata(hObject, handles);% Update handles structure 242 uiresume(handles.get_field); 243 drawnow 234 244 235 245 % ----------------------------------------------------------------------- … … 250 260 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 251 261 if isfield(Field, Field.ListGlobalAttribute{iline}) 252 eval(['val=Field.' Field.ListGlobalAttribute{iline} ';'])262 val=Field.(Field.ListGlobalAttribute{iline}); 253 263 if ischar(val);% attribute value is char string 254 264 Tabcell{iline,2}=val; … … 285 295 if ~isempty(Tabcell) 286 296 Tabchar=cell2tab(Tabcell,'='); 287 Tabchar=[{''};Tabchar];297 % Tabchar=[{''};Tabchar]; 288 298 end 289 299 set(handles.attributes,'Value',1);% select the first item … … 319 329 end 320 330 321 322 323 %------------------------------------------------------------------------ 324 % --- Executes on button press in CheckPlot1D. 325 function CheckPlot1D_Callback(hObject, eventdata, handles) 326 %------------------------------------------------------------------------ 327 val=get(handles.CheckPlot1D,'Value'); 328 if isequal(val,0) 329 set(handles.Panel1Dplot,'Visible','off') 331 %------------------------------------------------------------------------ 332 % --- Executes on selection change in FieldOption. 333 %------------------------------------------------------------------------ 334 function FieldOption_Callback(hObject, eventdata, handles) 335 336 FieldList=get(handles.FieldOption,'String'); 337 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 338 switch FieldOption 339 case '1D plot' 340 set(handles.PanelOrdinate,'Visible','on') 341 pos=get(handles.PanelOrdinate,'Position'); 342 pos(1)=2; 343 pos_coord=get(handles.Coordinates,'Position'); 344 pos(2)=pos_coord(2)-pos(4)-2; 345 set(handles.PanelOrdinate,'Position',pos) 346 set(handles.PanelScalar,'Visible','off') 347 set(handles.PanelVectors,'Visible','off') 348 set(handles.Coord_y,'Visible','off') 349 set(handles.Y_title,'Visible','off') 350 set(handles.Coord_z,'Visible','off') 351 set(handles.Z_title,'Visible','off') 352 ordinate_Callback(hObject, eventdata, handles) 353 case 'scalar' 354 set(handles.PanelOrdinate,'Visible','off') 355 set(handles.PanelScalar,'Visible','on') 356 set(handles.PanelVectors,'Visible','off') 357 pos=get(handles.PanelScalar,'Position'); 358 pos(1)=2; 359 pos_coord=get(handles.Coordinates,'Position'); 360 pos(2)=pos_coord(2)-pos(4)-2; 361 set(handles.PanelScalar,'Position',pos) 362 set(handles.Coord_y,'Visible','on') 363 set(handles.Y_title,'Visible','on') 364 scalar_Callback(hObject, eventdata, handles) 365 case 'vectors' 366 set(handles.PanelOrdinate,'Visible','off') 367 set(handles.PanelScalar,'Visible','off') 368 set(handles.PanelVectors,'Visible','on') 369 pos=get(handles.PanelVectors,'Position'); 370 pos(1)=2; 371 pos_coord=get(handles.Coordinates,'Position'); 372 pos(2)=pos_coord(2)-pos(4)-2; 373 set(handles.PanelVectors,'Position',pos) 374 set(handles.Coord_y,'Visible','on') 375 set(handles.Y_title,'Visible','on') 376 vector_Callback(handles) 377 end 378 379 %------------------------------------------------------------------------ 380 function ordinate_Callback(hObject, eventdata, handles) 381 %------------------------------------------------------------------------ 382 Field=get(handles.get_field,'UserData'); 383 y_index=get(handles.ordinate,'Value'); 384 y_menu=get(handles.ordinate,'String'); 385 YName=y_menu{y_index}; 386 387 %% set list of possible coordinates 388 test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate 389 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 390 ListCoord={''}; 391 dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable 392 393 for ilist=1:numel(Field.Display.VarDimName) 394 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 395 if isequal(dimnames,dim_var) 396 test_component(ilist)=1; 397 elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable 398 test_coord(ilist)=1; 399 end 400 end 401 var_component=find(test_component);% list of variable indices elligible as unstructured coordinates 402 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 403 ListCoord=Field.Display.ListVarName([var_component var_coord]); 404 405 %% set default coord selection 406 if numel(find(test_coord))>3 407 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 408 end 409 if numel(var_component)<2 410 if numel(test_coord)<2 411 ListCoord={''}; 412 else 413 set(handles.Coord_x,'Value',2) 414 set(handles.Coord_y,'Value',1) 415 end 330 416 else 331 332 end 333 334 %------------------------------------------------------------------------ 335 function ordinate_Callback(hObject, eventdata, handles) 336 %------------------------------------------------------------------------ 417 coord_val=1; 418 for ilist=1:numel(var_component) 419 ivar=var_component(ilist); 420 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') 421 Role=Field.Display.VarAttribute{ivar}.Role; 422 if strcmp(Role,'coord_x') 423 coord_val=ilist; 424 end 425 end 426 end 427 set(handles.Coord_x,'Value',coord_val) 428 end 429 set(handles.Coord_x,'String',ListCoord) 430 431 432 %% set list of time coordinates 433 menu=get(handles.SwitchVarIndexTime,'String'); 434 TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; 435 switch TimeOption 436 case 'variable' 437 if numel(find(test_coord))<3 438 ListTime={''}; 439 else 440 ListTime=Field.Display.ListVarName(find(test_coord,end)); 441 end 442 set(handles.TimeName,'Value',1) 443 set(handles.TimeName,'String',ListTime) 444 case 'dim index' 445 if numel(find(test_coord))<3 446 ListTime={''}; 447 else 448 ListTime=Field.Display.VarDimName{find(test_coord,end)}; 449 end 450 set(handles.TimeName,'Value',1) 451 set(handles.TimeName,'String',ListTime) 452 end 453 update_field(handles,YName) 454 455 %------------------------------------------------------------------------ 456 % --- Executes on selection change in scalar menu. 457 %------------------------------------------------------------------------ 458 function scalar_Callback(hObject, eventdata, handles) 459 337 460 Field=get(handles.get_field,'UserData'); 338 list=get(handles.ordinate,'String'); 339 yindex=get(handles.ordinate,'Value'); 340 yindex=name2index(list{yindex(1)},Field.ListVarName); 341 if ~isempty(yindex) 342 set(handles.variables,'Value',yindex+1) 343 variables_Callback(hObject, eventdata, handles) 344 end 345 [CellInfo,NbDim,errormsg]=find_field_cells(Field); 346 %[CellVarIndex,NbDim,VarRole,errormsg]=find_field_cells(Field); 347 for icell=1:numel(CellInfo) 348 VarIndex=CellInfo{icell}.VarIndex; 349 if ~isempty(find(VarIndex==yindex,1)) && (isempty(CellInfo{icell}.VarIndex_coord_x)||~isequal(CellInfo{icell}.VarIndex_coord_x,VarIndex)) 350 cell_select=icell; 351 break 352 end 353 end 354 %val=get(handles.abscissa,'Value'); 355 %set(handles.abscissa,'Value',min(val,2)); 356 coord_x_index=CellInfo{cell_select}.VarIndex_coord_x; 357 coord_x_index=coord_x_index(coord_x_index~=0); 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))']) 360 361 %------------------------------------------------------------------------ 362 % --- Executes on button press in CheckScalar. 363 function CheckScalar_Callback(hObject, eventdata, handles) 364 %------------------------------------------------------------------------ 365 val=get(handles.CheckScalar,'Value'); 366 if isequal(val,0) 367 set(handles.PanelScalar,'Visible','off') 461 scalar_index=get(handles.scalar,'Value'); 462 scalar_menu=get(handles.scalar,'String'); 463 ScalarName=scalar_menu{scalar_index}; 464 465 %% set list of possible coordinates 466 test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate 467 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 468 ListCoord={''}; 469 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable 470 471 for ilist=1:numel(Field.Display.VarDimName) 472 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 473 if isequal(dimnames,dim_var) 474 test_component(ilist)=1; 475 elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable 476 test_coord(ilist)=1; 477 end 478 end 479 var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes 480 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 481 ListCoord=Field.Display.ListVarName([var_component var_coord]); 482 483 %% set default coord selection 484 if numel(find(test_coord))>3 485 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 486 end 487 if numel(var_component)<2 488 if numel(test_coord)<2 489 ListCoord={''}; 490 else 491 set(handles.Coord_x,'Value',2) 492 set(handles.Coord_y,'Value',1) 493 end 368 494 else 369 370 end 371 372 %------------------------------------------------------------------------ 373 % --- Executes on button press in CheckVector. 374 function CheckVector_Callback(hObject, eventdata, handles) 375 %------------------------------------------------------------------------ 376 val=get(handles.CheckVector,'Value'); 377 if isequal(val,0) 378 set(handles.PanelVectors,'Visible','off') 379 else 380 381 end 382 383 384 %------------------------------------------------------------------------ 385 % --- Executes on selection change in scalar menu. 386 function scalar_Callback(hObject, eventdata, handles) 387 %------------------------------------------------------------------------ 388 Field=get(handles.get_field,'UserData'); 389 index=get(handles.scalar,'Value'); 390 string=get(handles.scalar,'String'); 391 VarName=string{index}; 392 update_field(hObject, eventdata, handles,VarName) 393 394 %eliminate time 395 TimeDimName='';%default 396 397 % SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); 398 % TimeVarOption=SwitchVarIndexTime{get(handles.SwitchVarIndexTime,'Value')}; 399 List=get(handles.TimeVarName,'String'); 400 if get(handles.CheckDimensionTime) 401 TimeDimName=List{get(handles.TimeVarName,'Value')}; 402 elseif ~get(handles.CheckAttributeTime) 403 TimeVarName=List{get(handles.TimeVarName,'Value')}; 404 end 405 % A completer 406 % if strcmp(get(handles.TimeDimensionMenu,'Visible'),'on') 407 % TimeDimList=get(handles.TimeDimensionMenu,'String'); 408 % TimeDimIndex=get(handles.TimeDimensionMenu,'Value'); 409 % TimeDimName=TimeDimList{TimeDimIndex}; 410 % end 411 412 %check possible coordinates 413 Field=get(handles.get_field,'UserData'); 414 dim_scalar=Field.VarDimName{index};%list of dimensions of the selected scalar 415 test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate 416 for ilist=1:numel(Field.VarDimName) 417 dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist 418 if isequal(dimnames,TimeDimName) 419 test_coord(ilist)=0;%mark time variables fo elimination 420 end 421 if ischar(dimnames) 422 dimnames={dimnames}; 423 end 424 for idim=1:numel(dimnames) 425 if isempty(find(strcmp(dimnames{idim},dim_scalar),1))%dimension not found in the scalar variable 426 test_coord(ilist)=0; 427 break 428 end 429 end 430 end 431 test_coord(index)=0;%the coordinate variable must be different from the scalar 432 433 string_coord=[{''};string(test_coord==1)]; 434 val=get(handles.XVarName,'Value'); 435 if val>numel(string_coord) 436 set(handles.XVarName,'Value',1) 437 end 438 set(handles.XVarName,'String',string_coord); 439 val=get(handles.ZVarName,'Value'); 440 if val>numel(string_coord) 441 set(handles.ZVarName,'Value',1) 442 end 443 set(handles.ZVarName,'String',string_coord); 444 val=get(handles.ZVarName,'Value'); 445 if val>numel(string_coord) 446 set(handles.ZVarName,'Value',1) 447 end 448 set(handles.YVarName,'String',string_coord); 449 450 451 %------------------------------------------------------------------------ 452 % --- Executes on selection change in abscissa. 453 function abscissa_Callback(hObject, eventdata, handles) 454 %------------------------------------------------------------------------ 455 hselect_field=get(handles.inputfile,'parent'); 456 Field=get(hselect_field,'UserData');%current input field 457 xdispindex=get(handles.abscissa,'Value');%index in the list of abscissa 458 % test_2D=get(handles.CheckVector,'Value');% =1 for vector fields 459 % test_scalar=get(handles.CheckScalar,'Value');% =1 for scalar fields 460 %if isequal(xdispindex,1)% blank selection, no selected TimeVariable for abscissa 461 % Txt=Field.ListVarName; 462 % set(handles.ordinate,'String',[{''} Txt ])% display all the varaibles in the list of ordinates 463 % xindex=[]; 464 % else 465 xlist=get(handles.abscissa,'String');%list of abscissa 466 VarName=xlist{xdispindex}; %selected variable name 467 update_field(hObject, eventdata, handles,VarName) 468 % xindex=name2index(xname,Field.ListVarName); %index of the selection in the total list of variables 469 % if ~isempty(xindex) 470 % set(handles.variables,'Value',xindex+1) 471 % variables_Callback(hObject, eventdata, handles) 472 % end 473 % set(handles.variables,'Value',xindex+1)%outline in the list of variables 474 % variables_Callback(hObject, eventdata, handles) %display properties of the TimeVariable (dim, attributes) 475 % if ~test_2D & ~test_scalar% look for possible varaibles to OK in ordinate 476 % index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa 477 % VarIndex=[]; 478 % for ilist=1:length(Field.VarDimIndex)%detect 479 % index_i=Field.VarDimIndex{ilist}; 480 % if ~isempty(index_i) 481 % if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible 482 % VarIndex=[VarIndex ilist]; 483 % end 484 % end 485 % end 486 % % set(handles.ordinate,'Value',1) 487 % set(handles.ordinate,'String',Field.ListVarName(VarIndex)) 488 % end 489 % end 490 % 491 % update_UserData(handles) 492 493 494 495 %------------------------------------------------------------------------ 496 % --- Executes on selection change in XVarName. 497 function XVarName_Callback(hObject, eventdata, handles) 498 %------------------------------------------------------------------------ 499 index=get(handles.XVarName,'Value'); 500 string=get(handles.XVarName,'String'); 501 VarName=string{index}; 502 update_field(hObject, eventdata, handles,VarName) 503 504 %------------------------------------------------------------------------ 505 % --- Executes on selection change in ZVarName. 506 function ZVarName_Callback(hObject, eventdata, handles) 507 %------------------------------------------------------------------------ 508 index=get(handles.ZVarName,'Value'); 509 string=get(handles.ZVarName,'String'); 510 VarName=string{index}; 511 update_field(hObject, eventdata, handles,VarName) 512 513 %------------------------------------------------------------------------ 514 % --- Executes on selection change in YVarName. 515 function YVarName_Callback(hObject, eventdata, handles) 516 %------------------------------------------------------------------------ 517 index=get(handles.YVarName,'Value'); 518 string=get(handles.YVarName,'String'); 519 VarName=string{index}; 520 update_field(hObject, eventdata, handles,VarName) 495 coord_val=[1 2]; 496 for ilist=1:numel(var_component) 497 ivar=var_component(ilist); 498 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') 499 Role=Field.Display.VarAttribute{ivar}.Role; 500 if strcmp(Role,'coord_x') 501 coord_val(1)=ilist; 502 elseif strcmp(Role,'coord_y') 503 coord_val(2)=ilist; 504 end 505 end 506 end 507 set(handles.Coord_x,'Value',coord_val(1)) 508 set(handles.Coord_y,'Value',coord_val(2)) 509 end 510 511 set(handles.Coord_y,'String',ListCoord) 512 set(handles.Coord_x,'String',ListCoord) 513 514 515 %% set list of time coordinates 516 menu=get(handles.SwitchVarIndexTime,'String'); 517 TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; 518 switch TimeOption 519 case 'variable' 520 if numel(find(test_coord))<3 521 ListTime={''}; 522 else 523 ListTime=Field.Display.ListVarName(find(test_coord,end)); 524 end 525 set(handles.TimeName,'Value',1) 526 set(handles.TimeName,'String',ListTime) 527 case 'dim index' 528 if numel(find(test_coord))<3 529 ListTime={''}; 530 else 531 ListTime=Field.Display.VarDimName{find(test_coord,end)}; 532 end 533 set(handles.TimeName,'Value',1) 534 set(handles.TimeName,'String',ListTime) 535 end 536 update_field(handles,ScalarName) 537 538 % --- Executes on button press in check_rgb. 539 function check_rgb_Callback(hObject, eventdata, handles) 540 521 541 522 542 %------------------------------------------------------------------------ … … 524 544 function vector_x_Callback(hObject, eventdata, handles) 525 545 %------------------------------------------------------------------------ 526 index=get(handles.vector_x,'Value'); 527 string=get(handles.vector_x,'String'); 528 VarName=string{index}; 529 530 %check possible coordinates 531 Field=get(handles.get_field,'UserData'); 532 dim_var=Field.VarDimName{index};%list of dimensions of the selected variable 533 test_coord=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as coordinate 534 test_component=ones(size(Field.VarDimName)); %=1 when variable #ilist is eligible as other vector component 535 for ilist=1:numel(Field.VarDimName) 536 dimnames=Field.VarDimName{ilist}; %list of dimensions for variable #ilist 537 if ~isequal(dimnames,dim_var) 538 test_component(ilist)=0; 539 end 540 for idim=1:numel(dimnames) 541 if isempty(find(strcmp(dimnames{idim},dim_var),1))%dimension not found in the scalar variable 542 test_coord(ilist)=0; 543 break 544 end 545 end 546 end 547 %eliminate time 548 if get(handles.TimeVariable,'Value') 549 TimeName=get(handles.TimeName,'String'); 550 index_time=find(strcmp( TimeName,Field.ListVarName)); 551 test_coord(index_time)=0; 552 end 553 vlength=numel(string(test_component==1)); 554 val=get(handles.vector_y,'Value'); 555 if val>vlength 556 set(handles.vector_y,'Value',1) 557 end 558 set(handles.vector_y,'String',[string(test_component==1)]) 559 val=get(handles.vector_z,'Value'); 560 if val>vlength+1 561 set(handles.vector_z,'Value',1) 562 end 563 set(handles.vector_z,'String',[{''};string(test_component==1)]) 564 val=get(handles.vec_color,'Value'); 565 if val>vlength+1 566 set(handles.vec_color,'Value',1) 567 end 568 set(handles.vec_color,'String',[{''};string(test_component==1)]) 569 string_coord=[{''};string(test_coord==1)]; 570 val=get(handles.XVarName,'Value'); 571 if val>numel(string_coord) 572 set(handles.XVarName,'Value',1) 573 end 574 set(handles.XVarName,'Visible','on'); 575 set(handles.XVarName,'String',string_coord); 576 val=get(handles.YVarName,'Value'); 577 if val>numel(string_coord) 578 set(handles.YVarName,'Value',1) 579 end 580 set(handles.YVarName,'Visible','on'); 581 set(handles.YVarName,'String',string_coord); 582 val=get(handles.TimeVarName,'Value'); 583 if val>numel(string_coord) 584 set(handles.TimeVarName,'Value',1) 585 end 586 set(handles.TimeVarName,'String',string_coord); 587 588 update_field(hObject, eventdata, handles,VarName) 589 590 %------------------------------------------------------------------------ 591 % --- Executes on selection change in vector_y. 546 vector_x_menu=get(handles.vector_x,'String'); 547 vector_x_index=get(handles.vector_x,'Value'); 548 vector_x=vector_x_menu{vector_x_index}; 549 vector_Callback(handles) 550 update_field(handles,vector_x) 551 552 %------------------------------------------------------------------------ 553 % --- Executes on selection change in vector_x. 592 554 function vector_y_Callback(hObject, eventdata, handles) 593 555 %------------------------------------------------------------------------ 594 index=get(handles.vector_y,'Value'); 595 string=get(handles.vector_y,'String'); 596 VarName=string{index}; 597 update_field(hObject, eventdata, handles,VarName) 556 vector_y_menu=get(handles.vector_x,'String'); 557 vector_y_index=get(handles.vector_x,'Value'); 558 vector_y=vector_y_menu{vector_y_index}; 559 vector_Callback(handles) 560 update_field(handles,vector_y) 598 561 599 562 %------------------------------------------------------------------------ … … 601 564 function vector_z_Callback(hObject, eventdata, handles) 602 565 %------------------------------------------------------------------------ 603 index=get(handles.vector_z,'Value'); 604 string=get(handles.vector_z,'String'); 605 VarName=Astring{index}; 606 update_field(hObject, eventdata, handles,VarName) 607 608 %------------------------------------------------------------------------ 609 % --- Executes on selection change in coord_x_vectors. 610 function coord_x_vectors_Callback(hObject, eventdata, handles) 611 %------------------------------------------------------------------------ 612 index=get(handles.coord_x_vectors,'Value'); 613 string=get(handles.coord_x_vectors,'String'); 614 VarName=string{index}; 615 update_field(hObject, eventdata, handles,VarName) 616 617 %------------------------------------------------------------------------ 618 % --- Executes on selection change in coord_y_vectors. 619 function coord_y_vectors_Callback(hObject, eventdata, handles) 620 %------------------------------------------------------------------------ 621 index=get(handles.coord_y_vectors,'Value'); 622 string=get(handles.coord_y_vectors,'String'); 623 VarName=string{index}; 624 update_field(hObject, eventdata, handles,VarName) 625 626 %------------------------------------------------------------------------ 627 % --- Executes on selection change in YVarName. 628 function TimeVarName_Callback(hObject, eventdata, handles) 629 %------------------------------------------------------------------------ 630 index=get(handles.TimeVarName,'Value'); 631 string=get(handles.TimeVarName,'String'); 632 VarName=string{index}; 633 update_field(hObject, eventdata, handles,VarName) 566 vector_z_menu=get(handles.vector_z,'String'); 567 vector_z_index=get(handles.vector_z,'Value'); 568 vector_z=vector_z_menu{vector_z_index}; 569 vector_Callback(handles) 570 update_field(handles,vector_z) 634 571 635 572 %------------------------------------------------------------------------ … … 640 577 string=get(handles.vec_color,'String'); 641 578 VarName=string{index}; 642 update_field(hObject, eventdata, handles,VarName) 579 vector_Callback(handles) 580 update_field(handles,VarName) 581 582 %------------------------------------------------------------------------ 583 % --- Executes on selection change in vector_x or vector_y 584 function vector_Callback( handles) 585 %------------------------------------------------------------------------ 586 Field=get(handles.get_field,'UserData'); 587 vector_x_index=get(handles.vector_x,'Value'); 588 vector_y_index=get(handles.vector_y,'Value'); 589 vec_color_index=get(handles.vec_color,'Value'); 590 591 %% set list of possible coordinates 592 test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate 593 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 594 check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn 595 ListCoord={''}; 596 dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable 597 if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index}) 598 check_consistent=0; 599 elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index}) 600 check_consistent=0; 601 end 602 if check_consistent 603 for ilist=1:numel(Field.Display.VarDimName) 604 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 605 if isequal(dimnames,dim_var) 606 test_component(ilist)=1; 607 elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable 608 test_coord(ilist)=1; 609 end 610 end 611 var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes 612 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 613 ListCoord=Field.Display.ListVarName([var_component var_coord]); 614 615 %% set default coord selection 616 if numel(find(test_coord))>3 617 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 618 end 619 if numel(var_component)<2 620 if numel(test_coord)<2 621 ListCoord={''}; 622 else 623 set(handles.Coord_x,'Value',2) 624 set(handles.Coord_y,'Value',1) 625 end 626 else 627 coord_val=[1 2]; 628 for ilist=1:numel(var_component) 629 ivar=var_component(ilist); 630 if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') 631 Role=Field.Display.VarAttribute{ivar}.Role; 632 if strcmp(Role,'coord_x') 633 coord_val(1)=ilist; 634 elseif strcmp(Role,'coord_y') 635 coord_val(2)=ilist; 636 end 637 end 638 end 639 set(handles.Coord_x,'Value',coord_val(1)) 640 set(handles.Coord_y,'Value',coord_val(2)) 641 end 642 end 643 set(handles.Coord_y,'String',ListCoord) 644 set(handles.Coord_x,'String',ListCoord) 645 646 647 %% set list of time coordinates 648 menu=get(handles.SwitchVarIndexTime,'String'); 649 TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; 650 switch TimeOption 651 case 'variable' 652 if numel(find(test_coord))<3 653 ListTime={''}; 654 else 655 ListTime=Field.Display.ListVarName(find(test_coord,end)); 656 end 657 set(handles.TimeName,'Value',1) 658 set(handles.TimeName,'String',ListTime) 659 case 'dim index' 660 if numel(find(test_coord))<3 661 ListTime={''}; 662 else 663 ListTime=Field.Display.VarDimName{find(test_coord,end)}; 664 end 665 set(handles.TimeName,'Value',1) 666 set(handles.TimeName,'String',ListTime) 667 end 668 669 %------------------------------------------------------------------------ 670 % --- Executes on selection change in SwitchVarIndexX. 671 %------------------------------------------------------------------------ 672 function SwitchVarIndexX_Callback(hObject, eventdata, handles) 673 674 %------------------------------------------------------------------------ 675 % --- Executes on selection change in Coord_x. 676 function Coord_x_Callback(hObject, eventdata, handles) 677 %------------------------------------------------------------------------ 678 index=get(handles.Coord_x,'Value'); 679 string=get(handles.Coord_x,'String'); 680 VarName=string{index}; 681 update_field(handles,VarName) 682 683 %------------------------------------------------------------------------ 684 % --- Executes on selection change in Coord_y. 685 function Coord_y_Callback(hObject, eventdata, handles) 686 %------------------------------------------------------------------------ 687 index=get(handles.Coord_y,'Value'); 688 string=get(handles.Coord_y,'String'); 689 VarName=string{index}; 690 update_field(handles,VarName) 691 692 %------------------------------------------------------------------------ 693 % --- Executes on selection change in Coord_z. 694 function Coord_z_Callback(hObject, eventdata, handles) 695 %------------------------------------------------------------------------ 696 index=get(handles.Coord_z,'Value'); 697 string=get(handles.Coord_z,'String'); 698 VarName=string{index}; 699 update_field(handles,VarName) 700 701 %------------------------------------------------------------------------ 702 % --- Executes on selection change in SwitchVarIndexTime. 703 %------------------------------------------------------------------------ 704 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 705 Field=get(handles.get_field,'UserData'); 706 menu=get(handles.SwitchVarIndexTime,'String'); 707 option=menu{get(handles.SwitchVarIndexTime,'Value')}; 708 709 switch option 710 case 'file index' 711 set(handles.TimeName, 'Visible','off')% the time is taken as the file index 712 case 'attribute' 713 set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes 714 time_index=[]; 715 PreviousList=get(handles.TimeName, 'String'); 716 index=[]; 717 if ~isempty(PreviousList) 718 PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; 719 index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes)); 720 end 721 if isempty(index) 722 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' 723 end 724 if ~isempty(time_index) 725 set(handles.TimeName,'Value',time_index(1)) 726 else 727 set(handles.TimeName,'Value',1) 728 end 729 set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) 730 case 'variable'% TimeName menu represents the available variables 731 set(handles.TimeName, 'Visible','on') 732 TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time) 733 List=get(handles.TimeName,'String'); 734 option=List{get(handles.TimeName,'Value')}; 735 ind=find(strcmp(option,TimeVarName)); 736 if isempty(ind) 737 set(handles.TimeName, 'Value',1); 738 else 739 set(handles.TimeName, 'Value',ind); 740 end 741 set(handles.TimeName, 'String',TimeVarName) 742 case 'dim index'% TimeName menu represents the available dimensions 743 set(handles.TimeName, 'Visible','on') 744 TimeVarName=Field.Display.SingleDimName; 745 List=get(handles.TimeName,'String'); 746 option=List{get(handles.TimeName,'Value')}; 747 ind=find(strcmp(option,TimeVarName)); 748 if isempty(ind) 749 set(handles.TimeName, 'Value',1); 750 else 751 set(handles.TimeName, 'Value',ind); 752 end 753 set(handles.TimeName, 'String',TimeVarName) 754 end 643 755 644 756 %----------------------------------------------------------------------- 645 function update_field(h Object, eventdata, handles,VarName)757 function update_field(handles,VarName) 646 758 %----------------------------------------------------------------------- 647 759 Field=get(handles.get_field,'UserData'); … … 649 761 if ~isempty(index) 650 762 set(handles.variables,'Value',index+1) 651 variables_Callback(hObject, eventdata, handles) 652 end 653 654 %------------------------------------------------------------------------ 655 % update the UserData Field for use of the selected variables outsde get_field (taken from RUN_Callback) 656 function update_UserData(handles) 657 %------------------------------------------------------------------------ 658 return 659 % global SubField 660 hselect_field=get(handles.inputfile,'parent');%handle of the get_field interface 661 Field=get(hselect_field,'UserData');% read the current field Structure in the get_field interface 662 if isfield(Field,'VarAttribute') 663 VarAttribute=Field.VarAttribute; 664 else 665 VarAttribute={}; 666 end 667 668 669 % select the indices of field variables for 2D plots 670 test_CheckPlot1D=get(handles.CheckPlot1D,'Value'); 671 test_scalar=get(handles.CheckScalar,'Value'); 672 test_vector=get(handles.CheckVector,'Value'); 673 674 %transform if needed (calibration) 675 list=get(handles.menu_coord,'String'); 676 index=get(handles.menu_coord,'Value'); 677 transform=list{index}; 678 if ~isequal(transform,'') 679 Field=feval(transform,Field); 680 end 681 VarIndex.u=[]; 682 VarIndex.v=[]; 683 VarIndex.w=[]; 684 VarIndex.A=[]; 685 VarIndex_tot=[]; 686 iuA=[]; 687 if test_scalar 688 Astring=get(handles.scalar,'String'); 689 Aindex=get(handles.scalar,'Value');%selected indices in the ordinate listbox 690 list_var=Astring(Aindex); 691 VarIndex.A=name2index(list_var,Field.ListVarName);%index of the variable A in ListVarName 692 VarIndex_tot= [VarIndex_tot VarIndex.A]; 693 DimIndex=Field.VarDimIndex{VarIndex.A};%dimension indices of the variable 694 DimValue=Field.DimValue(DimIndex); 695 ind=find(DimValue==1); 696 DimIndex(ind)=[];%Mremove singleton 697 end 698 if test_vector 699 Ustring=get(handles.vector_x,'String'); 700 Uindex=get(handles.vector_x,'Value'); %selected indices in the ordinate listbox 701 list_var=Ustring{Uindex};%name of the selected scalar 702 VarIndex.u=name2index(list_var,Field.ListVarName); 703 Vstring=get(handles.vector_y,'String'); 704 Vindex=get(handles.vector_y,'Value'); %selected indices in the ordinate listbox 705 list_var=Ustring{Vindex};%name of the selected scalar 706 VarIndex.v=name2index(list_var,Field.ListVarName); 707 if isequal(VarIndex.u,VarIndex.A)|isequal(VarIndex.v,VarIndex.A) 708 iuA=VarIndex.A; %same variable used for vector and scalar 709 VarIndex_tot(iuA)=[]; 710 end 711 VarIndex_tot=[VarIndex_tot VarIndex.u VarIndex.v]; 712 %dimensions 713 DimIndex_u=Field.VarDimIndex{VarIndex.u};%dimension indices of the variable 714 DimValue=Field.DimValue(DimIndex_u); 715 ind=find(DimValue==1); 716 DimIndex_u(ind)=[];%Mremove singleton 717 DimIndex_v=Field.VarDimIndex{VarIndex.v};%dimension indices of the variable 718 DimValue=Field.DimValue(DimIndex_v); 719 ind=find(DimValue==1); 720 DimIndex_v(ind)=[];%Mremove singleton 721 if ~isequal(DimIndex_u,DimIndex_v) 722 msgbox_uvmat('ERROR','inconsistent dimensions for u and v') 723 set(handles.vector_y,'Value',1); 724 return 725 elseif test_scalar & ~isequal(DimIndex_u,DimIndex) 726 msgbox_uvmat('ERROR','inconsistent dimensions for vector and scalar represented as vector color') 727 set(handles.scalar,'Value',1); 728 return 729 end 730 DimIndex=DimIndex_u; 731 %TODO possibility of selecting 3 times the same TimeVariable for u, v, w components 732 end 733 734 735 % select the TimeVariable index (or indices) for z coordinates 736 test_grid=0; 737 if test_scalar | test_vector 738 nbdim=length(DimIndex); 739 if nbdim > 3 740 msgbox_uvmat('ERROR','array with more than three dimensions, not supported') 741 return 742 else 743 perm_ind=1:nbdim; 744 end 745 if nbdim==3 746 zstring=get(handles.coord_z_vectors_scalar,'String'); 747 zindex=get(handles.coord_z_vectors_scalar,'Value'); %selected indices in the ordinate listbox 748 list_var=zstring(zindex); 749 VarIndex_z=name2index(list_var,Field.ListVarName);%index of the selected variable 750 if isequal(VarIndex.A,VarIndex_z)|isequal(VarIndex.u,VarIndex_z)|isequal(VarIndex.v,VarIndex_z)|isequal(VarIndex.w,VarIndex_z) 751 if zindex ~= 1 752 set(handles.coord_z_vectors_scalar,'Value',1)%ordinate cannot be the same as scalar or vector components 753 return 754 end 755 else 756 VarIndex_tot=[VarIndex_tot VarIndex_z]; 757 DimIndex_z=Field.VarDimIndex{VarIndex_z}; 758 DimValue=Field.DimValue(DimIndex_z); 759 ind=find(DimValue==1); 760 DimIndex_z(ind)=[];%Mremove singleton 761 if isequal(DimIndex_z,DimIndex) 762 VarAttribute{VarIndex_z}.Role='coord_z';%unstructured coordinates 763 elseif length(DimIndex_z)==1 764 VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; %dimension variable 765 ind_z=find(DimIndex==DimIndex_z(1)); 766 perm_ind(ind_z)=1; 767 test_grid=1; 768 else 769 msgbox_uvmat('ERROR','multiple dimensions for the z coordinate') 770 return 771 end 772 end 773 % if ~isempty(VarIndex_z) 774 % DimIndex_z=Field.VarDimIndex{VarIndex_z};%dimension indices of the TimeVariable 775 % if length(DimIndex_z)==1 & nbdim==3 %dimension TimeVariable 776 % VarAttribute{VarIndex_z}.Role=Field.ListDimName{DimIndex_z}; 777 % ind_z=find(DimIndex==DimIndex_z(1)); 778 % perm_ind(ind_z)=1; 779 % test_grid=1; 780 % end 781 % end 782 end 783 end 784 785 % select the TimeVariable index (or indices) for ordinate 786 ystring=get(handles.ordinate,'String'); 787 yindex=get(handles.ordinate,'Value'); %selected indices in the ordinate listbox 788 list_var=ystring(yindex); 789 VarIndex.y=name2index(list_var,Field.ListVarName); 790 if isequal(VarIndex.A,VarIndex.y) 791 set(handles.ZVarName,'Value',1) 792 elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y) 793 set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components 794 else 795 for ivar=1:length(VarIndex.y) 796 VarAttribute{VarIndex.y(ivar)}.Role='coord_y'; 797 end 798 VarIndex_tot=[VarIndex_tot VarIndex.y]; 799 end 800 if (test_scalar | test_vector) & ~isempty(VarIndex.y) 801 DimIndex_y=Field.VarDimIndex{VarIndex.y};%dimension indices of the variable 802 if length(DimIndex_y)==1 803 ind_y=find(DimIndex==DimIndex_y(1)); 804 test_grid=1; 805 if nbdim==3 806 VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; 807 perm_ind(ind_y)=2; 808 elseif nbdim==2 809 VarAttribute{VarIndex.y}.Role=Field.ListDimName{DimIndex_y}; 810 perm_ind(ind_y)=1; 811 end 812 elseif test_grid 813 msgbox_uvmat('ERROR','the dimension of the y coordinate variable should be 1') 814 end 815 end 816 817 %select the TimeVariable index for the abscissa 818 xstring=get(handles.abscissa,'String'); 819 xindex=get(handles.abscissa,'Value'); 820 list_var=xstring(xindex); 821 VarIndex.x=name2index(list_var,Field.ListVarName);%var index corresponding to var name list_var 822 if length(VarIndex.x)==1 823 DimIndex_x=Field.VarDimIndex{VarIndex.x}; 824 DimValue=Field.DimValue(DimIndex_x); 825 ind=find(DimValue==1); 826 DimIndex_x(ind)=[];%Mremove singleton 827 VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; %dimension variable 828 % VarAttribute{VarIndex.x}.Role='coord_x';%default (may be modified) 829 index_detect=find(VarIndex_tot==VarIndex.x); 830 else 831 index_detect=[];%coord x variable not already used 832 end 833 if isempty(index_detect) 834 VarIndex_tot=[VarIndex_tot VarIndex.x]; 835 elseif ~test_CheckPlot1D 836 VarIndex.x=[]; 837 set(handles.abscissa,'Value',1)%vchosen abscissa already chosen, suppres it as abscissa 838 end 839 840 if (test_scalar | test_vector) & ~isempty(VarIndex.x) 841 DimIndex_x=Field.VarDimIndex{VarIndex.x};%dimension indices of the variable 842 if length(DimIndex_x)==1 843 ind_x=find(DimIndex==DimIndex_x(1)); 844 if nbdim==3 845 %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; 846 perm_ind(ind_x)=3; 847 elseif nbdim==2 848 %VarAttribute{VarIndex.x}.Role=Field.ListDimName{DimIndex_x}; 849 perm_ind(ind_x)=2; 850 end 851 if isequal(perm_ind,1:nbdim) 852 test_grid=0; 853 end 854 DimIndex=DimIndex(perm_ind); 855 elseif test_grid 856 msgbox_uvmat('ERROR','the dimension of the x coordinate variable should be 1') 857 end 858 if isequal(DimIndex_x,DimIndex) 859 VarAttribute{VarIndex.x}.Role='coord_x';%unstructured coordinates 860 end 861 end 862 863 %defined the selected sub-field SubField 864 SubField.ListGlobalAttribute{1}='InputFile'; 865 SubField.InputFile=get(handles.inputfile,'String'); 866 SubField.ListDimName=Field.ListDimName; 867 SubField.DimValue=Field.DimValue; 868 SubField.ListVarName=Field.ListVarName(VarIndex_tot); 869 SubField.VarDimIndex=Field.VarDimIndex(VarIndex_tot); 870 871 testperm=0; 872 testattr=0; 873 for ivar=VarIndex.u 874 VarAttribute{ivar}.Role='vector_x'; 875 testattr=1; 876 if test_grid 877 VarDimIndex{ivar}=DimIndex; %permute dimensions 878 testperm=1; 879 end 880 end 881 for ivar=VarIndex.v 882 VarAttribute{ivar}.Role='vector_y'; 883 testattr=1; 884 if test_grid 885 VarDimIndex{ivar}=DimIndex;%permute dimensions 886 testperm=1; 887 end 888 end 889 for ivar=VarIndex.A 890 if test_grid 891 VarDimIndex{ivar}=DimIndex;%permute dimensions 892 testperm=1; 893 end 894 if isempty(iuA) 895 VarAttribute{ivar}.Role='scalar';%Role =scalar 896 testattr=1; 897 else 898 VarAttribute=[VarAttribute VarAttribute(ivar)]; %duplicate the attribute for a new variable 899 nbattr=length(VarAttribute); 900 VarAttribute{nbattr}.Role='scalar'; 901 testattr=1; 902 end 903 end 904 if testperm 905 SubField.VarDimIndex=VarDimIndex(VarIndex_tot); 906 end 907 if testattr 908 SubField.VarAttribute=VarAttribute(VarIndex_tot); 909 end 910 set(hselect_field,'UserData',Field) 911 912 %--------------------------------------------------------- 913 % --- Executes on button press in OK. 914 915 function OK_Callback(hObject, eventdata, handles) 916 %--------------------------------------------------------- 917 918 handles.output=read_GUI(handles.get_field); 919 guidata(hObject, handles);% Update handles structure 920 uiresume(handles.get_field); 921 drawnow 922 return 923 924 %%%% SKIPPED %%%% 925 hfield=[]; 926 huvmat=findobj(allchild(0),'tag','uvmat'); 927 hseries=findobj(allchild(0),'tag','series'); 928 check_series=0; 929 % look for the status of the GUI uvmat 930 if ~isempty(huvmat) 931 hh=guidata(huvmat); 932 FieldMenu=get(hh.FieldName,'String'); 933 FieldName=FieldMenu{get(hh.FieldName,'Value')}; 934 if strcmp(FieldName,'get_field...') 935 hfield=hh.FieldName; %FieldName on uvmat 936 elseif strcmp(get(hh.FieldName_1,'Visible'),'on') 937 FieldMenu=get(hh.FieldName_1,'String'); 938 if ~isempty(FieldMenu) 939 FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; 940 if strcmp(FieldName,'get_field...') 941 hfield=hh.FieldName_1; %FieldName_1 on uvmat 942 end 943 end 944 end 945 end 946 % if no filed data is concerned on uvmat, look at the GUI series 947 if isempty(hfield) && ~isempty(hseries) 948 check_series=1; 949 hh=guidata(hseries); 950 FieldMenu=get(hh.FieldName,'String'); 951 FieldName=FieldMenu{get(hh.FieldName,'Value')}; 952 if strcmp(FieldName,'get_field...') 953 hfield=hh.FieldName; %FieldName on series 954 else 955 FieldMenu=get(hh.FieldName_1,'String'); 956 FieldName=FieldMenu{get(hh.FieldName_1,'Value')}; 957 if strcmp(FieldName,'get_field...') 958 hfield=hh.FieldName_1; %FieldName_1 on series 959 end 960 end 961 end 962 if ~isempty(hfield) 963 get_field_GUI=read_GUI(handles.get_field); 964 if isfield(get_field_GUI,'PanelVectors') 965 set(hh.Coord_x,'value',1) 966 set(hh.Coord_y,'value',1) 967 set(hh.Coord_x,'String',{get_field_GUI.PanelVectors.coord_x_vectors}) 968 set(hh.Coord_y,'String',{get_field_GUI.PanelVectors.coord_y_vectors}) 969 UName=get_field_GUI.PanelVectors.vector_x; 970 VName=get_field_GUI.PanelVectors.vector_y; 971 menu_str=[{['vec(' UName ',' VName ')']};{UName};{VName};{['norm(' UName ',' VName ')']};{'get_field...'}]; 972 menu_color=[{''};{UName};{VName};{['norm(' UName ',' VName ')']}]; 973 set(hfield,'Value',1) 974 set(hfield,'String',menu_str) 975 if ~check_series 976 ind_menu=find(strcmp(get_field_GUI.PanelVectors.vec_color,menu_color)); 977 if ~isempty(ind_menu) 978 set(hh.ColorScalar,'Value',ind_menu) 979 else 980 set(hh.ColorScalar,'Value',1) 981 end 982 set(hh.ColorScalar,'String',menu_color) 983 end 984 elseif isfield(get_field_GUI,'PanelScalar') 985 set(hh.Coord_x,'value',1) 986 set(hh.Coord_y,'value',1) 987 set(hh.Coord_x,'String',{get_field_GUI.PanelScalar.coord_x_scalar}) 988 set(hh.Coord_y,'String',{get_field_GUI.PanelScalar.coord_y_scalar}) 989 AName=get_field_GUI.PanelScalar.scalar; 990 menu=get(hfield,'String'); 991 ind_select=find(strcmp(AName,menu)); 992 if isempty(ind_select) 993 menu=[menu(1:end-1);{AName};{'get_field...'}]; 994 ind_select=numel(menu)-1; 995 end 996 set(hfield,'Value',ind_select); 997 set(hfield,'String',menu); 998 elseif isfield(get_field_GUI,'Panel1Dplot') 999 set(hh.Coord_x,'Value',1) 1000 set(hh.Coord_x,'String',{get_field_GUI.Panel1Dplot.abscissa}) 1001 set(hh.Coord_y,'String',get_field_GUI.Panel1Dplot.ordinate) 1002 set(hh.Coord_y,'Max', numel(get_field_GUI.Panel1Dplot.ordinate)) 1003 set(hh.Coord_y,'Value',1:numel(get_field_GUI.Panel1Dplot.ordinate)) 1004 set(hfield,'Value',1) 1005 set(hfield,'String',[{''};{'get_field...'}]) 1006 end 1007 if ~check_series && strcmp(get(gcbf,'tag'),'get_field')%get_field is not called by another GUI (uvmat) 1008 uvmat('run0_Callback',hObject,eventdata,hh); %refresh uvmat 1009 end 1010 end 1011 delete(handles.get_field) 1012 1013 763 variables_Callback(handles.variables, [], handles) 764 end 1014 765 1015 766 %------------------------------------------------- … … 1036 787 end 1037 788 end 1038 1039 1040 % -----------------------------------------------------------------------1041 function TimeName_Callback(hObject, eventdata, handles)1042 1043 scalar_Callback(hObject, eventdata, handles)% suppress time variable from possible spatial coordinates1044 vector_x_Callback(hObject, eventdata, handles)1045 1046 %------------------------------------------------------------------------1047 % --- Executes on button press in TimeAttribute.1048 function TimeAttribute_Callback(hObject, eventdata, handles)1049 %------------------------------------------------------------------------1050 val=get(handles.TimeAttribute,'Value');1051 if val1052 set(handles.TimeAttributeMenu,'Visible','on')1053 Field=get(handles.get_field,'UserData');1054 time_value=zeros(size(Field.ListGlobalAttribute));1055 test_time=zeros(size(Field.ListGlobalAttribute));1056 for ilist=1:numel(Field.ListGlobalAttribute)1057 if isnumeric(eval(['Field.' Field.ListGlobalAttribute{ilist}]))1058 eval(['time_val=Field.' Field.ListGlobalAttribute{ilist} ';'])1059 if ~isempty(time_val)1060 time_value(ilist)=time_val;1061 test_time(ilist)=1;1062 end1063 end1064 end1065 ListTimeAttribute=Field.ListGlobalAttribute(test_time==1);1066 attr_index=get(handles.TimeAttributeMenu,'Value');1067 if attr_index>numel(ListTimeAttribute)1068 attr_index=1;1069 set(handles.TimeAttributeMenu,'Value',1);1070 end1071 if isempty(ListTimeAttribute)1072 set(handles.TimeAttributeMenu,'String',{''})1073 set(handles.TimeValue,'Visible','off')1074 else1075 set(handles.TimeValue,'Visible','on')1076 set(handles.TimeAttributeMenu,'String',ListTimeAttribute)1077 set(handles.TimeValue,'String',num2str(time_value(attr_index)))1078 end1079 set(handles.TimeDimension,'Value',0)1080 TimeDimension_Callback(hObject, eventdata, handles)1081 set(handles.TimeVariable,'Value',0)1082 TimeVariable_Callback(hObject, eventdata, handles)1083 else1084 set(handles.TimeAttributeMenu,'Visible','off')1085 set(handles.TimeValue,'Visible','off')1086 end1087 1088 %------------------------------------------------------------------------1089 % --- Executes on selection change in TimeAttributeMenu.1090 function TimeAttributeMenu_Callback(hObject, eventdata, handles)1091 ListTimeAttribute=get(handles.TimeAttributeMenu,'String');1092 index=get(handles.TimeAttributeMenu,'Value');1093 AttrName=ListTimeAttribute{index};1094 Field=get(handles.get_field,'UserData');1095 eval(['time_val=Field.' AttrName ';'])1096 set(handles.TimeValue,'String',num2str(time_val))1097 %------------------------------------------------------------------------1098 1099 %------------------------------------------------------------------------1100 % --- Executes on button press in TimeVariable.1101 function TimeDimension_Callback(hObject, eventdata, handles)1102 %------------------------------------------------------------------------1103 val=get(handles.TimeDimension,'Value');%=1 if check box TimeDimension is selected1104 if val %if check box TimeDimension is selected1105 Field=get(handles.get_field,'UserData');% structure describing the currently opened field1106 previous_menu=get(handles.TimeDimensionMenu,'String');1107 if ~isequal(previous_menu,Field.ListDimName)%update the list of available dimensions in the menu1108 ind_select=find(strcmpi('time',Field.ListDimName),1);% look for a dimension named 'time' or 'Time'1109 if isempty(ind_select)1110 ind_select=1;% select the first item in the list if 'time' is not found1111 end1112 set(handles.TimeDimensionMenu,'Value',ind_select);1113 set(handles.TimeDimensionMenu,'String',Field.ListDimName)% put the list of available dimensions in the menu1114 end1115 set(handles.TimeDimensionMenu,'Visible','on')% the menu is made visible1116 set(handles.TimeIndexValue,'Visible','on')% the time matrix index value selected is made visible1117 TimeDimensionMenu_Callback(hObject, eventdata, handles)1118 set(handles.TimeAttribute,'Value',0) %deselect alternative options for time1119 set(handles.TimeVariable,'Value',0)1120 TimeAttribute_Callback(hObject, eventdata, handles)1121 else1122 set(handles.TimeDimensionMenu,'Visible','off')1123 set(handles.TimeIndexValue,'Visible','off')1124 end1125 %1126 % %------------------------------------------------------------------------1127 % % --- Executes on selection change in TimeDimensionMenu.1128 % function TimeDimensionMenu_Callback(hObject, eventdata, handles)1129 % %------------------------------------------------------------------------1130 % index=get(handles.TimeDimensionMenu,'Value');1131 % DimList=get(handles.TimeDimensionMenu,'String');1132 % DimName=DimList{index};1133 % Field=get(handles.get_field,'UserData');1134 % DimIndex=find(strcmp(DimName,Field.ListDimName),1);1135 % ref_index=round(Field.DimValue(DimIndex)/2);1136 % set(handles.TimeIndexValue,'String',num2str(ref_index))1137 % scalar_Callback(hObject, eventdata, handles)1138 % vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)1139 % % look for a corresponding time variable and value1140 % time_test=zeros(size(Field.VarDimName));1141 % for ilist=1:numel(Field.VarDimName)1142 % if isequal(Field.VarDimName{ilist},{DimName})1143 % time_test(ilist)=1;1144 % end1145 % end1146 % ListVariable=Field.ListVarName(time_test==1);1147 % set(handles.TimeVariableMenu,'Value',1)1148 % if isempty(ListVariable)1149 % set(handles.TimeVariableMenu,'String',{''})1150 % set(handles.TimeVarValue,'String','')1151 % else1152 % set(handles.TimeVariableMenu,'String',ListVariable)1153 % TimeVarName=ListVariable{1};1154 % VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables1155 % inputfile=get(handles.inputfile,'String');% read the input file1156 % SubField=nc2struct(inputfile,{TimeVarName});1157 % eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])1158 % set(handles.TimeVarValue,'Visible','on')1159 % set(handles.TimeVariableMenu,'Visible','on')1160 % set(handles.TimeVarValue,'String',num2str(TimeValue))1161 % end1162 %1163 %1164 % % % -----------------------------------------------------------------------1165 % % % --- Executes on button press in TimeVariable.1166 % % function TimeVariable_Callback(hObject, eventdata, handles)1167 % % % -----------------------------------------------------------------------1168 % % val=get(handles.TimeVariable,'Value');1169 % % if val1170 % % Field=get(handles.get_field,'UserData');1171 % % time_test=zeros(size(Field.VarDimName));1172 % % for ilist=1:numel(Field.VarDimName)1173 % % if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension1174 % % time_test(ilist)=1;1175 % % end1176 % % end1177 % % ind_test=find(time_test);1178 % % if isempty(time_test)1179 % % set(handles.TimeVariable,'Value',0)1180 % % set(handles.TimeVariableMenu,'Visible','off')1181 % % set(handles.TimeVarValue,'Visible','off')1182 % % else1183 % % set(handles.TimeVariableMenu,'Visible','on')1184 % % set(handles.TimeVarValue,'Visible','on')1185 % % if get(handles.TimeVariableMenu,'Value')>numel(ind_test)1186 % % set(handles.TimeVariableMenu,'Value',1)1187 % % end1188 % % set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))1189 % % TimeVariableMenu_Callback(hObject, eventdata, handles)1190 % % set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time1191 % % set(handles.TimeAttribute,'Value',0)1192 % % TimeAttribute_Callback(hObject, eventdata, handles)1193 % % end1194 % % else1195 % % set(handles.TimeVariableMenu,'Visible','off')1196 % % set(handles.TimeVarValue,'Visible','off')1197 % % end1198 %1199 % % -----------------------------------------------------------------------1200 % % --- Executes on selection change in TimeVariableMenu.1201 % function TimeVariableMenu_Callback(hObject, eventdata, handles)1202 % % -----------------------------------------------------------------------1203 % ListVar=get(handles.TimeVariableMenu,'String');1204 % index=get(handles.TimeVariableMenu,'Value');1205 % TimeVariable=ListVar{index};% name of the selected variable1206 % if isempty(TimeVariable)% case of blank selection1207 % return1208 % end1209 % Field=get(handles.get_field,'UserData'); %index of1210 % VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables1211 % DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable1212 % set(handles.TimeDimensionMenu,'Value',1)1213 % set(handles.TimeDimensionMenu,'String',DimName)1214 % inputfile=get(handles.inputfile,'String');% read the input file1215 % SubField=nc2struct(inputfile,{TimeVariable});1216 % eval(['TimeDimension=numel(SubField.' TimeVariable ');'])1217 % ref_index=round(TimeDimension/2);1218 % eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])1219 % set(handles.TimeIndexValue,'String',num2str(ref_index))1220 % set(handles.TimeVarValue,'String',num2str(TimeValue))1221 1222 1223 % --- Executes on button press in check_rgb.1224 function check_rgb_Callback(hObject, eventdata, handles)1225 1226 1227 % --- Executes when user attempts to close get_field.1228 function get_field_CloseRequestFcn(hObject, eventdata, handles)1229 if isequal(get(handles.get_field, 'waitstatus'), 'waiting')1230 % The GUI is still in UIWAIT, us UIRESUME1231 uiresume(handles.get_field);1232 else1233 % The GUI is no longer waiting, just close it1234 delete(handles.get_field);1235 end1236 1237 1238 1239 %------------------------------------------------------------------------1240 % --- Executes on selection change in SwitchVarIndexX.1241 %------------------------------------------------------------------------1242 function SwitchVarIndexX_Callback(hObject, eventdata, handles)1243 1244 %------------------------------------------------------------------------1245 % --- Executes on selection change in SwitchVarIndexTime.1246 %------------------------------------------------------------------------1247 function SwitchVarIndexTime_Callback(hObject, eventdata, handles)1248 1249 menu=get(handles.SwitchVarIndexTime,'String');1250 option=menu{get(handles.SwitchVarIndexTime,'Value')};1251 Field=get(handles.get_field,'UserData');1252 switch option1253 case 'file index'1254 set(handles.TimeVarName, 'Visible','off')1255 case 'attribute'1256 set(handles.TimeVarName, 'Visible','on')1257 time_index=[];1258 PreviousList=get(handles.TimeVarName, 'String');1259 index=[];1260 if ~isempty(PreviousList)1261 PreviousAttr=PreviousList{get(handles.TimeVarName, 'Value')};1262 index=find(strcmp(PreviousAttr,Field.ListNumAttributes));1263 end1264 if isempty(index)1265 time_index=find(~cellfun('isempty',regexp(Field.ListNumAttributes,'Time')));% index of the attributes containing the string 'Time'1266 end1267 if ~isempty(time_index)1268 set(handles.TimeVarName,'Value',time_index(1))1269 else1270 set(handles.TimeVarName,'Value',1)1271 end1272 set(handles.TimeVarName, 'String',Field.ListNumAttributes)1273 case 'variable'1274 set(handles.TimeVarName, 'Visible','on')1275 TimeVarName=Field.SingleVarName;1276 List=get(handles.TimeVarName,'String');1277 option=List{get(handles.TimeVarName,'Value')};1278 ind=find(strcmp(option,TimeVarName));1279 if isempty(ind)1280 set(handles.TimeVarName, 'Value',1);1281 else1282 set(handles.TimeVarName, 'Value',ind);1283 end1284 set(handles.TimeVarName, 'String',TimeVarName)1285 case 'dim index'1286 set(handles.TimeVarName, 'Visible','on')1287 TimeVarName=Field.SingleDimName;1288 List=get(handles.TimeVarName,'String');1289 option=List{get(handles.TimeVarName,'Value')};1290 ind=find(strcmp(option,TimeVarName));1291 if isempty(ind)1292 set(handles.TimeVarName, 'Value',1);1293 else1294 set(handles.TimeVarName, 'Value',ind);1295 end1296 set(handles.TimeVarName, 'String',TimeVarName)1297 end1298 1299 % --- Executes on selection change in FieldOption.1300 function FieldOption_Callback(hObject, eventdata, handles)1301 FieldList=get(handles.FieldOption,'String');1302 FieldOption=FieldList{get(handles.FieldOption,'Value')};1303 switch FieldOption1304 case '1D plot'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')1319 case 'scalar'1320 set(handles.Panel1Dplot,'Visible','off')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')1330 case 'vectors'1331 set(handles.Panel1Dplot,'Visible','off')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 -
trunk/src/nc2struct.m
r534 r648 23 23 % nc: name of a netcdf file (char string) or netcdf object 24 24 % additional arguments: 25 % -no additional arguments: all the variables of the netcdf fi elare read.25 % -no additional arguments: all the variables of the netcdf file are read. 26 26 % -a cell array, ListVarName, made of char strings {'VarName1', 'VarName2',...} ) 27 % if ListVarName=[] or {}, no variable s is read (only global attributes)27 % if ListVarName=[] or {}, no variable value is read (only global attributes and list of variables and dimensions) 28 28 % if ListVarName is absent, or = '*', ALL the variables of the netcdf file are read. 29 29 % if ListVarName is a cell array with n lines, the set of variables will be sought by order of priority 30 30 % in the list, while output names will be set by the first line 31 31 % - the string 'ListGlobalAttribute' followed by a list of attribute names: reads only these attributes (fast reading) 32 % 32 % - the string 'TimeVarName', a string (the variable considered as 33 % time), an integer (the selected time index), the cell of other 34 % input variables limited to the input time index (considered as the last index of arrays) 35 % - the string 'TimeDimName', a string (the dimension considered as time), an integer (the selected time index), the cell of other 36 % input variables limited to the input time index (considered as the last index of arrays) 37 33 38 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 34 39 % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. … … 91 96 return 92 97 end 98 99 %% time variable or dimension 100 input_index=1; 101 if isequal(varargin{1},'TimeVarName') 102 TimeVarName=varargin{2}; 103 TimeVarIndex=varargin{3}; 104 input_index=4; 105 elseif isequal(varargin{1},'TimeDimName') 106 TimeDimName=varargin{2}; 107 TimeVarIndex=varargin{3}; 108 input_index=4; 109 end 93 110 94 111 %% full reading: get the nbre of dimensions, variables, global attributes 95 ListVarName=varargin{ 1};112 ListVarName=varargin{input_index}; 96 113 [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the netcdf file 97 114 … … 130 147 if ~isempty(ListDimNameNetcdf) 131 148 flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused) 149 end 150 if isequal(varargin{1},'TimeDimName')% time dimension introduced 151 TimeDimIndex=find(strcmp(varargin{2},ListDimNameNetcdf)); 152 if isempty(TimeDimIndex) 153 Data.Txt=['requested time dimension ' varargin{2} ' not found']; 154 return 155 end 156 if dim_value(TimeDimIndex)<varargin{3} 157 Data.Txt=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension']; 158 return 159 end 132 160 end 133 161 … … 180 208 181 209 %% get the dimensions and attributes associated to variables 210 var_dim=cell(size(var_index));% initiate list of dimensions for variables 182 211 for ivar=1:length(var_index) 183 212 var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar … … 208 237 end 209 238 end 239 210 240 211 241 %% select the dimensions used for the set of input variables … … 221 251 VarName=Data.ListVarName{ivar}; 222 252 VarName=regexprep(VarName,'-',''); %suppress '-' if it exists in the netcdf variable name 223 eval(['Data.' VarName '=double(netcdf.getVar(nc,var_index(ivar)-1));'])%read the variable data 253 CheckSub=0; 254 if input_index==4% if a dimension is selected as time 255 if var_dim{ivar}(end)==TimeDimIndex% if the last dim of the variable is the time 256 slice_length=prod(var_dim{ivar}(1:end-1)); 257 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1),TimeIndex*slice_length,slice_length); %read the variable data 258 CheckSub=1; 259 end 260 end 261 if ~CheckSub 262 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1)); %read the whole variable data 263 end 224 264 end 225 265 end -
trunk/src/proj_field.m
r646 r648 84 84 ProjData=[]; 85 85 86 %% in the absence of object Type or projection mode, or object coordinaes, the output is empty86 %% check input projection object: type, projection mode and Coord: 87 87 if ~isfield(ObjectData,'Type')||~isfield(ObjectData,'ProjMode') 88 88 return 89 89 end 90 % case of no projection (object is used only as graph display) 91 if ise qual(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')90 ListProjMode={'projection','interp_lin','interp_tps'};%list of effective projection modes 91 if isempty(strcmp(ObjectData.ProjMode,ListProjMode)) 92 92 return 93 93 end … … 103 103 switch ObjectData.Type 104 104 case 'points' 105 [ProjData,errormsg]=proj_points(FieldData,ObjectData);105 [ProjData,errormsg]=proj_points(FieldData,ObjectData); 106 106 case {'line','polyline'} 107 [ProjData,errormsg] = proj_line(FieldData,ObjectData);107 [ProjData,errormsg] = proj_line(FieldData,ObjectData); 108 108 case {'polygon','rectangle','ellipse'} 109 109 if isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside') … … 113 113 end 114 114 case 'plane' 115 115 [ProjData,errormsg] = proj_plane(FieldData,ObjectData); 116 116 case 'volume' 117 117 [ProjData,errormsg] = proj_volume(FieldData,ObjectData); … … 344 344 %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS 345 345 for icell=1:length(CellInfo) 346 testX=0;347 testY=0;346 CoordType=CellInfo{icell}.CoordType; 347 % testY=0; 348 348 test_Amat=0; 349 349 if NbDim(icell)~=2% proj_patch acts only on fields of space dimension 2 … … 429 429 end 430 430 elseif isequal(ObjectData.Type,'polygon') 431 if testX431 if strcmp(CoordType,'scattered') 432 432 testin=inpolygon(coord_x,coord_y,ObjectData.Coord(:,1),ObjectData.Coord(:,2)); 433 elseif test_Amat433 elseif strcmp(CoordType,'grid') 434 434 testin=inpolygon(Xi,Yi,ObjectData.Coord(:,1),ObjectData.Coord(:,2)); 435 435 else%calculate the scalar … … 439 439 X2Max=widthx*widthx; 440 440 Y2Max=(widthy)*(widthy); 441 if testX441 if strcmp(CoordType,'scattered') 442 442 distX=(coord_x-ObjectData.Coord(1,1)); 443 443 distY=(coord_y-ObjectData.Coord(1,2)); 444 444 testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1; 445 elseif test_Amat%case of usual 2x2 matrix445 elseif strcmp(CoordType,'grid') %case of usual 2x2 matrix 446 446 distX=(Xi-ObjectData.Coord(1,1)); 447 447 distY=(Yi-ObjectData.Coord(1,2)); … … 495 495 ProjData.NbDim=1; 496 496 %initialisation of the input parameters and defaultoutput 497 ProjMode=ObjectData.ProjMode; 497 ProjMode=ObjectData.ProjMode; %rmq: ProjMode always defined from input={'projection','interp_lin','interp_tps'} 498 498 % ProjAngle=90; %90 degrees projection by default 499 500 width=0;%default width of the projection band 501 if isfield(ObjectData,'Range')&&size(ObjectData.Range,2)>=2 502 width=abs(ObjectData.Range(1,2)); 503 end 499 width=0; 504 500 if isfield(ObjectData,'RangeY') 505 width=max(ObjectData.RangeY); 506 end 507 501 width=max(ObjectData.RangeY);%Rangey needed bfor mode 'projection' 502 end 508 503 % default output 509 errormsg= [];%default504 errormsg='';%default 510 505 Xline=[]; 511 506 flux=0; 512 507 circul=0; 513 508 liny=ObjectData.Coord(:,2); 514 siz_line=size(ObjectData.Coord); 515 if siz_line(1)<2 516 return% line needs at least 2 points to be defined 517 end 509 NbPoints=size(ObjectData.Coord,1); 518 510 testfalse=0; 519 511 ListIndex={}; 520 512 521 %% angles of the polyline and boundaries of action 522 dlinx=diff(ObjectData.Coord(:,1)); 523 dliny=diff(ObjectData.Coord(:,2)); 524 theta=angle(dlinx+1i*dliny);%angle of each segment 525 theta(siz_line(1))=theta(siz_line(1)-1); 513 514 %% projection line: object types selected from proj_field='line','polyline','polygon','rectangle','ellipse': 515 LineCoord=ObjectData.Coord; 516 switch ObjectData.Type 517 case 'ellipse' 518 LineLength=2*pi*ObjectData.RangeX*ObjectData.RangeY; 519 NbSegment=0; 520 case 'rectangle' 521 LineCoord([1 4],1)=ObjectData.Coord(1,1)-ObjectData.RangeX; 522 LineCoord([1 2],2)=ObjectData.Coord(1,2)-ObjectData.RangeY; 523 LineCoord([2 3],1)=ObjectData.Coord(1,1)+ObjectData.RangeX; 524 LineCoord([4 1],2)=ObjectData.Coord(1,2)+ObjectData.RangeY; 525 case 'polygon' 526 LineCoord(NbPoints+1)=LineCoord(1); 527 end 528 if ~strcmp(ObjectData.Type,'ellipse') 529 if ~strcmp(ObjectData.Type,'rectangle') && NbPoints<2 530 return% line needs at least 2 points to be defined 531 end 532 dlinx=diff(LineCoord(:,1)); 533 dliny=diff(LineCoord(:,2)); 534 [theta,dlength]=cart2pol(dlinx,dliny);%angle and length of each segment 535 LineLength=sum(dlength); 536 NbSegment=numel(LineLength); 537 end 538 CheckClosedLine=~isempty(find(strcmp(ObjectData.Type,{'rectangle','ellipse','polygon'}))); 539 540 % x = a \ \cosh \mu \ \cos \nu 541 % 542 % y = a \ \sinh \mu \ \sin \nu 543 544 %% angles of the polyline and boundaries of action for mode 'projection' 545 526 546 % determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'interp_tps') 527 xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1)); 528 if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps') 529 xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1)); 530 xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1)); 531 ysup(1)=ObjectData.Coord(1,2)+width*cos(theta(1)); 532 yinf(1)=ObjectData.Coord(1,2)-width*cos(theta(1)); 533 for ip=2:siz_line(1) 534 xsup(ip)=ObjectData.Coord(ip,1)-width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2); 535 xinf(ip)=ObjectData.Coord(ip,1)+width*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2); 536 ysup(ip)=ObjectData.Coord(ip,2)+width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2); 537 yinf(ip)=ObjectData.Coord(ip,2)-width*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2); 538 end 539 end 540 % 541 % 542 % x = a \ \cosh \mu \ \cos \nu 543 % 544 % y = a \ \sinh \mu \ \sin \nu 547 xsup=zeros(1,NbPoints); xinf=zeros(1,NbPoints); ysup=zeros(1,NbPoints); yinf=zeros(1,NbPoints); 548 if isequal(ProjMode,'projection') 549 if strcmp(ObjectData.Type,'line') 550 xsup=ObjectData.Coord(:,1)-width*sin(theta); 551 xinf=ObjectData.Coord(:,1)+width*sin(theta); 552 ysup=ObjectData.Coord(:,2)+width*cos(theta); 553 yinf=ObjectData.Coord(:,2)-width*cos(theta); 554 else 555 errormsg='mode projection only available for simple line, use interpolation otherwise'; 556 return 557 end 558 else % need to define the set of interpolation points 559 if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX) 560 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 561 if CheckClosedLine 562 NbPoint=ceil(LineLength/DX); 563 DX=LineLength/NbPoint;%adjust DX to get an integer nbre of intervals in a closed line 564 DX_end=DX/2; 565 else 566 DX_end=(LineLength-DX*floor(LineLength/DX))/2;%margin from the first point and first interpolation point 567 end 568 XI=[]; 569 YI=[]; 570 ThetaI=[]; 571 dlengthI=[]; 572 if strcmp(ObjectData.Type,'ellipse') 573 phi=(DX_end:DX:LineLength)*2*pi/LineLength; 574 XI=ObjectData.RangeX*cos(phi); 575 YI=ObjectData.RangeY*sin(phi); 576 dphi=2*pi*DX/LineLength; 577 [ThetaI,dlengthI]=cart2pol(-ObjectData.RangeX*sin(phi)*dphi,ObjectData.RangeY*cos(phi)*dphi); 578 else 579 for isegment=1:NbSegment 580 costheta=cos(theta(isegment)); 581 sintheta=sin(theta(isegment)); 582 XIsegment=(LineCoord(isegment,1)+DX_end*costheta:DX*costheta:LineCoord(isegment+1,1)); 583 YIsegment=(LineCoord(isegment,2)+DX_end*sintheta:DX*sintheta:LineCoord(isegment+1,2)); 584 XI=[XI XIsegment]; 585 YI=[YI YIsegment]; 586 ThetaI=[ThetaI theta(isegment)*ones(1,numel(XIsegment))]; 587 dlengthI=[dlengthI DX*ones(1,numel(XIsegment))]; 588 DX_end=DX_end+DX-(dlength(isegment)-DX*(numel(XIsegment)-1)); 589 end 590 end 591 Xproj=cumsum(dlengthI); 592 else 593 errormsg='mesh DX needed for interpolation'; 594 return 595 end 596 end 545 597 546 598 … … 551 603 return 552 604 end 553 554 %% loop on variable cells with the same space dimension 605 CellInfo=CellInfo(NbDim==2); %keep only the 2D cells 606 %%%%%% TODO: treat 1D fields: project as identity so that P o P=P for projection operation 607 608 %% loop on variable cells with the same space dimension 2 555 609 ProjData.ListVarName={}; 556 610 ProjData.VarDimName={}; 557 611 for icell=1:length(CellInfo) 558 if NbDim(icell)~=2% proj_line acts only on fields of space dimension 2, TODO: check 3D case 559 continue 560 end 561 562 % select types of variables to be projected 563 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; 564 check_proj=false(size(FieldData.ListVarName)); 565 for ilist=1:numel(ListProj) 566 if isfield(CellInfo{icell},ListProj{ilist}) 567 check_proj(CellInfo{icell}.(ListProj{ilist}))=1; 568 end 569 end 570 VarIndex=find(check_proj); 571 572 %% identify vector components 612 % list of variable types to be projected 613 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; 614 check_proj=false(size(FieldData.ListVarName)); 615 for ilist=1:numel(ListProj) 616 if isfield(CellInfo{icell},ListProj{ilist}) 617 check_proj(CellInfo{icell}.(ListProj{ilist}))=1; 618 end 619 end 620 VarIndex=find(check_proj);% indices of the variables to be projected 621 622 %% identify vector components 573 623 testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors 574 624 if testU … … 577 627 vector_x=FieldData.(UName); 578 628 vector_y=FieldData.(VName); 579 end 629 end 580 630 %identify error flag 581 testfalse=isfield(CellInfo{icell},'VarIndex_errorflag');% test forerror flag582 if testfalse631 errorflag=0; %default, no error flag 632 if isfield(CellInfo{icell},'VarIndex_errorflag');% test for error flag 583 633 FFName=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag}; 584 634 errorflag=FieldData.(FFName); 585 end 635 end 636 VarName=FieldData.ListVarName(VarIndex);% cell array of the names of variables to pje 637 %% check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 586 638 587 %% check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y 588 if strcmp(CellInfo{icell}.CoordType,'scattered') 589 if strcmp(ProjMode,'projection') 590 if width==0 591 errormsg='range of the projection object is missing'; 592 return 593 end 594 % else 595 % lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line 596 % end 597 else 598 if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX) 599 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 639 % circul=0; 640 % flux=0; 641 %%%%%%% % A FAIRE CALCULER MEAN DES QUANTITES %%%%%% 642 switch CellInfo{icell}.CoordType 643 %case of unstructured coordinates 644 case 'scattered' 645 XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 646 YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 647 coord_x=FieldData.(XName); 648 coord_y=FieldData.(YName); 649 if isequal(ProjMode,'projection') 650 if width==0 651 errormsg='range of the projection object is missing'; 652 return 653 end 654 % select the (non false) input data located in the band of projection 655 flagsel=(errorflag==0) & ((coord_y -yinf(1))*(xinf(2)-xinf(1))>(coord_x-xinf(1))*(yinf(2)-yinf(1))) ... 656 & ((coord_y -ysup(1))*(xsup(2)-xsup(1))<(coord_x-xsup(1))*(ysup(2)-ysup(1))) ... 657 & ((coord_y -yinf(2))*(xsup(2)-xinf(2))>(coord_x-xinf(2))*(ysup(2)-yinf(2))) ... 658 & ((coord_y -yinf(1))*(xsup(1)-xinf(1))<(coord_x-xinf(1))*(ysup(1)-yinf(1))); 659 coord_x=coord_x(flagsel); 660 coord_y=coord_y(flagsel); 661 costheta=cos(theta); 662 sintheta=sin(theta); 663 Xproj=(coord_x-ObjectData.Coord(1,1))*costheta + (coord_y-ObjectData.Coord(1,2))*sintheta; %projection on the line 664 [Xproj,indsort]=sort(Xproj);% sort points by increasing absissa along the projection line 665 for ivar=1:numel(VarIndex) 666 ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict vrtibles to the projection band 667 ProjData.(VarName{ivar})=ProjData.(VarName{ivar})(indsort);% sort by absissa 668 end 669 % project the velocity components if vectors are projected 670 if testU 671 vector_x=ProjData.(UName); 672 ProjData.(UName)=costheta*vector_x+sintheta*ProjData.(VName);% longitudinal component 673 ProjData.(VName)=-sintheta*vector_x+costheta*ProjData.(VName);%transverse component 674 end 675 elseif isequal(ProjMode,'interp_lin') %filtering %linear interpolation: 676 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([coord_x coord_y],FieldData,CellInfo{icell}.FieldName,XI,YI); 677 ProjData.X=Xproj; 678 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 679 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 680 nbvar=numel(ProjData.ListVarName); 681 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; 682 ProjData.ListVarName=[ProjData.ListVarName ListFieldProj]; 683 ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute]; 684 for ivar=1:numel(VarAttribute) 685 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 686 ProjData.VarAttribute{ivar+nbvar}.Role='continuous';% will promote plots of the profiles with continuous lines 687 ProjData.(ListFieldProj{ivar})=ProjVar{ivar}; 688 end 689 end 690 case 'tps'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 691 if strcmp(ProjMode,'interp_tps') 692 Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex}); 693 NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps}); 694 SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps}); 695 if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps') 696 FieldVar=cat(3,FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x_tps}),FieldData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y_tps})); 697 end 698 % coord_x_proj=XMin:DX:XMax; 699 % coord_y_proj=YMin:DY:YMax; 700 % np_x=numel(coord_x_proj); 701 % np_y=numel(coord_y_proj); 702 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI)); 703 ProjData.X=Xproj; 704 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 705 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 706 nbvar=numel(ProjData.ListVarName); 707 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; 708 ProjVarName=(fieldnames(DataOut))'; 709 ProjData.ListVarName=[ProjData.ListVarName ProjVarName]; 710 ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute]; 711 for ivar=1:numel(VarAttribute) 712 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 713 ProjData.VarAttribute{ivar+nbvar}.Role='continuous';% will promote plots of the profiles with continuous lines 714 ProjData.(ProjVarName{ivar})=DataOut.(ProjVarName{ivar}); 715 end 716 end 717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 718 719 case 'grid' %case of structured coordinates 720 if ~isequal(ObjectData.Type,'line')% exclude polyline 721 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; % 600 722 else 601 errormsg='DX missing'; 602 return 603 end 604 end 605 XName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 606 YName= FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 607 coord_x=FieldData.(XName); 608 coord_y=FieldData.(YName); 609 end 610 611 %% initiate projection 612 for ivar=1:length(VarIndex) 613 ProjLine{ivar}=[]; 614 end 615 XLine=[]; 616 linelengthtot=0; 617 618 % circul=0; 619 % flux=0; 620 %%%%%%% % A FAIRE CALCULER MEAN DES QUANTITES %%%%%% 621 %case of unstructured coordinates 622 if strcmp(CellInfo{icell}.CoordType,'scattered') 623 for ip=1:siz_line(1)-1 %Loop on the segments of the polyline 624 linelength=sqrt(dlinx(ip)*dlinx(ip)+dliny(ip)*dliny(ip)); 625 %select the vector indices in the range of action 626 if testfalse 627 flagsel=(errorflag==0); % keep only non false vectors 628 else 629 flagsel=ones(size(coord_x)); 630 end 631 if isequal(ProjMode,'projection') %|| isequal(ProjMode,'interp_tps') 632 flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ... 633 & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ... 634 & ((coord_y -yinf(ip+1))*(xsup(ip+1)-xinf(ip+1))>(coord_x-xinf(ip+1))*(ysup(ip+1)-yinf(ip+1))) ... 635 & ((coord_y -yinf(ip))*(xsup(ip)-xinf(ip))<(coord_x-xinf(ip))*(ysup(ip)-yinf(ip))); 636 end 637 indsel=find(flagsel);%indsel =indices of good vectors 638 X_sel=coord_x(indsel); 639 Y_sel=coord_y(indsel); 640 nbvar=0; 641 for iselect=1:numel(VarIndex)-2*testU 642 VarName=FieldData.ListVarName{VarIndex(iselect)}; 643 ProjVar{iselect}=FieldData.(VarName)(indsel);%scalar value 644 end 645 if testU 646 ProjVar{numel(VarIndex)-1}=cos(theta(ip))*vector_x(indsel)+sin(theta(ip))*vector_y(indsel);% longitudinal component 647 ProjVar{numel(VarIndex)}=-sin(theta(ip))*vector_x(indsel)+cos(theta(ip))*vector_y(indsel);%transverse component 648 end 649 if isequal(ProjMode,'projection') 650 sintheta=sin(theta(ip)); 651 costheta=cos(theta(ip)); 652 Xproj=(X_sel-ObjectData.Coord(ip,1))*costheta + (Y_sel-ObjectData.Coord(ip,2))*sintheta; %projection on the line 653 [Xproj,indsort]=sort(Xproj); 654 for ivar=1:numel(ProjVar) 655 if ~isempty(ProjVar{ivar}) 656 ProjVar{ivar}=ProjVar{ivar}(indsort); 657 end 658 end 659 elseif isequal(ProjMode,'interp_lin')||isequal(ProjMode,'interp_tps') %filtering %linear interpolation: 660 npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 661 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 662 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1); 663 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2); 664 if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') 665 VarName_x=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}; 666 VarName_y=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}; 667 if isfield(CellInfo{icell},'VarIndex_errorflag') 668 FieldData.(VarName_x)=FieldData.(VarName_x)(indsel); 669 FieldData.(VarName_y)=FieldData.(VarName_y)(indsel); 670 end 671 if ~isfield(CellInfo{icell},'CheckSub') || ~CellInfo{icell}.CheckSub 672 vector_x_proj=numel(ProjData.ListVarName)+1; 673 vector_y_proj=numel(ProjData.ListVarName)+2; 674 end 675 end 676 if isfield(CellInfo{icell},'VarIndex_scalar') 677 VarName_scalar=FieldData.ListVarName{CellInfo{icell}.VarIndex_scalar}; 678 if isfield(CellInfo{icell},'errorflag') && ~isempty(CellInfo{icell}.errorflag) 679 FieldData.(VarName_scalar)=FieldData.(VarName_scalar)(indsel); 680 end 681 end 682 if isfield(CellInfo{icell},'VarIndex_ancillary')% do not project ancillary data with interp 683 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_ancillary}); 684 end 685 if isfield(CellInfo{icell},'VarIndex_warnflag')% do not project ancillary data with interp 686 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_warnflag}); 687 end 688 if isfield(CellInfo{icell},'VarIndex_errorflag')% do not project ancillary data with interp 689 FieldData=rmfield(FieldData,FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag}); 690 end 691 if isequal(ProjMode,'interp_lin') 692 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_interp([X_sel Y_sel],FieldData,CellInfo{icell}.FieldName,xreg',yreg'); 693 else 694 [ProjVar,ListFieldProj,VarAttribute,errormsg]=calc_field_tps([X_sel Y_sel],FieldData,CellInfo{icell}.FieldName,xreg',yreg'); 695 end 696 ivar_vector_x=[]; 697 ivar_vector_y=[]; 698 for ivar=1:numel(VarAttribute) 699 if isfield(VarAttribute{ivar},'Role') 700 if strcmp(VarAttribute{ivar}.Role,'vector_x') 701 ivar_vector_x=ivar; 702 elseif strcmp(VarAttribute{ivar}.Role,'vector_y') 703 ivar_vector_y=ivar; 704 end 705 end 706 end 707 if ~isempty(ivar_vector_x)&&~isempty(ivar_vector_y) 708 ProjVar{ivar_vector_x}=cos(theta(ip))*ProjVar{ivar_vector_x}+sin(theta(ip))*ProjVar{ivar_vector_y};% longitudinal component 709 ProjVar{ivar_vector_y}=-sin(theta(ip))*ProjVar{ivar_vector_x}+cos(theta(ip))*ProjVar{ivar_vector_y};%transverse component 710 end 711 elseif isequal(ProjMode,'interp_tps') %filtering 712 % TODO 713 % npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX) 714 % Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 715 % siz=size(X_sel); 716 % xregij=cos(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,1); 717 % yregij=sin(theta(ip))*ones(siz(1),1)*Xproj+ObjectData.Coord(ip,2); 718 % xij=X_sel*ones(1,npoint); 719 % yij=Y_sel*ones(1,npoint); 720 % Aij=exp(-lambda*((xij-xregij).*(xij-xregij)+(yij-yregij).*(yij-yregij))); 721 % norm=Aij'*ones(siz(1),1); 722 % for ivar=1:numel(ProjVar) 723 % if ~isempty(ProjVar{ivar}) 724 % ProjVar{ivar}=Aij'*ProjVar{ivar}./norm; 725 % 726 % end 727 % end 728 end 729 %prolongate the total record 730 for ivar=1:numel(ProjVar) 731 if ~isempty(ProjVar{ivar}) 732 if numel(ProjLine)>=ivar 733 ProjLine{ivar}=[ProjLine{ivar}; ProjVar{ivar}]; 734 else 735 ProjLine{ivar}=ProjVar{ivar}; 736 end 737 end 738 end 739 XLine=[XLine ;(Xproj+linelengthtot)];%along line abscissa 740 linelengthtot=linelengthtot+linelength; 741 % circul=circul+(sum(U_sel))*linelength/npoint; 742 % flux=flux+(sum(V_sel))*linelength/npoint; 743 end 744 ProjData.X=XLine'; 745 ProjData.ListVarName=[ProjData.ListVarName {XName}]; 746 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 747 ProjData.VarAttribute{1}.long_name='abscissa along line'; 748 for iselect=1:numel(VarIndex) 749 VarName=FieldData.ListVarName{VarIndex(iselect)}; 750 eval(['ProjData.' VarName '=ProjLine{iselect};']) 751 ProjData.ListVarName=[ProjData.ListVarName {VarName}]; 752 ProjData.VarDimName=[ProjData.VarDimName {XName}]; 753 ProjData.VarAttribute{iselect}=FieldData.VarAttribute{VarIndex(iselect)}; 754 if strcmp(ProjMode,'projection') 755 ProjData.VarAttribute{iselect}.Role='discrete'; 756 else 757 ProjData.VarAttribute{iselect}.Role='continuous'; 758 end 759 end 760 761 %case of structured coordinates 762 elseif strcmp(CellInfo{icell}.CoordType,'grid') 763 if ~isequal(ObjectData.Type,'line')% exclude polyline 764 errormsg=['no projection available on ' ObjectData.Type 'for structured coordinates']; % 765 else 766 test_Amat=1;%image or 2D matrix 767 test_interp2=0;%default 768 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 769 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 770 eval(['AX=FieldData.' AXName ';']);% set of x positions 771 eval(['AY=FieldData.' AYName ';']);% set of y positions 772 AName=FieldData.ListVarName{VarIndex(1)}; 773 eval(['A=FieldData.' AName ';']);% scalar 774 npxy=size(A); 775 npx=npxy(2); 776 npy=npxy(1); 777 if numel(AX)==2 778 DX=(AX(2)-AX(1))/(npx-1); 779 else 780 DX_vec=diff(AX); 781 DX=max(DX_vec); 782 DX_min=min(DX_vec); 783 if (DX-DX_min)>0.0001*abs(DX) 784 test_interp2=1; 785 DX=DX_min; 786 end 787 end 788 if numel(AY)==2 789 DY=(AY(2)-AY(1))/(npy-1); 790 else 791 DY_vec=diff(AY); 792 DY=max(DY_vec); 793 DY_min=min(DY_vec); 794 if (DY-DY_min)>0.0001*abs(DY) 795 test_interp2=1; 796 DY=DY_min; 797 end 798 end 799 AXI=linspace(AX(1),AX(end), npx);%set of x positions for the interpolated input data 800 AYI=linspace(AY(1),AY(end), npy);%set of x positions for the interpolated input data 801 if isfield(ObjectData,'DX') 802 DXY_line=ObjectData.DX;%mesh on the projection line 803 else 804 DXY_line=sqrt(abs(DX*DY));% mesh on the projection line 805 end 806 dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1); 807 dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2); 808 linelength=sqrt(dlinx*dlinx+dliny*dliny); 809 theta=angle(dlinx+i*dliny);%angle of the line 810 if isfield(FieldData,'RangeX') 811 XMin=min(FieldData.RangeX);%shift of the origin on the line 812 else 813 XMin=0; 814 end 815 eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line 816 y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line) 817 eval(['npX=length(ProjData.' AXName ');']) 818 npY=length(y); %TODO: utiliser proj_grid 819 eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates 820 XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta); 821 YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta); 822 XIMA=(XIMA-AX(1))/DX+1;% index of the original image along x 823 YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y 824 XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 825 YIMA=reshape(round(YIMA),1,npX*npY); 826 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 827 ind_in=find(flagin); 828 ind_out=find(~flagin); 829 ICOMB=(XIMA-1)*npy+YIMA; 830 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 831 nbcolor=1; %color images 832 if numel(npxy)==2 833 nbcolor=1; 834 elseif length(npxy)==3 835 nbcolor=npxy(3); 836 else 837 errormsg='multicomponent field not projected'; 838 display(errormsg) 839 return 840 end 841 nbvar=length(ProjData.ListVarName);% number of var from previous cells 842 ProjData.ListVarName=[ProjData.ListVarName {AXName}]; 843 ProjData.VarDimName=[ProjData.VarDimName {AXName}]; 844 for ivar=VarIndex 845 %VarName{ivar}=FieldData.ListVarName{ivar}; 846 if test_interp2% interpolate on new grid 847 FieldData.(FieldData.ListVarName{ivar})=interp2(FieldData.(AXName),FieldData.(AYName),FieldData.(FieldData.ListVarName{ivar}),AXI,AYI);%TO TEST 848 end 849 vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum 850 if nbcolor==1 851 vec_B(ind_in)=vec_A(ICOMB); 852 vec_B(ind_out)=zeros(size(ind_out)); 853 A_out=reshape(vec_B,npY,npX); 854 ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY; 855 elseif nbcolor==3 856 vec_B(ind_in,1:3)=vec_A(ICOMB,:); 857 vec_B(ind_out,1)=zeros(size(ind_out)); 858 vec_B(ind_out,2)=zeros(size(ind_out)); 859 vec_B(ind_out,3)=zeros(size(ind_out)); 860 A_out=reshape(vec_B,npY,npX,nbcolor); 861 ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY); 862 end 863 ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}]; 864 ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate 865 ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line 866 end 867 if testU 868 vector_x =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 869 vector_y =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}); 870 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y; 871 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y; 872 end 873 ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line'; 874 if nbcolor==3 875 ProjData.VarDimName{end}={AXName,'rgb'}; 876 end 877 end 878 elseif strcmp(CellInfo{icell}.CoordType,'tps') 879 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX) 880 DX=abs(ObjectData.DX);%mesh of interpolation points along the line 881 Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint); 882 xreg=cos(theta(ip))*Xproj+ObjectData.Coord(ip,1) 883 yreg=sin(theta(ip))*Xproj+ObjectData.Coord(ip,2) 884 % coord_x_proj=XMin:DX:XMax; 885 % coord_y_proj=YMin:DY:YMax; 886 DataOut=calc_field_tps(FieldData.FieldList,FieldData,cat(3,xreg,yreg)); 887 ProjData.ListVarName=[ProjData.ListVarName DataOut.ListVarName]; 888 ProjData.VarDimName=[ProjData.VarDimName DataOut.VarDimName]; 889 ProjData.VarAttribute=[ProjData.VarAttribute DataOut.VarAttribute]; 890 DataOut.ListVarName(1)=[]; 891 DataOut.VarDimName(1)=[]; 892 DataOut.VarAttribute(1)=[]; 893 for ilist=2:length(DataOut.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise 894 VarName=DataOut.ListVarName{ilist}; 895 ProjData.(VarName)=DataOut.(VarName); 896 end 897 ProjData.coord_x=Xproj; 898 end 899 end 723 test_Amat=1;%image or 2D matrix 724 test_interp2=0;%default 725 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 726 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 727 eval(['AX=FieldData.' AXName ';']);% set of x positions 728 eval(['AY=FieldData.' AYName ';']);% set of y positions 729 AName=FieldData.ListVarName{VarIndex(1)}; 730 eval(['A=FieldData.' AName ';']);% scalar 731 npxy=size(A); 732 npx=npxy(2); 733 npy=npxy(1); 734 if numel(AX)==2 735 DX=(AX(2)-AX(1))/(npx-1); 736 else 737 DX_vec=diff(AX); 738 DX=max(DX_vec); 739 DX_min=min(DX_vec); 740 if (DX-DX_min)>0.0001*abs(DX) 741 test_interp2=1; 742 DX=DX_min; 743 end 744 end 745 if numel(AY)==2 746 DY=(AY(2)-AY(1))/(npy-1); 747 else 748 DY_vec=diff(AY); 749 DY=max(DY_vec); 750 DY_min=min(DY_vec); 751 if (DY-DY_min)>0.0001*abs(DY) 752 test_interp2=1; 753 DY=DY_min; 754 end 755 end 756 AXI=linspace(AX(1),AX(end), npx);%set of x positions for the interpolated input data 757 AYI=linspace(AY(1),AY(end), npy);%set of x positions for the interpolated input data 758 if isfield(ObjectData,'DX') 759 DXY_line=ObjectData.DX;%mesh on the projection line 760 else 761 DXY_line=sqrt(abs(DX*DY));% mesh on the projection line 762 end 763 dlinx=ObjectData.Coord(2,1)-ObjectData.Coord(1,1); 764 dliny=ObjectData.Coord(2,2)-ObjectData.Coord(1,2); 765 linelength=sqrt(dlinx*dlinx+dliny*dliny); 766 theta=angle(dlinx+i*dliny);%angle of the line 767 if isfield(FieldData,'RangeX') 768 XMin=min(FieldData.RangeX);%shift of the origin on the line 769 else 770 XMin=0; 771 end 772 eval(['ProjData.' AXName '=linspace(XMin,XMin+linelength,linelength/DXY_line+1);'])%abscissa of the new pixels along the line 773 y=linspace(-width,width,2*width/DXY_line+1);%ordintes of the new pixels (coordinate across the line) 774 eval(['npX=length(ProjData.' AXName ');']) 775 npY=length(y); %TODO: utiliser proj_grid 776 eval(['[X,Y]=meshgrid(ProjData.' AXName ',y);'])%grid in the line coordinates 777 XIMA=ObjectData.Coord(1,1)+(X-XMin)*cos(theta)-Y*sin(theta); 778 YIMA=ObjectData.Coord(1,2)+(X-XMin)*sin(theta)+Y*cos(theta); 779 XIMA=(XIMA-AX(1))/DX+1;% index of the original image along x 780 YIMA=(YIMA-AY(1))/DY+1;% index of the original image along y 781 XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 782 YIMA=reshape(round(YIMA),1,npX*npY); 783 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 784 ind_in=find(flagin); 785 ind_out=find(~flagin); 786 ICOMB=(XIMA-1)*npy+YIMA; 787 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 788 nbcolor=1; %color images 789 if numel(npxy)==2 790 nbcolor=1; 791 elseif length(npxy)==3 792 nbcolor=npxy(3); 793 else 794 errormsg='multicomponent field not projected'; 795 display(errormsg) 796 return 797 end 798 nbvar=length(ProjData.ListVarName);% number of var from previous cells 799 ProjData.ListVarName=[ProjData.ListVarName {AXName}]; 800 ProjData.VarDimName=[ProjData.VarDimName {AXName}]; 801 for ivar=VarIndex 802 %VarName{ivar}=FieldData.ListVarName{ivar}; 803 if test_interp2% interpolate on new grid 804 FieldData.(FieldData.ListVarName{ivar})=interp2(FieldData.(AXName),FieldData.(AYName),FieldData.(FieldData.ListVarName{ivar}),AXI,AYI);%TO TEST 805 end 806 vec_A=reshape(squeeze(FieldData.(FieldData.ListVarName{ivar})),npx*npy,nbcolor); %put the original image in colum 807 if nbcolor==1 808 vec_B(ind_in)=vec_A(ICOMB); 809 vec_B(ind_out)=zeros(size(ind_out)); 810 A_out=reshape(vec_B,npY,npX); 811 ProjData.(FieldData.ListVarName{ivar}) =sum(A_out,1)/npY; 812 elseif nbcolor==3 813 vec_B(ind_in,1:3)=vec_A(ICOMB,:); 814 vec_B(ind_out,1)=zeros(size(ind_out)); 815 vec_B(ind_out,2)=zeros(size(ind_out)); 816 vec_B(ind_out,3)=zeros(size(ind_out)); 817 A_out=reshape(vec_B,npY,npX,nbcolor); 818 ProjData.(FieldData.ListVarName{ivar})=squeeze(sum(A_out,1)/npY); 819 end 820 ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName{ivar}]; 821 ProjData.VarDimName=[ProjData.VarDimName {AXName}];%to generalize with the initial name of the x coordinate 822 ProjData.VarAttribute{ivar}.Role='continuous';% for plot with continuous line 823 end 824 if testU 825 vector_x =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}); 826 vector_y =ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}); 827 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x}) =cos(theta)*vector_x+sin(theta)*vector_y; 828 ProjData.(FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_y}) =-sin(theta)*vector_x+cos(theta)*vector_y; 829 end 830 ProjData.VarAttribute{nbvar+1}.long_name='abscissa along line'; 831 if nbcolor==3 832 ProjData.VarDimName{end}={AXName,'rgb'}; 833 end 834 end 835 end 900 836 end 901 837 -
trunk/src/read_field.m
r635 r648 73 73 ListVar=[ListVar InputField(ilist)]; 74 74 Role{numel(ListVar)}='scalar'; 75 % FieldRequest{numel(ListVar)}='interp_lin';%scalar field (requires interpolation for plot)75 ProjModeRequest{numel(ListVar)}='interp_lin';%scalar field (requires interpolation for plot) 76 76 else 77 77 ListVar=[ListVar {r.UName,r.VName}]; 78 78 Role{numel(ListVar)}='vector_y'; 79 79 Role{numel(ListVar)-1}='vector_x'; 80 % TODO; introduce that for unstructured coordinates81 % switch r.Operator TODO; introduce that for unstructured coordinates82 % case 'norm'83 % FieldRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot)84 % FieldRequest{numel(ListVar)}='interp_lin';85 % otherwise86 % FieldRequest{numel(ListVar)-1}='';87 %end80 switch r.Operator 81 case 'norm' 82 ProjModeRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot) 83 ProjModeRequest{numel(ListVar)}='interp_lin'; 84 otherwise 85 ProjModeRequest{numel(ListVar)-1}=''; 86 ProjModeRequest{numel(ListVar)}=''; 87 end 88 88 end 89 89 end … … 91 91 Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected) 92 92 end 93 if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array 94 [Field,var_detect,ichoice]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 95 else 93 96 [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 97 end 94 98 if isfield(Field,'Txt') 95 99 errormsg=Field.Txt; … … 98 102 for ivar=1:numel(ListVar) 99 103 Field.VarAttribute{ivar+2}.Role=Role{ivar}; 100 % Field.VarAttribute{ivar+2}.FieldRequest=FieldRequest{ivar}; 101 end 102 104 if isfield(ParamIn,'FieldName') 105 Field.VarAttribute{ivar+2}.FieldName=ParamIn.FieldName; 106 end 107 Field.VarAttribute{ivar+2}.ProjModeRequest=ProjModeRequest{ivar}; 108 end 103 109 case 'video' 104 110 if strcmp(class(ParamIn),'VideoReader') -
trunk/src/series.m
r644 r648 500 500 end 501 501 502 %% detect root name, nomenclature and indices in the input file name: 503 [FilePath,FileName,FileExt]=fileparts(fileinput); 504 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 505 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 506 [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]); 507 if isempty(RootFile)&&isempty(i1_series) 508 errormsg='no input file in the series'; 509 return 510 end 511 if strcmp(FileType,'txt') 512 edit(fileinput) 513 return 514 elseif strcmp(FileType,'xml') 515 editxml(fileinput) 516 return 517 elseif strcmp(FileType,'figure') 518 open(fileinput) 519 return 520 end 521 502 522 %% enable other menus and uicontrols 503 523 set(handles.MenuOpen_insert,'Enable','on') … … 512 532 drawnow 513 533 514 %% detect root name, nomenclature and indices in the input file name: 515 [FilePath,FileName,FileExt]=fileparts(fileinput); 516 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 517 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 518 [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]); 519 if isempty(RootFile)&&isempty(i1_series) 520 errormsg='no input file in the series'; 521 return 522 end 534 523 535 524 536 %% fill the list of file series … … 1845 1857 end 1846 1858 set(handles.ActionName,'BackgroundColor',[1 1 0]) 1847 huigetfile=findobj(allchild(0),'tag','status_display') 1859 huigetfile=findobj(allchild(0),'tag','status_display'); 1848 1860 if ~isempty(huigetfile) 1849 1861 delete(huigetfile) … … 2598 2610 set(handles.PairString,'ColumnWidth',{Pos(3)-5}) 2599 2611 2600 2612 %------------------------------------------------------------------------ 2601 2613 % --- Executes on button press in status. 2614 %------------------------------------------------------------------------ 2602 2615 function status_Callback(hObject, eventdata, handles) 2603 2616 … … 2628 2641 %------------------------------------------------------------------------ 2629 2642 % launched by selecting a file on the list 2643 %------------------------------------------------------------------------ 2630 2644 function view_file(hObject, eventdata) 2631 %------------------------------------------------------------------------ 2645 2632 2646 list=get(hObject,'String'); 2633 2647 index=get(hObject,'Value'); … … 2669 2683 %------------------------------------------------------------------------ 2670 2684 % launched by refreshing the status figure 2685 %------------------------------------------------------------------------ 2671 2686 function refresh_GUI(hfig) 2672 %------------------------------------------------------------------------ 2687 2673 2688 htitlebox=findobj(hfig,'tag','titlebox'); 2674 2689 hlist=findobj(hfig,'tag','list'); -
trunk/src/set_object.m
r646 r648 247 247 if isempty(get(handles.ProjMode,'UserData')) 248 248 switch Type 249 case {'points','line','p olyline','plane'}249 case {'points','line','plane'} 250 250 menu_proj={'projection';'interp_lin';'interp_tps';'none'}; 251 case 'polyline' 252 menu_proj={'interp_lin';'interp_tps';'none'}; 251 253 case {'polygon','rectangle','ellipse'} 252 menu_proj={'inside';'outside';'mask_inside';'mask_outside' };254 menu_proj={'inside';'outside';'mask_inside';'mask_outside';'interp_lin';'interp_tps';'none'}; 253 255 case 'volume' 254 256 menu_proj={'interp_lin';'none'}; -
trunk/src/uigetfile_uvmat.m
r646 r648 1 1 %'uigetfile_uvmat': browser, and display of directories, faster than the Matlab fct uigetfile 2 2 %------------------------------------------------------------------------ 3 % hfig=uigetfile_uvmat(OutputDir,option)3 % fileinput=uigetfile_uvmat(title,InputName,FilterExt) 4 4 % 5 5 % OUTPUT: … … 7 7 % 8 8 % INPUT: 9 % title: = displayed title, 'status': display advancement of a series calculation 10 % InputDir: directory to browse at first display 9 % title: = displayed title, 10 % if title='status_display': display advancement of a series calculation, 11 % else uigetfile_uvmat used as browser. 12 % InputName: initial file or directory selection for the browser 13 % FilterExt: string to filter the file display: 14 % '*' (default) all files displayed 15 % 'image': any image or movie 16 % '.ext': display only files with extension '.ext' 11 17 12 18 function fileinput=uigetfile_uvmat(title,InputName,FilterExt) … … 106 112 InputFileName=''; 107 113 end 114 if ~exist('FilterExt','var') 115 FilterExt='*'; 116 end 108 117 hfig=get(hObject,'parent'); 109 118 hlist=findobj(hfig,'tag','list');% find the list object … … 222 231 set(hObject,'BackgroundColor',[0.7 0.7 0.7]) 223 232 set(htitlebox,'String',FullSelectName)% record the new dir name 224 elseif exist(FullSelectName,'file')%visualise the field if it exists 225 FileType=get_file_type(FullSelectName); 226 if strcmp(FileType,'txt') 227 edit(FullSelectName) 228 elseif strcmp(FileType,'xml') 229 editxml(FullSelectName) 230 elseif strcmp(FileType,'figure') 231 open(FullSelectName) 232 else 233 %uvmat(FullSelectName); 234 switch option 235 case 'browser' 236 set(htitlebox,'String',FullSelectName); 237 uiresume(hfig) 238 case 'status_display' 233 elseif exist(FullSelectName,'file')%visualise the field if it exists 234 switch option 235 case 'browser' 236 set(htitlebox,'String',FullSelectName); 237 uiresume(hfig) 238 case 'status_display' 239 FileType=get_file_type(FullSelectName); 240 if strcmp(FileType,'txt') 241 edit(FullSelectName) 242 elseif strcmp(FileType,'xml') 243 editxml(FullSelectName) 244 elseif strcmp(FileType,'figure') 245 open(FullSelectName) 246 else 239 247 uvmat(FullSelectName); 240 end248 end 241 249 end 242 250 end … … 256 264 ListFiles=ListCells(1,:);%list of file names 257 265 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 258 259 266 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 267 if exist('filter_ext','var') && ~strcmp(filter_ext,'*') 268 if strcmp(filter_ext,'image') 269 check_keep=cellfun(@isimage,ListFiles) ; 270 elseif strcmp(filter_ext(1),'.') 271 ind_ext=regexp(ListFiles,[filter_ext '$']);%look for the input file extension 272 check_keep=~cellfun('isempty',ind_ext); 273 end 274 check_keep=check_keep|check_dir; 275 ListFiles=ListFiles(check_keep); 276 ListCells=ListCells(:,check_keep); 277 check_dir=check_dir(check_keep); 278 end 260 279 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 261 280 if isnumeric(sort_option) … … 275 294 cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . ) 276 295 check_keep=cellfun('isempty', cell_remove); 277 if exist('filter_ext')278 switch filter_ext279 case 'image'280 check_keep=check_keep & (cellfun(@isimage,ListFiles) |check_dir);281 end282 end283 296 ListFiles=[{'+/..'} ListFiles(check_keep)]; 284 297 if check_date … … 348 361 349 362 [pp,name,ext]=fileparts(filename); 350 ext351 363 CheckImage=~isempty(ext)&&~strcmp(ext,'.')&&~isempty(imformats(regexprep(ext,'^.',''))); -
trunk/src/uvmat.m
r646 r648 518 518 SubDir=get(handles.SubDir,'String'); 519 519 fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir)); 520 520 521 if ~isempty(fileinput_1) 521 % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);522 % if ~ischar(FileName),return,end %abandon if the browser is cancelled523 % fileinput_1=[PathName FileName];%complete file name524 522 525 523 % refresh the current displayed field … … 720 718 end 721 719 720 %% detect root name, nomenclature and indices in the input file name: 721 [FilePath,FileName,FileExt]=fileparts(fileinput); 722 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 723 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 724 [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]); 725 if strcmp(FileType,'txt') 726 edit(fileinput) 727 return 728 elseif strcmp(FileType,'xml') 729 editxml(fileinput) 730 return 731 elseif strcmp(FileType,'figure') 732 open(fileinput) 733 return 734 end 735 722 736 %% set the mouse pointer to 'watch' 723 737 set(handles.uvmat,'Pointer','watch') … … 750 764 set(handles.NomType_1,'Visible','on'); 751 765 end 752 753 %% detect root name, nomenclature and indices in the input file name:754 [FilePath,FileName,FileExt]=fileparts(fileinput);755 % detect the file type, get the movie object if relevant, and look for the corresponding file series:756 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists757 [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]);758 766 759 767 %% open the file or fill the GUI uvmat according to the detected file type … … 945 953 end 946 954 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 955 if index==1 956 set(handles.TimeName,'video') 957 else 958 set(handles.TimeName_1,'video') 959 end 947 960 ColorType='truecolor'; 948 961 elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image … … 1012 1025 end 1013 1026 end 1014 if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 1027 if (isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 1028 if index==1 1029 set(handles.TimeName,'xml') 1030 else 1031 set(handles.TimeName_1,'xml') 1032 end 1033 else 1015 1034 XmlData.Time=Time; %time set by video 1016 1035 end … … 1021 1040 end 1022 1041 1023 %% store last index in handles. lat_i and .last_j1042 %% store last index in handles.MaxIndex_i and .MaxIndex_j 1024 1043 nbfield=max(max(max(i2_series))); 1025 1044 if isempty(nbfield) … … 1033 1052 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 1034 1053 if isequal(size(XmlData.Time,1),1) 1035 %NomType=get(handles.NomType,'String');1036 1054 XmlData.Time=(XmlData.Time)'; 1037 1055 end 1038 1056 end 1039 last_i_cell=get(handles. last_i,'String');1057 last_i_cell=get(handles.MaxIndex_i,'String'); 1040 1058 if isempty(nbfield) 1041 1059 last_i_cell{index}=''; … … 1043 1061 last_i_cell{index}=num2str(nbfield); 1044 1062 end 1045 set(handles. last_i,'String',last_i_cell)1046 last_j_cell=get(handles. last_j,'String');1063 set(handles.MaxIndex_i,'String',last_i_cell) 1064 last_j_cell=get(handles.MaxIndex_j,'String'); 1047 1065 if isempty(nbfield_j) 1048 1066 last_j_cell{index}=''; … … 1050 1068 last_j_cell{index}=num2str(nbfield_j); 1051 1069 end 1052 set(handles. last_j,'String',last_j_cell);1070 set(handles.MaxIndex_j,'String',last_j_cell); 1053 1071 1054 1072 %% store geometric calibration in UvData … … 1093 1111 %% update the data attached to the uvmat interface 1094 1112 if ~isempty(TimeUnit) 1095 set(handles. time_var,'String',['time (' TimeUnit ')'])1113 set(handles.TimeName,'String',['time (' TimeUnit ')']) 1096 1114 end 1097 1115 UvData.TimeUnit=TimeUnit; 1098 1116 UvData.XmlData{index}=XmlData; 1099 1117 UvData.NewSeries=1; 1100 % UvData.MovieObject=MovieObject;1101 1118 1102 1119 %display warning message … … 1179 1196 set(handles.j1,'Visible',state_j) 1180 1197 set(handles.j2,'Visible',state_j) 1181 set(handles. last_j,'Visible',state_j);1198 set(handles.MaxIndex_j,'Visible',state_j); 1182 1199 %set(handles.frame_j,'Visible',state_j); 1183 1200 set(handles.j_text,'Visible',state_j); … … 1377 1394 end 1378 1395 end 1379 if mdetect==0 1380 MaskFullName=uigetfile_uvmat('pick a mask image file:',fullfile(RootPath,SubDir),'image'); 1381 [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 1382 [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt]); 1383 if ~(isempty(i2_series) && isempty(j2_series)) 1384 MaskNomType='*'; 1385 end 1386 end 1387 Mask.Path=MaskPath; 1388 Mask.File=MaskFile; 1389 Mask.Ext=MaskExt; 1390 Mask.NomType=MaskNomType; 1391 set(handles.CheckMask,'UserData',Mask); 1392 end 1393 errormsg=update_mask(handles); 1396 end 1397 if mdetect==0 1398 MaskFullName=uigetfile_uvmat('pick a mask image file:',fullfile(RootPath,SubDir),'image'); 1399 if isempty(MaskFullName) 1400 set(handles.CheckMask,'Value',0) 1401 end 1402 [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); 1403 [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt]); 1404 if ~(isempty(i2_series) && isempty(j2_series)) 1405 MaskNomType='*'; 1406 end 1407 end 1408 Mask.Path=MaskPath; 1409 Mask.File=MaskFile; 1410 Mask.Ext=MaskExt; 1411 Mask.NomType=MaskNomType; 1412 set(handles.CheckMask,'UserData',Mask); 1413 errormsg=update_mask(handles); 1394 1414 else % desactivate mask display 1395 1415 MaskData=get(handles.CheckMask,'UserData'); … … 2153 2173 ParamIn.FieldName=FieldName; 2154 2174 ParamIn.VelType=VelType; 2155 XNameMenu=get(handles.Coord_x,'String'); 2156 if ~isempty(XNameMenu) 2157 ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); 2158 end 2159 % YNameMenu=get(handles.Coord_y,'String'); 2175 ParamIn.Coord_x=get(handles.Coord_x,'String'); 2160 2176 ParamIn.Coord_y=get(handles.Coord_y,'Data'); 2161 % if ~isempty(YNameMenu)2162 % ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value'));2163 % end2164 2177 end 2165 2178 check_tps = 0; … … 2176 2189 set(handles.num_Npy,'String',num2str(ParamOut.Npy)); 2177 2190 end 2178 if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2179 set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2180 end 2181 if isfield(ParamOut,'TimeValue') 2182 Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2183 end 2191 % 2192 % if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field 2193 % set(handles.i1,'String',num2str(ParamOut.TimeIndex)) 2194 % end 2195 % if isfield(ParamOut,'TimeValue') 2196 % Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field 2197 % end 2184 2198 Field{1}.ZIndex=z_index; %used for multiplane 3D calibration 2185 2199 … … 2196 2210 return 2197 2211 end 2198 % Name=FileName_1;2199 2212 switch UvData.FileType{2} 2200 2213 case {'civx','civdata','netcdf'}; … … 2374 2387 %% display time 2375 2388 abstime=[];%default inputs 2376 abstime_1=[];2377 2389 dt=[]; 2378 2390 TimeUnit=''; … … 2390 2402 siz=size(UvData.XmlData{1}.Time); 2391 2403 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) 2404 set(handles.TimeName,'xml')% indicate that time is from xml 2392 2405 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 2393 2406 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); … … 2423 2436 % look for timing in the input file if not defined in a xml file or movie 2424 2437 if isempty(abstime) 2425 if isfield(Field{1},'Dt') 2426 dt=Field{1}.Dt;%dt read from the netcdf input file 2427 if isfield(Field{1},'TimeUnit') 2428 TimeUnit=Field{1}.TimeUnit; 2429 end 2430 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 2431 dt=Field{2}.Dt;%dt read from the netcdf input file 2432 if isfield(Field{2},'TimeUnit') 2433 TimeUnit=Field{2}.TimeUnit; 2434 end 2435 end 2438 TimeName=get(handles.TimeName,'String'); 2439 if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2440 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file 2441 end 2442 if isfield(Field{1},'Dt') 2443 dt=Field{1}.Dt;%dt read from the netcdf input file 2444 if isfield(Field{1},'TimeUnit') 2445 TimeUnit=Field{1}.TimeUnit; 2446 end 2447 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 2448 dt=Field{2}.Dt;%dt read from the netcdf input file 2449 if isfield(Field{2},'TimeUnit') 2450 TimeUnit=Field{2}.TimeUnit; 2451 end 2452 end 2436 2453 end 2437 2454 % if ~isequal(numel(abstime),1) … … 2441 2458 % abstime_1=[]; 2442 2459 % end 2443 set(handles.abs_time,'String',num2str(abstime,5)) 2444 set(handles.abs_time_1,'String',num2str(abstime_1,5)) 2460 abstime_1=[]; 2461 TimeName_1=get(handles.TimeName_1,'String'); 2462 if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2463 abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file 2464 end 2465 set(handles.TimeValue_1,'String',num2str(abstime_1,5)) 2445 2466 if isempty(dt)||isequal(dt,0) 2446 2467 set(handles.Dt_txt,'String','') … … 2499 2520 2500 2521 %% analyse input field 2501 %test_x=0;2502 %test_z=0;% test for unstructured z coordinate2503 %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure2504 % if ~isempty(errormsg)2505 % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error2506 % return2507 % end2508 2522 [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2509 2523 if ~isempty(errormsg) … … 2517 2531 NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates 2518 2532 end 2519 2520 %UvData.Field=get_bounds(UvData.Field);2521 2533 2522 2534 %% get bounds and mesh (needed to propose default options for projection objects) … … 3036 3048 set(handles.SubDir_1,'Visible','off'); 3037 3049 set(handles.NomType_1,'Visible','off'); 3038 set(handles. abs_time_1,'Visible','off')3050 set(handles.TimeValue_1,'Visible','off') 3039 3051 set(handles.FileIndex_1,'Visible','off'); 3040 3052 set(handles.FileExt_1,'Visible','off'); … … 3118 3130 function FieldName_Callback(hObject, eventdata, handles) 3119 3131 %------------------------------------------------------------------------ 3132 3133 %% read data from uvmat 3120 3134 UvData=get(handles.uvmat,'UserData'); 3121 3135 list_fields=get(handles.FieldName,'String');% list menu fields 3122 3136 index_fields=get(handles.FieldName,'Value');% selected string index 3123 3137 field= list_fields{index_fields(1)}; % selected string 3124 3125 %% fill the coordinates and variables from selections in get_field3126 if isequal(field,'get_field...')3127 ParamIn=[];3128 if strcmp(get(handles.VelType,'Visible'),'on')3129 % we use the civ choice as default input3130 ParamIn.SwitchVarIndexTime='attribute';3131 ListVelType=get(handles.VelType,'String');3132 VelType=ListVelType{get(handles.VelType,'Value')};3133 switch VelType3134 case 'civ1'3135 ParamIn.TimeVarName='Civ1_Time';3136 ParamIn.vector_x='Civ1_U';3137 ParamIn.vector_y='Civ1_V';3138 ParamIn.vec_color='Civ1_C';3139 case 'filter1'3140 ParamIn.TimeVarName='Civ1_Time';3141 ParamIn.vector_x='Civ1_U_smooth';3142 ParamIn.vector_y='Civ1_V_smooth';3143 case 'civ2'3144 ParamIn.TimeVarName='Civ2_Time';3145 ParamIn.vector_x='Civ2_U';3146 ParamIn.vector_y='Civ2_V';3147 case 'filter2'3148 ParamIn.TimeVarName='Civ2_Time';3149 ParamIn.vector_x='Civ2_U_smooth';3150 ParamIn.vector_y='Civ2_V_smooth';3151 ParamIn.vec_color='Civ2_C';3152 end3153 end3154 set(handles.FixVelType,'visible','off')3155 set(handles.VelType,'Visible','off')3156 set(handles.VelType_1,'Visible','off')3157 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);3158 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];3159 GetFieldData=get_field(FileName,ParamIn);3160 FieldList={};3161 VecColorList={};3162 XName=GetFieldData.Coordinates.XVarName;3163 switch GetFieldData.FieldOption3164 case 'vectors'3165 UName=GetFieldData.PanelVectors.vector_x;3166 VName=GetFieldData.PanelVectors.vector_y;3167 XName=GetFieldData.Coordinates.XVarName;3168 YName=GetFieldData.Coordinates.YVarName;3169 CName=GetFieldData.PanelVectors.vec_color;3170 [FieldList,VecColorList]=set_field_list(UName,VName,CName);3171 case 'scalar'3172 AName=GetFieldData.PanelScalar.scalar;3173 XName=GetFieldData.Coordinates.XVarName;3174 YName=GetFieldData.Coordinates.YVarName;3175 FieldList={AName};3176 case '1D plot'3177 YName=GetFieldData.CheckPlot1D.ordinate;3178 end3179 set(handles.Coord_x,'String',{XName})3180 set(handles.Coord_y,'String',{YName})3181 set(handles.FieldName,'Value',1)3182 set(handles.FieldName,'String',[FieldList; {'get_field...'}]);3183 set(handles.ColorScalar,'Value',1)3184 set(handles.ColorScalar,'String',VecColorList);3185 UvData.FileType{1}='netcdf';3186 set(handles.uvmat,'UserData',UvData)3187 run0_Callback(hObject, eventdata, handles)3188 return %no further action3189 end3190 3191 3192 3193 %read the rootfile input display3194 3138 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3195 3139 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3196 3140 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3197 if isequal(field,'image') 3198 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3199 imagename=UvData.Field.Civ2_ImageA; 3200 elseif isfield(UvData.Field,'Civ1_ImageA')% 3201 imagename=UvData.Field.Civ1_ImageA; 3202 else 3203 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3204 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3205 end 3206 if ~exist(imagename,'file') 3207 [FileName,PathName] = uigetfile( ... 3208 {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; 3209 '*.jpg',' jpeg image files'; ... 3210 '*.png','.png image files'; ... 3211 '*.tif','.tif image files'; ... 3212 '*.avi;*.AVI','.avi movie files'; ... 3213 '*.vol','.volume images (png)'; ... 3214 '*.*', 'All Files (*.*)'}, ... 3215 'Pick an image',imagename); 3216 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3217 imagename=[PathName FileName]; 3218 end 3219 % display the selected field and related information 3220 display_file_name(handles,imagename)%display the image 3221 return 3222 else 3223 ext=get(handles.FileExt,'String'); 3224 if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file 3225 [FileName,PathName] = uigetfile( ... 3226 {'*.nc', ' (*.nc)'; 3227 '*.nc',' netcdf files'; ... 3228 '*.*', 'All Files (*.*)'}, ... 3229 'Pick a netcdf file',FileBase); 3230 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3231 FullFileName=[PathName FileName]; 3141 3142 switch field 3143 3144 case 'get_field...' 3145 %% fill the coordinates and variables from selections in get_field 3146 ParamIn=[]; 3147 % in case of civ data, we use the civ choice as default input for the GUI get_field 3148 if strcmp(get(handles.VelType,'Visible'),'on') 3149 ParamIn.SwitchVarIndexTime='attribute'; 3150 ListVelType=get(handles.VelType,'String'); 3151 VelType=ListVelType{get(handles.VelType,'Value')}; 3152 switch VelType 3153 case 'civ1' 3154 ParamIn.TimeVarName='Civ1_Time'; 3155 ParamIn.vector_x='Civ1_U'; 3156 ParamIn.vector_y='Civ1_V'; 3157 ParamIn.vec_color='Civ1_C'; 3158 case 'filter1' 3159 ParamIn.TimeVarName='Civ1_Time'; 3160 ParamIn.vector_x='Civ1_U_smooth'; 3161 ParamIn.vector_y='Civ1_V_smooth'; 3162 case 'civ2' 3163 ParamIn.TimeVarName='Civ2_Time'; 3164 ParamIn.vector_x='Civ2_U'; 3165 ParamIn.vector_y='Civ2_V'; 3166 case 'filter2' 3167 ParamIn.TimeVarName='Civ2_Time'; 3168 ParamIn.vector_x='Civ2_U_smooth'; 3169 ParamIn.vector_y='Civ2_V_smooth'; 3170 ParamIn.vec_color='Civ2_C'; 3171 end 3172 end 3173 3174 % VelType menu desactivated 3175 set(handles.FixVelType,'visible','off') 3176 set(handles.VelType,'Visible','off') 3177 set(handles.VelType_1,'Visible','off') 3178 3179 %read selection from get_field 3180 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 3181 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 3182 GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field 3183 FieldList={}; 3184 VecColorList={}; 3185 XName=GetFieldData.Coordinates.Coord_x; 3186 switch GetFieldData.FieldOption 3187 case 'vectors' 3188 UName=GetFieldData.PanelVectors.vector_x; 3189 VName=GetFieldData.PanelVectors.vector_y; 3190 XName=GetFieldData.Coordinates.Coord_x; 3191 YName={GetFieldData.Coordinates.Coord_y}; 3192 CName=GetFieldData.PanelVectors.vec_color; 3193 [FieldList,VecColorList]=set_field_list(UName,VName,CName); 3194 case 'scalar' 3195 AName=GetFieldData.PanelScalar.scalar; 3196 XName=GetFieldData.Coordinates.Coord_x; 3197 YName={GetFieldData.Coordinates.Coord_y}; 3198 FieldList={AName}; 3199 case '1D plot' 3200 YName=GetFieldData.PanelOrdinate.ordinate; 3201 XName=GetFieldData.Coordinates.Coord_x; 3202 end 3203 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 3204 if strcmp(TimeNameStr,'file index') 3205 set(handles.TimeName,'String',''); 3206 else 3207 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]); 3208 end 3209 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index 3210 set(handles.NomType,'String','*') 3211 set(handles.RootFile,FileName) 3212 end 3213 % set(handles.TimeValue,'String' SwitchVarIndexTime 3214 set(handles.Coord_x,'String',XName) 3215 if ischar(YName) 3216 YName={YName}; 3217 end 3218 set(handles.Coord_y,'Data',YName) 3219 set(handles.FieldName,'Value',1) 3220 set(handles.FieldName,'String',[FieldList; {'get_field...'}]); 3221 set(handles.ColorScalar,'Value',1) 3222 set(handles.ColorScalar,'String',VecColorList); 3223 UvData.FileType{1}='netcdf'; 3224 set(handles.uvmat,'UserData',UvData) 3225 run0_Callback(hObject, eventdata, handles) 3226 3227 case 'image' 3228 %% look for image corresponding to civ data 3229 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3230 imagename=UvData.Field.Civ2_ImageA; 3231 elseif isfield(UvData.Field,'Civ1_ImageA')% 3232 imagename=UvData.Field.Civ1_ImageA; 3233 else 3234 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3235 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3236 end 3237 if ~exist(imagename,'file') 3238 imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); 3239 if isempty(imagename) 3240 return 3241 end 3242 end 3232 3243 % display the selected field and related information 3233 display_file_name( handles,FullFileName) 3234 return 3235 end 3236 end 3237 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3238 set(handles.FileIndex,'String',indices) 3239 3240 %common to Fields_1_Callback 3241 list_fields_1=get(handles.FieldName_1,'String');% list menu fields 3242 field_1=''; 3243 if ~isempty(list_fields_1) 3244 field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string 3245 end 3246 if isequal(field,'image')||isequal(field_1,'image') 3247 set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons 3248 set(handles.num_Npx,'Visible','on') 3249 set(handles.num_Npy,'Visible','on') 3250 else 3251 set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons 3252 set(handles.num_Npx,'Visible','off') 3253 set(handles.num_Npy,'Visible','off') 3254 end 3255 if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 3256 run0_Callback(hObject, eventdata, handles) 3257 end 3244 display_file_name(handles,imagename)%display the image 3245 % otherwise 3246 % ext=get(handles.FileExt,'String'); 3247 % if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file 3248 % [FileName,PathName] = uigetfile( ... 3249 % {'*.nc', ' (*.nc)'; 3250 % '*.nc',' netcdf files'; ... 3251 % '*.*', 'All Files (*.*)'}, ... 3252 % 'Pick a netcdf file',FileBase); 3253 % if ~ischar(FileName),return,end %abandon if the browser is cancelled 3254 % FullFileName=[PathName FileName]; 3255 % % display the selected field and related information 3256 % display_file_name( handles,FullFileName) 3257 % return 3258 % end 3259 end 3260 % indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3261 % set(handles.FileIndex,'String',indices) 3262 % 3263 % %common to Fields_1_Callback 3264 % list_fields_1=get(handles.FieldName_1,'String');% list menu fields 3265 % field_1=''; 3266 % if ~isempty(list_fields_1) 3267 % field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string 3268 % end 3269 % if isequal(field,'image')||isequal(field_1,'image') 3270 % set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons 3271 % set(handles.num_Npx,'Visible','on') 3272 % set(handles.num_Npy,'Visible','on') 3273 % else 3274 % set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons 3275 % set(handles.num_Npx,'Visible','off') 3276 % set(handles.num_Npy,'Visible','off') 3277 % end 3278 % if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) 3279 % run0_Callback(hObject, eventdata, handles) 3280 % end 3258 3281 3259 3282 %---------------------------------------------------------------- … … 3261 3284 function FieldName_1_Callback(hObject, eventdata, handles) 3262 3285 %------------------------------------------------- 3286 3287 %%%%%% TODO: modify like FieldName_Callback 3263 3288 %% read input data 3264 3289 check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered … … 3664 3689 end 3665 3690 if strcmp(transform_name,'more...'); 3666 [FileName, PathName] = uigetfile( ... 3667 {'*.m', ' (*.m)'; 3668 '*.m', '.m files '; ... 3669 '*.*', 'All Files (*.*)'}, ... 3670 'Pick the transform function', prev_path); 3671 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3672 path_transform_fct =fullfile(PathName,FileName); 3673 if isempty(regexp(FileName,'\.m$'))% detect file extension .m 3674 msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 3675 return 3676 else 3677 transform_name=regexprep(FileName,'\.m',''); 3678 end 3679 ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu 3680 if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) 3681 menu=[menu(1:end-1);{transform_name};{'more...'}]; 3682 ichoice=numel(menu)-1; 3683 end 3684 list_path{ichoice}=PathName;%update the list fo fct paths 3685 set(handles.TransformName,'String',menu) 3686 set(handles.TransformName,'Value',ichoice) 3687 3688 % save the new menu in the personal file 'uvmat_perso.mat' 3689 dir_perso=prefdir;%personal Matalb directory 3690 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3691 if exist(profil_perso,'file') 3692 nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat 3693 if nb_builtin<numel(list_path) 3694 for ilist=nb_builtin+1:numel(list_path) 3695 transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; 3696 end 3697 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 3691 transform_fct=uigetfile_uvmat('Pick the transform function',prev_path,'.m'); 3692 % [FileName, PathName] = uigetfile( ... 3693 % {'*.m', ' (*.m)'; 3694 % '*.m', '.m files '; ... 3695 % '*.*', 'All Files (*.*)'}, ... 3696 % 'Pick the transform function', prev_path); 3697 % if ~ischar(FileName),return,end %abandon if the browser is cancelled 3698 % path_transform_fct =fullfile(PathName,FileName); 3699 if ~isempty(transform_fct) 3700 [PathName,transform_name]=fileparts(transform_fct); 3701 % if isempty(regexp(FileName,'\.m$'))% detect file extension .m 3702 % msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); 3703 % return 3704 % else 3705 % transform_name=regexprep(FileName,'\.m',''); 3706 % end 3707 ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu 3708 if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) 3709 menu=[menu(1:end-1);{transform_name};{'more...'}]; 3710 ichoice=numel(menu)-1; 3711 end 3712 list_path{ichoice}=PathName;%update the list fo fct paths 3713 set(handles.TransformName,'String',menu) 3714 set(handles.TransformName,'Value',ichoice) 3715 3716 % save the new menu in the personal file 'uvmat_perso.mat' 3717 dir_perso=prefdir;%personal Matalb directory 3718 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 3719 if exist(profil_perso,'file') 3720 nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat 3721 if nb_builtin<numel(list_path) 3722 for ilist=nb_builtin+1:numel(list_path) 3723 transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; 3724 end 3725 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat 3726 end 3698 3727 end 3699 3728 end … … 4460 4489 hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface 4461 4490 list_str=get(hlist_object,'String');%objet list 4462 % if isequal(floor(hObject),hObject) %case of an index 4463 if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 4464 if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') 4465 hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4491 if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 4492 if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') 4493 hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4494 for iview=1:length(hdisplay) 4495 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4496 ObjectData=get(hdisplay(iview),'UserData'); 4497 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) 4498 delete(ObjectData.SubObject); 4499 end 4500 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) 4501 delete(ObjectData.DeformPoint); 4502 end 4503 delete(hdisplay(iview)) 4504 end 4505 ishandle(hdisplay(iview)) 4506 end 4507 for iobj=IndexObj+1:length(UvData.ProjObject) 4508 hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; 4466 4509 for iview=1:length(hdisplay) 4467 4510 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4468 ObjectData=get(hdisplay(iview),'UserData'); 4469 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) 4470 delete(ObjectData.SubObject); 4471 end 4472 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) 4473 delete(ObjectData.DeformPoint); 4474 end 4475 delete(hdisplay(iview)) 4476 end 4477 ishandle(hdisplay(iview)) 4478 end 4479 for iobj=IndexObj+1:length(UvData.ProjObject) 4480 hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; 4481 for iview=1:length(hdisplay) 4482 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4483 PlotData=get(hdisplay(iview),'UserData'); 4484 PlotData.IndexObj=iobj-1; 4485 set(hdisplay(iview),'UserData',PlotData); 4486 end 4511 PlotData=get(hdisplay(iview),'UserData'); 4512 PlotData.IndexObj=iobj-1; 4513 set(hdisplay(iview),'UserData',PlotData); 4487 4514 end 4488 4515 end 4489 4516 end 4490 UvData.ProjObject(IndexObj)=[]; 4491 if ~isempty(list_str) 4492 list_str(IndexObj)=[]; 4493 end 4494 end 4495 % elseif ishandle(hObject)%object handle 4496 % userdata=get(hObject,'UserData'); 4497 % if ishandle(userdata)%the selected line depends on a parent line 4498 % hdisplay=userdata;% the parent object becomes the current one 4499 % else 4500 % hdisplay=hObject;% the selected object becomes the current one 4501 % end 4502 % PlotData=get(hdisplay,'UserData'); 4503 % if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject) 4504 % delete(PlotData.SubObject); 4505 % end 4506 % if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint) 4507 % delete(PlotData.DeformPoint); 4508 % end 4509 % delete(hdisplay); 4510 % if isfield(PlotData,'IndexObj') 4511 % IndexObj=PlotData.IndexObj; 4512 % if isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj 4513 % if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj 4514 % UvData.ProjObject(IndexObj)=[]; 4515 % end 4516 % list_str(IndexObj)=[]; 4517 % end 4518 % end 4519 % end 4517 end 4518 UvData.ProjObject(IndexObj)=[]; 4519 if ~isempty(list_str) 4520 list_str(IndexObj)=[]; 4521 end 4522 end 4520 4523 set(huvmat,'UserData',UvData); 4521 4524 set(hlist_object,'String',list_str) … … 4677 4680 ylim=get(newaxes,'YLim'); 4678 4681 set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) 4679 time_str=get(handles. abs_time,'String');4682 time_str=get(handles.TimeValue,'String'); 4680 4683 set(htitle,'String',['t=' time_str]) 4681 4684 set(handles.speed,'Value',1) … … 4684 4687 runpm(hObject,eventdata,handles,increment)% run plus 4685 4688 drawnow 4686 time_str=get(handles. abs_time,'String');4689 time_str=get(handles.TimeValue,'String'); 4687 4690 if ishandle(htitle) 4688 4691 set(htitle,'String',['t=' time_str]) … … 4797 4800 end 4798 4801 4799 %% append a new line to the list of projection objects A METTRE PLUS TARD 4800 % ListObject=get(handles.ListObject,'String'); 4801 % if isempty(ListObject) 4802 % ListObject={''}; 4803 % end 4804 % if ~strcmp(ListObject{end},'') 4805 % ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object 4806 % set(handles.ListObject,'String',ListObject) 4807 % end 4808 % IndexObj=length(ListObject); 4809 % set(handles.ListObject,'Value',IndexObj) 4802 %% initiate the new projection object 4810 4803 UvData=get(handles.uvmat,'UserData'); 4811 % UvData.ProjObject{IndexObj}=[]; %create a new empty object4812 % UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object4813 % UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation4814 % set(handles.uvmat,'UserData',UvData)4815 4816 %% initiate the new projection object4817 4804 data.Name=data.Type;% default name=type 4818 4805 data.Coord=[0 0]; %default … … 4843 4830 hchild=get(hset_object,'children'); 4844 4831 set(hchild,'enable','on') 4845 4846 4847 set(handles.delete_object,'Visible','on') 4832 set(handles.delete_object,'Visible','on')% make the object delete button visible 4848 4833 4849 4834 %------------------------------------------------------------------------ … … 5393 5378 set(handles.Slider1,'Visible','on') 5394 5379 set(handles.Slider2,'Visible','on') 5395 %ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1;5396 %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2;5397 % ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1;5398 %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2;5399 5380 set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) 5400 5381 set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) … … 5417 5398 5418 5399 5419 5420 function time_var_1_Callback(hObject, eventdata, handles)5421 % hObject handle to time_var_1 (see GCBO)5422 % eventdata reserved - to be defined in a future version of MATLAB5423 % handles structure with handles and user data (see GUIDATA)5424 5425 % Hints: get(hObject,'String') returns contents of time_var_1 as text5426 % str2double(get(hObject,'String')) returns contents of time_var_1 as a double5427 5428 5429 % --- Executes during object creation, after setting all properties.5430 function time_var_1_CreateFcn(hObject, eventdata, handles)5431 % hObject handle to time_var_1 (see GCBO)5432 % eventdata reserved - to be defined in a future version of MATLAB5433 % handles empty - handles not created until after all CreateFcns called5434 5435 % Hint: edit controls usually have a white background on Windows.5436 % See ISPC and COMPUTER.5437 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))5438 set(hObject,'BackgroundColor','white');5439 end
Note: See TracChangeset
for help on using the changeset viewer.