Changeset 128 for trunk/src


Ignore:
Timestamp:
Nov 21, 2010, 10:06:11 PM (14 years ago)
Author:
sommeria
Message:

series: give writting access to the group for all subdirectories produced
uvmat.fig: change of vect and scalar frames (to be consistent with view_field)
uvmat: various cleaning
plot_field: various cleaning to improve axes definition and avoid blinking
geometry_calib: improved dispay of point coordiantes, improved link with dataview for REPLICATE.
struct2nc: repair bug , file was not closed.
cell2tab: cleaning
dataview: improve the browser
civ: solve pb of image naming

Location:
trunk/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cell2tab.m

    r126 r128  
    44%
    55% OUTPUT:
    6 % Tabchar: character array suitable for table display
     6% Tabchar: column cell of char strings suitable for display (equal length)
    77%
    88% INPUT:
    9 % Tabcell: (ni,nj) cell table, for ni lines
    10 % separator: character used for separating displayed columns
     9% 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
    1111
    1212function Tabchar=cell2tab(Tabcell,separator)
    13 Tabchar={};%default
    1413[ni,nj]=size(Tabcell);
    1514
    1615%determine width of each column
    17 widthcolumn=max(cellfun(@length,Tabcell));
     16if isequal(ni,1)
     17    widthcolumn=cellfun('length',Tabcell);% case of a single line, no justification used
     18else
     19    widthcolumn=max(cellfun('length',Tabcell));
     20end
     21lsep=numel(separator); %nbre of characters of the separator
     22nbchar_line=(sum(widthcolumn)+(nj-1)*lsep); %total nbre of characters in each output line
     23default_line=blanks(nbchar_line); %default blank line
     24Tabmat=reshape(blanks(nbchar_line*ni),ni,nbchar_line);
     25Tabchar=mat2cell(Tabmat,ones(1,ni),nbchar_line); %default output
    1826
    1927%justify table
    2028for itab=1:ni   
    21     charchain=[];        
     29    charchain=default_line; 
    2230    for jtab=1:nj% read line
    2331        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;
    2739        end
    28         if ~isempty(charchain)
    29             textlu=[separator textlu];
    30         end
    31         charchain=[charchain textlu];
    3240    end
    3341    Tabchar(itab,1)={charchain};
    3442end
    35 
    36 %nb : char(Tabchar(:,jtab)) gives directly a column with the blanks filled
  • trunk/src/civ.m

    r127 r128  
    9292if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
    9393    set(handles.ImaExt,'String',ext)
     94    browse.ext_ima=ext;
    9495    if exist('nom_type_read','var')
    9596        browse.nom_type_ima=nom_type_read; % the image nomenclature is stored
     
    452453pxcmy_search=[];%default
    453454filebase=get(handles.RootName,'String');
    454 ext=get(handles.ImaDoc,'String');
     455ext_imadoc=get(handles.ImaDoc,'String');
    455456browse=get(handles.browse_root,'UserData')%default
    456457if isfield(browse,'nom_type_ima')
     
    498499
    499500%look for an image documentation file
    500 if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI')
     501if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi')
    501502    if exist([filebase '.xml'],'file')
    502         ext='.xml';
     503        ext_imadoc='.xml';
    503504    elseif exist([filebase '.civxml'],'file')
    504         ext='.civxml';
     505        ext_imadoc='.civxml';
    505506    elseif exist([filebase '.civ'],'file')
    506         ext='.civ';
     507        ext_imadoc='.civ';
    507508    elseif exist([filebase '.avi'],'file')
    508         ext='.avi';
     509        ext_imadoc='.avi';
    509510    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)
    513514end
    514515
     
    517518set(handles.ImaDoc,'BackgroundColor',[1 1 0])
    518519drawnow
    519 if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ')
     520if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ')
    520521    set(handles.ref_i,'Visible','On')%use a reference index
    521522    set(handles.ref_j,'Visible','On')
    522 elseif isequal(ext,'.avi') || isequal(ext,'.AVI')
     523elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI')
    523524    set(handles.ref_j,'Visible','Off')
    524525else
     
    527528end
    528529testima_xml=0;
    529 if isequal(ext,'.civxml')%TO ABANDON
     530if isequal(ext_imadoc,'.civxml')%TO ABANDON
    530531    [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']);
    531532    mode='pair j1-j2';
     
    533534        nom_type_ima='_i_j';
    534535    end
    535 elseif isequal(ext,'.xml')
     536elseif isequal(ext_imadoc,'.xml')
    536537    [XmlData,warntext]=imadoc2struct([filebase '.xml']);
    537538    ext_ima_read=[];
     
    577578        end
    578579    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 previously
    582 %         else   %keep the image extension
    583 %             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 %             end
    586 %         end
    587         nom_type_ima=nom_type_read;
    588     end
    589 elseif strcmp(ext,'.civ')% case of .civ image documentation file
     580%     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
     590elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file
    590591    [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
    591592    if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
    592593    elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
    593594    end
    594     %         ImaExt='.png';
    595     nom_type_ima='png_old';
    596 elseif strcmpi(ext,'.avi')
     595    nom_type_ima='001a';
     596elseif strcmpi(ext_imadoc,'.avi')
    597597    nom_type_ima='*';
    598     ext_ima=ext;
     598    ext_ima=ext_imadoc;
    599599    set(handles.mode,'String',{'series(Di)'})
    600600    dt=0.04;%default
    601     if exist([filebase ext],'file')==2
    602         info=aviinfo([filebase ext]);%read infos on the avi movie
     601    if exist([filebase ext_imadoc],'file')==2
     602        info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie
    603603        dt=1/info.FramesPerSecond;%time interval between successive frames
    604604        nbfield=info.NumFrames;%number of frames
     
    627627                appendix=char(96+first_j);
    628628                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
    640631    end
    641632end
     
    651642% no image documentation file found: look for a series of existing files,images by priority or .nc files
    652643if isempty(nom_type_ima)
    653     ext_search=ext;
     644    ext_search=ext_imadoc;
    654645    nom_type_search=nom_type_nc;
    655646else
     
    29882979        %create the new subdir_civ1
    29892980        if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
    2990             [xx,m2]=mkdir(subdir_civ1_new);
    2991             if ~isequal(m2,'')
    2992                 msgbox_uvmat('ERROR', m2)%error message for directory creation
     2981            [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
    29932984                cd(currentdir)
    29942985                filecell={};
    29952986                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
    29962995            end
    29972996        end
     
    30243023            %create the new subdir_civ1
    30253024            if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir')
    3026                 [xx,m2]=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])
    30293028                    cd(currentdir)
    30303029                    filecell={};
    30313030                    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
    30323039                end
    30333040            end
     
    31513158            end
    31523159        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)
    31563164            if ~isequal(m2,'')
    3157                 msgbox_uvmat('ERROR', m2)
     3165                msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2])
    31583166                filecell={};
    31593167                cd(currentdir)
     
    31883196            if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
    31893197                [xx,m2]=mkdir(subdir_civ2_new);
     3198                 [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g)
    31903199                if ~isequal(m2,'')
    3191                     msgbox_uvmat('ERROR', m2)%error message for directory creation
     3200                    msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation
    31923201                    cd(currentdir)
    31933202                    filecell={};
  • trunk/src/dataview.m

    r127 r128  
    3232                   'gui_LayoutFcn',  [] , ...
    3333                   'gui_Callback',   []);
    34 if nargin & ischar(varargin{1})
     34if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))             
    3535    gui_State.gui_Callback = str2func(varargin{1});
    3636end
     
    119119function browser_Callback(hObject, eventdata, handles)
    120120%------------------------------------------------------------------------
    121 CurrentFile='/raid/PROJETS';%get(handles.RootDirectory,'String');
     121CurrentFile=fileparts(get(handles.RootDirectory,'String'));
     122if ~exist(CurrentFile,'dir')
     123    CurrentFile='/fsnet/project/coriolis';
     124end
    122125set(handles.SubCampaignTest,'Value',0)
    123126CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
     
    129132function OpenSubCampaign_Callback(hObject, eventdata, handles)
    130133%------------------------------------------------------------------------
    131 CurrentFile='/coriolis/bigone/PROJETS';%get(handles.RootDirectory,'String');
     134CurrentFile=get(handles.RootDirectory,'String');
     135if ~exist(CurrentFile,'dir')
     136    CurrentFile='/fsnet/project/coriolis';
     137end
    132138set(handles.SubCampaignTest,'Value',1)
    133139CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
     
    184190set(handles.ListDevices,'String',[{'*'};ListDevices'])
    185191set(handles.ListXml,'String',[{'*'};ListXml'])
     192'TEST'
     193testList
    186194if testList
    187195    DataviewData=get(handles.figure,'UserData');
    188     DataView.List=List;
     196    DataviewData.List=List;
    189197    set(handles.figure,'UserData',DataviewData)
    190198end
     
    502510message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)';
    503511answer=msgbox_uvmat('INPUT_Y-N',message);
    504 if ~isequal(answer{1},'OK')
     512if ~isequal(answer,'Yes')
    505513    return
    506514end
    507515set(handles.ListExperiments,'Value',1)
    508516ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    509 DataviewData=get(handles.figure,'UserData');
     517DataviewData=get(handles.figure,'UserData')
    510518List=DataviewData.List;
    511519Currentpath=get(handles.RootDirectory,'String');
  • trunk/src/geometry_calib.m

    r121 r128  
    5454                   'gui_LayoutFcn',  [] , ...
    5555                   'gui_Callback',   []);
    56 if nargin && ischar(varargin{1})
     56if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once'))
    5757    gui_State.gui_Callback = str2func(varargin{1});
    5858end
     
    9595if exist('inputfile','var')&& ~isempty(inputfile)
    9696    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);
    9998    if ~strcmp(ext,'.xml')
    10099        inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
     
    103102set(handles.ListCoord,'String',{'......'})
    104103if 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
     105end
     106if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
     107    struct.Campaign=Heading.Campaign;
     108end
     109set(hObject,'UserData',struct)
    107110set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
    108111
     
    213216    ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
    214217    ['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
    215220if strcmp(answer,'Yes')
    216221    if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration
     
    219224            Z_plane=0; %default
    220225        else
    221             Z_plane=str2num(answer_1);
     226            Z_plane=str2double(answer_1);
    222227        end
    223228        GeometryCalib.NbSlice=1;
     
    228233        msgbox_uvmat('ERROR',errormsg);
    229234    end
     235   
    230236    %display image with new calibration in the currently opened uvmat interface
    231237    hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers
     
    251257%------------------------------------------------------------------
    252258% --- Executes on button press in calibrate_lin.
     259
    253260function 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
     264calib_cell=get(handles.calib_type,'String'); %#ok<NASGU>
     265val=get(handles.calib_type,'Value'); %#ok<NASGU>
    261266
    262267%read the current calibration points
     
    288293    [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima));
    289294    [EM,ind_dim]=max(GeometryCalib.ErrorMax);
    290     index=index(ind_dim);
     295%     index=index(ind_dim);
    291296    %set the Z position of the reference plane used for calibration
    292297    Z_plane=[];
     
    295300    end
    296301    answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane));
    297     Z_plane=str2num(answer_1);
     302    Z_plane=str2double(answer_1);
    298303    GeometryCalib.NbSlice=1;
    299304    GeometryCalib.SliceCoord=[0 0 Z_plane];
     
    304309    %record the points
    305310    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
     311end
     312
     313%% display calibration paprameters
    311314display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
    312315
     
    319322set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    320323
    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
    341325h_dataview=findobj(allchild(0),'name','dataview');
    342326if ~isempty(h_dataview)
     
    344328end
    345329CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata
    346 
     330InputFile='';
    347331if isfield(CalibData,'XmlInputFile')
    348     XmlInput=fileparts(CalibData.XmlInputFile);
    349     [XmlInput,filename,ext]=fileparts(XmlInput);
     332    InputDir=fileparts(CalibData.XmlInputFile);
     333    [InputDir,DirName]=fileparts(InputDir);
    350334end
    351335SubCampaignTest='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
     336testup=0;
     337if isfield(CalibData,'SubCampaign')
     338    SubCampaignTest='y';
     339    dir_ref=CalibData.SubCampaign;
     340    testup=1;
     341elseif isfield(CalibData,'Campaign')
     342    dir_ref=CalibData.Campaign;
     343    testup=1;
     344end
     345while testup
     346    [InputDir,DirName]=fileparts(InputDir);
     347    if strcmp(DirName,dir_ref)
     348        break
     349    end
     350end
     351InputDir=fullfile(InputDir,DirName);
     352answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir);
     353if strcmp(answer,'Cancel')
     354    return
     355end
     356
     357dataview(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
    389390
    390391%------------------------------------------------------------------------
     
    434435R=[R;[0 0]];
    435436GeometryCalib.R=[R [0;0;1]];
    436 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]
     437GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0];
    437438%------------------------------------------------------------------------
    438439% determine the tsai parameters for a view normal to the grid plane
     
    700701
    701702%--------------------------------------------------------------------------
    702 function GeometryCalib=calib_tsai(Coord,handles)% old version using gauthier's bianry ccal_fo
     703function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo
    703704% NOT USED
    704705%------------------------------------------------------------------------
     
    811812huvmat=findobj(allchild(0),'Name','uvmat');
    812813hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
    813 RootPath='';
    814 RootFile='';
     814% RootPath='';
     815% RootFile='';
    815816if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile)
    816817    testhandle=1;
     
    830831        listfile={outputfile};
    831832    else
    832         listfile=[listfile;{outputfile}]%update the list of coord files
     833        listfile=[listfile;{outputfile}];%update the list of coord files
    833834    end
    834835    set(handles.coord_files,'string',listfile);
     
    901902end
    902903coord_str=Coord_cell{val};
    903 k=findstr('|',coord_str);
     904k=findstr(' | ',coord_str);
    904905if isempty(k)%last line '.....' selected
    905906    if ~isempty(hhh)
     
    10001001%------------------------------------------------------------------------
    10011002huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    1002 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
     1003%UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    10031004hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
    1004 hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
     1005%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
    10051006h_menu_coord=findobj(huvmat,'Tag','transform_fct');
    10061007menu=get(h_menu_coord,'String');
     
    10791080
    10801081%size(data.Coord,1)
    1081 Tabchar=cell2tab(Coord,'    |    ');
     1082Tabchar=cell2tab(Coord,' | ');
    10821083Tabchar=[Tabchar ;{'......'}];
    10831084set(handles.ListCoord,'String',Tabchar)
     
    12361237     Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits
    12371238end
    1238 Tabchar=cell2tab(Coord(end:-1:1,:),'    |    ');
     1239Tabchar=cell2tab(Coord(end:-1:1,:),' | ');
    12391240Tabchar=[Tabchar ;{'......'}];
    12401241set(handles.ListCoord,'Value',1)
     
    12661267   end
    12671268end
    1268 Tabchar=cell2tab(Coord,'    |    ');
     1269Tabchar=cell2tab(Coord,' | ');
    12691270Tabchar=[Tabchar; {'.....'}];
    12701271%set(handles.ListCoord,'Value',1)
     
    13101311   end
    13111312end
    1312 Tabchar=cell2tab(Coord,'    |    ');
     1313Tabchar=cell2tab(Coord,'| ');
    13131314Tabchar=[Tabchar;{'......'}];
    13141315set(handles.ListCoord,'Value',1)
     
    14601461end
    14611462CoordCell=reshape(CoordCell,[],5);
    1462 Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
     1463Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
    14631464Tabchar=[Tabchar;{'......'}];
    14641465set(handles.ListCoord,'Value',1)
     
    15411542
    15421543% -----------------------------------------------------------------------
    1543 function loadfile(handles,fileinput)
    1544 %------------------------------------------------------------------------
     1544function Heading=loadfile(handles,fileinput)
     1545%------------------------------------------------------------------------
     1546Heading=[];%default
    15451547[s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
     1548if ~isempty(errormsg)
     1549    msgbox_uvmat('ERROR',['Error for reading ' fileinput ': '  errormsg])
     1550    return
     1551end
     1552if ~isempty(s.Heading)
     1553    Heading=s.Heading;
     1554end
     1555   
    15461556GeometryCalib=s.GeometryCalib;
    15471557fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
     
    15851595    end
    15861596    CoordCell=reshape(CoordCell,[],5);
    1587     Tabchar=cell2tab(CoordCell,'    |    ');%transform cells into table ready for display
     1597    Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
    15881598    MenuPlot_Callback(handles.geometry_calib, [], handles)
    15891599end
  • trunk/src/get_field.m

    r107 r128  
    3232                   'gui_LayoutFcn',  [] , ...
    3333                   'gui_Callback',   []);
    34 if nargin & isstr(varargin{1})
     34if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
    3535    gui_State.gui_Callback = str2func(varargin{1});
    3636end
     
    4848%------------------------------------------------------------------------
    4949global nb_builtin
     50
     51%% look at the existing figues in the work space
    5052browse_fig(handles.list_fig)
    5153
    52 % Choose default command line output for get_field
     54%% Choose default command line output for get_field
    5355handles.output = hObject;
    5456
    55 % Update handles structure
     57%% Update handles structure
    5658guidata(hObject, handles);
    5759
    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
     61set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
     62
     63%% prepare the list of builtin fcts and set their paths
     64menu_str={'PLOT';'FFT';'filter_band';'histogram'}; %list of functions included by default in 'get_field.m'
    6065nb_builtin=numel(menu_str);
    6166path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
     
    7277end
    7378rmpath(fullfile(path_uvmat,'get_field'))
    74 
    7579dir_perso=prefdir;
    7680profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     
    102106set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
    103107set(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
     110if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
    106111    set(handles.inputfile,'String',filename)% prefill the input file name
    107112    set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
     
    113118    set(handles.MenuHelp,'Visible','off')
    114119    inputfile_Callback(hObject, eventdata, handles)
    115 else
     120else  %master mode
    116121    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
     143end
     144%transfer input field  in slave mode
     145if exist('Field','var') && isstruct(Field)
    120146        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
    124152    set(hObject,'UserData',Field);
    125153end
    126154
    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
    148156
    149157%------------------------------------------------------------------------
     
    822830end
    823831
    824 %------------------------------------------------
    825 % --- Executes on button press in Plot_histo.
    826 %RUN global histograms
    827 %-------------------------------------------------
    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 MATLAB
    831 % handles    structure with handles and user data (see GUIDATA)
    832 
    833 %time plots
    834 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 else
    843     Uval_p=Uval;
    844     Vval_p=Vval;
    845     Uhist_p=Uhist;
    846     Vhist_p=Vhist;
    847     xlab='velocity (pixels)';
    848 end
    849 if (get(handles.vector_y,'Value') == 1)
    850    hhh=figure(2);
    851    hold on
    852    title([filebase ', ' strindex ', ' fieldtitle])
    853    plot(Uval_p,Uhist_p,'b-')
    854    n=n+1;
    855    leg{n}='Uhist';
    856    xlabel(xlab)
    857 end
    858 if (get(handles.Vhist_input,'Value') == 1)
    859    hhh=figure(2);
    860    hold on
    861    title([filebase ', ' strindex ', ' fieldtitle])
    862    plot(Vval_p,Vhist_p,'r-')
    863    n=n+1;
    864    leg{n}='Vhist';
    865    xlabel(xlab);
    866 end
    867 if (get(handles.Chist_input,'Value') == 1)
    868    hhhh=figure(3);
    869    hold on
    870    title([filebase ', ' strindex ', ' fieldtitle])
    871    plot(Cval,Chist,'k-')
    872    leg{1}='Chist';
    873 end
    874 % hold off
    875 grid on
    876 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);
    877885
    878886% %-------------------------------------------------------------
     
    10281036    var_select=list_var{index};
    10291037    set(handles.attributes_txt,'String', ['attributes of ' var_select])
    1030     if isfield(Field,'VarAttribute')& length(Field.VarAttribute)>=index-1
     1038    if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1
    10311039%         nbline=0;
    10321040        VarAttr=Field.VarAttribute{index-1};
     
    10501058    Tabchar=[{''};Tabchar];
    10511059end
     1060set(handles.attributes,'Value',1);% select the first item
    10521061set(handles.attributes,'String',Tabchar);
    10531062
  • trunk/src/get_plot_handles.m

    r61 r128  
    1919PlotHandles.Contours=handles.Contours;
    2020PlotHandles.IncrA=handles.IncrA;
    21 PlotHandles.SCALAR_title=handles.SCALAR_title;
     21%PlotHandles.SCALAR_title=handles.SCALAR_title;
    2222PlotHandles.min_title=handles.min_title;
    2323PlotHandles.max_title=handles.max_title;
     
    3030%For vector field representation
    3131PlotHandles.frame_vect=handles.frame_vect;
    32 PlotHandles.VECT_title=handles.VECT_title;
     32%PlotHandles.VECT_title=handles.VECT_title;
    3333PlotHandles.VecScale=handles.VecScale;
    3434PlotHandles.AutoVec=handles.AutoVec;
  • trunk/src/plot_field.m

    r109 r128  
    105105% use htext: handles of the text edit box (uicontrol)
    106106% introduce PlotParam.Hold: 'on' or 'off' (for curves)
    107  
     107
    108108%default output
    109109if ~exist('PlotParam','var'),PlotParam=[];end;
     
    127127    if ishandle(haxes)
    128128        if isequal(get(haxes,'Type'),'axes')
    129             axes(haxes)
     129%             axes(haxes)
    130130            testnewfig=0;
    131131            AxeData=get(haxes,'UserData');
     
    139139    end
    140140end
     141
    141142if testnewfig% create a new figure and axes if the plotting axes does not exist
    142143    hfig=figure;
     
    157158    haxes=axes;
    158159    set(haxes,'position',[0.13,0.2,0.775,0.73])
    159 else
    160     hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab
    161160end
    162161if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
     
    182181    [Data.NbDim]=max(NbDim);
    183182end
     183errormsg=[];
    184184if isequal(Data.NbDim,0)
    185185        AxeData=plot_text(Data,htext);
    186186        PlotType='text';
     187        errormsg=[];
    187188elseif isequal(Data.NbDim,1)
    188     [AxeData,haxes]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
     189    [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%
    189190    if testzoomaxes
    190191        [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);
     
    192193    end
    193194    PlotType='line';
     195    errormsg=[];
    194196elseif isequal(Data.NbDim,2)
    195197    ind_select=find(NbDim>=2);
    196198    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
    206207    end
    207208elseif isequal(Data.NbDim,3)
     209    errormsg='volume plot not implemented yet';
     210end
     211if ~isempty(errormsg)
    208212    msgbox_uvmat('ERROR','volume plot not implemented yet')
    209213    return
    210 % else
    211 %     testnbdim=0;
    212214end
    213215
     
    234236%set(haxes,'UserData',AxeData)
    235237set(haxes,'UserData',Data)
    236 if ~testnewfig
    237 set(0,'Children',hstack);%put back the initial figure stack after plot creation
    238 %set(haxes,'Tag','uvmat');
    239 end
     238% if ~testnewfig
     239% %set(0,'Children',hstack);%put back the initial figure stack after plot creation
     240%
     241% end
    240242
    241243
     
    303305function [AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)
    304306%-------------------------------------------------------------------
    305 %axes(haxes)
     307%TODO: modify existing plot if it exists
     308
    306309hfig=get(haxes,'parent');
    307310AxeData=data;
     
    322325legend_str={};
    323326
    324 %initiates string of the plot command
     327%% prepare the string for plot command
     328%initiate  the plot command
    325329plotstr='hhh=plot(';
    326330textmean={};
    327 % abscissa_name='';
    328331coord_x_index=[];
    329332test_newplot=1;
     
    331334% num_curve=numel(hh);
    332335% icurve=0;
     336
     337%loop on input  fields
    333338for icell=1:length(CellVarIndex)
    334     testfalse=0;
    335339    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     end
    340     XName=DimCell{1}; %first dimension considered as abscissa
    341340    if ~isempty(VarType{icell}.coord_x)
    342341        coord_x_index=VarType{icell}.coord_x;
     
    353352    end
    354353    testplot=ones(size(data.ListVarName));%default test for plotted variables
    355     testcoordvar=0;
    356     charplot_0='''-''';%default
    357     if isfield(data,'ObjectProjMode')&& isequal(data.ObjectProjMode,'projection')
    358         charplot_0='+';
    359     end
    360     xtitle=''; 
    361    
    362354    xtitle=data.ListVarName{coord_x_index};
    363355    eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
    364356    if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units')
    365          xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')'];
     357        xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')'];
    366358    end
    367359    eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
    368 %     testcoordvar=1;
    369360    testplot(coord_x_index)=0;
    370361    if ~isempty(VarType{icell}.ancillary')
    371             testplot(VarType{icell}.ancillary)=0;
     362        testplot(VarType{icell}.ancillary)=0;
    372363    end
    373364    if ~isempty(VarType{icell}.warnflag')
    374             testplot(VarType{icell}.warnflag)=0;
    375     end
    376  
     365        testplot(VarType{icell}.warnflag)=0;
     366    end
    377367    if isfield(data,'VarAttribute')
    378368        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              else
    383                  plotname{VarIndex(ivar)}=data.ListVarName{VarIndex(ivar)};%name for display in plot A METTRE
    384              end
    385         end
    386     end 
    387 %     test_newplot=0;%default
    388 %     if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves
    389 %         if ~isempty(VarType{icell}.discrete')
    390 %             charplot_0='+';
    391 %             LineStyle='none';
    392 %         else
    393 %             charplot_0='none';
    394 %             LineStyle='-';
    395 %         end
    396 %         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 %             end
    407 %         end
    408 %     else% new plot
    409         if ~isempty(VarType{icell}.discrete')
    410             charplot_0='''+''';
    411         else
    412             charplot_0='''-''';
    413         end
    414369        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
     425end
     426
     427%% activate the plot
    442428if test_newplot && ~isequal(plotstr,'hhh=plot(')
    443429    plotstr=[plotstr '''tag'',''plot_line'');'];
    444430                %execute plot (instruction  plotstr) 
     431    axes(haxes)% select the plotting axes for plot operation
    445432    eval(plotstr)
    446433   
     
    502489
    503490%-------------------------------------------------------------------
    504 function [AxeData,haxes,PlotParamOut,PlotType]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
     491function [AxeData,haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)
    505492%-------------------------------------------------------------------
     493
    506494grid(haxes, 'off')
    507495%default plotting parameters
     
    517505end
    518506PlotParamOut=PlotParam;%default
    519 
    520 %plotting axes
    521507hfig=get(haxes,'parent');
    522508hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
     
    530516    AxeData.ObjectCoord=Data.ObjectCoord;
    531517end
    532 
     518errormsg=[];%default
    533519test_ima=0; %default: test for image or map plot
    534520test_vec=0; %default: test for vector plots
     
    548534    ivar_C=[VarType.scalar VarType.image VarType.color VarType.ancillary]; %defines index (indices) for the scalar or ancillary fields
    549535    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';
    551537        return
    552538    end
     
    558544    end
    559545%     idim_Y=[]; 
    560     test_grid=0;
     546%     test_grid=0;
    561547    if ~isempty(ivar_U) && ~isempty(ivar_V)% vector components detected
    562548        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';
    564550            return
    565551        else
     
    570556                eval(['vec_X=Data.' Data.ListVarName{ivar_X} ';'])
    571557                eval(['vec_Y=Data.' Data.ListVarName{ivar_Y} ';'])
    572             elseif numel(VarType.coord)==2 & VarType.coord~=[0 0];%coordinates defines by dimension variables
     558            elseif numel(VarType.coord)==2 && ~isequal(VarType.coord,[0 0]);%coordinates defines by dimension variables
    573559                eval(['y=Data.' Data.ListVarName{VarType.coord(1)} ';'])
    574560                eval(['x=Data.' Data.ListVarName{VarType.coord(2)} ';'])
     
    581567                [vec_X,vec_Y]=meshgrid(x,y); 
    582568            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';
    584570                return
    585571            end
     
    605591    elseif ~isempty(ivar_C) %scalar or image
    606592        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';
    608594            return
    609595        end
     
    635621                    x_units=['(' Data.VarAttribute{VarType.coord(2)}.units ')'];
    636622                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')
    638624                    y_units=['(' Data.VarAttribute{VarType.coord(1)}.units ')'];
    639625                end
     
    644630                DAY_max=max(DAY);
    645631                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)} ];
    647633                      return
    648634                end
     
    654640                DAX_max=max(DAX);
    655641                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)} ];
    657643                      return
    658644                end
     
    682668            AY=[AY(1) AY(end)];
    683669        else
    684             msgbox_uvmat('ERROR','error in plot_field: invalid coordinate definition ')
     670            errormsg='error in plot_field: invalid coordinate definition ';
    685671            return
    686672        end
    687           x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
     673          %x_label=[Data.ListVarName{ivar_X} '(' x_units ')'];
    688674    end         
    689675end
    690676
    691 %%%%%%%%%%%%%%%%%%%%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
     677%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
    692678
    693679if ~isfield(PlotParam.Scalar,'Contours')
     
    700686    siz=numel(np);
    701687    if siz>3
    702         msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(siz) ' dimensions'])
     688       errormsg=['unrecognized scalar type: ' num2str(siz) ' dimensions'];
    703689            return
    704690    end
     
    709695            siz=3;%color image
    710696        else
    711              msgbox_uvmat('ERROR',['unrecognized scalar type: ' num2str(np(3)) ' color components'])
     697            errormsg=['unrecognized scalar type: ' num2str(np(3)) ' color components'];
    712698            return
    713699        end
    714700    end
     701   
    715702    %set the color map
    716703    if isfield(PlotParam.Scalar,'BW')
     
    719706        BW=(siz==2) && (isa(A,'uint8')|| isa(A,'uint16'));% non color images represented in gray scale by default
    720707    end
    721     if siz==2 %for black and white images
     708   
     709    %case of grey level images or contour plot
     710    if siz==2
    722711        if ~isfield(PlotParam.Scalar,'AutoScal')
    723712            PlotParam.Scalar.AutoScal=0;%default
     
    729718            PlotParam.Scalar.MaxA=[];%default
    730719        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 box
     720        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
    732721            MinA=double(min(min(A)));
    733722        else
     
    741730        PlotParamOut.Scalar.MinA=MinA;
    742731        PlotParamOut.Scalar.MaxA=MaxA;
    743         axes(haxes)
     732       
     733        % case of contour plot
    744734        if isequal(PlotParam.Scalar.Contours,1)
    745             if ~isempty(hima) & ishandle(hima)
     735            if ~isempty(hima) && ishandle(hima)
    746736                delete(hima)
    747737            end
     
    770760            txt=ver;%version of Matlab
    771761            Release=txt(1).Release;
    772             relnumb=str2num(Release(3:4));
     762            relnumb=str2double(Release(3:4));
    773763            if relnumb >= 14
    774764                    vec=linspace(0,1,(abscontmax-abscontmin)/intercont);%define a greyscale colormap with steps intercont
     
    788778            colormap(map);
    789779        end
     780       
     781        % set  colormap for  image display
    790782        if ~isequal(PlotParam.Scalar.Contours,1) 
    791783            % rescale the grey levels with min and max, put a grey scale colorbar
     
    799791            end
    800792        end
    801     else %color images
    802         axes(haxes)
     793       
     794    % case of color images
     795    else
    803796        if BW
    804797            B=uint16(sum(A,3));
     
    809802        MaxA=255;
    810803    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
    813808        test_interp=1;
    814809        if max(np) <= 64
     
    829824            yi=linspace(AY(1),AY(2),npxy(1));
    830825            B = interp2(X,Y,double(B),xi,yi');
    831         end       
     826        end           
     827        % create new image if there  no image handle is found
    832828        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
    833831            tag=get(haxes,'Tag');
    834832            if MinA<MaxA
    835833                hima=imagesc(AX,AY,B,[MinA MaxA]);
    836             else
     834            else % to deal with uniform field
    837835                hima=imagesc(AX,AY,B,[MaxA-1 MaxA]);
    838836            end
    839837            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
    841840        else
    842841            set(hima,'CData',B);
     
    857856    AxeData.AY=[AY(1) AY(end)];
    858857    test_ima=1;
     858   
    859859    %display the colorbar code for B/W images if Poscolorbar not empty
    860860    if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar)
     
    865865                 set(hcol,'Position',PosColorbar)           
    866866        end
    867         YTick=0;%default
     867        %YTick=0;%default
    868868        if MaxA>MinA
    869869            if isequal(PlotParam.Scalar.Contours,1)
     
    873873                YTick_scaled=colbarlim(1)+scale_bar*(YTick-abscontmin);
    874874                set(hcol,'YTick',YTick_scaled);
    875             elseif (isfield(PlotParam.Scalar,'BW') & isequal(PlotParam.Scalar.BW,1))|isa(A,'uint8')| isa(A,'uint16')%images
     875            elseif (isfield(PlotParam.Scalar,'BW') && isequal(PlotParam.Scalar.BW,1))||isa(A,'uint8')|| isa(A,'uint16')%images
    876876                hi=get(hcol,'children');
    877877                if iscell(hi)%multiple images in colorbar
     
    879879                end
    880880                set(hi,'YData',[MinA MaxA])
    881                 set(hi,'CData',[1:256]')
     881                set(hi,'CData',(1:256)')
    882882                set(hcol,'YLim',[MinA MaxA])
    883883                YTick=colbartick(MinA,MaxA);
     
    889889                end
    890890                set(hi,'YData',[MinA MaxA])
    891                 set(hi,'CData',[1:64]')
     891                set(hi,'CData',(1:64)')
    892892                YTick=colbartick(MinA,MaxA);
    893893                set(hcol,'YLim',[MinA MaxA])
     
    912912end
    913913
    914 %%%%%%%%%%%%%%%%%%%%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
     914%%   vector plot %%%%%%%%%%%%%%%%%%%%%%%%%%
    915915if test_vec
    916916   %vector scale representation
     
    927927    if  ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')...
    928928               ||isempty(PlotParam.Vectors.VecScale)||~isa(PlotParam.Vectors.VecScale,'double') %automatic vector scale
    929         scale=[];
     929%         scale=[];
    930930        if test_false %remove false vectors
    931931            indsel=find(AxeData.FF==0);%indsel =indices of good vectors
     
    10451045listdim={'AY','AX',{'AY','AX'},'nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors','nb_vectors'};
    10461046Role={'coord_y','coord_x','scalar','coord_x','coord_y','vector_x','vector_y','scalar','vector_z','warnflag','errorflag'};
    1047 ind_select=[];
     1047%ind_select=[];
    10481048nbvar=0;
    10491049AxeData.ListVarName={};
     
    11681168    isn=isnan(colorlist(icolor,:));%test if color NaN
    11691169    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)
    11711175        if ~isn(1) %if the vectors are visible color not nan
    11721176            if n(2)>0
  • trunk/src/read_geometry_calib.m

    r71 r128  
    99    k=findstr('|',coord_str);%find separators '|'
    1010    if length(k)>=4 % test for separators '|'
    11         data1=str2num(coord_str(1:k(1)-5));
    12         data2=str2num(coord_str(k(1)+5:k(2)-5));
    13         data3=str2num(coord_str(k(2)+5:k(3)-5));
    14         data4=str2num(coord_str(k(3)+5:k(4)-5));
    15         data5=str2num(coord_str(k(4)+5:end));
    16         if ~isempty(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)
    1717            iline=iline+1;
    18             if ~isempty(data1)
     18            if ~isnan(data1)
    1919                data.Coord(iline,1)=data1;
    2020            end   
    21             if ~isempty(data2)
     21            if ~isnan(data2)
    2222                data.Coord(iline,2)=data2;
    2323            end
    24             if ~isempty(data3)
     24            if ~isnan(data3)
    2525                data.Coord(iline,3)=data3;
    2626            end
    27             if ~isempty(data4)
     27            if ~isnan(data4)
    2828                data.Coord(iline,4)=data4;
    2929            end
    30             if isempty(data5)
     30            if isnan(data5)
    3131                data.Coord(iline,5)=0;
    3232            else
  • trunk/src/series/aver_stat.m

    r107 r128  
    277277    if ~isequal(m2,'')
    278278         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
    279285    end
    280286    cd(dircur) %back to the initial working directory
  • trunk/src/series/ima_levels.m

    r71 r128  
    2121cd(path);
    2222mkdir([subdir_ima '_levels']);
     23  [xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
     24if ~strcmp(msg2,'')
     25    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
     26    cd(dircur)
     27    return
     28end
     29cd(dircur);
    2330cd(curdir);
    2431basename_new=fullfile(path,[subdir_ima '_levels'],namebase);
  • trunk/src/series/merge_proj.m

    r127 r128  
    234234    succeed=mkdir(subdir);
    235235    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);
    237243    else
    238     msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
    239     return
    240     end       
     244        msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
     245        return
     246    end
    241247end
    242248filebasesub=fullfile(res_subdir,Series.RootFile{1});
  • trunk/src/series/relabel_i_j.m

    r71 r128  
    2121cd(path);
    2222mkdir([subdir_ima '_ij']);
     23[xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
     24if ~strcmp(msg2,'')
     25    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
     26    cd(dircur)
     27    return
     28end
    2329cd(curdir);
    2430basename_new=fullfile(path,[subdir_ima '_ij'],namebase);
  • trunk/src/series/sub_background.m

    r89 r128  
    115115cd(path);
    116116mkdir([subdir_ima '_b']);
     117[xx,msg2] = fileattrib(subdir_ima,'+w','g'); %yield writing access (+w) to user group (g)
     118if ~strcmp(msg2,'')
     119    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
     120    cd(curdir)
     121    return
     122end
    117123cd(curdir);
    118124filebase_b=fullfile(path,[subdir_ima '_b'],namebase);
  • trunk/src/series/time_series.m

    r107 r128  
    278278    if ~isequal(m2,'')
    279279         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
    280286    end
    281287    cd(dircur) %back to the initial working directory
  • trunk/src/struct2nc.m

    r107 r128  
    4242    return
    4343end
    44 hhh=which('netcdf.create');% look for built-in matlab library
     44hhh=which('netcdf.create');% look for built-in matlab netcdf library
    4545
    46 %USE OF built-in netcdf library
     46%USE OF built-in matlab netcdf library
    4747if ~isequal(hhh,'')
    4848    FilePath=fileparts(flname);
     
    6868                if ~testvar               
    6969                    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
    7172                        netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
    72                     else
    73                         errormsg='global attributes must be characters or numbers';
    74                         return
    7573                    end
    7674                end
     
    7977    end
    8078    %create dimensions
    81     dimid=[];
     79    dimid=zeros(1,length(Data.ListDimName));
    8280    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));
    8482    end
    8583    VarAttribute={}; %default
     
    8987        testattr=1;
    9088    end
    91     varid=[];
     89    varid=zeros(1,length(Data.ListVarName));
    9290    for ivar=1:length(ListVarName)
    93         varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'double',dimid(Data.VarDimIndex{ivar}));%define variable 
     91        varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(Data.VarDimIndex{ivar}));%define variable 
    9492    end
    9593     %write variable attributes
     
    117115                VarDimName={VarDimName};
    118116            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
    122120            if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
    123121                errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
     
    126124            if testline || testrange
    127125                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
    129127                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'));
    132129            else
    133130                netcdf.putVar(nc,varid(ivar), double(VarVal));
    134                 %nc{ListVarName{ivar}}(:) = VarVal;
    135             end
    136            
     131            end     
    137132        end
    138133    end
     134    netcdf.close(nc)
    139135%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    140136%OLD netcdf toolbox
  • trunk/src/uvmat.m

    r127 r128  
    181181                   'gui_LayoutFcn',     [], ...
    182182                   'gui_Callback',      []);
    183 if nargin && ischar(varargin{1})
     183if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
    184184    gui_State.gui_Callback = str2func(varargin{1});
    185185end
     
    11511151   set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    11521152   set(handles.Fields_1,'Value',2) % set menu to 'image'
    1153 elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
     1153elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
    11541154   Data=nc2struct(fileinput_1,[]);
    11551155   if isfield(Data,'absolut_time_T0')
     
    16211621%-------------------------------------------------------------------
    16221622huvmat=get(handles.MenuExport,'parent');
    1623 UvData=get(huvmat,'UserData');
     1623%UvData=get(huvmat,'UserData');
    16241624hfig=figure;
    1625 newaxes=copyobj(handles.axes3,hfig);
     1625copyobj(handles.axes3,hfig);
    16261626map=colormap(handles.axes3);
    16271627colormap(map);%transmit the current colormap to the zoom fig
     
    16411641set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16421642drawnow
    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
     1644increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
     1645if isnan(increment)
     1646    set(handles.increment_scan,'String','1')%default value
     1647    increment=1;
     1648end
     1649errormsg=runpm(hObject,eventdata,handles,increment);
     1650if ~isempty(errormsg)
     1651    msgbox_uvmat('ERROR',errormsg);
     1652end
     1653set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
    16461654
    16471655%-------------------------------------------------------------------
     
    16531661set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16541662drawnow
    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
     1663increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
     1664if isnan(increment)
     1665    set(handles.increment_scan,'String','1')%default value
     1666    increment=1;
     1667end
     1668errormsg=runpm(hObject,eventdata,handles,increment);
     1669if ~isempty(errormsg)
     1670    msgbox_uvmat('ERROR',errormsg);
     1671end
     1672set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
    16581673
    16591674%-------------------------------------------------------------------
     
    16631678set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16641679drawnow
    1665 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
     1680increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
     1681if isnan(increment)
     1682    set(handles.increment_scan,'String','1')%default value
     1683    increment=1;
     1684end
    16661685set(handles.STOP,'Visible','on')
    16671686set(handles.speed,'Visible','on')
    16681687set(handles.speed_txt,'Visible','on')
    16691688set(handles.Movie,'BusyAction','queue')
    1670 testavi=0;
    16711689UvData=get(handles.uvmat,'UserData');
    16721690
     
    16741692        errormsg=runpm(hObject,eventdata,handles,increment);
    16751693        if ~isempty(errormsg)
     1694            set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    16761695            return
    16771696        end
     
    16901709set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
    16911710drawnow
    1692 increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
     1711increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
     1712if isnan(increment)
     1713    set(handles.increment_scan,'String','1')%default value
     1714    increment=1;
     1715end
    16931716set(handles.STOP,'Visible','on')
    16941717set(handles.speed,'Visible','on')
    16951718set(handles.speed_txt,'Visible','on')
    16961719set(handles.MovieBackward,'BusyAction','queue')
    1697 testavi=0;
    16981720UvData=get(handles.uvmat,'UserData');
    16991721
    1700 while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
     1722while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
    17011723        errormsg=runpm(hObject,eventdata,handles,increment);
    17021724        if ~isempty(errormsg)
     1725            set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    17031726            return
    17041727        end
     
    17601783     num1=num1+increment;
    17611784     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);
    17631786     if sub_value% set the second field name and indices
    17641787        num1_1=num1_1+increment;
     
    17791802% refresh plots
    17801803errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
    1781 
    17821804if isempty(errormsg)  %update the index counters
    17831805    set(handles.i1,'String',num2stra(num1,NomType,1));
     
    18031825        movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
    18041826    end
    1805 else
    1806      msgbox_uvmat('ERROR',errormsg);
    1807 end
    1808 
     1827end
    18091828
    18101829
     
    19741993end   
    19751994set(handles.run0,'BackgroundColor',[1 0 0])
     1995
    19761996%------------------------------------------------------------------------
    19771997% --- read the input files and refresh all the plots, including projection.
     
    19832003% num_i1,num_i2,num_j1,num_j2; frame indices
    19842004% Field: structure describing an optional input field (then replace the input file)
    1985 
    19862005function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
    19872006%------------------------------------------------------------------------
    19882007
    19892008%initialisation
    1990 
    1991 errormsg=[]; % default error message
     2009% errormsg=[]; % default error message
    19922010abstime=[];
    19932011abstime_1=[];
     
    20122030end
    20132031
    2014 % determine the main input file information for action
     2032%% determine the main input file information for action
    20152033FileType=[];%default
    20162034if ~isempty(filename)
     
    20232041    %update the z position index
    20242042    nbslice_str=get(handles.nb_slice,'String');
    2025     z_index=1;%default
     2043   % z_index=1;%default
    20262044    if isequal(nbslice_str,'volume')
    20272045        z_index=num_j1;
     
    20742092    end
    20752093end
    2076 
    2077 % choose a second field if Subfield option is 'on'
     2094%% choose a second field if Subfield option is 'on'
    20782095FieldName_1=[];
    20792096scal_color=[];
    20802097VelType_1=setfield_1(handles);
    2081 sub_value=get(handles.SubField,'Value');
     2098% sub_value=get(handles.SubField,'Value');
    20822099FileType_1='none';%default
    20832100if ~isempty(filename_1)
     
    21372154end
    21382155
    2139 %read the input field(s)
     2156%% read the input field(s)
    21402157%read images
    21412158if ~isempty(filename) && isequal(FieldName,'image')
     
    22412258                hget_field= get_field(filename);%open the get_field GUI   
    22422259                set(hget_field,'name','uvmat_field')
    2243             elseif UvData.NewSeries
     2260            elseif UvData.NewSeries% refresh the fet_field GUI for a new series
    22442261                delete(hget_field)
    22452262                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
    22472264            end
    22482265            hhget_field=guidata(hget_field);
    22492266            funct_list=get(hhget_field.ACTION,'UserData');
    22502267            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 GUI
     2268            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
    22532270            CivStage=0;
    22542271            VelType_out=[];   
     
    22902307end
    22912308
    2292 %update the display buttons for the first velocity type (first menuline)
     2309%% update the display buttons for the first velocity type (first menuline)
    22932310veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    22942311if ~isequal(FileType,'netcdf')
     
    23042321end
    23052322
    2306 %update the display buttons for the second velocity type (second menuline)
     2323%% update the display buttons for the second velocity type (second menuline)
    23072324veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    23082325if ~isequal(FileType_1,'netcdf')
     
    23182335end
    23192336
    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)
    23212338if ~isfield(UvData,'NewSeries')
    23222339    UvData.NewSeries=1;
     
    23422359        set(handles.Fields_1,'Visible','on');
    23432360        Field{1}.AName='w';
    2344         testscal=1;
     2361%         testscal=1;
    23452362    end
    23462363end           
     
    23502367      isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
    23512368       siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
    2352        if siz(1)>1
    2353            NbSlice=siz(1);
    2354        else
    2355            NbSlice=1;
    2356        end
     2369%        if siz(1)>1
     2370%            NbSlice=siz(1);
     2371%        else
     2372%            NbSlice=1;
     2373%        end
    23572374end
    23582375
     
    23682385end
    23692386
    2370 %coordinate transform or user fct
     2387%% coordinate transform or user fct
    23712388XmlData=[];%default
    23722389if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
     
    23772394   XmlData_1=UvData.XmlData_1;
    23782395end
    2379 menu_transform=get(handles.transform_fct,'String');
     2396% menu_transform=get(handles.transform_fct,'String');
    23802397choice_value=get(handles.transform_fct,'Value');
    23812398transform_list=get(handles.transform_fct,'UserData');
    23822399transform=transform_list{choice_value};%selected function handles
    2383 
    23842400% z index
    23852401if ~isempty(filename)
    23862402    Field{1}.ZIndex=z_index;
    23872403end
    2388 
    23892404%px to phys or other transform on field
    23902405if ~isempty(transform)
     
    24002415end
    24012416
    2402 %calculate scalar
     2417%% calculate scalar
    24032418if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
    24042419    Field{1}=calc_field(InputField,Field{1});
     
    24072422    Field{2}=calc_field(InputField_1,Field{2});
    24082423end
    2409 
    24102424% combine the two input fields (e.g. substract velocity fields)
    24112425if numel(Field)==2
     
    24152429end
    24162430
    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)
    24182432test_x=0;
    24192433test_z=0;% test for unstructured z coordinate
     
    24782492    end
    24792493end
     2494
    24802495%case of structured coordinates
    24812496if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')
     
    25722587%multilevel case (single menuplane in a 3D space)
    25732588elseif 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')
    25752590        XmlData=UvData.XmlData;
    25762591        if isfield(XmlData,'PlanePos')
     
    25892604end
    25902605
    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)
     2607if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
    25952608    set(handles.MinA,'String','0')
    25962609    set(handles.MaxA,'String','255')
    25972610end
    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)
     2615IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
    26002616if 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)
     2619end
     2620plot_handles{1}=handles;
     2621haxes(1)=handles.axes3;
     2622PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
     2623keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits
     2624PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
     2625
     2626% second projection object (view_field display)
     2627IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
     2628if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
    26072629    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
     2638end
     2639
     2640%loop on the projection objects: one or two
    26102641for 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)
    26692702            else
    2670                 PosColorbar='*';%default position
     2703                errormsg='The field defined by get_field cannot be plotted';
     2704                return
    26712705            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
     2708end
     2709
     2710%write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
    26992711UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
    27002712set(handles.uvmat,'UserData',UvData)
    27012713
    2702 %update the mask
     2714%% update the mask
    27032715if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
    27042716   update_mask(handles,num_i1,num_i2);
    27052717end
    27062718
    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)
     2720menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
    27092721ind_bad=[];
    27102722nb_histo=1;
    2711 for ivar=1:numel(menu_histo)
     2723
     2724% suppress coordinates from the histogram menu
     2725for ivar=1:numel(menu_histo)%l loop on field variables:
    27122726    if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
    27132727        Role=UvData.Field.VarAttribute{ivar}.Role;
     
    27312745end
    27322746menu_histo(ind_bad)=[];
     2747
     2748%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     2749% display menus and plot histograms
    27332750test_v=0;
    27342751if ~isempty(menu_histo)
    27352752    set(handles.histo1_menu,'Value',1)
    27362753    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
    27392757        test_v=1;
    27402758        set(handles.histo2_menu,'Visible','on')
     
    27422760        set(handles.histo2_menu,'String',menu_histo)
    27432761        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
    27452763    end
    27462764end
     
    27512769    set(handles.histo2_menu,'Value',1)
    27522770end
    2753 
    2754 %display time
     2771%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     2772
     2773%% display time
    27552774testimedoc=0;
    27562775if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
     
    27652784    end
    27662785    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)
    27682787        abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
    27692788        dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
     
    27722791end
    27732792if 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=str2num(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);
    27762795    if isempty(num_i2)
    27772796        num_i2=num_i1;
    27782797    end
    2779     num_j1=str2num(str_a);
     2798    num_j1=str2double(str_a);
    27802799    if isempty(num_j1)
    27812800        num_j1=1;
    27822801    end
    2783     num_j2=str2num(str_b);
     2802    num_j2=str2double(str_b);
    27842803    if isempty(num_j2)
    27852804        num_j2=num_j1;
    27862805    end
    2787     num_i1=str2num(str1);
     2806    num_i1=str2double(str1);
    27882807    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)
    27902809        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
    27912810    end
     
    28052824    end
    28062825end
    2807 %update the input file name in the get_field GUI
     2826
     2827%% update the input file name in the get_field GUI
    28082828if isequal(FieldName,'get_field...')
    28092829    set(hhget_field.inputfile,'String',filename)
    28102830    Tabchar={''};%default
    28112831    Tabcell=[];
    2812     if isfield(Field{1},'ListGlobalAttribute')& ~isempty(Field{1}.ListGlobalAttribute)
     2832    if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute)
    28132833        for iline=1:length(Field{1}.ListGlobalAttribute)
    28142834            Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
     
    28522872    set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field
    28532873end
    2854 
    28552874
    28562875
     
    40154034histo_value=get(handles.histo1_menu,'Value');
    40164035FieldName=histo_menu{histo_value};
    4017 UvData=get(huvmat,'UserData');
     4036% UvData=get(huvmat,'UserData');
    40184037update_histo(handles.histo_u,huvmat,FieldName)
    40194038
     
    40264045histo_value=get(handles.histo2_menu,'Value');
    40274046FieldName=histo_menu{histo_value};
    4028 UvData=get(huvmat,'UserData');
     4047% UvData=get(huvmat,'UserData');
    40294048update_histo(handles.histo_v,huvmat,FieldName)
    40304049
     
    40344053function update_histo(haxes,huvmat,FieldName)
    40354054UvData=get(huvmat,'UserData');
    4036 
    40374055if ~isfield(UvData.Field,FieldName)
    40384056    msgbox_uvmat('ERROR',['no field  ' FieldName ' for histogram'])
     
    40414059Field=UvData.Field;
    40424060FieldHisto=eval(['Field.' FieldName]);
    4043 if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
     4061if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
    40444062    indsel=find(Field.FF==0);%find values marked as false
    40454063    if ~isempty(indsel)
     
    42644282AxeData=get(haxes,'UserData');
    42654283PlotParam=read_plot_param(handles);
    4266 PlotParam.Scalar
    42674284[PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
    42684285write_plot_param(handles,PlotParamOut); %update the auto plot parameters
     
    44764493dlg_title = 'select properties of the output avi movie';
    44774494num_lines= 1;
    4478 nbfield_cell=get(handles.last_i,'String');
     4495% nbfield_cell=get(handles.last_i,'String');
    44794496def     = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
    44804497answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
    44814498aviname=answer{1};
    4482 fps=str2num(answer{2});
     4499fps=str2double(answer{2});
    44834500% check for existing file with output name aviname
    44844501if exist(aviname,'file')
     
    45044521newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
    45054522set(newaxes,'Tag','movieaxes')
    4506 nbpix=[512 384]*str2num(answer{3});
     4523nbpix=[512 384]*str2double(answer{3});
    45074524set(gcf,'Position',[1 1 nbpix])% resolution XVGA
    45084525set(newaxes,'Position',eval(answer{4}));
     
    45134530UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
    45144531set(huvmat,'UserData',UvData);
    4515 increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
     4532increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
     4533if isnan(increment)
     4534    set(handles.increment_scan,'String','1')%default value
     4535    increment=1;
     4536end
    45164537set(handles.STOP,'Visible','on')
    45174538set(handles.speed,'Visible','on')
     
    45194540set(handles.Movie,'BusyAction','queue')
    45204541
    4521 imin=str2num(get(handles.i1,'String'));
    4522 imax=str2num(answer{5});
     4542%imin=str2double(get(handles.i1,'String'));
     4543imax=str2double(answer{5});
    45234544% if isfield(UvData,'Time')
    45244545htitle=get(newaxes,'Title');
     
    45304551set(handles.speed,'Value',1)
    45314552for i=1:imax
    4532     if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
    4533             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
    45344555            drawnow
    45354556            time_str=get(handles.abs_time,'String');
     
    45414562    end
    45424563end
    4543 aviobj=close(aviobj);
     4564close(aviobj);
    45444565UvData.Object{1}.plotaxes=handles.axes3;
    45454566set(huvmat,'UserData',UvData);
     
    47894810end
    47904811if isequal(get(handles.scan_i,'Value'),1)
    4791     param.incr_i=str2num(get(handles.increment_scan,'String'));
     4812    param.incr_i=str2double(get(handles.increment_scan,'String'));
    47924813elseif isequal(get(handles.scan_j,'Value'),1)
    4793     param.incr_j=str2num(get(handles.increment_scan,'String'));
     4814    param.incr_j=str2double(get(handles.increment_scan,'String'));
    47944815end
    47954816param.list_fields=get(handles.Fields,'String');% list menu fields
  • trunk/src/write_plot_param.m

    r85 r128  
    6666function set_scal_display(handles,state)
    6767%------------------------------------------------------------------
    68 set(handles.SCALAR_title,'Visible',state)
     68% set(handles.SCALAR_title,'Visible',state)
    6969set(handles.MaxA,'Visible',state)
    7070set(handles.MinA,'Visible',state)
     
    7373set(handles.BW,'Visible',state)
    7474set(handles.Contours,'Visible',state)
    75 set(handles.SCALAR_title,'Visible',state)
    7675set(handles.min_title,'Visible',state)
    7776set(handles.max_title,'Visible',state)
     
    8887%------------------------------------------------------------------
    8988set(handles.frame_vect,'Visible',state)
    90 set(handles.VECT_title,'Visible',state)
     89% set(handles.VECT_title,'Visible',state)
    9190set(handles.VecScale,'Visible',state)
    9291set(handles.AutoVec,'Visible',state)
Note: See TracChangeset for help on using the changeset viewer.