- Timestamp:
- Nov 21, 2010, 10:06:11 PM (14 years ago)
- Location:
- trunk/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cell2tab.m
r126 r128 4 4 % 5 5 % OUTPUT: 6 % Tabchar: c haracter array suitable for table display6 % Tabchar: column cell of char strings suitable for display (equal length) 7 7 % 8 8 % INPUT: 9 % Tabcell: (ni,nj) cell table, for ni lines10 % separator: char acterused for separating displayed columns9 % Tabcell: (ni,nj) cell matrix of char strings to be displayed as ni lines , nj column 10 % separator: char string used for separating displayed columns 11 11 12 12 function Tabchar=cell2tab(Tabcell,separator) 13 Tabchar={};%default14 13 [ni,nj]=size(Tabcell); 15 14 16 15 %determine width of each column 17 widthcolumn=max(cellfun(@length,Tabcell)); 16 if isequal(ni,1) 17 widthcolumn=cellfun('length',Tabcell);% case of a single line, no justification used 18 else 19 widthcolumn=max(cellfun('length',Tabcell)); 20 end 21 lsep=numel(separator); %nbre of characters of the separator 22 nbchar_line=(sum(widthcolumn)+(nj-1)*lsep); %total nbre of characters in each output line 23 default_line=blanks(nbchar_line); %default blank line 24 Tabmat=reshape(blanks(nbchar_line*ni),ni,nbchar_line); 25 Tabchar=mat2cell(Tabmat,ones(1,ni),nbchar_line); %default output 18 26 19 27 %justify table 20 28 for itab=1:ni 21 charchain= [];29 charchain=default_line; 22 30 for jtab=1:nj% read line 23 31 textlu=Tabcell{itab,jtab}; 24 if widthcolumn(jtab)>length(textlu) 25 blankstr=char(32*ones(1,widthcolumn(jtab)-length(textlu))); 26 textlu=[textlu blankstr]; 32 if jtab==1 33 charchain(1:length(textlu))=textlu;%introduce separator chain string except for the first column 34 ind_column=widthcolumn(1);%new current char index in the line 35 else 36 charchain(ind_column+1:ind_column+lsep)=separator;%introduce separator chain string except for the first column 37 charchain(ind_column+lsep+1:ind_column+lsep+length(textlu))=textlu;%introduce separator chain string except for the first column 38 ind_column=ind_column+widthcolumn(jtab)+lsep; 27 39 end 28 if ~isempty(charchain)29 textlu=[separator textlu];30 end31 charchain=[charchain textlu];32 40 end 33 41 Tabchar(itab,1)={charchain}; 34 42 end 35 36 %nb : char(Tabchar(:,jtab)) gives directly a column with the blanks filled -
trunk/src/civ.m
r127 r128 92 92 if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat 93 93 set(handles.ImaExt,'String',ext) 94 browse.ext_ima=ext; 94 95 if exist('nom_type_read','var') 95 96 browse.nom_type_ima=nom_type_read; % the image nomenclature is stored … … 452 453 pxcmy_search=[];%default 453 454 filebase=get(handles.RootName,'String'); 454 ext =get(handles.ImaDoc,'String');455 ext_imadoc=get(handles.ImaDoc,'String'); 455 456 browse=get(handles.browse_root,'UserData')%default 456 457 if isfield(browse,'nom_type_ima') … … 498 499 499 500 %look for an image documentation file 500 if ~ isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI')501 if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') 501 502 if exist([filebase '.xml'],'file') 502 ext ='.xml';503 ext_imadoc='.xml'; 503 504 elseif exist([filebase '.civxml'],'file') 504 ext ='.civxml';505 ext_imadoc='.civxml'; 505 506 elseif exist([filebase '.civ'],'file') 506 ext ='.civ';507 ext_imadoc='.civ'; 507 508 elseif exist([filebase '.avi'],'file') 508 ext ='.avi';509 ext_imadoc='.avi'; 509 510 elseif exist([filebase '.AVI'],'file') 510 ext ='.AVI';511 end 512 set(handles.ImaDoc,'String',ext )511 ext_imadoc='.AVI'; 512 end 513 set(handles.ImaDoc,'String',ext_imadoc) 513 514 end 514 515 … … 517 518 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) 518 519 drawnow 519 if isequal(ext ,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ')520 if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') 520 521 set(handles.ref_i,'Visible','On')%use a reference index 521 522 set(handles.ref_j,'Visible','On') 522 elseif isequal(ext ,'.avi') || isequal(ext,'.AVI')523 elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') 523 524 set(handles.ref_j,'Visible','Off') 524 525 else … … 527 528 end 528 529 testima_xml=0; 529 if isequal(ext ,'.civxml')%TO ABANDON530 if isequal(ext_imadoc,'.civxml')%TO ABANDON 530 531 [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); 531 532 mode='pair j1-j2'; … … 533 534 nom_type_ima='_i_j'; 534 535 end 535 elseif isequal(ext ,'.xml')536 elseif isequal(ext_imadoc,'.xml') 536 537 [XmlData,warntext]=imadoc2struct([filebase '.xml']); 537 538 ext_ima_read=[]; … … 577 578 end 578 579 end 579 if ~isempty(ext_ima_read) && ~isempty(nom_type_read)580 % if isempty(ext_ima)581 % ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously582 % else %keep the image extension583 % if ~strcmp(ext_ima_read,ext_ima)584 % msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])585 % end586 % end587 nom_type_ima=nom_type_read;588 end589 elseif strcmp(ext ,'.civ')% case of .civ image documentation file580 % if ~isempty(ext_ima_read) && ~isempty(nom_type_read) 581 % % if isempty(ext_ima) 582 % % ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously 583 % % else %keep the image extension 584 % % if ~strcmp(ext_ima_read,ext_ima) 585 % % msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) 586 % % end 587 % % end 588 % nom_type_ima=nom_type_read; 589 % end 590 elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file 590 591 [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); 591 592 if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); 592 593 elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 593 594 end 594 % ImaExt='.png'; 595 nom_type_ima='png_old'; 596 elseif strcmpi(ext,'.avi') 595 nom_type_ima='001a'; 596 elseif strcmpi(ext_imadoc,'.avi') 597 597 nom_type_ima='*'; 598 ext_ima=ext ;598 ext_ima=ext_imadoc; 599 599 set(handles.mode,'String',{'series(Di)'}) 600 600 dt=0.04;%default 601 if exist([filebase ext ],'file')==2602 info=aviinfo([filebase ext ]);%read infos on the avi movie601 if exist([filebase ext_imadoc],'file')==2 602 info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie 603 603 dt=1/info.FramesPerSecond;%time interval between successive frames 604 604 nbfield=info.NumFrames;%number of frames … … 627 627 appendix=char(96+first_j); 628 628 dirima=dir([filebase '*' num2str(first_i) appendix '.*']); 629 % if ~isempty(dirima) 630 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 631 % end 632 % else 633 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 634 end 635 % else 636 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 637 end 638 % else 639 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 629 end 630 end 640 631 end 641 632 end … … 651 642 % no image documentation file found: look for a series of existing files,images by priority or .nc files 652 643 if isempty(nom_type_ima) 653 ext_search=ext ;644 ext_search=ext_imadoc; 654 645 nom_type_search=nom_type_nc; 655 646 else … … 2988 2979 %create the new subdir_civ1 2989 2980 if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') 2990 [xx,m 2]=mkdir(subdir_civ1_new);2991 if ~ isequal(m2,'')2992 msgbox_uvmat('ERROR', m2)%error message for directory creation2981 [xx,msg1]=mkdir(subdir_civ1_new); 2982 if ~strcmp(msg1,'') 2983 msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation 2993 2984 cd(currentdir) 2994 2985 filecell={}; 2995 2986 return 2987 else 2988 [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) 2989 if ~strcmp(msg2,'') 2990 msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg2])%error message for directory creation 2991 cd(currentdir) 2992 filecell={}; 2993 return 2994 end 2996 2995 end 2997 2996 end … … 3024 3023 %create the new subdir_civ1 3025 3024 if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') 3026 [xx,m 2]=mkdir(subdir_civ1_new);3027 if ~ isequal(m2,'')3028 msgbox_uvmat('ERROR', m2)3025 [xx,msg1]=mkdir(subdir_civ1_new); 3026 if ~strcmpl(msg1,'') 3027 msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) 3029 3028 cd(currentdir) 3030 3029 filecell={}; 3031 3030 return 3031 else 3032 [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) 3033 if ~strcmp(msg2,'') 3034 msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation 3035 cd(currentdir) 3036 filecell={}; 3037 return 3038 end 3032 3039 end 3033 3040 end … … 3151 3158 end 3152 3159 end 3153 %create the new subdir_civ2 3154 if ~exist(fullfile(Path_ima,subdir_civ2),'dir') 3155 [xx,m2]=mkdir(subdir_civ2); 3160 %create the new subdir_civ2_new 3161 if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') 3162 [xx,m2]=mkdir(subdir_civ2_new); 3163 [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) 3156 3164 if ~isequal(m2,'') 3157 msgbox_uvmat('ERROR', m2)3165 msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) 3158 3166 filecell={}; 3159 3167 cd(currentdir) … … 3188 3196 if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') 3189 3197 [xx,m2]=mkdir(subdir_civ2_new); 3198 [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) 3190 3199 if ~isequal(m2,'') 3191 msgbox_uvmat('ERROR', m2)%error message for directory creation3200 msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation 3192 3201 cd(currentdir) 3193 3202 filecell={}; -
trunk/src/dataview.m
r127 r128 32 32 'gui_LayoutFcn', [] , ... 33 33 'gui_Callback', []); 34 if nargin & ischar(varargin{1})34 if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) 35 35 gui_State.gui_Callback = str2func(varargin{1}); 36 36 end … … 119 119 function browser_Callback(hObject, eventdata, handles) 120 120 %------------------------------------------------------------------------ 121 CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String'); 121 CurrentFile=fileparts(get(handles.RootDirectory,'String')); 122 if ~exist(CurrentFile,'dir') 123 CurrentFile='/fsnet/project/coriolis'; 124 end 122 125 set(handles.SubCampaignTest,'Value',0) 123 126 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser … … 129 132 function OpenSubCampaign_Callback(hObject, eventdata, handles) 130 133 %------------------------------------------------------------------------ 131 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String'); 134 CurrentFile=get(handles.RootDirectory,'String'); 135 if ~exist(CurrentFile,'dir') 136 CurrentFile='/fsnet/project/coriolis'; 137 end 132 138 set(handles.SubCampaignTest,'Value',1) 133 139 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser … … 184 190 set(handles.ListDevices,'String',[{'*'};ListDevices']) 185 191 set(handles.ListXml,'String',[{'*'};ListXml']) 192 'TEST' 193 testList 186 194 if testList 187 195 DataviewData=get(handles.figure,'UserData'); 188 Data View.List=List;196 DataviewData.List=List; 189 197 set(handles.figure,'UserData',DataviewData) 190 198 end … … 502 510 message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)'; 503 511 answer=msgbox_uvmat('INPUT_Y-N',message); 504 if ~isequal(answer {1},'OK')512 if ~isequal(answer,'Yes') 505 513 return 506 514 end 507 515 set(handles.ListExperiments,'Value',1) 508 516 ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories 509 DataviewData=get(handles.figure,'UserData') ;517 DataviewData=get(handles.figure,'UserData') 510 518 List=DataviewData.List; 511 519 Currentpath=get(handles.RootDirectory,'String'); -
trunk/src/geometry_calib.m
r121 r128 54 54 'gui_LayoutFcn', [] , ... 55 55 'gui_Callback', []); 56 if nargin && ischar(varargin{1}) 56 if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) 57 57 gui_State.gui_Callback = str2func(varargin{1}); 58 58 end … … 95 95 if exist('inputfile','var')&& ~isempty(inputfile) 96 96 struct.XmlInputFile=inputfile; 97 set(hObject,'UserData',struct) 98 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile); 97 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile); 99 98 if ~strcmp(ext,'.xml') 100 99 inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file … … 103 102 set(handles.ListCoord,'String',{'......'}) 104 103 if exist(inputfile,'file') 105 loadfile(handles,inputfile)% load the point coordiantes existing in the xml file 106 end 104 Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file 105 end 106 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 107 struct.Campaign=Heading.Campaign; 108 end 109 set(hObject,'UserData',struct) 107 110 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function 108 111 … … 213 216 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 214 217 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}); 218 219 %% record the calibration parameters and display the current image of uvmat in the new phys coordinates 215 220 if strcmp(answer,'Yes') 216 221 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration … … 219 224 Z_plane=0; %default 220 225 else 221 Z_plane=str2 num(answer_1);226 Z_plane=str2double(answer_1); 222 227 end 223 228 GeometryCalib.NbSlice=1; … … 228 233 msgbox_uvmat('ERROR',errormsg); 229 234 end 235 230 236 %display image with new calibration in the currently opened uvmat interface 231 237 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers … … 251 257 %------------------------------------------------------------------ 252 258 % --- Executes on button press in calibrate_lin. 259 253 260 function REPLICATE_Callback(hObject, eventdata, handles) 254 % %%%%%%Todo: correct on the model of APPLY_Callback%%%%%%%%%% 255 %------------------------------------------------------------------------ 256 calib_cell=get(handles.calib_type,'String'); 257 val=get(handles.calib_type,'Value'); 258 Coord_cell=get(handles.ListCoord,'String'); 259 Object=read_geometry_calib(Coord_cell); 260 GeometryCalib=feval(['calib_' calib_cell{val}],Object.Coord,handles); 261 %------------------------------------------------------------------------ 262 263 %% Apply calibration 264 calib_cell=get(handles.calib_type,'String'); %#ok<NASGU> 265 val=get(handles.calib_type,'Value'); %#ok<NASGU> 261 266 262 267 %read the current calibration points … … 288 293 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 289 294 [EM,ind_dim]=max(GeometryCalib.ErrorMax); 290 index=index(ind_dim);295 % index=index(ind_dim); 291 296 %set the Z position of the reference plane used for calibration 292 297 Z_plane=[]; … … 295 300 end 296 301 answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane)); 297 Z_plane=str2 num(answer_1);302 Z_plane=str2double(answer_1); 298 303 GeometryCalib.NbSlice=1; 299 304 GeometryCalib.SliceCoord=[0 0 Z_plane]; … … 304 309 %record the points 305 310 GeometryCalib.SourceCalib.PointCoord=Coord; 306 % errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file 307 % if ~strcmp(errormsg,'') 308 % msgbox_uvmat('ERROR',errormsg); 309 % end 310 end 311 end 312 313 %% display calibration paprameters 311 314 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 312 315 … … 319 322 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4)) 320 323 321 % indicate the plane of the calibration grid if defined 322 % huvmat=findobj(allchild(0),'Name','uvmat'); 323 % hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 324 % RootPath=''; 325 % RootFile=''; 326 % if ~isempty(hhuvmat.RootPath)& ~isempty(hhuvmat.RootFile) 327 % testhandle=1; 328 % RootPath=get(hhuvmat.RootPath,'String'); 329 % RootFile=get(hhuvmat.RootFile,'String'); 330 % filebase=fullfile(RootPath,RootFile); 331 % outputfile=[filebase '.xml']; 332 % else 333 % question={'save the calibration data and point coordinates in'}; 334 % def={fullfile(RootPath,['ObjectCalib.xml'])}; 335 % options.Resize='on'; 336 % answer=inputdlg(question,'save average in a new file',1,def,options); 337 % outputfile=answer{1}; 338 % end 339 340 %open and read the dataview GUI 324 %% open the GUI dataview 341 325 h_dataview=findobj(allchild(0),'name','dataview'); 342 326 if ~isempty(h_dataview) … … 344 328 end 345 329 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata 346 330 InputFile=''; 347 331 if isfield(CalibData,'XmlInputFile') 348 XmlInput=fileparts(CalibData.XmlInputFile);349 [ XmlInput,filename,ext]=fileparts(XmlInput);332 InputDir=fileparts(CalibData.XmlInputFile); 333 [InputDir,DirName]=fileparts(InputDir); 350 334 end 351 335 SubCampaignTest='n'; %default 352 testinput=0; 353 if isfield(CalibData,'Heading') 354 Heading=CalibData.Heading; 355 if isfield(Heading,'Record') && isequal([filename ext],Heading.Record) 356 [XmlInput,filename,ext]=fileparts(XmlInput); 357 end 358 if isfield(Heading,'Device') && isequal([filename ext],Heading.Device) 359 [XmlInput,filename,ext]=fileparts(XmlInput); 360 Device=Heading.Device; 361 end 362 if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment) 363 [PP,filename,ext]=fileparts(XmlInput); 364 end 365 testinput=0; 366 if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign) 367 SubCampaignTest='y'; 368 testinput=1; 369 elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign) 370 testinput=1; 371 end 372 end 373 if ~testinput 374 filename='PROJETS';%default 375 if isfield(CalibData,'XmlInputFile') 376 [pp,filename]=fileparts(CalibData.XmlInputFile); 377 end 378 while ~isequal(filename,'PROJETS') && numel(filename)>1 379 filename_1=filename; 380 pp_1=pp; 381 [pp,filename]=fileparts(pp); 382 end 383 XmlInput=fullfile(pp_1,filename_1); 384 testinput=1; 385 end 386 if testinput 387 outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib); 388 end 336 testup=0; 337 if isfield(CalibData,'SubCampaign') 338 SubCampaignTest='y'; 339 dir_ref=CalibData.SubCampaign; 340 testup=1; 341 elseif isfield(CalibData,'Campaign') 342 dir_ref=CalibData.Campaign; 343 testup=1; 344 end 345 while testup 346 [InputDir,DirName]=fileparts(InputDir); 347 if strcmp(DirName,dir_ref) 348 break 349 end 350 end 351 InputDir=fullfile(InputDir,DirName); 352 answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir); 353 if strcmp(answer,'Cancel') 354 return 355 end 356 357 dataview(answer,SubCampaignTest,GeometryCalib); 358 359 % if isfield(Heading,'Device') && isequal([filename ext],Heading.Device) 360 % [XmlInput,filename,ext]=fileparts(XmlInput); 361 % Device=Heading.Device; 362 % end 363 % if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment) 364 % [PP,filename,ext]=fileparts(XmlInput); 365 % end 366 % testinput=0; 367 % if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign) 368 % SubCampaignTest='y'; 369 % testinput=1; 370 % elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign) 371 % testinput=1; 372 % % end 373 % end 374 % if ~testinput 375 % filename='PROJETS';%default 376 % if isfield(CalibData,'XmlInputFile') 377 % [pp,filename]=fileparts(CalibData.XmlInputFile); 378 % end 379 % while ~isequal(filename,'PROJETS') && numel(filename)>1 380 % filename_1=filename; 381 % pp_1=pp; 382 % [pp,filename]=fileparts(pp); 383 % end 384 % XmlInput=fullfile(pp_1,filename_1); 385 % testinput=1; 386 % end 387 % if testinput 388 % outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib); 389 % end 389 390 390 391 %------------------------------------------------------------------------ … … 434 435 R=[R;[0 0]]; 435 436 GeometryCalib.R=[R [0;0;1]]; 436 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0] 437 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]; 437 438 %------------------------------------------------------------------------ 438 439 % determine the tsai parameters for a view normal to the grid plane … … 700 701 701 702 %-------------------------------------------------------------------------- 702 function GeometryCalib=calib_tsai(Coord,handles)% old version using gauthier's bianry ccal_fo703 function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo 703 704 % NOT USED 704 705 %------------------------------------------------------------------------ … … 811 812 huvmat=findobj(allchild(0),'Name','uvmat'); 812 813 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 813 RootPath='';814 RootFile='';814 % RootPath=''; 815 % RootFile=''; 815 816 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 816 817 testhandle=1; … … 830 831 listfile={outputfile}; 831 832 else 832 listfile=[listfile;{outputfile}] %update the list of coord files833 listfile=[listfile;{outputfile}];%update the list of coord files 833 834 end 834 835 set(handles.coord_files,'string',listfile); … … 901 902 end 902 903 coord_str=Coord_cell{val}; 903 k=findstr(' |',coord_str);904 k=findstr(' | ',coord_str); 904 905 if isempty(k)%last line '.....' selected 905 906 if ~isempty(hhh) … … 1000 1001 %------------------------------------------------------------------------ 1001 1002 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 1002 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface1003 %UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 1003 1004 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat 1004 hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat1005 %hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat 1005 1006 h_menu_coord=findobj(huvmat,'Tag','transform_fct'); 1006 1007 menu=get(h_menu_coord,'String'); … … 1079 1080 1080 1081 %size(data.Coord,1) 1081 Tabchar=cell2tab(Coord,' |');1082 Tabchar=cell2tab(Coord,' | '); 1082 1083 Tabchar=[Tabchar ;{'......'}]; 1083 1084 set(handles.ListCoord,'String',Tabchar) … … 1236 1237 Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits 1237 1238 end 1238 Tabchar=cell2tab(Coord(end:-1:1,:),' |');1239 Tabchar=cell2tab(Coord(end:-1:1,:),' | '); 1239 1240 Tabchar=[Tabchar ;{'......'}]; 1240 1241 set(handles.ListCoord,'Value',1) … … 1266 1267 end 1267 1268 end 1268 Tabchar=cell2tab(Coord,' |');1269 Tabchar=cell2tab(Coord,' | '); 1269 1270 Tabchar=[Tabchar; {'.....'}]; 1270 1271 %set(handles.ListCoord,'Value',1) … … 1310 1311 end 1311 1312 end 1312 Tabchar=cell2tab(Coord,' |');1313 Tabchar=cell2tab(Coord,'| '); 1313 1314 Tabchar=[Tabchar;{'......'}]; 1314 1315 set(handles.ListCoord,'Value',1) … … 1460 1461 end 1461 1462 CoordCell=reshape(CoordCell,[],5); 1462 Tabchar=cell2tab(CoordCell,' |');%transform cells into table ready for display1463 Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1463 1464 Tabchar=[Tabchar;{'......'}]; 1464 1465 set(handles.ListCoord,'Value',1) … … 1541 1542 1542 1543 % ----------------------------------------------------------------------- 1543 function loadfile(handles,fileinput) 1544 %------------------------------------------------------------------------ 1544 function Heading=loadfile(handles,fileinput) 1545 %------------------------------------------------------------------------ 1546 Heading=[];%default 1545 1547 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib'); 1548 if ~isempty(errormsg) 1549 msgbox_uvmat('ERROR',['Error for reading ' fileinput ': ' errormsg]) 1550 return 1551 end 1552 if ~isempty(s.Heading) 1553 Heading=s.Heading; 1554 end 1555 1546 1556 GeometryCalib=s.GeometryCalib; 1547 1557 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default … … 1585 1595 end 1586 1596 CoordCell=reshape(CoordCell,[],5); 1587 Tabchar=cell2tab(CoordCell,' |');%transform cells into table ready for display1597 Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1588 1598 MenuPlot_Callback(handles.geometry_calib, [], handles) 1589 1599 end -
trunk/src/get_field.m
r107 r128 32 32 'gui_LayoutFcn', [] , ... 33 33 'gui_Callback', []); 34 if nargin & isstr(varargin{1})34 if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) 35 35 gui_State.gui_Callback = str2func(varargin{1}); 36 36 end … … 48 48 %------------------------------------------------------------------------ 49 49 global nb_builtin 50 51 %% look at the existing figues in the work space 50 52 browse_fig(handles.list_fig) 51 53 52 % Choose default command line output for get_field54 %% Choose default command line output for get_field 53 55 handles.output = hObject; 54 56 55 % Update handles structure57 %% Update handles structure 56 58 guidata(hObject, handles); 57 59 58 %ACTION menu: builtin fcts 59 menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included in 'get_field.m' 60 %% activate the mouse action function: visualise the current field on work space by right click action 61 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles}) 62 63 %% prepare the list of builtin fcts and set their paths 64 menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included by default in 'get_field.m' 60 65 nb_builtin=numel(menu_str); 61 66 path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat' … … 72 77 end 73 78 rmpath(fullfile(path_uvmat,'get_field')) 74 75 79 dir_perso=prefdir; 76 80 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); … … 102 106 set(handles.path_action,'String',fullfile(path_uvmat,'get_field')) 103 107 set(handles.ACTION,'Value',1)% PLOT option selected 104 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})%set mouse click action function 105 if exist('filename','var')& ischar(filename) 108 109 %% settings for 'slave' mode, called by uvamt, or 'master' mode 110 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 106 111 set(handles.inputfile,'String',filename)% prefill the input file name 107 112 set(handles.inputfile,'Enable','off')% desactivate the input file edit box … … 113 118 set(handles.MenuHelp,'Visible','off') 114 119 inputfile_Callback(hObject, eventdata, handles) 115 else 120 else %master mode 116 121 set(handles.inputfile,'String','') 117 end 118 %ACTION_Callback(hObject, eventdata, handles) 119 if exist('Field','var') & isstruct(Field) 122 % load the list of previously browsed files for the upper bar menu Open 123 dir_perso=prefdir; 124 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% 125 if exist(profil_perso,'file') 126 h=load (profil_perso); 127 if isfield(h,'MenuFile_1') 128 set(handles.MenuFile_1,'Label',h.MenuFile_1); 129 end 130 if isfield(h,'MenuFile_1') 131 set(handles.MenuFile_2,'Label',h.MenuFile_2); 132 end 133 if isfield(h,'MenuFile_1') 134 set(handles.MenuFile_3,'Label',h.MenuFile_3); 135 end 136 if isfield(h,'MenuFile_1') 137 set(handles.MenuFile_4,'Label',h.MenuFile_4); 138 end 139 if isfield(h,'MenuFile_1') 140 set(handles.MenuFile_5,'Label',h.MenuFile_5); 141 end 142 end 143 end 144 %transfer input field in slave mode 145 if exist('Field','var') && isstruct(Field) 120 146 Field_input(eventdata,handles,Field) 121 if exist('haxes','var') 122 Field.PlotAxes=haxes; 123 end 147 % if exist('haxes','var') 148 % 'TESTget' 149 % get(haxes,'Tag') 150 % Field.PlotAxes=haxes; 151 % end 124 152 set(hObject,'UserData',Field); 125 153 end 126 154 127 %load the list of previously browsed files in menus Open 128 dir_perso=prefdir; 129 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% 130 if exist(profil_perso,'file') 131 h=load (profil_perso); 132 if isfield(h,'MenuFile_1') 133 set(handles.MenuFile_1,'Label',h.MenuFile_1); 134 end 135 if isfield(h,'MenuFile_1') 136 set(handles.MenuFile_2,'Label',h.MenuFile_2); 137 end 138 if isfield(h,'MenuFile_1') 139 set(handles.MenuFile_3,'Label',h.MenuFile_3); 140 end 141 if isfield(h,'MenuFile_1') 142 set(handles.MenuFile_4,'Label',h.MenuFile_4); 143 end 144 if isfield(h,'MenuFile_1') 145 set(handles.MenuFile_5,'Label',h.MenuFile_5); 146 end 147 end 155 148 156 149 157 %------------------------------------------------------------------------ … … 822 830 end 823 831 824 % ------------------------------------------------825 % --- Executes on button press in Plot_histo.826 % RUN global histograms827 % -------------------------------------------------828 function RUN_histo_Callback(hObject, eventdata, handles)829 % hObject handle to RUN (see GCBO)830 % eventdata reserved - to be defined in a future version of MATLAB831 % handles structure with handles and user data (see GUIDATA)832 833 % time plots834 leg={};835 n=0;836 if (get(handles.cm_switch,'Value')==1)837 Uval_p=Uval_cm;838 Vval_p=Vval_cm;839 Uhist_p=Uhist_cm;840 Vhist_p=Vhist_cm;841 xlab='velocity (cm/s)';842 else843 Uval_p=Uval;844 Vval_p=Vval;845 Uhist_p=Uhist;846 Vhist_p=Vhist;847 xlab='velocity (pixels)';848 end849 if (get(handles.vector_y,'Value') == 1)850 hhh=figure(2);851 hold on852 title([filebase ', ' strindex ', ' fieldtitle])853 plot(Uval_p,Uhist_p,'b-')854 n=n+1;855 leg{n}='Uhist';856 xlabel(xlab)857 end858 if (get(handles.Vhist_input,'Value') == 1)859 hhh=figure(2);860 hold on861 title([filebase ', ' strindex ', ' fieldtitle])862 plot(Vval_p,Vhist_p,'r-')863 n=n+1;864 leg{n}='Vhist';865 xlabel(xlab);866 end867 if (get(handles.Chist_input,'Value') == 1)868 hhhh=figure(3);869 hold on870 title([filebase ', ' strindex ', ' fieldtitle])871 plot(Cval,Chist,'k-')872 leg{1}='Chist';873 end874 % hold off875 grid on876 legend(leg);832 % %------------------------------------------------ 833 % % --- Executes on button press in Plot_histo. 834 % %RUN global histograms 835 % %------------------------------------------------- 836 % function RUN_histo_Callback(hObject, eventdata, handles) 837 % % hObject handle to RUN (see GCBO) 838 % % eventdata reserved - to be defined in a future version of MATLAB 839 % % handles structure with handles and user data (see GUIDATA) 840 % 841 % %time plots 842 % leg={}; 843 % n=0; 844 % if (get(handles.cm_switch,'Value')==1) 845 % Uval_p=Uval_cm; 846 % Vval_p=Vval_cm; 847 % Uhist_p=Uhist_cm; 848 % Vhist_p=Vhist_cm; 849 % xlab='velocity (cm/s)'; 850 % else 851 % Uval_p=Uval; 852 % Vval_p=Vval; 853 % Uhist_p=Uhist; 854 % Vhist_p=Vhist; 855 % xlab='velocity (pixels)'; 856 % end 857 % if (get(handles.vector_y,'Value') == 1) 858 % hhh=figure(2); 859 % hold on 860 % title([filebase ', ' strindex ', ' fieldtitle]) 861 % plot(Uval_p,Uhist_p,'b-') 862 % n=n+1; 863 % leg{n}='Uhist'; 864 % xlabel(xlab) 865 % end 866 % if (get(handles.Vhist_input,'Value') == 1) 867 % hhh=figure(2); 868 % hold on 869 % title([filebase ', ' strindex ', ' fieldtitle]) 870 % plot(Vval_p,Vhist_p,'r-') 871 % n=n+1; 872 % leg{n}='Vhist'; 873 % xlabel(xlab); 874 % end 875 % if (get(handles.Chist_input,'Value') == 1) 876 % hhhh=figure(3); 877 % hold on 878 % title([filebase ', ' strindex ', ' fieldtitle]) 879 % plot(Cval,Chist,'k-') 880 % leg{1}='Chist'; 881 % end 882 % % hold off 883 % grid on 884 % legend(leg); 877 885 878 886 % %------------------------------------------------------------- … … 1028 1036 var_select=list_var{index}; 1029 1037 set(handles.attributes_txt,'String', ['attributes of ' var_select]) 1030 if isfield(Field,'VarAttribute')& length(Field.VarAttribute)>=index-11038 if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 1031 1039 % nbline=0; 1032 1040 VarAttr=Field.VarAttribute{index-1}; … … 1050 1058 Tabchar=[{''};Tabchar]; 1051 1059 end 1060 set(handles.attributes,'Value',1);% select the first item 1052 1061 set(handles.attributes,'String',Tabchar); 1053 1062 -
trunk/src/get_plot_handles.m
r61 r128 19 19 PlotHandles.Contours=handles.Contours; 20 20 PlotHandles.IncrA=handles.IncrA; 21 PlotHandles.SCALAR_title=handles.SCALAR_title;21 %PlotHandles.SCALAR_title=handles.SCALAR_title; 22 22 PlotHandles.min_title=handles.min_title; 23 23 PlotHandles.max_title=handles.max_title; … … 30 30 %For vector field representation 31 31 PlotHandles.frame_vect=handles.frame_vect; 32 PlotHandles.VECT_title=handles.VECT_title;32 %PlotHandles.VECT_title=handles.VECT_title; 33 33 PlotHandles.VecScale=handles.VecScale; 34 34 PlotHandles.AutoVec=handles.AutoVec; -
trunk/src/plot_field.m
r109 r128 105 105 % use htext: handles of the text edit box (uicontrol) 106 106 % introduce PlotParam.Hold: 'on' or 'off' (for curves) 107 107 108 108 %default output 109 109 if ~exist('PlotParam','var'),PlotParam=[];end; … … 127 127 if ishandle(haxes) 128 128 if isequal(get(haxes,'Type'),'axes') 129 axes(haxes)129 % axes(haxes) 130 130 testnewfig=0; 131 131 AxeData=get(haxes,'UserData'); … … 139 139 end 140 140 end 141 141 142 if testnewfig% create a new figure and axes if the plotting axes does not exist 142 143 hfig=figure; … … 157 158 haxes=axes; 158 159 set(haxes,'position',[0.13,0.2,0.775,0.73]) 159 else160 hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab161 160 end 162 161 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1) … … 182 181 [Data.NbDim]=max(NbDim); 183 182 end 183 errormsg=[]; 184 184 if isequal(Data.NbDim,0) 185 185 AxeData=plot_text(Data,htext); 186 186 PlotType='text'; 187 errormsg=[]; 187 188 elseif isequal(Data.NbDim,1) 188 [AxeData ,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%189 [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);% 189 190 if testzoomaxes 190 191 [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam); … … 192 193 end 193 194 PlotType='line'; 195 errormsg=[]; 194 196 elseif isequal(Data.NbDim,2) 195 197 ind_select=find(NbDim>=2); 196 198 if numel(ind_select)>2 197 msgbox_uvmat('ERROR','more than two fields to map') 198 display('more than two fields to map') 199 return 200 end 201 [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar); 202 if testzoomaxes 203 [AxeData,zoomaxes,PlotParamOut]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar); 204 %AxeData.ZoomAxes=zoomaxes; 205 Data.ZoomAxes=zoomaxes; 199 errormsg='more than two fields to map'; 200 else 201 [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar); 202 if testzoomaxes && isempty(errormsg) 203 [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar); 204 %AxeData.ZoomAxes=zoomaxes; 205 Data.ZoomAxes=zoomaxes; 206 end 206 207 end 207 208 elseif isequal(Data.NbDim,3) 209 errormsg='volume plot not implemented yet'; 210 end 211 if ~isempty(errormsg) 208 212 msgbox_uvmat('ERROR','volume plot not implemented yet') 209 213 return 210 % else211 % testnbdim=0;212 214 end 213 215 … … 234 236 %set(haxes,'UserData',AxeData) 235 237 set(haxes,'UserData',Data) 236 if ~testnewfig237 set(0,'Children',hstack);%put back the initial figure stack after plot creation238 % set(haxes,'Tag','uvmat');239 end238 % if ~testnewfig 239 % %set(0,'Children',hstack);%put back the initial figure stack after plot creation 240 % 241 % end 240 242 241 243 … … 303 305 function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam) 304 306 %------------------------------------------------------------------- 305 %axes(haxes) 307 %TODO: modify existing plot if it exists 308 306 309 hfig=get(haxes,'parent'); 307 310 AxeData=data; … … 322 325 legend_str={}; 323 326 324 %initiates string of the plot command 327 %% prepare the string for plot command 328 %initiate the plot command 325 329 plotstr='hhh=plot('; 326 330 textmean={}; 327 % abscissa_name='';328 331 coord_x_index=[]; 329 332 test_newplot=1; … … 331 334 % num_curve=numel(hh); 332 335 % icurve=0; 336 337 %loop on input fields 333 338 for icell=1:length(CellVarIndex) 334 testfalse=0;335 339 VarIndex=CellVarIndex{icell};% indices of the selected variables in the list data.ListVarName 336 DimCell=data.VarDimName{VarIndex(1)};337 if ischar(DimCell)338 DimCell={DimCell};339 end340 XName=DimCell{1}; %first dimension considered as abscissa341 340 if ~isempty(VarType{icell}.coord_x) 342 341 coord_x_index=VarType{icell}.coord_x; … … 353 352 end 354 353 testplot=ones(size(data.ListVarName));%default test for plotted variables 355 testcoordvar=0;356 charplot_0='''-''';%default357 if isfield(data,'ObjectProjMode')&& isequal(data.ObjectProjMode,'projection')358 charplot_0='+';359 end360 xtitle='';361 362 354 xtitle=data.ListVarName{coord_x_index}; 363 355 eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x 364 356 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units') 365 357 xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')']; 366 358 end 367 359 eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x 368 % testcoordvar=1;369 360 testplot(coord_x_index)=0; 370 361 if ~isempty(VarType{icell}.ancillary') 371 362 testplot(VarType{icell}.ancillary)=0; 372 363 end 373 364 if ~isempty(VarType{icell}.warnflag') 374 testplot(VarType{icell}.warnflag)=0; 375 end 376 365 testplot(VarType{icell}.warnflag)=0; 366 end 377 367 if isfield(data,'VarAttribute') 378 368 VarAttribute=data.VarAttribute; 379 for ivar=1:length(VarIndex)380 if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name')381 plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name;382 else383 plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE384 end385 end386 end387 % test_newplot=0;%default388 % if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves389 % if ~isempty(VarType{icell}.discrete')390 % charplot_0='+';391 % LineStyle='none';392 % else393 % charplot_0='none';394 % LineStyle='-';395 % end396 % for ivar=1:length(VarIndex)397 % if testplot(VarIndex(ivar))398 % icurve=icurve+1;399 % VarName=data.ListVarName{VarIndex(ivar)};400 % eval(['data.' VarName '=squeeze(data.' VarName ');'])401 % set(hh(icurve),'LineStyle',LineStyle)402 % set(hh(icurve),'Marker',charplot_0)403 % set(hh(icurve),'XData',coord_x{icell})404 % eval(['yy=data.' VarName ';'])405 % set(hh(icurve),'YData',yy);406 % end407 % end408 % else% new plot409 if ~isempty(VarType{icell}.discrete')410 charplot_0='''+''';411 else412 charplot_0='''-''';413 end414 369 for ivar=1:length(VarIndex) 415 if testplot(VarIndex(ivar)) 416 VarName=data.ListVarName{VarIndex(ivar)}; 417 eval(['data.' VarName '=squeeze(data.' VarName ');']) 418 % if isequal(VarName,'A') 419 % charplot='''-'''; 420 % else 421 % charplot=charplot_0; 422 % end 423 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; 424 eval(['nbcomponent2=size(data.' VarName ',2);']); 425 eval(['nbcomponent1=size(data.' VarName ',1);']); 426 if numel(coord_x{icell})==2 427 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1); 428 end 429 eval(['varmean=mean(double(data.' VarName '));']);%mean value 430 textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}]; 431 if nbcomponent1==1|| nbcomponent2==1 432 legend_str=[legend_str {VarName}]; %variable with one component 433 else %variable with severals components 434 for ic=1:min(nbcomponent1,nbcomponent2) 435 legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals components 436 end % labeled by their index (e.g. color component) 437 end 438 end 439 end 440 % end 441 end 370 if length(VarAttribute)>=VarIndex(ivar) && isfield(VarAttribute{VarIndex(ivar)},'long_name') 371 plotname{VarIndex(ivar)}=VarAttribute{VarIndex(ivar)}.long_name; 372 else 373 plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE 374 end 375 end 376 end 377 % test_newplot=0;%default 378 % if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves 379 % if ~isempty(VarType{icell}.discrete') 380 % charplot_0='+'; 381 % LineStyle='none'; 382 % else 383 % charplot_0='none'; 384 % LineStyle='-'; 385 % end 386 % for ivar=1:length(VarIndex) 387 % if testplot(VarIndex(ivar)) 388 % icurve=icurve+1; 389 % VarName=data.ListVarName{VarIndex(ivar)}; 390 % eval(['data.' VarName '=squeeze(data.' VarName ');']) 391 % set(hh(icurve),'LineStyle',LineStyle) 392 % set(hh(icurve),'Marker',charplot_0) 393 % set(hh(icurve),'XData',coord_x{icell}) 394 % eval(['yy=data.' VarName ';']) 395 % set(hh(icurve),'YData',yy); 396 % end 397 % end 398 % else% new plot 399 if ~isempty(VarType{icell}.discrete') 400 charplot_0='''+'''; 401 else 402 charplot_0='''-'''; 403 end 404 for ivar=1:length(VarIndex) 405 if testplot(VarIndex(ivar)) 406 VarName=data.ListVarName{VarIndex(ivar)}; 407 eval(['data.' VarName '=squeeze(data.' VarName ');']) 408 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; 409 eval(['nbcomponent2=size(data.' VarName ',2);']); 410 eval(['nbcomponent1=size(data.' VarName ',1);']); 411 if numel(coord_x{icell})==2 412 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1); 413 end 414 eval(['varmean=mean(double(data.' VarName '));']);%mean value 415 textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}]; 416 if nbcomponent1==1|| nbcomponent2==1 417 legend_str=[legend_str {VarName}]; %variable with one component 418 else %variable with severals components 419 for ic=1:min(nbcomponent1,nbcomponent2) 420 legend_str=[legend_str [VarName '_' num2str(ic)]]; %variable with severals components 421 end % labeled by their index (e.g. color component) 422 end 423 end 424 end 425 end 426 427 %% activate the plot 442 428 if test_newplot && ~isequal(plotstr,'hhh=plot(') 443 429 plotstr=[plotstr '''tag'',''plot_line'');']; 444 430 %execute plot (instruction plotstr) 431 axes(haxes)% select the plotting axes for plot operation 445 432 eval(plotstr) 446 433 … … 502 489 503 490 %------------------------------------------------------------------- 504 function [AxeData,haxes,PlotParamOut,PlotType ]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)491 function [AxeData,haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar) 505 492 %------------------------------------------------------------------- 493 506 494 grid(haxes, 'off') 507 495 %default plotting parameters … … 517 505 end 518 506 PlotParamOut=PlotParam;%default 519 520 %plotting axes521 507 hfig=get(haxes,'parent'); 522 508 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes … … 530 516 AxeData.ObjectCoord=Data.ObjectCoord; 531 517 end 532 518 errormsg=[];%default 533 519 test_ima=0; %default: test for image or map plot 534 520 test_vec=0; %default: test for vector plots … … 548 534 ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields 549 535 if numel(ivar_C)>1 550 msgbox_uvmat('ERROR','error in plot_field: too many scalar inputs')536 errormsg= 'error in plot_field: too many scalar inputs'; 551 537 return 552 538 end … … 558 544 end 559 545 % idim_Y=[]; 560 test_grid=0;546 % test_grid=0; 561 547 if ~isempty(ivar_U) && ~isempty(ivar_V)% vector components detected 562 548 if test_vec 563 msgbox_uvmat('ERROR','error in plot_field: attempt to plot two vector fields')549 errormsg='error in plot_field: attempt to plot two vector fields'; 564 550 return 565 551 else … … 570 556 eval(['vec_X=Data.' Data.ListVarName{ivar_X} ';']) 571 557 eval(['vec_Y=Data.' Data.ListVarName{ivar_Y} ';']) 572 elseif numel(VarType.coord)==2 & VarType.coord~=[0 0];%coordinates defines by dimension variables558 elseif numel(VarType.coord)==2 && ~isequal(VarType.coord,[0 0]);%coordinates defines by dimension variables 573 559 eval(['y=Data.' Data.ListVarName{VarType.coord(1)} ';']) 574 560 eval(['x=Data.' Data.ListVarName{VarType.coord(2)} ';']) … … 581 567 [vec_X,vec_Y]=meshgrid(x,y); 582 568 else 583 msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition for vector field')569 errormsg='error in plot_field: invalid coordinate definition for vector field'; 584 570 return 585 571 end … … 605 591 elseif ~isempty(ivar_C) %scalar or image 606 592 if test_ima 607 msgbox_uvmat('ERROR','attempt to plot two scalar fields or images')593 errormsg='attempt to plot two scalar fields or images'; 608 594 return 609 595 end … … 635 621 x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')']; 636 622 end 637 if numel(Data.VarAttribute)>=VarType.coord(1) & isfield(Data.VarAttribute{VarType.coord(1)},'units')623 if numel(Data.VarAttribute)>=VarType.coord(1) && isfield(Data.VarAttribute{VarType.coord(1)},'units') 638 624 y_units=['(' Data.VarAttribute{VarType.coord(1)}.units ')']; 639 625 end … … 644 630 DAY_max=max(DAY); 645 631 if sign(DAY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise 646 errormsg=['errror in plot_field.m: non monotonic dimension variable # 'ListVarName{VarType.coord(1)} ];632 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarType.coord(1)} ]; 647 633 return 648 634 end … … 654 640 DAX_max=max(DAX); 655 641 if sign(DAX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise 656 errormsg=['errror in plot_field.m: non monotonic dimension variable # 'ListVarName{VarType.coord(2)} ];642 errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarType.coord(2)} ]; 657 643 return 658 644 end … … 682 668 AY=[AY(1) AY(end)]; 683 669 else 684 msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition ')670 errormsg='error in plot_field: invalid coordinate definition '; 685 671 return 686 672 end 687 x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];673 %x_label=[Data.ListVarName{ivar_X} '(' x_units ')']; 688 674 end 689 675 end 690 676 691 %% %%%%%%%%%%%%%%%%%%%image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%677 %% image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%% 692 678 693 679 if ~isfield(PlotParam.Scalar,'Contours') … … 700 686 siz=numel(np); 701 687 if siz>3 702 msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(siz) ' dimensions'])688 errormsg=['unrecognized scalar type: ' num2str(siz) ' dimensions']; 703 689 return 704 690 end … … 709 695 siz=3;%color image 710 696 else 711 msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(np(3)) ' color components'])697 errormsg=['unrecognized scalar type: ' num2str(np(3)) ' color components']; 712 698 return 713 699 end 714 700 end 701 715 702 %set the color map 716 703 if isfield(PlotParam.Scalar,'BW') … … 719 706 BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default 720 707 end 721 if siz==2 %for black and white images 708 709 %case of grey level images or contour plot 710 if siz==2 722 711 if ~isfield(PlotParam.Scalar,'AutoScal') 723 712 PlotParam.Scalar.AutoScal=0;%default … … 729 718 PlotParam.Scalar.MaxA=[];%default 730 719 end 731 if isequal(PlotParam.Scalar.AutoScal,0)| isempty(PlotParam.Scalar.MinA)|~isa(PlotParam.Scalar.MinA,'double') %correct if there is no numerical data in edit box720 if isequal(PlotParam.Scalar.AutoScal,0)||isempty(PlotParam.Scalar.MinA)||~isa(PlotParam.Scalar.MinA,'double') %correct if there is no numerical data in edit box 732 721 MinA=double(min(min(A))); 733 722 else … … 741 730 PlotParamOut.Scalar.MinA=MinA; 742 731 PlotParamOut.Scalar.MaxA=MaxA; 743 axes(haxes) 732 733 % case of contour plot 744 734 if isequal(PlotParam.Scalar.Contours,1) 745 if ~isempty(hima) & ishandle(hima)735 if ~isempty(hima) && ishandle(hima) 746 736 delete(hima) 747 737 end … … 770 760 txt=ver;%version of Matlab 771 761 Release=txt(1).Release; 772 relnumb=str2 num(Release(3:4));762 relnumb=str2double(Release(3:4)); 773 763 if relnumb >= 14 774 764 vec=linspace(0,1,(abscontmax-abscontmin)/intercont);%define a greyscale colormap with steps intercont … … 788 778 colormap(map); 789 779 end 780 781 % set colormap for image display 790 782 if ~isequal(PlotParam.Scalar.Contours,1) 791 783 % rescale the grey levels with min and max, put a grey scale colorbar … … 799 791 end 800 792 end 801 else %color images 802 axes(haxes) 793 794 % case of color images 795 else 803 796 if BW 804 797 B=uint16(sum(A,3)); … … 809 802 MaxA=255; 810 803 end 811 if ~isequal(PlotParam.Scalar.Contours,1) 812 %interpolate to increase resolution 804 805 % display usual image 806 if ~isequal(PlotParam.Scalar.Contours,1) 807 % interpolate field to increase resolution of image display 813 808 test_interp=1; 814 809 if max(np) <= 64 … … 829 824 yi=linspace(AY(1),AY(2),npxy(1)); 830 825 B = interp2(X,Y,double(B),xi,yi'); 831 end 826 end 827 % create new image if there no image handle is found 832 828 if isempty(hima) 829 % axes(haxes)% set haxes the current axes for image creation 830 set(hfig,'CurrentAxes',haxes) % set haxes the current axes for image creation 833 831 tag=get(haxes,'Tag'); 834 832 if MinA<MaxA 835 833 hima=imagesc(AX,AY,B,[MinA MaxA]); 836 else 834 else % to deal with uniform field 837 835 hima=imagesc(AX,AY,B,[MaxA-1 MaxA]); 838 836 end 839 837 set(hima,'Tag','ima','HitTest','off') 840 set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!) 838 set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!) 839 % update an existing image 841 840 else 842 841 set(hima,'CData',B); … … 857 856 AxeData.AY=[AY(1) AY(end)]; 858 857 test_ima=1; 858 859 859 %display the colorbar code for B/W images if Poscolorbar not empty 860 860 if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar) … … 865 865 set(hcol,'Position',PosColorbar) 866 866 end 867 YTick=0;%default867 %YTick=0;%default 868 868 if MaxA>MinA 869 869 if isequal(PlotParam.Scalar.Contours,1) … … 873 873 YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin); 874 874 set(hcol,'YTick',YTick_scaled); 875 elseif (isfield(PlotParam.Scalar,'BW') & isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16')%images875 elseif (isfield(PlotParam.Scalar,'BW') && isequal(PlotParam.Scalar.BW,1))||isa(A,'uint8')|| isa(A,'uint16')%images 876 876 hi=get(hcol,'children'); 877 877 if iscell(hi)%multiple images in colorbar … … 879 879 end 880 880 set(hi,'YData',[MinA MaxA]) 881 set(hi,'CData', [1:256]')881 set(hi,'CData',(1:256)') 882 882 set(hcol,'YLim',[MinA MaxA]) 883 883 YTick=colbartick(MinA,MaxA); … … 889 889 end 890 890 set(hi,'YData',[MinA MaxA]) 891 set(hi,'CData', [1:64]')891 set(hi,'CData',(1:64)') 892 892 YTick=colbartick(MinA,MaxA); 893 893 set(hcol,'YLim',[MinA MaxA]) … … 912 912 end 913 913 914 %% %%%%%%%%%%%%%%%%%%%vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%914 %% vector plot %%%%%%%%%%%%%%%%%%%%%%%%%% 915 915 if test_vec 916 916 %vector scale representation … … 927 927 if ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')... 928 928 ||isempty(PlotParam.Vectors.VecScale)||~isa(PlotParam.Vectors.VecScale,'double') %automatic vector scale 929 scale=[];929 % scale=[]; 930 930 if test_false %remove false vectors 931 931 indsel=find(AxeData.FF==0);%indsel =indices of good vectors … … 1045 1045 listdim={'AY','AX',{'AY','AX'},'nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors'}; 1046 1046 Role={'coord_y','coord_x','scalar','coord_x','coord_y','vector_x','vector_y','scalar','vector_z','warnflag','errorflag'}; 1047 ind_select=[];1047 %ind_select=[]; 1048 1048 nbvar=0; 1049 1049 AxeData.ListVarName={}; … … 1168 1168 isn=isnan(colorlist(icolor,:));%test if color NaN 1169 1169 if 2*icolor > sizh(1) %if icolor exceeds the number of existing ones 1170 axes(haxes) 1170 %axes(haxes) 1171 hfig=get(haxes,'parent'); 1172 % axes(haxes) 1173 set(0,'CurrentFigure',hfig) 1174 set(hfig,'CurrentAxes',haxes) 1171 1175 if ~isn(1) %if the vectors are visible color not nan 1172 1176 if n(2)>0 -
trunk/src/read_geometry_calib.m
r71 r128 9 9 k=findstr('|',coord_str);%find separators '|' 10 10 if length(k)>=4 % test for separators '|' 11 data1=str2 num(coord_str(1:k(1)-5));12 data2=str2 num(coord_str(k(1)+5:k(2)-5));13 data3=str2 num(coord_str(k(2)+5:k(3)-5));14 data4=str2 num(coord_str(k(3)+5:k(4)-5));15 data5=str2 num(coord_str(k(4)+5:end));16 if ~is empty(data1)||~isempty(data2)||~isempty(data3)||~isempty(data4)||~isempty(data5)11 data1=str2double(coord_str(1:k(1)-2)); 12 data2=str2double(coord_str(k(1)+2:k(2)-2)); 13 data3=str2double(coord_str(k(2)+2:k(3)-2)); 14 data4=str2double(coord_str(k(3)+2:k(4)-2)); 15 data5=str2double(coord_str(k(4)+2:end)); 16 if ~isnan(data1)||~isnan(data2)||~isnan(data3)||~isnan(data4)||~isnan(data5) 17 17 iline=iline+1; 18 if ~is empty(data1)18 if ~isnan(data1) 19 19 data.Coord(iline,1)=data1; 20 20 end 21 if ~is empty(data2)21 if ~isnan(data2) 22 22 data.Coord(iline,2)=data2; 23 23 end 24 if ~is empty(data3)24 if ~isnan(data3) 25 25 data.Coord(iline,3)=data3; 26 26 end 27 if ~is empty(data4)27 if ~isnan(data4) 28 28 data.Coord(iline,4)=data4; 29 29 end 30 if is empty(data5)30 if isnan(data5) 31 31 data.Coord(iline,5)=0; 32 32 else -
trunk/src/series/aver_stat.m
r107 r128 277 277 if ~isequal(m2,'') 278 278 msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation 279 end 280 [xx,msg2] = fileattrib(subdir_result,'+w','g'); %yield writing access (+w) to user group (g) 281 if ~strcmp(msg2,'') 282 msgbox_uvmat('ERROR',['pb of permission for ' subdir_result ': ' msg2])%error message for directory creation 283 cd(curdir) 284 return 279 285 end 280 286 cd(dircur) %back to the initial working directory -
trunk/src/series/ima_levels.m
r71 r128 21 21 cd(path); 22 22 mkdir([subdir_ima '_levels']); 23 [xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g) 24 if ~strcmp(msg2,'') 25 msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation 26 cd(dircur) 27 return 28 end 29 cd(dircur); 23 30 cd(curdir); 24 31 basename_new=fullfile(path,[subdir_ima '_levels'],namebase); -
trunk/src/series/merge_proj.m
r127 r128 234 234 succeed=mkdir(subdir); 235 235 if succeed 236 cd(dircur); 236 [xx,msg2] = fileattrib(res_subdir,'+w','g'); %yield writing access (+w) to user group (g) 237 if ~strcmp(msg2,'') 238 msgbox_uvmat('ERROR',['pb of permission for ' res_subdir ': ' msg2])%error message for directory creation 239 cd(dircur) 240 return 241 end 242 cd(dircur); 237 243 else 238 msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])239 return240 end 244 msgbox_uvmat('ERROR',['Cannot create directory ' fulldir]) 245 return 246 end 241 247 end 242 248 filebasesub=fullfile(res_subdir,Series.RootFile{1}); -
trunk/src/series/relabel_i_j.m
r71 r128 21 21 cd(path); 22 22 mkdir([subdir_ima '_ij']); 23 [xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g) 24 if ~strcmp(msg2,'') 25 msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation 26 cd(dircur) 27 return 28 end 23 29 cd(curdir); 24 30 basename_new=fullfile(path,[subdir_ima '_ij'],namebase); -
trunk/src/series/sub_background.m
r89 r128 115 115 cd(path); 116 116 mkdir([subdir_ima '_b']); 117 [xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g) 118 if ~strcmp(msg2,'') 119 msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation 120 cd(curdir) 121 return 122 end 117 123 cd(curdir); 118 124 filebase_b=fullfile(path,[subdir_ima '_b'],namebase); -
trunk/src/series/time_series.m
r107 r128 278 278 if ~isequal(m2,'') 279 279 msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation 280 end 281 [xx,msg2] = fileattrib(subdir_result,'+w','g'); %yield writing access (+w) to user group (g) 282 if ~strcmp(msg2,'') 283 msgbox_uvmat('ERROR',['pb of permission for ' subdir_result ': ' msg2])%error message for directory creation 284 cd(dircur) 285 return 280 286 end 281 287 cd(dircur) %back to the initial working directory -
trunk/src/struct2nc.m
r107 r128 42 42 return 43 43 end 44 hhh=which('netcdf.create');% look for built-in matlab library44 hhh=which('netcdf.create');% look for built-in matlab netcdf library 45 45 46 %USE OF built-in netcdf library46 %USE OF built-in matlab netcdf library 47 47 if ~isequal(hhh,'') 48 48 FilePath=fileparts(flname); … … 68 68 if ~testvar 69 69 eval(['cte=Data.' keys{iattr} ';']) 70 if (ischar(cte) ||isnumeric(cte)) && ~isempty(cte)&& ~isequal(cte,'') 70 if (ischar(cte) ||isnumeric(cte)) && ~isempty(cte)%&& ~isequal(cte,'') 71 %write constant only if it is numeric or char string, and not empty 71 72 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte) 72 else73 errormsg='global attributes must be characters or numbers';74 return75 73 end 76 74 end … … 79 77 end 80 78 %create dimensions 81 dimid= [];79 dimid=zeros(1,length(Data.ListDimName)); 82 80 for idim=1:length(Data.ListDimName) 83 dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 81 dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 84 82 end 85 83 VarAttribute={}; %default … … 89 87 testattr=1; 90 88 end 91 varid= [];89 varid=zeros(1,length(Data.ListVarName)); 92 90 for ivar=1:length(ListVarName) 93 varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},' double',dimid(Data.VarDimIndex{ivar}));%define variable91 varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(Data.VarDimIndex{ivar}));%define variable 94 92 end 95 93 %write variable attributes … … 117 115 VarDimName={VarDimName}; 118 116 end 119 testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2); 120 testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex)); 121 testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1); 117 testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values. 118 testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector 119 testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);%matlab column vector 122 120 if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex)) 123 121 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m']; … … 126 124 if testline || testrange 127 125 if testrange 128 VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex)); 126 VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));% restitute the whole array of coordinate values 129 127 end 130 %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates 131 netcdf.putVar(nc,varid(ivar), double(VarVal')); 128 netcdf.putVar(nc,varid(ivar), double(VarVal')); 132 129 else 133 130 netcdf.putVar(nc,varid(ivar), double(VarVal)); 134 %nc{ListVarName{ivar}}(:) = VarVal; 135 end 136 131 end 137 132 end 138 133 end 134 netcdf.close(nc) 139 135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 140 136 %OLD netcdf toolbox -
trunk/src/uvmat.m
r127 r128 181 181 'gui_LayoutFcn', [], ... 182 182 'gui_Callback', []); 183 if nargin && ischar(varargin{1}) 183 if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) 184 184 gui_State.gui_Callback = str2func(varargin{1}); 185 185 end … … 1151 1151 set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'}) 1152 1152 set(handles.Fields_1,'Value',2) % set menu to 'image' 1153 elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')1153 elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf') 1154 1154 Data=nc2struct(fileinput_1,[]); 1155 1155 if isfield(Data,'absolut_time_T0') … … 1621 1621 %------------------------------------------------------------------- 1622 1622 huvmat=get(handles.MenuExport,'parent'); 1623 UvData=get(huvmat,'UserData');1623 %UvData=get(huvmat,'UserData'); 1624 1624 hfig=figure; 1625 newaxes=copyobj(handles.axes3,hfig);1625 copyobj(handles.axes3,hfig); 1626 1626 map=colormap(handles.axes3); 1627 1627 colormap(map);%transmit the current colormap to the zoom fig … … 1641 1641 set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow 1642 1642 drawnow 1643 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d 1644 runpm(hObject,eventdata,handles,increment) 1645 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button in yellow 1643 %TODO: introduce the option: increment ='*' to move to the next available view 1644 increment=str2double(get(handles.increment_scan,'String')); %get the field increment d 1645 if isnan(increment) 1646 set(handles.increment_scan,'String','1')%default value 1647 increment=1; 1648 end 1649 errormsg=runpm(hObject,eventdata,handles,increment); 1650 if ~isempty(errormsg) 1651 msgbox_uvmat('ERROR',errormsg); 1652 end 1653 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red 1646 1654 1647 1655 %------------------------------------------------------------------- … … 1653 1661 set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow 1654 1662 drawnow 1655 increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d 1656 runpm(hObject,eventdata,handles,increment) 1657 set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button in yellow 1663 increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d 1664 if isnan(increment) 1665 set(handles.increment_scan,'String','1')%default value 1666 increment=1; 1667 end 1668 errormsg=runpm(hObject,eventdata,handles,increment); 1669 if ~isempty(errormsg) 1670 msgbox_uvmat('ERROR',errormsg); 1671 end 1672 set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red 1658 1673 1659 1674 %------------------------------------------------------------------- … … 1663 1678 set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow 1664 1679 drawnow 1665 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d 1680 increment=str2double(get(handles.increment_scan,'String')); %get the field increment d 1681 if isnan(increment) 1682 set(handles.increment_scan,'String','1')%default value 1683 increment=1; 1684 end 1666 1685 set(handles.STOP,'Visible','on') 1667 1686 set(handles.speed,'Visible','on') 1668 1687 set(handles.speed_txt,'Visible','on') 1669 1688 set(handles.Movie,'BusyAction','queue') 1670 testavi=0;1671 1689 UvData=get(handles.uvmat,'UserData'); 1672 1690 … … 1674 1692 errormsg=runpm(hObject,eventdata,handles,increment); 1675 1693 if ~isempty(errormsg) 1694 set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1676 1695 return 1677 1696 end … … 1690 1709 set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow 1691 1710 drawnow 1692 increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d 1711 increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d 1712 if isnan(increment) 1713 set(handles.increment_scan,'String','1')%default value 1714 increment=1; 1715 end 1693 1716 set(handles.STOP,'Visible','on') 1694 1717 set(handles.speed,'Visible','on') 1695 1718 set(handles.speed_txt,'Visible','on') 1696 1719 set(handles.MovieBackward,'BusyAction','queue') 1697 testavi=0;1698 1720 UvData=get(handles.uvmat,'UserData'); 1699 1721 1700 while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command1722 while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command 1701 1723 errormsg=runpm(hObject,eventdata,handles,increment); 1702 1724 if ~isempty(errormsg) 1725 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1703 1726 return 1704 1727 end … … 1760 1783 num1=num1+increment; 1761 1784 num2=num2+increment; 1762 [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir) 1785 [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir); 1763 1786 if sub_value% set the second field name and indices 1764 1787 num1_1=num1_1+increment; … … 1779 1802 % refresh plots 1780 1803 errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b); 1781 1782 1804 if isempty(errormsg) %update the index counters 1783 1805 set(handles.i1,'String',num2stra(num1,NomType,1)); … … 1803 1825 movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated 1804 1826 end 1805 else 1806 msgbox_uvmat('ERROR',errormsg); 1807 end 1808 1827 end 1809 1828 1810 1829 … … 1974 1993 end 1975 1994 set(handles.run0,'BackgroundColor',[1 0 0]) 1995 1976 1996 %------------------------------------------------------------------------ 1977 1997 % --- read the input files and refresh all the plots, including projection. … … 1983 2003 % num_i1,num_i2,num_j1,num_j2; frame indices 1984 2004 % Field: structure describing an optional input field (then replace the input file) 1985 1986 2005 function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field) 1987 2006 %------------------------------------------------------------------------ 1988 2007 1989 2008 %initialisation 1990 1991 errormsg=[]; % default error message 2009 % errormsg=[]; % default error message 1992 2010 abstime=[]; 1993 2011 abstime_1=[]; … … 2012 2030 end 2013 2031 2014 % determine the main input file information for action2032 %% determine the main input file information for action 2015 2033 FileType=[];%default 2016 2034 if ~isempty(filename) … … 2023 2041 %update the z position index 2024 2042 nbslice_str=get(handles.nb_slice,'String'); 2025 z_index=1;%default2043 % z_index=1;%default 2026 2044 if isequal(nbslice_str,'volume') 2027 2045 z_index=num_j1; … … 2074 2092 end 2075 2093 end 2076 2077 % choose a second field if Subfield option is 'on' 2094 %% choose a second field if Subfield option is 'on' 2078 2095 FieldName_1=[]; 2079 2096 scal_color=[]; 2080 2097 VelType_1=setfield_1(handles); 2081 sub_value=get(handles.SubField,'Value');2098 % sub_value=get(handles.SubField,'Value'); 2082 2099 FileType_1='none';%default 2083 2100 if ~isempty(filename_1) … … 2137 2154 end 2138 2155 2139 % read the input field(s)2156 %% read the input field(s) 2140 2157 %read images 2141 2158 if ~isempty(filename) && isequal(FieldName,'image') … … 2241 2258 hget_field= get_field(filename);%open the get_field GUI 2242 2259 set(hget_field,'name','uvmat_field') 2243 elseif UvData.NewSeries 2260 elseif UvData.NewSeries% refresh the fet_field GUI for a new series 2244 2261 delete(hget_field) 2245 2262 hget_field= get_field(filename);%open the get_field GUI 2246 set(hget_field,'name','uvmat_field') 2263 set(hget_field,'name','uvmat_field')%rename get_field GUI for the 'slave' mode 2247 2264 end 2248 2265 hhget_field=guidata(hget_field); 2249 2266 funct_list=get(hhget_field.ACTION,'UserData'); 2250 2267 funct_index=get(hhget_field.ACTION,'Value'); 2251 funct=funct_list{funct_index}; 2252 Field{1}=funct(hget_field); % read the names of the variables to plot in the get_field GUI2268 funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT 2269 Field{1}=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 2253 2270 CivStage=0; 2254 2271 VelType_out=[]; … … 2290 2307 end 2291 2308 2292 % update the display buttons for the first velocity type (first menuline)2309 %% update the display buttons for the first velocity type (first menuline) 2293 2310 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2]; 2294 2311 if ~isequal(FileType,'netcdf') … … 2304 2321 end 2305 2322 2306 % update the display buttons for the second velocity type (second menuline)2323 %% update the display buttons for the second velocity type (second menuline) 2307 2324 veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1]; 2308 2325 if ~isequal(FileType_1,'netcdf') … … 2318 2335 end 2319 2336 2320 % introduce w as background image by default for a new series (only for nbdim=2)2337 %% introduce w as background image by default for a new series (only for nbdim=2) 2321 2338 if ~isfield(UvData,'NewSeries') 2322 2339 UvData.NewSeries=1; … … 2342 2359 set(handles.Fields_1,'Visible','on'); 2343 2360 Field{1}.AName='w'; 2344 testscal=1;2361 % testscal=1; 2345 2362 end 2346 2363 end … … 2350 2367 isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord') 2351 2368 siz=size(UvData.XmlData.GeometryCalib.SliceCoord); 2352 if siz(1)>12353 NbSlice=siz(1);2354 else2355 NbSlice=1;2356 end2369 % if siz(1)>1 2370 % NbSlice=siz(1); 2371 % else 2372 % NbSlice=1; 2373 % end 2357 2374 end 2358 2375 … … 2368 2385 end 2369 2386 2370 % coordinate transform or user fct2387 %% coordinate transform or user fct 2371 2388 XmlData=[];%default 2372 2389 if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority … … 2377 2394 XmlData_1=UvData.XmlData_1; 2378 2395 end 2379 menu_transform=get(handles.transform_fct,'String');2396 % menu_transform=get(handles.transform_fct,'String'); 2380 2397 choice_value=get(handles.transform_fct,'Value'); 2381 2398 transform_list=get(handles.transform_fct,'UserData'); 2382 2399 transform=transform_list{choice_value};%selected function handles 2383 2384 2400 % z index 2385 2401 if ~isempty(filename) 2386 2402 Field{1}.ZIndex=z_index; 2387 2403 end 2388 2389 2404 %px to phys or other transform on field 2390 2405 if ~isempty(transform) … … 2400 2415 end 2401 2416 2402 % calculate scalar2417 %% calculate scalar 2403 2418 if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')% 2404 2419 Field{1}=calc_field(InputField,Field{1}); … … 2407 2422 Field{2}=calc_field(InputField_1,Field{2}); 2408 2423 end 2409 2410 2424 % combine the two input fields (e.g. substract velocity fields) 2411 2425 if numel(Field)==2 … … 2415 2429 end 2416 2430 2417 % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)2431 %% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object) 2418 2432 test_x=0; 2419 2433 test_z=0;% test for unstructured z coordinate … … 2478 2492 end 2479 2493 end 2494 2480 2495 %case of structured coordinates 2481 2496 if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A') … … 2572 2587 %multilevel case (single menuplane in a 3D space) 2573 2588 elseif isfield(UvData,'Z') 2574 if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys')& isfield(UvData,'XmlData')2589 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') 2575 2590 XmlData=UvData.XmlData; 2576 2591 if isfield(XmlData,'PlanePos') … … 2589 2604 end 2590 2605 2591 %Plot the projections on all existing projection objects 2592 keeplim=get(handles.FixedLimits,'Value'); 2593 %reset the min and max of scalar if only the mask is displayed 2594 if isfield(UvData,'Mask')&~isfield(UvData,'A') 2606 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) 2607 if isfield(UvData,'Mask')&& ~isfield(UvData,'A') 2595 2608 set(handles.MinA,'String','0') 2596 2609 set(handles.MaxA,'String','255') 2597 2610 end 2598 IndexObj(1)=get(handles.list_object_1,'Value'); 2599 haxes_1=handles.axes3; 2611 2612 %% Plot the projections on the selected projection objects 2613 2614 % main projection object (uvmat display) 2615 IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view 2600 2616 if IndexObj(1)> numel(UvData.Object) 2601 IndexObj(1)=1; 2602 haxes_1=handles.axes3; 2603 end 2604 view_field_handle=[]; 2605 IndexObj_2=get(handles.list_object_2,'Value'); 2606 if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object) 2617 IndexObj(1)=1;%select the first object if the selected one does not exist 2618 set(handles.list_object_1,'Value',1) 2619 end 2620 plot_handles{1}=handles; 2621 haxes(1)=handles.axes3; 2622 PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac 2623 keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits 2624 PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface 2625 2626 % second projection object (view_field display) 2627 IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view 2628 if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2}) 2607 2629 IndexObj(2)=IndexObj_2; 2608 view_field_handle=findobj(allchild(0),'tag','view_field'); 2609 end 2630 view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI 2631 if ~isempty(view_field_handle) 2632 plot_handles{2}=guidata(view_field_handle); 2633 haxes(2)=plot_handles{2}.axes3; 2634 PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface 2635 keeplim(2)=get(plot_handles{2}.FixedLimits,'Value'); 2636 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2637 end 2638 end 2639 2640 %loop on the projection objects: one or two 2610 2641 for imap=1:numel(IndexObj) 2611 iobj=IndexObj(imap); 2612 if ~isempty(UvData.Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes) 2613 %Projeter les champs sur l'objet:* 2614 ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj); 2615 %use of mask 2616 if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2) 2617 if isfield(ObjectData,'Mask') && isfield(ObjectData,'A') 2618 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions 2619 AX=ObjectData.AX; 2620 AY=ObjectData.AY; 2621 MaskX=ObjectData.MaskX; 2622 MaskY=ObjectData.MaskY; 2623 if ~isequal(MaskX,AX)||~isequal(MaskY,AY) 2624 nxy=size(flag_mask); 2625 sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel 2626 sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); 2627 x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 2628 y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display 2629 %project on the positions of the scalar 2630 npxy=size(ObjectData.A); 2631 dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y 2632 dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x 2633 xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); 2634 yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); 2635 [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates 2636 flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); 2637 end 2638 AClass=class(ObjectData.A); 2639 ObjectData.A=flag_mask.*double(ObjectData.A); 2640 ObjectData.A=feval(AClass,ObjectData.A); 2641 ind_off=[]; 2642 if isfield(ObjectData,'ListVarName') 2643 for ilist=1:length(ObjectData.ListVarName) 2644 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2645 ind_off=[ind_off ilist]; 2646 end 2647 end 2648 ObjectData.ListVarName(ind_off)=[]; 2649 ObjectData.VarDimIndex(ind_off)=[]; 2650 ind_off=[]; 2651 for ilist=1:length(ObjectData.ListDimName) 2652 if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY') 2653 ind_off=[ind_off ilist]; 2654 end 2655 end 2656 ObjectData.ListDimName(ind_off)=[]; 2657 ObjectData.DimValue(ind_off)=[]; 2658 end 2659 end 2660 end 2661 if ~isempty(ObjectData) 2662 % haxes=[];%default 2663 % if isfield(UvData.Object{iobj},'plotaxes') 2664 % haxes=UvData.Object{iobj}.plotaxes;%axes used for representing the projection on the object 2665 % end 2666 PosColorbar=[];%default: no colorbar 2667 if ishandle(haxes_1) & isequal(get(haxes_1,'Tag'),'axes3')& isfield(UvData,'PosColorbar') 2668 PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface 2642 iobj=IndexObj(imap); 2643 ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);% project field on the object 2644 2645 %use of mask (TODO: check) 2646 if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') 2647 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions 2648 AX=ObjectData.AX;%x coordiantes for the scalar field 2649 AY=ObjectData.AY;%y coordinates for the scalar field 2650 MaskX=ObjectData.MaskX;%x coordiantes for the mask 2651 MaskY=ObjectData.MaskY;%y coordiantes for the mask 2652 if ~isequal(MaskX,AX)||~isequal(MaskY,AY) 2653 nxy=size(flag_mask); 2654 sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel 2655 sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); 2656 x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 2657 y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display 2658 %project on the positions of the scalar 2659 npxy=size(ObjectData.A); 2660 dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y 2661 dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x 2662 xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); 2663 yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); 2664 [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates 2665 flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); 2666 end 2667 AClass=class(ObjectData.A); 2668 ObjectData.A=flag_mask.*double(ObjectData.A); 2669 ObjectData.A=feval(AClass,ObjectData.A); 2670 ind_off=[]; 2671 if isfield(ObjectData,'ListVarName') 2672 for ilist=1:length(ObjectData.ListVarName) 2673 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2674 ind_off=[ind_off ilist]; 2675 end 2676 end 2677 ObjectData.ListVarName(ind_off)=[]; 2678 ObjectData.VarDimIndex(ind_off)=[]; 2679 ind_off=[]; 2680 for ilist=1:length(ObjectData.ListDimName) 2681 if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY') 2682 ind_off=[ind_off ilist]; 2683 end 2684 end 2685 ObjectData.ListDimName(ind_off)=[]; 2686 ObjectData.DimValue(ind_off)=[]; 2687 end 2688 end 2689 2690 if ~isempty(ObjectData) 2691 PlotType='none'; %default 2692 if imap==2 && isempty(view_field_handle) 2693 view_field(ObjectData) 2694 else 2695 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap}); 2696 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters 2697 end 2698 if isequal(PlotType,'none') 2699 hget_field=findobj(allchild(0),'name','get_field'); 2700 if isempty(hget_field) 2701 get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) 2669 2702 else 2670 PosColorbar='*';%default position 2703 errormsg='The field defined by get_field cannot be plotted'; 2704 return 2671 2705 end 2672 if imap==1 %plot on uvmat 2673 PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface 2674 [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes_1,PlotParam,keeplim,PosColorbar); 2675 elseif ~isempty(view_field_handle) 2676 view_field_hh=guidata(view_field_handle); 2677 PlotParam=read_plot_param(view_field_hh);%read plotting parameters on the uvmat interface 2678 [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,view_field_hh.axes3,PlotParam,keeplim,PosColorbar); 2679 else 2680 [pt,so,UvData.Object{iobj}.plotaxes]=view_field(ObjectData); 2681 end 2682 2683 if isequal(PlotType,'none') 2684 hget_field=findobj(allchild(0),'name','get_field'); 2685 if isempty(hget_field) 2686 get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) 2687 else 2688 errormsg='The field defined by get_field cannot be plotted'; 2689 return 2690 end 2691 end 2692 UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters 2693 end 2694 end 2695 end 2696 2697 %display the updated plotting parameters for the base menuplane 2698 write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters 2706 end 2707 end 2708 end 2709 2710 %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters 2699 2711 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) 2700 2712 set(handles.uvmat,'UserData',UvData) 2701 2713 2702 % update the mask2714 %% update the mask 2703 2715 if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on 2704 2716 update_mask(handles,num_i1,num_i2); 2705 2717 end 2706 2718 2707 % prepare the menus of histograms (for the whole menuvolume in 3D case)2708 menu_histo=(UvData.Field.ListVarName)'; 2719 %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) 2720 menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display 2709 2721 ind_bad=[]; 2710 2722 nb_histo=1; 2711 for ivar=1:numel(menu_histo) 2723 2724 % suppress coordinates from the histogram menu 2725 for ivar=1:numel(menu_histo)%l loop on field variables: 2712 2726 if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') 2713 2727 Role=UvData.Field.VarAttribute{ivar}.Role; … … 2731 2745 end 2732 2746 menu_histo(ind_bad)=[]; 2747 2748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2749 % display menus and plot histograms 2733 2750 test_v=0; 2734 2751 if ~isempty(menu_histo) 2735 2752 set(handles.histo1_menu,'Value',1) 2736 2753 set(handles.histo1_menu,'String',menu_histo) 2737 histo1_menu_Callback(handles.histo1_menu, [], handles) 2738 if nb_histo > 1 2754 histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram 2755 % case of more than one variables (eg vector components) 2756 if nb_histo > 1 2739 2757 test_v=1; 2740 2758 set(handles.histo2_menu,'Visible','on') … … 2742 2760 set(handles.histo2_menu,'String',menu_histo) 2743 2761 set(handles.histo2_menu,'Value',2) 2744 histo2_menu_Callback(handles.histo2_menu,[], handles) 2762 histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram 2745 2763 end 2746 2764 end … … 2751 2769 set(handles.histo2_menu,'Value',1) 2752 2770 end 2753 2754 %display time 2771 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2772 2773 %% display time 2755 2774 testimedoc=0; 2756 2775 if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time') … … 2765 2784 end 2766 2785 siz=size(UvData.XmlData.Time); 2767 if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)2786 if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) 2768 2787 abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files 2769 2788 dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1)); … … 2772 2791 end 2773 2792 if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time') 2774 [P,F,str1,str2,str_a,str_b,E ,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);2775 num_i2=str2 num(str2);2793 [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); 2794 num_i2=str2double(str2); 2776 2795 if isempty(num_i2) 2777 2796 num_i2=num_i1; 2778 2797 end 2779 num_j1=str2 num(str_a);2798 num_j1=str2double(str_a); 2780 2799 if isempty(num_j1) 2781 2800 num_j1=1; 2782 2801 end 2783 num_j2=str2 num(str_b);2802 num_j2=str2double(str_b); 2784 2803 if isempty(num_j2) 2785 2804 num_j2=num_j1; 2786 2805 end 2787 num_i1=str2 num(str1);2806 num_i1=str2double(str1); 2788 2807 siz=size(UvData.XmlData_1.Time); 2789 if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)2808 if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) 2790 2809 abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files 2791 2810 end … … 2805 2824 end 2806 2825 end 2807 %update the input file name in the get_field GUI 2826 2827 %% update the input file name in the get_field GUI 2808 2828 if isequal(FieldName,'get_field...') 2809 2829 set(hhget_field.inputfile,'String',filename) 2810 2830 Tabchar={''};%default 2811 2831 Tabcell=[]; 2812 if isfield(Field{1},'ListGlobalAttribute')& ~isempty(Field{1}.ListGlobalAttribute)2832 if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute) 2813 2833 for iline=1:length(Field{1}.ListGlobalAttribute) 2814 2834 Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline}; … … 2852 2872 set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field 2853 2873 end 2854 2855 2874 2856 2875 … … 4015 4034 histo_value=get(handles.histo1_menu,'Value'); 4016 4035 FieldName=histo_menu{histo_value}; 4017 UvData=get(huvmat,'UserData');4036 % UvData=get(huvmat,'UserData'); 4018 4037 update_histo(handles.histo_u,huvmat,FieldName) 4019 4038 … … 4026 4045 histo_value=get(handles.histo2_menu,'Value'); 4027 4046 FieldName=histo_menu{histo_value}; 4028 UvData=get(huvmat,'UserData');4047 % UvData=get(huvmat,'UserData'); 4029 4048 update_histo(handles.histo_v,huvmat,FieldName) 4030 4049 … … 4034 4053 function update_histo(haxes,huvmat,FieldName) 4035 4054 UvData=get(huvmat,'UserData'); 4036 4037 4055 if ~isfield(UvData.Field,FieldName) 4038 4056 msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) … … 4041 4059 Field=UvData.Field; 4042 4060 FieldHisto=eval(['Field.' FieldName]); 4043 if isfield(Field,'FF') & ~isempty(Field.FF)& isequal(size(Field.FF),size(FieldHisto))4061 if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) 4044 4062 indsel=find(Field.FF==0);%find values marked as false 4045 4063 if ~isempty(indsel) … … 4264 4282 AxeData=get(haxes,'UserData'); 4265 4283 PlotParam=read_plot_param(handles); 4266 PlotParam.Scalar4267 4284 [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1); 4268 4285 write_plot_param(handles,PlotParamOut); %update the auto plot parameters … … 4476 4493 dlg_title = 'select properties of the output avi movie'; 4477 4494 num_lines= 1; 4478 nbfield_cell=get(handles.last_i,'String');4495 % nbfield_cell=get(handles.last_i,'String'); 4479 4496 def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; 4480 4497 answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); 4481 4498 aviname=answer{1}; 4482 fps=str2 num(answer{2});4499 fps=str2double(answer{2}); 4483 4500 % check for existing file with output name aviname 4484 4501 if exist(aviname,'file') … … 4504 4521 newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure 4505 4522 set(newaxes,'Tag','movieaxes') 4506 nbpix=[512 384]*str2 num(answer{3});4523 nbpix=[512 384]*str2double(answer{3}); 4507 4524 set(gcf,'Position',[1 1 nbpix])% resolution XVGA 4508 4525 set(newaxes,'Position',eval(answer{4})); … … 4513 4530 UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes 4514 4531 set(huvmat,'UserData',UvData); 4515 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d 4532 increment=str2double(get(handles.increment_scan,'String')); %get the field increment d 4533 if isnan(increment) 4534 set(handles.increment_scan,'String','1')%default value 4535 increment=1; 4536 end 4516 4537 set(handles.STOP,'Visible','on') 4517 4538 set(handles.speed,'Visible','on') … … 4519 4540 set(handles.Movie,'BusyAction','queue') 4520 4541 4521 imin=str2num(get(handles.i1,'String'));4522 imax=str2 num(answer{5});4542 %imin=str2double(get(handles.i1,'String')); 4543 imax=str2double(answer{5}); 4523 4544 % if isfield(UvData,'Time') 4524 4545 htitle=get(newaxes,'Title'); … … 4530 4551 set(handles.speed,'Value',1) 4531 4552 for i=1:imax 4532 if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command4533 runpm(hObject,eventdata,handles,increment) 4553 if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command 4554 runpm(hObject,eventdata,handles,increment)% run plus 4534 4555 drawnow 4535 4556 time_str=get(handles.abs_time,'String'); … … 4541 4562 end 4542 4563 end 4543 aviobj=close(aviobj);4564 close(aviobj); 4544 4565 UvData.Object{1}.plotaxes=handles.axes3; 4545 4566 set(huvmat,'UserData',UvData); … … 4789 4810 end 4790 4811 if isequal(get(handles.scan_i,'Value'),1) 4791 param.incr_i=str2 num(get(handles.increment_scan,'String'));4812 param.incr_i=str2double(get(handles.increment_scan,'String')); 4792 4813 elseif isequal(get(handles.scan_j,'Value'),1) 4793 param.incr_j=str2 num(get(handles.increment_scan,'String'));4814 param.incr_j=str2double(get(handles.increment_scan,'String')); 4794 4815 end 4795 4816 param.list_fields=get(handles.Fields,'String');% list menu fields -
trunk/src/write_plot_param.m
r85 r128 66 66 function set_scal_display(handles,state) 67 67 %------------------------------------------------------------------ 68 set(handles.SCALAR_title,'Visible',state)68 % set(handles.SCALAR_title,'Visible',state) 69 69 set(handles.MaxA,'Visible',state) 70 70 set(handles.MinA,'Visible',state) … … 73 73 set(handles.BW,'Visible',state) 74 74 set(handles.Contours,'Visible',state) 75 set(handles.SCALAR_title,'Visible',state)76 75 set(handles.min_title,'Visible',state) 77 76 set(handles.max_title,'Visible',state) … … 88 87 %------------------------------------------------------------------ 89 88 set(handles.frame_vect,'Visible',state) 90 set(handles.VECT_title,'Visible',state)89 % set(handles.VECT_title,'Visible',state) 91 90 set(handles.VecScale,'Visible',state) 92 91 set(handles.AutoVec,'Visible',state)
Note: See TracChangeset
for help on using the changeset viewer.