Changeset 569


Ignore:
Timestamp:
Feb 19, 2013, 7:19:07 PM (12 years ago)
Author:
sommeria
Message:

many corrections; introduction of browse_data to scan the whole set of data, used also to replicate data in calibration mode

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)
    22%------------------------------------------------------------------------
    33% function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)
  • trunk/src/fill_GUI.m

    r515 r569  
    3131        hh=[];
    3232        input_data=Param.(fields{ifield});
    33 %                     display(fields{ifield})
    34 %                     display(input_data)
    3533        check_done=0;
    3634        if isfield(handles,fields{ifield})
  • trunk/src/find_field_cells.m

    r546 r569  
    232232    if CoordSize(ilist)==2% case of uniform grid coordinate defined by lower and upper bounds only
    233233        ListDimName{ilist}=ListCoordName{ilist};% replace the dimension name by the coordinate variable name
    234 %         if check_var
    235 %             check_index= strcmp(ListCoordName{ilist},Data.ListDimName);
    236 %             CoordSize(ilist)=Data.DimValue(check_index);
    237 %         else
    238 %             CoordSize(ilist)=numel(Data.(ListCoordName{ilist}));
    239 % %         end
    240 %     else
    241 %         CoordSize(ilist)=DimValue;
    242234    end
    243235end
     
    288280NbDim=[NbDim NewNbDim];
    289281CellInfo=[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
     289check_remove=false(size(CellInfo));
     290for 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
     294end
     295CellInfo(check_remove)=[];
     296NbDim(check_remove)=[];
    300297
    301298%% document roles of non-coordinate variables
  • trunk/src/geometry_calib.m

    r565 r569  
    150150
    151151%------------------------------------------------------------------------
    152 % --- Executes on button press in calibrate_lin.
     152% --- Executes on button press APPLY (used to launch the calibration).
    153153function APPLY_Callback(hObject, eventdata, handles)
    154154%------------------------------------------------------------------------
     
    156156huvmat=findobj(allchild(0),'Name','uvmat');
    157157hhuvmat=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
     159RootPath='';
     160if ~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
     164else
     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};
     170end
     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
     174if ~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
     179end
     180errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
     181if ~strcmp(errormsg,'')
     182    msgbox_uvmat('ERROR',errormsg);
     183end
     184
     185%% display image with new calibration in the currently opened uvmat interface
     186hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers
     187if ~isempty(hhh)
     188    delete(hhh);
     189end
     190hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points');
     191if ~isempty(hhh)
     192    delete(hhh);
     193end
     194set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off'
     195set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     196UserData=get(handles.geometry_calib,'UserData');
     197UserData.XmlInputFile=outputfile;%save the current xml file name
     198set(handles.geometry_calib,'UserData',UserData)
     199uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
     200MenuPlot_Callback(hObject, eventdata, handles)
     201set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake)
     202ListCoord_Callback(hObject, eventdata, handles)
     203figure(handles.geometry_calib)
     204
     205%------------------------------------------------------------------------
     206% --- Executes on button press in REPLICATE
     207function REPLICATE_Callback(hObject, eventdata, handles)
     208%------------------------------------------------------------------------
     209
     210%% look for the GUI uvmat and check for an image as input
     211huvmat=findobj(allchild(0),'Name','uvmat');
     212hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
     213GeometryCalib=calibrate(handles,hhuvmat);% apply calibration
     214
     215%% open the GUI browse_data
     216CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata
     217if isfield(CalibData,'XmlInputFile')
     218    InputDir=fileparts(fileparts(CalibData.XmlInputFile));
     219end
     220answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate?',InputDir);
     221if strcmp(answer,'Cancel')
     222    return
     223end
     224OutPut=browse_data(answer);
     225nbcalib=0;
     226for 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
     243end
     244msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated for ' num2str(nbcalib) ' experiments']);
     245
     246%------------------------------------------------------------------------
     247% --- activate calibration and store parameters in ouputfile .
     248function [GeometryCalib,index]=calibrate(handles,hhuvmat)
     249%------------------------------------------------------------------------
    170250%% read the current calibration points
    171251Coord_cell=get(handles.ListCoord,'String');
     
    220300
    221301%% store the calibration data, by default in the xml file of the currently displayed image
    222 UvData=get(huvmat,'UserData');
     302UvData=get(hhuvmat.uvmat,'UserData');
    223303NbSlice_j=1;%default
    224304ZStart=Z_plane;
     
    233313    end
    234314end
    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
     316answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';...
    250317    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
    251318    ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']});
    252319
    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)
     321if ~strcmp(answer,'Yes')
    331322    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);
     323end
     324if 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});
     341end
     342
     343
    409344
    410345%------------------------------------------------------------------------
     
    456391GeometryCalib.R=[R [0;0;-epsilon]];
    457392GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0];
     393
    458394%------------------------------------------------------------------------
    459395% determine the tsai parameters for a view normal to the grid plane
  • trunk/src/plot_field.m

    r546 r569  
    102102if ~exist('PlotParam','var'),PlotParam=[];end;
    103103PlotType='text'; %default
    104 PlotParamOut=PlotParam;%default
    105104if ~isfield(PlotParam,'Coordinates')
    106105    PlotParam.Coordinates=[];
    107106end
     107PlotParamOut=PlotParam;%default
    108108
    109109%% check input structure
     
    152152    haxes=axes;
    153153    set(haxes,'position',[0.13,0.2,0.775,0.73])
    154     PlotParam.NextPlot='add'; %parameter for plot_profile and plot_his
     154    PlotParamOut.NextPlot='add'; %parameter for plot_profile
    155155else
    156156    hfig=get(haxes,'parent');
     
    160160
    161161%% set axes properties
    162 if isfield(PlotParam.Coordinates,'CheckFixLimits') && isequal(PlotParam.Coordinates.CheckFixLimits,1)  %adjust the graph limits
     162if isfield(PlotParamOut.Coordinates,'CheckFixLimits') && isequal(PlotParamOut.Coordinates.CheckFixLimits,1)  %adjust the graph limits
    163163    set(haxes,'XLimMode', 'manual')
    164164    set(haxes,'YLimMode', 'manual')
     
    171171% end
    172172errormsg='';
    173 PlotParamOut.Coordinates=[]; %default output
     173%PlotParamOut.Coordinates=[]; %default output
    174174AxeData=get(haxes,'UserData');
    175175
     
    179179else  %plot 2D field
    180180    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);
    182182    AxeData.NbDim=2;
    183183    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);
    185185        AxeData.ZoomAxes=zoomaxes;
    186186    end
     
    193193    end
    194194else %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);%
    196196    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);
    198198        AxeData.ZoomAxes=zoomaxes;
    199199    end
    200     if ~isempty(Coordinates)
    201         PlotParamOut.Coordinates=Coordinates;
    202     end
     200%     if ~isempty(Coordinates)
     201%         PlotParamOut.Coordinates=Coordinates;
     202%     end
    203203    PlotType='line';
    204204end
     
    231231%     AxeData=[];
    232232    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];
    235235    end
    236236    set(haxes,'UserData',AxeData)
     
    359359ytitle='';
    360360test_newplot=1;
    361 
     361MinX=[];
     362MaxX=[];
     363MinY_cell=[];
     364MaxY_cell=[];
    362365%loop on input  fields
    363366for icell=1:numel(CellInfo)
     
    367370    coord_x_name{icell}=data.ListVarName{coord_x_index};
    368371    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 selected
     372    if isempty(find(strcmp(coord_x_name{icell},coord_x_name(1:end-1)), 1)) %xtitle not already selected
    370373        xtitle=[xtitle coord_x_name{icell}];
    371374        if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
     
    375378        end
    376379    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});
    379382    testplot(coord_x_index)=0;
    380383    if isfield(CellInfo{icell},'VarIndex_ancillary')
     
    399402        charplot_0='''-''';
    400403    end
    401     YMin=0;
    402     YMax=1;%default
     404    MinY=[];
     405    MaxY=[];%default
     406   
     407    nbplot=0;
    403408    for ivar=1:length(VarIndex)
    404409        if testplot(VarIndex(ivar))
    405410            VarName=data.ListVarName{VarIndex(ivar)};
     411            nbplot=nbplot+1;
    406412            ytitle=[ytitle VarName];
    407413            if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units')
     
    412418            eval(['data.' VarName '=squeeze(data.' VarName ');'])
    413419            %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)));
    416422            plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ','];
    417423            eval(['nbcomponent2=size(data.' VarName ',2);']);
     
    429435        end
    430436    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
    433441end
    434442
     
    478486    end
    479487    htitle=title(title_str);
    480 %     txt=ver('MATLAB');
    481 %     Release=txt.Release;
    482 %     relnumb=str2double(Release(3:4));
    483 %     if relnumb >= 14
    484488    set(htitle,'Interpreter','none')% desable tex interpreter
    485 %     end
    486489end
    487490
    488491%% determine axes bounds
    489 %CoordinatesOut.RangeX=[min(XMin) max(XMax)];
    490 %CoordinatesOut.RangeY=[min(YMin_cell) max(YMax_cell)];
    491492fix_lim=isfield(Coordinates,'CheckFixLimits') && Coordinates.CheckFixLimits;
     493check_lim=isfield(Coordinates,'MinX')&&isfield(Coordinates,'MaxX')&&isfield(Coordinates,'MinY')&&isfield(Coordinates,'MaxY');
    492494if fix_lim
    493     if ~isfield(Coordinates,'MinX')||~isfield(Coordinates,'MaxX')||~isfield(Coordinates,'MinY')||~isfield(Coordinates,'MaxY')
    494         fix_lim=0; %free limits if lits are not set,
     495    if ~check_lim
     496        fix_lim=0; %free limits if limits are not set,
    495497    end
    496498end
     
    498500    set(haxes,'XLim',[Coordinates.MinX Coordinates.MaxX])
    499501    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);
     502else
     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
    505521end
    506522
     
    791807        PlotParamOut.Scalar.MinA=MinA;
    792808        PlotParamOut.Scalar.MaxA=MaxA;
     809        PlotParamOut.Scalar.Npx=size(A,2);
     810        PlotParamOut.Scalar.Npy=size(A,1);
    793811        % case of contour plot
    794812        if CheckContour
     
    10891107%store the coordinate extrema occupied by the field
    10901108if ~isempty(Data)
    1091     XMin=[];
    1092     XMax=[];
    1093     YMin=[];
    1094     YMax=[];
     1109    MinX=[];
     1110    MaxX=[];
     1111    MinY=[];
     1112    MaxY=[];
    10951113    fix_lim=isfield(PlotParam.Coordinates,'CheckFixLimits') && PlotParam.Coordinates.CheckFixLimits;
    10961114    if fix_lim
    10971115        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...
    11031121    else
    11041122        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);
    11091127            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));
    11141132            end
    11151133        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>XMin
    1127         set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates
    1128     end
    1129     if YMax>YMin
    1130         set(haxes,'YLim',[YMin YMax]);% set x limits of frame in axes coordinates
     1134            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
    11311149    end
    11321150    set(haxes,'YDir','normal')
  • trunk/src/proj_field.m

    r546 r569  
    887887
    888888%% mesh sizes DX and DY
     889DX=[];
     890DY=[];%default
    889891if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX)
    890892     DX=abs(ObjectData.DX);%mesh of interpolation points
    891 else
    892     DX=FieldData.Mesh;
     893% else
     894%     DX=FieldData.Mesh;
    893895end
    894896if isfield(ObjectData,'DY') && ~isempty(ObjectData.DY)
    895897     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;
     900end
     901if  ~strcmp(ObjectData.ProjMode,'projection') && (isempty(DX)||isempty(DY))
     902        errormsg='DX or DY not defined';
    902903        return
    903904end
     
    913914        XMax=max(ObjectData.RangeX);
    914915        testXMin=XMax>XMin;
    915         testXMax=1;
     916        testXMax=1;% range restriction along X
    916917else
    917918    XMin=FieldData.XMin;%default
     
    960961ProjData.VarDimName={};
    961962ProjData.VarAttribute={};
    962 if ~isequal(DX,0)&& ~isequal(DY,0)
     963if ~isempty(DX) && ~isempty(DY)
    963964    ProjData.Mesh=sqrt(DX*DY);%define typical data mesh, useful for mouse selection in plots
    964965elseif isfield(FieldData,'Mesh')
     
    12341235           
    12351236            %% case of input fields defined on a structured  grid
    1236         case 'grid'
    1237            
     1237        case 'grid'         
    12381238            VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions
    12391239            DimValue=size(FieldData.(VarName));%input matrix dimensions
     
    12751275            Coord_z=[];
    12761276            Coord_y=[];
    1277             Coord_x=[];
    1278            
     1277            Coord_x=[];     
    12791278            for idim=1:NbDim %loop on space dimensions
    12801279                test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
     
    13021301                end
    13031302            end
    1304             if DY==0
     1303            if isempty(DY)
    13051304                DY=abs(DCoord_min(NbDim-1));
    13061305            end
    13071306            npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol
    1308             if DX==0
     1307            if isempty(DX)
    13091308                DX=abs(DCoord_min(NbDim));
    13101309            end
     
    13691368                coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line
    13701369            end
    1371             % case with no  interpolation
     1370            % case with no interpolation
    13721371            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
    13741373                    ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName(VarIndex)];
    13751374                    ProjData.VarDimName=[ProjData.VarDimName FieldData.VarDimName(VarIndex)]; 
     
    14081407                    end
    14091408                    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);                 
    14121410                    if test90y
    14131411                        ind_new=[3 2 1];
    14141412                        DimCell={AYProjName,AXProjName};
    1415                         %                     DimValue=DimValue(ind_new);
    14161413                        iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1;
    14171414                        for ivar=VarIndex
  • trunk/src/set_object.m

    r546 r569  
    504504            hhview_field=guidata(hview_field);
    505505            [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
    507512        end
    508513        haxes=findobj(hview_field,'tag','axes3');
  • trunk/src/update_project.m

    r488 r569  
    2222function varargout = update_project(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 01-Jul-2012 15:47:48
     24% Last Modified by GUIDE v2.5 15-Feb-2013 19:22:23
    2525
    2626% Begin initialization code - DO NOT EDIT
     
    4545%------------------------------------------------------------------------
    4646% --- Executes just before update_project is made visible.
    47 function update_project_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib)
     47function update_project_OpeningFcn(hObject, eventdata, handles, RootXml, SubCampaignTst,GeometryCalib)
    4848%------------------------------------------------------------------------
    4949% Choose default command line output for update_project
     
    9494   set(handles.SubCampaignTest,'Value',1);
    9595end
    96 if exist('RootDir','var')
    97    set(handles.SourceDir,'String',RootDir);
    98    set(handles.clean_civ_cmx,'Visible','off')
     96if 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')
    99109   set(handles.edit_xml,'Visible','off')
    100110   set(handles.HELP,'Visible','off')
     
    104114   set(hObject,'Visible','on')
    105115   drawnow
    106    RootDirectory_Callback(hObject, eventdata, handles)
     116%    RootDirectory_Callback(hObject, eventdata, handles)
    107117   % UIWAIT makes translate_points wait for user response (see UIRESUME)
    108118   uiwait(handles.figure);
     
    198208                idir=idir+1;
    199209                ExpName{idir}=hdir(ilist).name;
    200                 mirror=fullfile(MirrorDir,ExpName{idir})
     210                mirror=fullfile(MirrorDir,ExpName{idir});
    201211                if ~exist(mirror,'dir')
    202212                   mkdir(mirror)
     
    818828    uiresume(handles.figure);
    819829end
    820 
    821 
    822 
  • trunk/src/uvmat.m

    r567 r569  
    334334function MenuBrowse_Callback(hObject, eventdata, handles)
    335335[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    336 %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    337336oldfile=fullfile(RootPath,SubDir);
    338337if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
     
    352351%% display the selected field and related information
    353352display_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
     357function MenuBrowseCampaign_Callback(hObject, eventdata, handles)
     358% -----------------------------------------------------------------------
     359CampaignPath=fileparts(fileparts(get(handles.RootPath,'String')));
     360DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
     361if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     362    return
     363end
     364OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
     365if ~isfield(OutPut,'Campaign')
     366    return
     367end
     368DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
     369hdir=dir(DirName); %list files and dirs
     370for 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
     379end
     380
     381%% display the selected field and related information
     382display_file_name( handles,fullfile(DirName,FileName))
    354383
    355384% -----------------------------------------------------------------------
     
    432461    end
    433462end
     463
     464% --------------------------------------------------------------------
     465function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles)
     466% -----------------------------------------------------------------------
     467CampaignPath=fileparts(fileparts(get(handles.RootPath,'String')));
     468DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK');
     469if ~ischar(DirFull)|| ~exist(DirFull,'dir')
     470    return
     471end
     472OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device
     473if ~isfield(OutPut,'Campaign')
     474    return
     475end
     476DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1});
     477hdir=dir(DirName); %list files and dirs
     478for 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
     487end
     488
     489%% display the selected field and related information
     490set(handles.SubField,'Value',1)
     491display_file_name( handles,fullfile(DirName,FileName),2)
    434492
    435493% -----------------------------------------------------------------------
     
    26232681            ObjectData.A=flag_mask.*double(ObjectData.A);
    26242682            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 %                     end
    2631 %                 end
    2632 %                 ObjectData.ListVarName(ind_off)=[];
    2633 %                 VarDimIndex(ind_off)=[];
    2634 %                 ind_off=[];
    2635 %             
    2636 %             end
    26372683        end
    26382684        if ~isempty(ObjectData)
    2639             PlotType='none'; %default
     2685            %PlotType='none'; %default
    26402686            if imap==2 && isempty(view_field_handle)
    26412687                view_field(ObjectData)
     
    49474993end
    49484994
    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 
    49644995% --- Executes on selection change in Coord_y.
    49654996function Coord_y_Callback(hObject, eventdata, handles)
     
    49715002% --- Executes on button press in CheckColorBar.
    49725003function CheckColorBar_Callback(hObject, eventdata, handles)
    4973 % hObject    handle to CheckColorBar (see GCBO)
    4974 % eventdata  reserved - to be defined in a future version of MATLAB
    4975 % handles    structure with handles and user data (see GUIDATA)
    4976 
    4977 % Hint: get(hObject,'Value') returns toggle state of CheckColorBar
    4978 
  • trunk/src/view_field.m

    r544 r569  
    8383        set(handles.Vectors,'Visible','on')
    8484    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
    8691end
    8792
     
    775780PlotParam=read_GUI(handles.view_field);
    776781[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
    777 write_plot_param(handles,PlotParamOut); %update the auto plot parameters
     782errormsg=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
    778788
    779789%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.