Changeset 569
- Timestamp:
- Feb 19, 2013, 7:19:07 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ListDir.m
r21 r569 1 %'ListDir': scan the structure of the directory tree (for dataview.m)1 %'ListDir': scan the structure of the directory tree (for browse_data.m) 2 2 %------------------------------------------------------------------------ 3 3 % function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in) -
trunk/src/fill_GUI.m
r515 r569 31 31 hh=[]; 32 32 input_data=Param.(fields{ifield}); 33 % display(fields{ifield})34 % display(input_data)35 33 check_done=0; 36 34 if isfield(handles,fields{ifield}) -
trunk/src/find_field_cells.m
r546 r569 232 232 if CoordSize(ilist)==2% case of uniform grid coordinate defined by lower and upper bounds only 233 233 ListDimName{ilist}=ListCoordName{ilist};% replace the dimension name by the coordinate variable name 234 % if check_var235 % check_index= strcmp(ListCoordName{ilist},Data.ListDimName);236 % CoordSize(ilist)=Data.DimValue(check_index);237 % else238 % CoordSize(ilist)=numel(Data.(ListCoordName{ilist}));239 % % end240 % else241 % CoordSize(ilist)=DimValue;242 234 end 243 235 end … … 288 280 NbDim=[NbDim NewNbDim]; 289 281 CellInfo=[CellInfo NewCellInfo]; 290 291 %% suppress empty cells 292 check_empty=cellfun(@isempty,CellInfo); 293 %check_empty=cellfun(@isempty,CellVarIndex); 294 CellInfo(check_empty)=[]; 295 296 % CellVarIndex(check_empty)=[]; 297 NbDim(check_empty)=[]; 298 % CoordType(check_empty)=[]; 299 % VarRole(check_empty)=[]; 282 % 283 % %% suppress empty cells 284 % check_empty=cellfun(@isempty,CellInfo); 285 % CellInfo(check_empty)=[]; 286 % NbDim(check_empty)=[]; 287 288 %% suppress empty cells or cells with a single coordinate variable 289 check_remove=false(size(CellInfo)); 290 for icell=1:numel(check_remove) 291 if isempty(CellInfo{icell})||(numel(CellInfo{icell}.VarIndex)==1 && check_coord(icell)) 292 check_remove(icell)=1; 293 end 294 end 295 CellInfo(check_remove)=[]; 296 NbDim(check_remove)=[]; 300 297 301 298 %% document roles of non-coordinate variables -
trunk/src/geometry_calib.m
r565 r569 150 150 151 151 %------------------------------------------------------------------------ 152 % --- Executes on button press in calibrate_lin.152 % --- Executes on button press APPLY (used to launch the calibration). 153 153 function APPLY_Callback(hObject, eventdata, handles) 154 154 %------------------------------------------------------------------------ … … 156 156 huvmat=findobj(allchild(0),'Name','uvmat'); 157 157 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 158 FileExt=get(hhuvmat.FileExt,'String'); 159 % check_input=0; 160 % if ~isempty(FileExt) 161 % if ~isempty(imformats(FileExt(2:end))) ||strcmpi(FileExt,'.avi') 162 % check_input=1; 163 % end 164 % end 165 % % if ~check_input 166 % msgbox_uvmat('ERROR','open an image with uvmat to perform calibration') 167 % return 168 % end 169 158 159 RootPath=''; 160 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 161 RootPath=get(hhuvmat.RootPath,'String'); 162 SubDirBase=regexprep(get(hhuvmat.SubDir,'String'),'\..+$',''); 163 outputfile=[fullfile(RootPath,SubDirBase) '.xml'];%xml file associated with the currently displayed image 164 else 165 question={'save the calibration data and point coordinates in'}; 166 def={fullfile(RootPath,'ObjectCalib.xml')}; 167 options.Resize='on'; 168 answer=inputdlg(question,'',1,def,options); 169 outputfile=answer{1}; 170 end 171 [GeometryCalib,index]=calibrate(handles,hhuvmat);% apply calibration 172 173 %% copy the xml file from the old location if appropriate, then update with the calibration parameters 174 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 175 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 176 if exist(oldxml,'file') 177 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 178 end 179 end 180 errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file 181 if ~strcmp(errormsg,'') 182 msgbox_uvmat('ERROR',errormsg); 183 end 184 185 %% display image with new calibration in the currently opened uvmat interface 186 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers 187 if ~isempty(hhh) 188 delete(hhh); 189 end 190 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points'); 191 if ~isempty(hhh) 192 delete(hhh); 193 end 194 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' 195 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 196 UserData=get(handles.geometry_calib,'UserData'); 197 UserData.XmlInputFile=outputfile;%save the current xml file name 198 set(handles.geometry_calib,'UserData',UserData) 199 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 200 MenuPlot_Callback(hObject, eventdata, handles) 201 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake) 202 ListCoord_Callback(hObject, eventdata, handles) 203 figure(handles.geometry_calib) 204 205 %------------------------------------------------------------------------ 206 % --- Executes on button press in REPLICATE 207 function REPLICATE_Callback(hObject, eventdata, handles) 208 %------------------------------------------------------------------------ 209 210 %% look for the GUI uvmat and check for an image as input 211 huvmat=findobj(allchild(0),'Name','uvmat'); 212 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 213 GeometryCalib=calibrate(handles,hhuvmat);% apply calibration 214 215 %% open the GUI browse_data 216 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata 217 if isfield(CalibData,'XmlInputFile') 218 InputDir=fileparts(fileparts(CalibData.XmlInputFile)); 219 end 220 answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate?',InputDir); 221 if strcmp(answer,'Cancel') 222 return 223 end 224 OutPut=browse_data(answer); 225 nbcalib=0; 226 for ilist=1:numel(OutPut.Experiment) 227 SubDirBase=regexprep(OutPut.Device{1},'\..+$',''); 228 XmlName=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']); 229 % copy the xml file from the old location if appropriate, then update with the calibration parameters 230 if ~exist(XmlName,'file') && ~isempty(SubDirBase) 231 oldxml=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},SubDirBase,[get(hhuvmat.RootFile,'String') '.xml']); 232 if exist(oldxml,'file') 233 [success,message]=copyfile(oldxml,XmlName);%copy the old xml file to a new one with the new convention 234 end 235 end 236 errormsg=update_imadoc(GeometryCalib,XmlName);% introduce the calibration data in the xml file 237 if ~strcmp(errormsg,'') 238 msgbox_uvmat('ERROR',errormsg); 239 else 240 display([XmlName ' updated with calibration parameters']) 241 nbcalib=nbcalib+1; 242 end 243 end 244 msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']); 245 246 %------------------------------------------------------------------------ 247 % --- activate calibration and store parameters in ouputfile . 248 function [GeometryCalib,index]=calibrate(handles,hhuvmat) 249 %------------------------------------------------------------------------ 170 250 %% read the current calibration points 171 251 Coord_cell=get(handles.ListCoord,'String'); … … 220 300 221 301 %% store the calibration data, by default in the xml file of the currently displayed image 222 UvData=get(h uvmat,'UserData');302 UvData=get(hhuvmat.uvmat,'UserData'); 223 303 NbSlice_j=1;%default 224 304 ZStart=Z_plane; … … 233 313 end 234 314 end 235 RootPath=''; 236 % RootFile=''; 237 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 238 RootPath=get(hhuvmat.RootPath,'String'); 239 SubDirBase=regexprep(get(hhuvmat.SubDir,'String'),'\..+$',''); 240 outputfile=[fullfile(RootPath,SubDirBase) '.xml'];%xml file associated with the currently displayed image 241 else 242 SubDirBase=''; 243 question={'save the calibration data and point coordinates in'}; 244 def={fullfile(RootPath,'ObjectCalib.xml')}; 245 options.Resize='on'; 246 answer=inputdlg(question,'save average in a new file',1,def,options); 247 outputfile=answer{1}; 248 end 249 answer=msgbox_uvmat('INPUT_Y-N',{[outputfile ' updated with calibration data'];... 315 316 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';... 250 317 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 251 318 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}); 252 319 253 %% record the calibration parameters and display the current image of uvmat in the new phys coordinates 254 if strcmp(answer,'Yes') 255 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 256 input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'}; 257 input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}]; 258 answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on'); 259 %answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane)); 260 GeometryCalib.NbSlice=str2double(answer{5}); 261 GeometryCalib.VolumeScan=answer{6}; 262 if isempty(answer) 263 Z_plane=0; %default 264 else 265 Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice); 266 end 267 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 268 GeometryCalib.SliceAngle(:,3)=0; 269 GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 270 GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 271 GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})]; 272 GeometryCalib.RefractionIndex=str2double(answer{4}); 273 end 274 UserData=get(handles.geometry_calib,'UserData'); 275 276 % get the timing from the xml file using the old convention if appropriate 277 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 278 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 279 if exist(oldxml,'file') 280 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 281 end 282 end 283 errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file 284 if ~strcmp(errormsg,'') 285 msgbox_uvmat('ERROR',errormsg); 286 end 287 288 %display image with new calibration in the currently opened uvmat interface 289 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers 290 if ~isempty(hhh) 291 delete(hhh); 292 end 293 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points'); 294 if ~isempty(hhh) 295 delete(hhh); 296 end 297 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' 298 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 299 300 UserData.XmlInputFile=outputfile;%save the current xml file name 301 set(handles.geometry_calib,'UserData',UserData) 302 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 303 MenuPlot_Callback(hObject, eventdata, handles) 304 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake) 305 ListCoord_Callback(hObject, eventdata, handles) 306 figure(handles.geometry_calib) 307 end 308 309 %------------------------------------------------------------------ 310 % --- Executes on button press in calibrate_lin. 311 312 function REPLICATE_Callback(hObject, eventdata, handles) 313 %------------------------------------------------------------------------ 314 315 %% Apply calibration 316 calib_cell=get(handles.calib_type,'String'); %#ok<NASGU> 317 val=get(handles.calib_type,'Value'); %#ok<NASGU> 318 319 %read the current calibration points 320 Coord_cell=get(handles.ListCoord,'String'); 321 Object=read_geometry_calib(Coord_cell); 322 Coord=Object.Coord; 323 324 % apply the calibration, whose type is selected in handles.calib_type 325 if ~isempty(Coord) 326 calib_cell=get(handles.calib_type,'String'); 327 val=get(handles.calib_type,'Value'); 328 GeometryCalib=feval(['calib_' calib_cell{val}],Coord,handles); 329 else 330 msgbox_uvmat('ERROR','No calibration points, abort') 320 %% get plane position(s) 321 if ~strcmp(answer,'Yes') 331 322 return 332 end 333 334 if ~isempty(Coord) 335 %check error 336 X=Coord(:,1); 337 Y=Coord(:,2); 338 Z=Coord(:,3); 339 x_ima=Coord(:,4); 340 y_ima=Coord(:,5); 341 [Xpoints,Ypoints]=px_XYZ(GeometryCalib,X,Y,Z); 342 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 343 [GeometryCalib.ErrorMax(1)]=max(abs(Xpoints-x_ima)); 344 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 345 [GeometryCalib.ErrorMax(2)]=max(abs(Ypoints-y_ima)); 346 % [EM,ind_dim]=max(GeometryCalib.ErrorMax); 347 %set the Z position of the reference plane used for calibration 348 Z_plane=[]; 349 if isequal(max(Z),min(Z)) 350 Z_plane=Z(1); 351 end 352 answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane)); 353 Z_plane=str2double(answer_1); 354 GeometryCalib.NbSlice=1; 355 GeometryCalib.SliceCoord=[0 0 Z_plane]; 356 %set the coordinate unit 357 unitlist=get(handles.CoordUnit,'String'); 358 unit=unitlist{get(handles.CoordUnit,'value')}; 359 GeometryCalib.CoordUnit=unit; 360 %record the points 361 GeometryCalib.SourceCalib.PointCoord=Coord; 362 end 363 364 %% display calibration paprameters 365 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 366 367 % Display extrinsinc parameters (rotation and translation of camera with respect to the phys coordiantes) 368 set(handles.Tx,'String',num2str(GeometryCalib.Tx_Ty_Tz(1),4)) 369 set(handles.Ty,'String',num2str(GeometryCalib.Tx_Ty_Tz(2),4)) 370 set(handles.Tz,'String',num2str(GeometryCalib.Tx_Ty_Tz(3),4)) 371 set(handles.Phi,'String',num2str(GeometryCalib.omc(1),4)) 372 set(handles.Theta,'String',num2str(GeometryCalib.omc(2),4)) 373 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4)) 374 375 %% open the GUI dataview 376 h_dataview=findobj(allchild(0),'name','dataview'); 377 if ~isempty(h_dataview) 378 delete(h_dataview) 379 end 380 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata 381 % InputFile=''; 382 if isfield(CalibData,'XmlInputFile') 383 InputDir=fileparts(CalibData.XmlInputFile); 384 [InputDir,DirName]=fileparts(InputDir); 385 end 386 SubCampaignTest='n'; %default 387 testup=0; 388 if isfield(CalibData,'SubCampaign') 389 SubCampaignTest='y'; 390 dir_ref=CalibData.SubCampaign; 391 testup=1; 392 elseif isfield(CalibData,'Campaign') 393 dir_ref=CalibData.Campaign; 394 testup=1; 395 end 396 while testup 397 [InputDir,DirName]=fileparts(InputDir); 398 if strcmp(DirName,dir_ref) 399 break 400 end 401 end 402 InputDir=fullfile(InputDir,DirName); 403 answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir); 404 if strcmp(answer,'Cancel') 405 return 406 end 407 408 dataview(answer,SubCampaignTest,GeometryCalib); 323 end 324 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration 325 input_key={'Z (first position)','Z (last position)','Z (water surface)', 'refractive index','NbSlice','volume scan (y/n)','tilt angle y axis','tilt angle x axis'}; 326 input_val=[{num2str(ZEnd)} {num2str(ZStart)} {num2str(ZStart)} {'1.333'} num2str(NbSlice_j) {volume_scan} {'0'} {'0'}]; 327 answer=inputdlg(input_key,'slice position(s)',ones(1,8), input_val,'on'); 328 GeometryCalib.NbSlice=str2double(answer{5}); 329 GeometryCalib.VolumeScan=answer{6}; 330 if isempty(answer) 331 Z_plane=0; %default 332 else 333 Z_plane=linspace(str2double(answer{1}),str2double(answer{2}),GeometryCalib.NbSlice); 334 end 335 GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; 336 GeometryCalib.SliceAngle(:,3)=0; 337 GeometryCalib.SliceAngle(:,2)=str2double(answer{7})*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) 338 GeometryCalib.SliceAngle(:,1)=str2double(answer{8})*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) 339 GeometryCalib.InterfaceCoord=[0 0 str2double(answer{3})]; 340 GeometryCalib.RefractionIndex=str2double(answer{4}); 341 end 342 343 409 344 410 345 %------------------------------------------------------------------------ … … 456 391 GeometryCalib.R=[R [0;0;-epsilon]]; 457 392 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]; 393 458 394 %------------------------------------------------------------------------ 459 395 % determine the tsai parameters for a view normal to the grid plane -
trunk/src/plot_field.m
r546 r569 102 102 if ~exist('PlotParam','var'),PlotParam=[];end; 103 103 PlotType='text'; %default 104 PlotParamOut=PlotParam;%default105 104 if ~isfield(PlotParam,'Coordinates') 106 105 PlotParam.Coordinates=[]; 107 106 end 107 PlotParamOut=PlotParam;%default 108 108 109 109 %% check input structure … … 152 152 haxes=axes; 153 153 set(haxes,'position',[0.13,0.2,0.775,0.73]) 154 PlotParam .NextPlot='add'; %parameter for plot_profile and plot_his154 PlotParamOut.NextPlot='add'; %parameter for plot_profile 155 155 else 156 156 hfig=get(haxes,'parent'); … … 160 160 161 161 %% set axes properties 162 if isfield(PlotParam .Coordinates,'CheckFixLimits') && isequal(PlotParam.Coordinates.CheckFixLimits,1) %adjust the graph limits162 if isfield(PlotParamOut.Coordinates,'CheckFixLimits') && isequal(PlotParamOut.Coordinates.CheckFixLimits,1) %adjust the graph limits 163 163 set(haxes,'XLimMode', 'manual') 164 164 set(haxes,'YLimMode', 'manual') … … 171 171 % end 172 172 errormsg=''; 173 PlotParamOut.Coordinates=[]; %default output173 %PlotParamOut.Coordinates=[]; %default output 174 174 AxeData=get(haxes,'UserData'); 175 175 … … 179 179 else %plot 2D field 180 180 if ~exist('PosColorbar','var'),PosColorbar=[];end; 181 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParam ,PosColorbar);181 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut,PosColorbar); 182 182 AxeData.NbDim=2; 183 183 if testzoomaxes && isempty(errormsg) 184 [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParam ,PosColorbar);184 [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut,PosColorbar); 185 185 AxeData.ZoomAxes=zoomaxes; 186 186 end … … 193 193 end 194 194 else %plot 1D field (usual graph y vs x) 195 Coordinates=plot_profile(Data,CellInfo(index_1D),haxes,PlotParam.Coordinates);%195 PlotParamOut.Coordinates=plot_profile(Data,CellInfo(index_1D),haxes,PlotParamOut.Coordinates);% 196 196 if testzoomaxes 197 [zoomaxes, Coordinates]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParam.Coordinates);197 [zoomaxes,PlotParamOut.Coordinates]=plot_profile(Data,CellInfo(index_1D),zoomaxes,PlotParamOut.Coordinates); 198 198 AxeData.ZoomAxes=zoomaxes; 199 199 end 200 if ~isempty(Coordinates)201 PlotParamOut.Coordinates=Coordinates;202 end200 % if ~isempty(Coordinates) 201 % PlotParamOut.Coordinates=Coordinates; 202 % end 203 203 PlotType='line'; 204 204 end … … 231 231 % AxeData=[]; 232 232 if isfield(PlotParamOut,'MinX') 233 AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX]; %'[PlotParamOut.MinX PlotParamOut.MaxX];234 AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY]; %[PlotParamOut.MinY PlotParamOut.MaxY]233 AxeData.RangeX=[PlotParamOut.MinX PlotParamOut.MaxX]; 234 AxeData.RangeY=[PlotParamOut.MinY PlotParamOut.MaxY]; 235 235 end 236 236 set(haxes,'UserData',AxeData) … … 359 359 ytitle=''; 360 360 test_newplot=1; 361 361 MinX=[]; 362 MaxX=[]; 363 MinY_cell=[]; 364 MaxY_cell=[]; 362 365 %loop on input fields 363 366 for icell=1:numel(CellInfo) … … 367 370 coord_x_name{icell}=data.ListVarName{coord_x_index}; 368 371 coord_x{icell}=data.(data.ListVarName{coord_x_index});%coordinate variable set as coord_x 369 if isempty(find(strcmp(coord_x_name{icell},coord_x_name(1:end-1)) )) %xtitle not already selected372 if isempty(find(strcmp(coord_x_name{icell},coord_x_name(1:end-1)), 1)) %xtitle not already selected 370 373 xtitle=[xtitle coord_x_name{icell}]; 371 374 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units') … … 375 378 end 376 379 end 377 XMin(icell)=min(coord_x{icell});378 XMax(icell)=max(coord_x{icell});380 MinX(icell)=min(coord_x{icell}); 381 MaxX(icell)=max(coord_x{icell}); 379 382 testplot(coord_x_index)=0; 380 383 if isfield(CellInfo{icell},'VarIndex_ancillary') … … 399 402 charplot_0='''-'''; 400 403 end 401 YMin=0; 402 YMax=1;%default 404 MinY=[]; 405 MaxY=[];%default 406 407 nbplot=0; 403 408 for ivar=1:length(VarIndex) 404 409 if testplot(VarIndex(ivar)) 405 410 VarName=data.ListVarName{VarIndex(ivar)}; 411 nbplot=nbplot+1; 406 412 ytitle=[ytitle VarName]; 407 413 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units') … … 412 418 eval(['data.' VarName '=squeeze(data.' VarName ');']) 413 419 %eval(['min(data.' VarName ')']) 414 YMin(ivar)=min(min(data.(VarName)));415 YMax(ivar)=max(max(data.(VarName)));420 MinY(ivar)=min(min(data.(VarName))); 421 MaxY(ivar)=max(max(data.(VarName))); 416 422 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; 417 423 eval(['nbcomponent2=size(data.' VarName ',2);']); … … 429 435 end 430 436 end 431 YMin_cell(icell)=min(YMin); 432 YMax_cell(icell)=max(YMax); 437 if ~isempty(MinY) 438 MinY_cell(icell)=min(MinY); 439 MaxY_cell(icell)=max(MaxY); 440 end 433 441 end 434 442 … … 478 486 end 479 487 htitle=title(title_str); 480 % txt=ver('MATLAB');481 % Release=txt.Release;482 % relnumb=str2double(Release(3:4));483 % if relnumb >= 14484 488 set(htitle,'Interpreter','none')% desable tex interpreter 485 % end486 489 end 487 490 488 491 %% determine axes bounds 489 %CoordinatesOut.RangeX=[min(XMin) max(XMax)];490 %CoordinatesOut.RangeY=[min(YMin_cell) max(YMax_cell)];491 492 fix_lim=isfield(Coordinates,'CheckFixLimits') && Coordinates.CheckFixLimits; 493 check_lim=isfield(Coordinates,'MinX')&&isfield(Coordinates,'MaxX')&&isfield(Coordinates,'MinY')&&isfield(Coordinates,'MaxY'); 492 494 if fix_lim 493 if ~ isfield(Coordinates,'MinX')||~isfield(Coordinates,'MaxX')||~isfield(Coordinates,'MinY')||~isfield(Coordinates,'MaxY')494 fix_lim=0; %free limits if li ts are not set,495 if ~check_lim 496 fix_lim=0; %free limits if limits are not set, 495 497 end 496 498 end … … 498 500 set(haxes,'XLim',[Coordinates.MinX Coordinates.MaxX]) 499 501 set(haxes,'YLim',[Coordinates.MinY Coordinates.MaxY]) 500 else 501 CoordinatesOut.MinX=min(XMin); 502 CoordinatesOut.MaxX=max(XMax); 503 CoordinatesOut.MinY=min(YMin_cell); 504 CoordinatesOut.MaxY=max(YMax_cell); 502 else 503 if ~isempty(MinX) 504 if check_lim 505 CoordinatesOut.MinX=min(min(MinX),CoordinatesOut.MinX); 506 CoordinatesOut.MaxX=max(max(MaxX),CoordinatesOut.MaxX); 507 else 508 CoordinatesOut.MinX=min(MinX); 509 CoordinatesOut.MaxX=max(MaxX); 510 end 511 end 512 if ~isempty(MinY_cell) 513 if check_lim 514 CoordinatesOut.MinY=min(min(MinY_cell),CoordinatesOut.MinY); 515 CoordinatesOut.MaxY=max(max(MaxY_cell),CoordinatesOut.MaxY); 516 else 517 CoordinatesOut.MinY=min(MinY_cell); 518 CoordinatesOut.MaxY=max(MaxY_cell); 519 end 520 end 505 521 end 506 522 … … 791 807 PlotParamOut.Scalar.MinA=MinA; 792 808 PlotParamOut.Scalar.MaxA=MaxA; 809 PlotParamOut.Scalar.Npx=size(A,2); 810 PlotParamOut.Scalar.Npy=size(A,1); 793 811 % case of contour plot 794 812 if CheckContour … … 1089 1107 %store the coordinate extrema occupied by the field 1090 1108 if ~isempty(Data) 1091 XMin=[];1092 XMax=[];1093 YMin=[];1094 YMax=[];1109 MinX=[]; 1110 MaxX=[]; 1111 MinY=[]; 1112 MaxY=[]; 1095 1113 fix_lim=isfield(PlotParam.Coordinates,'CheckFixLimits') && PlotParam.Coordinates.CheckFixLimits; 1096 1114 if fix_lim 1097 1115 if isfield(PlotParam.Coordinates,'MinX')&&isfield(PlotParam.Coordinates,'MaxX')&&isfield(PlotParam.Coordinates,'MinY')&&isfield(PlotParam.Coordinates,'MaxY') 1098 XMin=PlotParam.Coordinates.MinX;1099 XMax=PlotParam.Coordinates.MaxX;1100 YMin=PlotParam.Coordinates.MinY;1101 YMax=PlotParam.Coordinates.MaxY;1102 end %else PlotParamOut. XMin =PlotParam.XMin...1116 MinX=PlotParam.Coordinates.MinX; 1117 MaxX=PlotParam.Coordinates.MaxX; 1118 MinY=PlotParam.Coordinates.MinY; 1119 MaxY=PlotParam.Coordinates.MaxY; 1120 end %else PlotParamOut.MinX =PlotParam.MinX... 1103 1121 else 1104 1122 if test_ima %both background image and vectors coexist, take the wider bound 1105 XMin=min(AX);1106 XMax=max(AX);1107 YMin=min(AY);1108 YMax=max(AY);1123 MinX=min(AX); 1124 MaxX=max(AX); 1125 MinY=min(AY); 1126 MaxY=max(AY); 1109 1127 if test_vec 1110 XMin=min(XMin,min(vec_X));1111 XMax=max(XMax,max(vec_X));1112 YMin=min(YMin,min(vec_Y));1113 YMax=max(YMax,max(vec_Y));1128 MinX=min(MinX,min(vec_X)); 1129 MaxX=max(MaxX,max(vec_X)); 1130 MinY=min(MinY,min(vec_Y)); 1131 MaxY=max(MaxY,max(vec_Y)); 1114 1132 end 1115 1133 elseif test_vec 1116 XMin=min(vec_X);1117 XMax=max(vec_X);1118 YMin=min(vec_Y);1119 YMax=max(vec_Y);1120 end 1121 end 1122 PlotParamOut.Coordinates.MinX= XMin;1123 PlotParamOut.Coordinates.MaxX= XMax;1124 PlotParamOut.Coordinates.MinY= YMin;1125 PlotParamOut.Coordinates.MaxY= YMax;1126 if XMax>XMin1127 set(haxes,'XLim',[ XMin XMax]);% set x limits of frame in axes coordinates1128 end 1129 if YMax>YMin1130 set(haxes,'YLim',[ YMin YMax]);% set x limits of frame in axes coordinates1134 MinX=min(vec_X); 1135 MaxX=max(vec_X); 1136 MinY=min(vec_Y); 1137 MaxY=max(vec_Y); 1138 end 1139 end 1140 PlotParamOut.Coordinates.MinX=MinX; 1141 PlotParamOut.Coordinates.MaxX=MaxX; 1142 PlotParamOut.Coordinates.MinY=MinY; 1143 PlotParamOut.Coordinates.MaxY=MaxY; 1144 if MaxX>MinX 1145 set(haxes,'XLim',[MinX MaxX]);% set x limits of frame in axes coordinates 1146 end 1147 if MaxY>MinY 1148 set(haxes,'YLim',[MinY MaxY]);% set x limits of frame in axes coordinates 1131 1149 end 1132 1150 set(haxes,'YDir','normal') -
trunk/src/proj_field.m
r546 r569 887 887 888 888 %% mesh sizes DX and DY 889 DX=[]; 890 DY=[];%default 889 891 if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX) 890 892 DX=abs(ObjectData.DX);%mesh of interpolation points 891 else892 DX=FieldData.Mesh;893 % else 894 % DX=FieldData.Mesh; 893 895 end 894 896 if isfield(ObjectData,'DY') && ~isempty(ObjectData.DY) 895 897 DY=abs(ObjectData.DY);%mesh of interpolation points 896 else 897 DY=FieldData.Mesh; 898 end 899 if ~strcmp(ObjectData.ProjMode,'projection') && (DX==0||DY==0) 900 errormsg='DX or DY missing'; 901 display(errormsg) 898 % else 899 % DY=FieldData.Mesh; 900 end 901 if ~strcmp(ObjectData.ProjMode,'projection') && (isempty(DX)||isempty(DY)) 902 errormsg='DX or DY not defined'; 902 903 return 903 904 end … … 913 914 XMax=max(ObjectData.RangeX); 914 915 testXMin=XMax>XMin; 915 testXMax=1; 916 testXMax=1;% range restriction along X 916 917 else 917 918 XMin=FieldData.XMin;%default … … 960 961 ProjData.VarDimName={}; 961 962 ProjData.VarAttribute={}; 962 if ~ise qual(DX,0)&& ~isequal(DY,0)963 if ~isempty(DX) && ~isempty(DY) 963 964 ProjData.Mesh=sqrt(DX*DY);%define typical data mesh, useful for mouse selection in plots 964 965 elseif isfield(FieldData,'Mesh') … … 1234 1235 1235 1236 %% case of input fields defined on a structured grid 1236 case 'grid' 1237 1237 case 'grid' 1238 1238 VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions 1239 1239 DimValue=size(FieldData.(VarName));%input matrix dimensions … … 1275 1275 Coord_z=[]; 1276 1276 Coord_y=[]; 1277 Coord_x=[]; 1278 1277 Coord_x=[]; 1279 1278 for idim=1:NbDim %loop on space dimensions 1280 1279 test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default … … 1302 1301 end 1303 1302 end 1304 if DY==01303 if isempty(DY) 1305 1304 DY=abs(DCoord_min(NbDim-1)); 1306 1305 end 1307 1306 npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol 1308 if DX==01307 if isempty(DX) 1309 1308 DX=abs(DCoord_min(NbDim)); 1310 1309 end … … 1369 1368 coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line 1370 1369 end 1371 % case with no 1370 % case with no interpolation 1372 1371 if isequal(ProjMode{icell},'projection') && (~testangle || test90y || test90x) 1373 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax 1372 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction 1374 1373 ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName(VarIndex)]; 1375 1374 ProjData.VarDimName=[ProjData.VarDimName FieldData.VarDimName(VarIndex)]; … … 1408 1407 end 1409 1408 min_indy=max(min_indy,1);% deals with margin (bound lower than the first index) 1410 min_indx=max(min_indx,1); 1411 1409 min_indx=max(min_indx,1); 1412 1410 if test90y 1413 1411 ind_new=[3 2 1]; 1414 1412 DimCell={AYProjName,AXProjName}; 1415 % DimValue=DimValue(ind_new);1416 1413 iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1; 1417 1414 for ivar=VarIndex -
trunk/src/set_object.m
r546 r569 504 504 hhview_field=guidata(hview_field); 505 505 [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing plot in view_field 506 write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object 506 errormsg=fill_GUI(PlotParam,hhview_field); 507 if ~isempty(errormsg) 508 msgbox_uvmat('ERROR',errormsg) 509 return 510 end 511 % write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object 507 512 end 508 513 haxes=findobj(hview_field,'tag','axes3'); -
trunk/src/update_project.m
r488 r569 22 22 function varargout = update_project(varargin) 23 23 24 % Last Modified by GUIDE v2.5 01-Jul-2012 15:47:4824 % Last Modified by GUIDE v2.5 15-Feb-2013 19:22:23 25 25 26 26 % Begin initialization code - DO NOT EDIT … … 45 45 %------------------------------------------------------------------------ 46 46 % --- Executes just before update_project is made visible. 47 function update_project_OpeningFcn(hObject, eventdata, handles, Root Dir, SubCampaignTst,GeometryCalib)47 function update_project_OpeningFcn(hObject, eventdata, handles, RootXml, SubCampaignTst,GeometryCalib) 48 48 %------------------------------------------------------------------------ 49 49 % Choose default command line output for update_project … … 94 94 set(handles.SubCampaignTest,'Value',1); 95 95 end 96 if exist('RootDir','var') 97 set(handles.SourceDir,'String',RootDir); 98 set(handles.clean_civ_cmx,'Visible','off') 96 if exist('RootXml','var') 97 RootDir=fileparts(RootXml); 98 [s,Heading]=xml2struct(RootXml);%read the xml file 99 if isfield(s,'SourceDir') 100 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 101 set(handles.MirrorDir,'String',RootDir);%display the opened mirror dir 102 set(handles.CreateMirror,'String','update_mirror') 103 else %a source dir has been opened 104 set(handles.SourceDir,'String',RootDir); 105 set(handles.CreateMirror,'String','create_mirror') 106 end 107 SourceDir_Callback([],[], handles) 108 % set(handles.clean_civ_cmx,'Visible','off') 99 109 set(handles.edit_xml,'Visible','off') 100 110 set(handles.HELP,'Visible','off') … … 104 114 set(hObject,'Visible','on') 105 115 drawnow 106 RootDirectory_Callback(hObject, eventdata, handles)116 % RootDirectory_Callback(hObject, eventdata, handles) 107 117 % UIWAIT makes translate_points wait for user response (see UIRESUME) 108 118 uiwait(handles.figure); … … 198 208 idir=idir+1; 199 209 ExpName{idir}=hdir(ilist).name; 200 mirror=fullfile(MirrorDir,ExpName{idir}) 210 mirror=fullfile(MirrorDir,ExpName{idir}); 201 211 if ~exist(mirror,'dir') 202 212 mkdir(mirror) … … 818 828 uiresume(handles.figure); 819 829 end 820 821 822 -
trunk/src/uvmat.m
r567 r569 334 334 function MenuBrowse_Callback(hObject, eventdata, handles) 335 335 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 336 %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];337 336 oldfile=fullfile(RootPath,SubDir); 338 337 if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box … … 352 351 %% display the selected field and related information 353 352 display_file_name( handles,fileinput) 353 354 % ----------------------------------------------------------------------- 355 % --- Executes on the menu Open/Browse campaign... 356 % search the file inside a campaign, using the GUI view_data 357 function MenuBrowseCampaign_Callback(hObject, eventdata, handles) 358 % ----------------------------------------------------------------------- 359 CampaignPath=fileparts(fileparts(get(handles.RootPath,'String'))); 360 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); 361 if ~ischar(DirFull)|| ~exist(DirFull,'dir') 362 return 363 end 364 OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device 365 if ~isfield(OutPut,'Campaign') 366 return 367 end 368 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); 369 hdir=dir(DirName); %list files and dirs 370 for ilist=1:numel(hdir) 371 if ~isequal(hdir(ilist).isdir,1)%look for files, not dir 372 FileName=hdir(ilist).name; 373 FileType=get_file_type(fullfile(DirName,FileName)); 374 switch FileType 375 case {'image','multimage','civx','civdata','netcdf'} 376 break 377 end 378 end 379 end 380 381 %% display the selected field and related information 382 display_file_name( handles,fullfile(DirName,FileName)) 354 383 355 384 % ----------------------------------------------------------------------- … … 432 461 end 433 462 end 463 464 % -------------------------------------------------------------------- 465 function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles) 466 % ----------------------------------------------------------------------- 467 CampaignPath=fileparts(fileparts(get(handles.RootPath,'String'))); 468 DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); 469 if ~ischar(DirFull)|| ~exist(DirFull,'dir') 470 return 471 end 472 OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device 473 if ~isfield(OutPut,'Campaign') 474 return 475 end 476 DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); 477 hdir=dir(DirName); %list files and dirs 478 for ilist=1:numel(hdir) 479 if ~isequal(hdir(ilist).isdir,1)%look for files, not dir 480 FileName=hdir(ilist).name; 481 FileType=get_file_type(fullfile(DirName,FileName)); 482 switch FileType 483 case {'image','multimage','civx','civdata','netcdf'} 484 break 485 end 486 end 487 end 488 489 %% display the selected field and related information 490 set(handles.SubField,'Value',1) 491 display_file_name( handles,fullfile(DirName,FileName),2) 434 492 435 493 % ----------------------------------------------------------------------- … … 2623 2681 ObjectData.A=flag_mask.*double(ObjectData.A); 2624 2682 ObjectData.A=feval(AClass,ObjectData.A); 2625 % ind_off=[];2626 % if isfield(ObjectData,'ListVarName')2627 % for ilist=1:length(ObjectData.ListVarName)2628 % if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')2629 % ind_off=[ind_off ilist];2630 % end2631 % end2632 % ObjectData.ListVarName(ind_off)=[];2633 % VarDimIndex(ind_off)=[];2634 % ind_off=[];2635 %2636 % end2637 2683 end 2638 2684 if ~isempty(ObjectData) 2639 PlotType='none'; %default2685 %PlotType='none'; %default 2640 2686 if imap==2 && isempty(view_field_handle) 2641 2687 view_field(ObjectData) … … 4947 4993 end 4948 4994 4949 4950 % --------------------------------------------------------------------4951 function MenuSetProject_Callback(hObject, eventdata, handles)4952 RootPath=get(handles.RootPath,'String');4953 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory');4954 datatree_browser(ProjectDir)4955 4956 4957 % --------------------------------------------------------------------4958 function MenuBrowseProject_Callback(hObject, eventdata, handles)4959 RootPath=get(handles.RootPath,'String');4960 ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory');4961 datatree_browser(ProjectDir)4962 4963 4964 4995 % --- Executes on selection change in Coord_y. 4965 4996 function Coord_y_Callback(hObject, eventdata, handles) … … 4971 5002 % --- Executes on button press in CheckColorBar. 4972 5003 function CheckColorBar_Callback(hObject, eventdata, handles) 4973 % hObject handle to CheckColorBar (see GCBO)4974 % eventdata reserved - to be defined in a future version of MATLAB4975 % handles structure with handles and user data (see GUIDATA)4976 4977 % Hint: get(hObject,'Value') returns toggle state of CheckColorBar4978 -
trunk/src/view_field.m
r544 r569 83 83 set(handles.Vectors,'Visible','on') 84 84 end 85 write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters 85 errormsg=fill_GUI(PlotParamOut,handles); 86 if ~isempty(errormsg) 87 msgbox_uvmat('ERROR',errormsg) 88 return 89 end 90 %write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters 86 91 end 87 92 … … 775 780 PlotParam=read_GUI(handles.view_field); 776 781 [PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); 777 write_plot_param(handles,PlotParamOut); %update the auto plot parameters 782 errormsg=fill_GUI(PlotParamOut,handles); 783 if ~isempty(errormsg) 784 msgbox_uvmat('ERROR',errormsg) 785 return 786 end 787 %write_plot_param(handles,PlotParamOut); %update the auto plot parameters 778 788 779 789 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.