Changeset 591


Ignore:
Timestamp:
Mar 25, 2013, 5:43:18 PM (8 years ago)
Author:
sommeria
Message:

various updates, in particular modification of series to do calculations in the cluster

Location:
trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r589 r591  
    8383end
    8484if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode')
    85     batch_mode=sparam.BatchParam.BatchMode; %sge is currently the only implemented batch mod
     85    batch_mode=sparam.BatchParam.BatchMode;
    8686    test_command='';
    8787    switch batch_mode
     
    900900    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
    901901    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    902     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     902    %uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
     903    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@stop_status);
    903904    hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI);
    904905    BarPosition=[0.05 0.81 0.01 0.05];
     
    10091010set(hhciv.status,'BackgroundColor',[0 1 0])
    10101011
    1011 %------------------------------------------------------------------------   
    1012 % launched by pressing OK on the status figure
    1013 function close_GUI(hObject, eventdata)
    1014 %------------------------------------------------------------------------
    1015     delete(gcbf)
     1012% %------------------------------------------------------------------------   
     1013% % launched by pressing OK on the status figure
     1014% function close_GUI(hObject, eventdata)
     1015% %------------------------------------------------------------------------
     1016%     delete(gcbf)
    10161017
    10171018
     
    13351336        write_param(Param);
    13361337             
    1337         % create the file used in run or batch
     1338        % create the command file name .m, .bat or .sh depending on the run option
    13381339        switch Param.Program
    13391340            case {'civ_matlab'}
     
    17581759ext_ima=get(handles.ImaExt,'String'); % image extension (the same for all images)
    17591760switch compare
    1760     case 'PIV'
     1761    case {'PIV','PIV volume'}
    17611762       RootFile_ima1=RootFile_ima2;% root name of the two image series is the same
    17621763       NomType_ima1=NomType_ima2;% the index of the first image follows the index of the second one
     
    24972498ListCompareMode=get(handles.ListCompareMode,'String');
    24982499option=ListCompareMode{get(handles.ListCompareMode,'Value')};
    2499 if ~strcmp(option,'PIV') % case 'displacement' or 'stereo PIV'
    2500     filebase=get(handles.RootPath,'String');
    2501     set(handles.sub_txt,'Visible','on')
    2502     set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible
    2503     mode_store=get(handles.ListPairMode,'String');%get the present 'mode'
    2504     set(handles.ListCompareMode,'UserData',mode_store);%store the mode display
    2505     set(handles.ListPairMode,'Visible','off')
    2506    
    2507     %% open an image file with the browser
    2508     ind_opening=1;%default
    2509     browse.incr_pair=[0 0]; %default
    2510     oldfile=get(handles.RootPath,'String');
    2511     menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)';
    2512         '*.png','.png image files'; ...
    2513         '*.jpg',' jpeg image files'; ...
    2514         '*.tif','.tif image files'; ...
    2515         '*.avi;*.AVI','.avi movie files'; ...
    2516         '*.*',  'All Files (*.*)'};
    2517     if strcmp(option,'displacement')
    2518         comment='Pick the reference file for displacements';
    2519     else
    2520         comment='Pick a file of the second series';
    2521     end
    2522     [FileName, PathName] = uigetfile( menu, comment,oldfile);
    2523     fileinput=[PathName FileName];%complete file name
    2524     sizf=size(fileinput);
    2525     if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    2526     [path,name,ext]=fileparts(fileinput);
    2527     [path1]=fileparts(filebase);
    2528     if isunix
    2529         [status,path]=system(['readlink ' path]);
    2530         [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths
    2531     end
    2532     if ~strcmp(path1,path)
    2533         msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one')
    2534         return
    2535     end
    2536     if strcmp(option,'displacement')
    2537         [tild,RootFile_1]=fileparts(name);
    2538     else
    2539         [FilePath,FileName,Ext]=fileparts(fileinput);
    2540 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    2541 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    2542 [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);
    2543 
    2544         %check image nom type
    2545         if ~strcmp(nom_type_1,get(handles.NomType,'String'))
    2546         msgbox_uvmat('ERROR','The second image series must have the same indexing type as the first one, or use the option displacement for a fixed image')
    2547         return
    2548         end
    2549     end   
    2550     %check image  extension
    2551     if ~strcmp(ext,get(handles.ImaExt,'String'))
    2552         msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')
    2553         return
    2554     end
    2555     set(handles.RootFile_1,'String',RootFile_1);
    2556 else
    2557     set(handles.ListPairMode,'Visible','on')
    2558     set(handles.RootFile_1,'Visible','Off');
    2559     set(handles.sub_txt,'Visible','off')
    2560     set(handles.RootFile_1,'String',[]);
    2561     mode_store=get(handles.ListCompareMode,'UserData');
    2562     set(handles.ListPairMode,'Value',1)
    2563     set(handles.ListPairMode,'String',mode_store)
    2564     set(handles.CheckStereo,'Value',0)
    2565     set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default
     2500switch option
     2501    case 'PIV'
     2502        set(handles.RootFile_1,'Visible','Off');
     2503        set(handles.sub_txt,'Visible','off')
     2504        set(handles.RootFile_1,'String',[]);
     2505        mode_store=get(handles.ListCompareMode,'UserData');
     2506        set(handles.ListPairMode,'Visible','on')
     2507        set(handles.ListPairMode,'Value',1)
     2508        set(handles.ListPairMode,'String',mode_store)
     2509        set(handles.CheckStereo,'Value',0)     
     2510    case 'PIV volume'     
     2511        set(handles.RootFile_1,'Visible','Off');
     2512        set(handles.sub_txt,'Visible','off')
     2513        set(handles.RootFile_1,'String',[]);
     2514        mode_store=get(handles.ListCompareMode,'UserData');
     2515        set(handles.ListPairMode,'Visible','on')
     2516        set(handles.ListPairMode,'Value',1)
     2517        set(handles.ListPairMode,'String',{'series(Di)'})
     2518        set(handles.CheckStereo,'Value',0)
     2519        set(handles.last_j,'String',get(handles.nb_field2,'String'))% select the whole volume scan by default
     2520        set(handles.incr_i,'String',num2str(2))%
     2521    otherwise
     2522        filebase=get(handles.RootPath,'String');
     2523        set(handles.sub_txt,'Visible','on')
     2524        set(handles.RootFile_1,'Visible','On');%mkes the second file input window visible
     2525        mode_store=get(handles.ListPairMode,'String');%get the present 'mode'
     2526        set(handles.ListCompareMode,'UserData',mode_store);%store the mode display
     2527        set(handles.ListPairMode,'Visible','off')
     2528       
     2529        %% open an image file with the browser
     2530        ind_opening=1;%default
     2531        browse.incr_pair=[0 0]; %default
     2532        oldfile=get(handles.RootPath,'String');
     2533        menu={'*.png;*.jpg;*.tif;*.avi;*.AVI;', ' (*.png,*.jpg ,.tif, *.avi,*.AVI)';
     2534            '*.png','.png image files'; ...
     2535            '*.jpg',' jpeg image files'; ...
     2536            '*.tif','.tif image files'; ...
     2537            '*.avi;*.AVI','.avi movie files'; ...
     2538            '*.*',  'All Files (*.*)'};
     2539        if strcmp(option,'displacement')
     2540            comment='Pick the reference file for displacements';
     2541        else
     2542            comment='Pick a file of the second series';
     2543        end
     2544        [FileName, PathName] = uigetfile( menu, comment,oldfile);
     2545        fileinput=[PathName FileName];%complete file name
     2546        sizf=size(fileinput);
     2547        if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
     2548        [path,name,ext]=fileparts(fileinput);
     2549        [path1]=fileparts(filebase);
     2550        if isunix
     2551            [status,path]=system(['readlink ' path]);
     2552            [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths
     2553        end
     2554        if ~strcmp(path1,path)
     2555            msgbox_uvmat('ERROR','The second image or series must be in the same directory as the first one')
     2556            return
     2557        end
     2558        if strcmp(option,'displacement')
     2559            [tild,RootFile_1]=fileparts(name);
     2560        else
     2561            [FilePath,FileName,Ext]=fileparts(fileinput);
     2562            % detect the file type, get the movie object if relevant, and look for the corresponding file series:
     2563            % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     2564            [RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);
     2565           
     2566            %check image nom type
     2567            if ~strcmp(nom_type_1,get(handles.NomType,'String'))
     2568                msgbox_uvmat('ERROR','The second image series must have the same indexing type as the first one, or use the option displacement for a fixed image')
     2569                return
     2570            end
     2571        end
     2572        %check image  extension
     2573        if ~strcmp(ext,get(handles.ImaExt,'String'))
     2574            msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one')
     2575            return
     2576        end
     2577        set(handles.RootFile_1,'String',RootFile_1);
     2578       
    25662579end
    25672580ListPairMode_Callback(hObject, eventdata, handles)
  • trunk/src/civ_matlab.m

    r582 r591  
    8585    end
    8686   
    87     % caluclate velocity data (y and v in indices, reverse to y component)
    88     [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1);
    89     if ~isempty(errormsg)
    90         return
    91     end
    9287    list_param=(fieldnames(Param.Civ1))';
    9388    Civ1_param=list_param;%default
     89   
    9490    %set the values of all the global attributes in list_param
     91    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];
    9592    for ilist=1:length(list_param)
    9693        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
    9794        Data.(['Civ1_' list_param{ilist}])=Param.Civ1.(list_param{ilist});
    9895    end
    99     Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];% {'Civ1_Time','Civ1_Dt'}];
     96    Data.CivStage=1;
     97   
     98    % set the list of variables
    10099    Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};%  cell array containing the names of the fields to record
    101100    Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'};
     
    105104    Data.VarAttribute{4}.Role='vector_y';
    106105    Data.VarAttribute{5}.Role='warnflag';
    107     Data.Civ1_X=reshape(xtable,[],1);
    108     Data.Civ1_Y=reshape(Param.Civ1.ImageHeight-ytable+1,[],1);
    109     Data.Civ1_U=reshape(utable,[],1);
    110     Data.Civ1_V=reshape(-vtable,[],1);
    111     Data.Civ1_C=reshape(ctable,[],1);
    112     Data.Civ1_F=reshape(F,[],1);
    113     Data.CivStage=1;
     106   
     107    if 'PIV volume'
     108        Data.ListVarName=[Data.ListVarName 'Civ1_Z'];
     109        Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[];
     110        Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[];Data.Civ1_F=[];
     111        for ivol=1:NbSlice
     112            % caluclate velocity data (y and v in indices, reverse to y component)
     113            [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1);
     114            if ~isempty(errormsg)
     115                return
     116            end
     117            Data.Civ1_X=[Data.Civ1_X reshape(xtable,[],1)];
     118            Data.Civ1_Y=[Data.Civ1_Y reshape(Param.Civ1.ImageHeight-ytable+1,[],1)];
     119            Data.Civ1_Z=[Data.Civ1_Z ivol*ones(numel(xtable),1)];% z=image index in image coordinates
     120            Data.Civ1_U=[Data.Civ1_U reshape(utable,[],1)];
     121            Data.Civ1_V=[Data.Civ1_V reshape(-vtable,[],1)];
     122            Data.Civ1_C=[Data.Civ1_C reshape(ctable,[],1)];
     123            Data.Civ1_F=[Data.Civ1_C reshape(F,[],1)];
     124        end
     125    else %usual PIV
     126        % caluclate velocity data (y and v in indices, reverse to y component)
     127        [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1);
     128        if ~isempty(errormsg)
     129            return
     130        end
     131        Data.Civ1_X=reshape(xtable,[],1);
     132        Data.Civ1_Y=reshape(Param.Civ1.ImageHeight-ytable+1,[],1);
     133        Data.Civ1_U=reshape(utable,[],1);
     134        Data.Civ1_V=reshape(-vtable,[],1);
     135        Data.Civ1_C=reshape(ctable,[],1);
     136        Data.Civ1_F=reshape(F,[],1);
     137    end
    114138else
    115139    if exist('ncfile','var')
  • trunk/src/fill_GUI.m

    r569 r591  
    11%'fill_GUI': fill a GUI with a set of parameters from a Matlab structure
    22% -----------------------------------------------------------------------
    3 % function errormsg=fill_GUI(Param,handles)
     3% function errormsg=fill_GUI(Param,GUI_handle)
    44% OUPUT:
    55% errormsg: error message, ='' by default
     
    1111% see also the reverse function read_GUI.m
    1212%
    13 function errormsg=fill_GUI(Param,handles)
     13function errormsg=fill_GUI(Param,GUI_handle)
    1414%------------------------------------------------------------------------
    1515errormsg='';
     16handles=guidata(GUI_handle);
     17UserData=get(GUI_handle,'UserData');
    1618fields=fieldnames(Param);%list of fields in Param
    1719% loop on the elements of the input structure Param
     
    2123        if isfield(handles,fields{ifield})
    2224            set(handles.(fields{ifield}),'Visible','on')
    23             children=get(handles.(fields{ifield}),'children');
    24             for ichild=1:numel(children)
    25                 hchild.(get(children(ichild),'tag'))=children(ichild);
    26             end
    27             errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure
     25%             children=get(handles.(fields{ifield}),'children');
     26%             for ichild=1:numel(children)
     27%                 hchild.(get(children(ichild),'tag'))=children(ichild);
     28%             end
     29         %   errormsg=fill_GUI(Param.(fields{ifield}),hchild);% apply the function to the substructure
     30         errormsg=fill_GUI(Param.(fields{ifield}),handles.(fields{ifield}));% apply the function to the substructure
     31           % if the input sub-structure fits with a tag name of the GUI and a
     32         % substructure of UserData
     33        elseif isfield(UserData,fields{ifield})&& isfield(handles,fields{ifield})&&isfield(Param.(fields{ifield}),'Name')
     34            UserData.(fields{ifield})=Param.(fields{ifield});
     35            set(handles.(fields{ifield}),'String',Param.(fields{ifield}).Name)
    2836        end
    2937    % case of an element
  • trunk/src/geometry_calib.m

    r569 r591  
    818818set(handles.XImage,'String',coord_str(k(3)+3:k(4)-1))
    819819set(handles.YImage,'String',coord_str(k(4)+3:end))
    820 h_menu_coord=findobj(huvmat,'Tag','transform_fct');
     820h_menu_coord=findobj(huvmat,'Tag','TransformName');
    821821menu=get(h_menu_coord,'String');
    822822choice=get(h_menu_coord,'Value');
     
    914914hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat
    915915%hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
    916 h_menu_coord=findobj(huvmat,'Tag','transform_fct');
     916h_menu_coord=findobj(huvmat,'Tag','TransformName');
    917917menu=get(h_menu_coord,'String');
    918918choice=get(h_menu_coord,'Value');
  • trunk/src/get_field.m

    r586 r591  
    225225%% Make choices in menus from input
    226226if exist('ParamIn','var')&&~isempty(ParamIn)
    227     fill_GUI(ParamIn,handles);
     227    fill_GUI(ParamIn,handles.get_field);
    228228end
    229229CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
  • trunk/src/get_file_series.m

    r540 r591  
    1515function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
    1616
    17 filecell={};
     17filecell={};i1_series={};i2_series={};j1_series={};j2_series={};
    1818InputTable=Param.InputTable;
    1919first_i=Param.IndexRange.first_i;
  • trunk/src/imadoc2struct.m

    r582 r591  
    8686        Dtk=[];%default
    8787        NbDtk=1;%default
    88         if isfield(Timing,'Dtk')
     88        if isfield(Timing{k},'Dtk')
    8989            Dtk=Timing{k}.Dtk;
    9090        end
    91         if isfield(Timing,'NbDtk')&&~isempty(Timing{k}.NbDtk)
     91        if isfield(Timing{k},'NbDtk')&&~isempty(Timing{k}.NbDtk)
    9292            NbDtk=Timing{k}.NbDtk;
    9393        end
  • trunk/src/read_GUI.m

    r517 r591  
    8888    end
    8989end
     90% read UserData if relevant
     91UserData=get(handle,'UserData');
     92if isstruct(UserData)
     93    List=fields(UserData);
     94    for ilist=1:numel(List)
     95        if isstruct(UserData.(List{ilist}))
     96            heditbox=findobj(handle,'Tag',List{ilist},'Style','edit','Visible','on');
     97            if isequal(numel(heditbox),1)
     98                struct.(List{ilist})=UserData.(List{ilist});
     99            end
     100        end
     101    end
     102end
  • trunk/src/series.m

    r586 r591  
    5959% --- Executes just before series is made visible.
    6060%--------------------------------------------------------------------------
    61 function series_OpeningFcn(hObject, eventdata, handles,param)
    62 global nb_builtin_ACTION nb_builtin_transform
     61function series_OpeningFcn(hObject, eventdata, handles,Param)
     62
    6363% Choose default command line output for series
    6464handles.output = hObject;
    6565% Update handles structure
    6666guidata(hObject, handles);
    67 %default initial parameters
     67
     68%% initial settings
    6869drawnow
    6970set(hObject,'Units','pixels')
     
    7475series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size
    7576set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display)
     77% check default input data
     78if ~exist('Param','var')
     79    Param=[]; %default
     80end
     81
     82%% default list of functions in the mebu ActionName
     83ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
     84[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
     85path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
     86path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled)
     87ActionPathList=regexprep(ActionList,'^.+$',path_series_fct);% set path=path_series to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string)
     88ActionPathList=[ActionPathList regexprep(ActionList,'^.+$',path_bin)];% set path to compiled functions
     89ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh)
     90RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh)
     91[s,w]=system('oarstat');% look for cluster system 'oar'
     92if isequal(s,0)
     93    RunModeList=[RunModeList;{'cluster_oar'}];
     94end
     95[s,w]=system('qstat');% look for cluster system 'sge'
     96if isequal(s,0)
     97    RunModeList=[RunModeList;{'cluster_sge'}];
     98end
     99set(handles.RunMode,'String',RunModeList)
     100
     101%% default list of functions in the mebu TransformName
     102TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in  TransformName_callback
     103path_transform_fct=fullfile(path_series,'transform_field');
     104TransformPathList=regexprep(TransformList,'^.+$',path_transform_fct);% set path=path_transform_fct to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string)
     105
     106%% load the personal file uvmat_perso.mat
    76107dir_perso=prefdir;
    77 test_profil_perso=0;
    78108profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    79109if exist(profil_perso,'file')
    80      h=load (profil_perso);
    81      if isfield(h,'MenuFile')
    82           for ifile=1:min(length(h.MenuFile),5)
    83               eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
    84           end
    85      end
    86      test_profil_perso=1;
    87 end
    88 
    89 %check default input data
    90 if ~exist('param','var')
    91     param=[]; %default
    92 end
    93 
    94 %% file name and browser initialisation
    95 if isfield(param,'transform_str')
    96     set(handles.TransformName,'String',param.transform_str)
    97 end
    98 if isfield(param,'transform_val')
    99     set(handles.TransformName,'Value',param.transform_val);
    100 else
    101      set(handles.TransformName,'Value',1);%default
    102 end
    103 if isfield(param,'FileName')
    104     InputTable={'','','','',''};
    105     set(handles.InputTable,'Data',InputTable)
    106     if isfield(param,'FileName_1')
    107         display_file_name(handles,param.FileName_1,0)
    108         display_file_name(handles,param.FileName,1)
    109     else
    110         display_file_name(handles,param.FileName,0)
    111     end
    112 end 
    113 if isfield(param,'incr_i')
    114     set(handles.num_incr_i,'String',num2str(param.incr_i))
    115 end
    116 if isfield(param,'incr_j')
    117     set(handles.num_incr_j,'String',num2str(param.incr_j))
    118 end
    119 
     110    h=load (profil_perso);
     111    %get the list of previous input files in the upper bar menu Open
     112    if isfield(h,'MenuFile')
     113        for ifile=1:min(length(h.MenuFile),5)
     114            eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
     115        end
     116    end
     117    %get the menu of actions
     118    if isfield(h,'ActionExtListUser') && iscell(h.ActionExtListUser)
     119        ActionExtList=[ActionExtList; h.ActionExtListUser];
     120    end
     121    if isfield(h,'ActionListUser') && iscell(h.ActionListUser) && isfield(h,'ActionPathListUser') && iscell(h.ActionPathListUser)
     122        ActionList=[ActionList;h.ActionListUser];
     123        ActionPathList=[ActionPathList;h.ActionPathListUser];
     124    end
     125    %get the menu of transform fct
     126    if isfield(h,'TransformListUser') && iscell(h.TransformListUser) && isfield(h,'TransformPathListUser') && iscell(h.TransformPathListUser)
     127        TransformList=[TransformList;h.TransformListUser];
     128        TransformPathList=[TransformPathList;h.TransformPathListUser];
     129    end
     130end
     131
     132%% selection of the input Action fct
     133ActionCheckExist=false(size(ActionList));
     134for ilist=1:numel(ActionList)
     135    ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file');
     136end
     137ActionPathList=ActionPathList(ActionCheckExist,:);
     138ActionList=ActionList(ActionCheckExist);
     139set(handles.ActionName,'String',[ActionList;{'more...'}])
     140set(handles.ActionName,'UserData',ActionPathList)
     141ActionIndex=[];
     142if isfield(Param,'ActionName')% copy the selected menu index transferred in Param from uvmat
     143    ActionIndex=find(strcmp(Param.ActionName,ActionList),1);
     144end
     145if isempty(ActionIndex)
     146    ActionIndex=1;
     147end
     148set(handles.ActionName,'Value',ActionIndex)
     149set(handles.ActionPath,'String',ActionPathList{ActionIndex})
     150set(handles.ActionExt,'Value',1)
     151set(handles.ActionExt,'String',ActionExtList)
     152
     153%% selection of the input transform fct
     154TransformCheckExist=false(size(TransformList));
     155TransformCheckExist(1)=1;%the first option is blank: no transform, always allowed
     156for ilist=2:numel(TransformList)
     157    TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file');
     158end
     159TransformPathList=TransformPathList(TransformCheckExist);
     160TransformList=TransformList(TransformCheckExist);
     161set(handles.TransformName,'String',[TransformList;{'more...'}])
     162set(handles.TransformName,'UserData',TransformPathList)
     163TransformIndex=[];
     164if isfield(Param,'TransformName')% copy the selected menu index transferred in Param from uvmat
     165    TransformIndex=find(strcmp(Param.TransformName,TransformList),1);
     166end
     167if isempty(TransformIndex)
     168    TransformIndex=1;
     169end
     170set(handles.TransformName,'Value',TransformIndex)
     171set(handles.TransformPath,'String',TransformPathList{TransformIndex})
     172   
    120173%% fields input initialisation
    121 if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields)
    122     set(handles.FieldName,'String',param.list_fields);% list menu fields
    123     set(handles.FieldName,'Value',param.index_fields);% selected string index
    124 end
    125 if isfield(param,'Coord_x_str')&& isfield(param,'Coord_x_val')
    126         set(handles.Coord_x,'String',param.Coord_x_str);% list menu fields
    127     set(handles.Coord_x,'Value',param.Coord_x_val);% selected string index
    128 end
    129 if isfield(param,'Coord_y_str')&& isfield(param,'Coord_y_val')
    130         set(handles.Coord_y,'String',param.Coord_y_str);% list menu fields
    131     set(handles.Coord_y,'Value',param.Coord_y_val);% selected string index
    132 end
    133 
    134 %loads the information stored in prefdir to initiate  the list of ActionName functions
    135 fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
    136 transform_menu={'';'phys';'px';'phys_polar'};
    137 nb_builtin_ACTION=numel(fct_menu); %number of functions
    138 nb_transform=numel(transform_menu);
    139 [path_series,name,ext]=fileparts(which('series'));
    140 path_series=fullfile(path_series,'series');%path of the function 'series'
    141 addpath (path_series) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory)
    142 path_transform=fullfile(path_series,'transform_field');%path to the field transform functions
    143 for ilist=1:length(fct_menu)
    144     fct_path{ilist,1}=path_series;%paths of the fuctions buil-in in 'series.m'
    145 end
    146 
    147 %% TRANSFORM menu: loads the information stored in prefdir to initiate  the list of field transform functions
    148 menu_str={'';'sub_field';'phys';'phys_polar'};
    149 nb_builtin_transform=numel(menu_str); %number of functions
    150 [path_uvmat,name,ext]=fileparts(which('uvmat'));
    151 addpath(fullfile(path_uvmat,'transform_field'))
    152 fct_handle{1,1}=[];
    153 testexist(1)=1;
    154 for ilist=2:length(menu_str)
    155     if exist(menu_str{ilist},'file')
    156         fct_handle{ilist,1}=str2func(menu_str{ilist});
    157         testexist(ilist)=1;
    158     else
    159         testexist(ilist)=0;
    160     end
    161 end
    162 rmpath(fullfile(path_uvmat,'transform_field'))
    163 
    164 %% read the list of transform functions stored in the personal file 'uvmat_perso.mat' in prefdir
    165 if test_profil_perso
    166     if isfield(h,'series_fct') && iscell(h.series_fct)
    167          for ilist=1:length(h.series_fct)
    168              [path,file]=fileparts(h.series_fct{ilist});
    169              fct_path=[fct_path; {path}];%concatene the list of paths
    170              fct_menu=[fct_menu; {file}];
    171          end
    172     end
    173     if isfield(h,'transform_fct') && iscell(h.transform_fct)
    174         for ilist=1:length(h.transform_fct);
    175              [path,file]=fileparts(h.transform_fct{ilist});
    176              addpath(path)
    177              if exist(file,'file')
    178                 h_func=str2func(file);
    179                 testexist=[testexist 1];
    180              else
    181                 h_func=[];
    182                 testexist=[testexist 0];
    183              end
    184              fct_handle=[fct_handle; {h_func}];%concatene the list of paths
    185              rmpath(path)
    186              menu_str=[menu_str; {file}];
    187         end
    188     end
    189 end
    190 fct_menu=[fct_menu;{'more...'}];
    191 set(handles.ActionName,'String',fct_menu)
    192 set(handles.ActionName,'UserData',fct_path)% store the list of path in UserData of ACTION
    193 menu_str=menu_str(find(testexist));
    194 fct_handle=fct_handle(find(testexist));
    195 menu_str=[menu_str;{'more...'}];
    196 set(handles.TransformName,'String',menu_str)
    197 set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION
     174if isfield(Param,'list_fields')&& isfield(Param,'index_fields') &&~isempty(Param.list_fields) &&~isempty(Param.index_fields)
     175    set(handles.FieldName,'String',Param.list_fields);% list menu fields
     176    set(handles.FieldName,'Value',Param.index_fields);% selected string index
     177end
     178if isfield(Param,'Coord_x_str')&& isfield(Param,'Coord_x_val')
     179        set(handles.Coord_x,'String',Param.Coord_x_str);% list menu fields
     180    set(handles.Coord_x,'Value',Param.Coord_x_val);% selected string index
     181end
     182if isfield(Param,'Coord_y_str')&& isfield(Param,'Coord_y_val')
     183        set(handles.Coord_y,'String',Param.Coord_y_str);% list menu fields
     184    set(handles.Coord_y,'Value',Param.Coord_y_val);% selected string index
     185end
    198186
    199187%% Adjust the GUI according to the binaries available in PARAM.xml
     
    207195        sparam=convert(t);
    208196    catch ME
    209         errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
     197        errormsg={' Unable to read the file PARAM.xml defining the binaries:';ME.message};
    210198    end
    211199else
    212     errormsg=[xmlfile ' not found: path to civx binaries undefined'];
     200    errormsg=[xmlfile ' not found: path to binaries undefined'];
    213201end
    214202if ~isempty(errormsg)
     
    228216    set(handles.RunMode,'String',{'local';'background';'cluster'})
    229217end
     218
     219%% introduce the input file name(s) if defined from input Param
     220if isfield(Param,'FileName')
     221    InputTable={'','','','',''}; % refresh the file input table
     222    set(handles.InputTable,'Data',InputTable)
     223    if isfield(Param,'FileName_1')
     224        display_file_name(handles,Param.FileName_1,0)
     225        display_file_name(handles,Param.FileName,1)
     226    else
     227        display_file_name(handles,Param.FileName,0)
     228    end
     229end 
     230if isfield(Param,'incr_i')
     231    set(handles.num_incr_i,'String',num2str(Param.incr_i))
     232end
     233if isfield(Param,'incr_j')
     234    set(handles.num_incr_j,'String',num2str(Param.incr_j))
     235end
     236
    230237
    231238%------------------------------------------------------------------------
     
    293300        msg_box_uvmat('ERROR','xml file heading is not <Series>')
    294301    else
    295         fill_GUI(Param,handles);%fill the GUI with the parameters retrieved from the xml file
     302        fill_GUI(Param,handles.series);%fill the GUI with the parameters retrieved from the xml file
    296303        if isfield(Param,'CheckObject')&& Param.CheckObject
    297304            set_object(Param.ProjObject)
     
    832839    x_index=find(pair_max{iview}>0)-index_min+1;
    833840    LineData(x_index)=1;
     841    if numel(x)>1
    834842    LineData=interp1(x,LineData,xI,'nearest');
    835843    CData(ind_y,:)=ones(size(ind_y'))*LineData;
     844    end
    836845end
    837846CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));
     
    13061315RunModeList=get(handles.RunMode,'String');
    13071316RunMode=RunModeList{get(handles.RunMode,'Value')};
    1308 
     1317ActionExtList=get(handles.ActionExt,'String');
     1318ActionExt=ActionExtList{get(handles.ActionExt,'Value')};% '.m' or '.sh' (compiled)
     1319ActionPath=get(handles.ActionPath,'String');
     1320ActionList=get(handles.ActionName,'String');
     1321ActionName=ActionList{get(handles.ActionName,'Value')};
     1322
     1323%% set nbre of processes
     1324if isfield(Series,'NbSlice')&&~isempty(Series.NbSlice)
     1325    NbProcess=Series.NbSlice;
     1326else
     1327    switch RunMode
     1328        case {'local','background'}
     1329         NbCore=1;% no need to split the calculation
     1330        case 'cluster'
     1331            if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
     1332                NbCore=1;% one core used only (limitation of Matlab licences)
     1333                msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
     1334            else
     1335            answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
     1336            NbCore=str2double(answer{1});
     1337            end
     1338    end
     1339    NbProcess=NbCore;% choose one process per core
     1340end
     1341for iprocess=1:NbProcess% TOD0
     1342%     split the input files
     1343%     adjust Param
     1344%     create xmlfile and batfile
     1345end
    13091346switch RunMode
    13101347    case 'local'
    1311         Series=h_fun(Series);
    1312         if ~isempty(filexml)
    1313             t=struct2xml(Series);
    1314             t=set(t,1,'name','Series');
    1315             save(t,filexml);
     1348        switch ActionExt
     1349            case '.m'
     1350                for iprocess=1:NbProcess
     1351                    if ~isempty(filexml)
     1352                        t=struct2xml(Series);
     1353                        t=set(t,1,'name','Series');
     1354                        save(t,filexml);
     1355                    end
     1356                    Series.RUNHandle=handles.RUN;
     1357                    Series.WaitbarHandle=handles.Waitbar;
     1358                    Series=h_fun(Series);
     1359                end
     1360            case '.sh'
     1361                for iprocess=1:NbProcess
     1362                    CivmBin=fullfile(ActionPath,[ActionName '.sh']); %path to the source directory of uvmat
     1363                    switch computer
     1364                        case {'PCWIN','PCWIN64'}
     1365                            filename=regexprep(filename,'\\','\\\\');% add '\' so that '\' are left as characters
     1366                            % TODO launch command in DOS
     1367                        case {'GLNX86','GLNXA64','MACI64'}
     1368                            cmd=['#!/bin/bash \n '...
     1369                                '#$ -cwd \n '...
     1370                                'hostname && date \n '...
     1371                                'umask 002 \n'...
     1372                                CivmBin ' ' Param.xml.RunTime ' ' regexprep(filename,'(.+)([/\\])(.+$)','$1$20_XML$2$3.xml') ' ' Param.OutputFile '.nc'];%allow writting access to created files for user group
     1373                    end
     1374                end
    13161375        end
    13171376    case 'background'
     
    13201379        else
    13211380            % update the xml file after interactive input with the function
    1322             Series.Specific='?';
    1323             Series=h_fun(Series);
     1381%             Series.Specific='?';
     1382%             Series=h_fun(Series);
    13241383            t=struct2xml(Series);
    13251384            t=set(t,1,'name','Series');
     
    13271386            path_uvmat=fileparts(which('uvmat'));
    13281387           
    1329             filename_bat=regexprep(filexml,'.xml$','.bat');
     1388            filename_bat=regexprep(filexml,'.xml$','.bat');% create executable file to run program in background
    13301389            [fid,message]=fopen(filename_bat,'w');
    13311390            if isequal(fid,-1)
     
    13331392                return
    13341393            end
    1335             path_fct=get(handles.ActionPath,'String');
     1394            %ActionPath=get(handles.ActionPath,'String');
    13361395            filelog=regexprep(filexml,'.xml$','.log');
    13371396       
     
    13621421            end
    13631422        end
    1364         update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate lounching is finished
     1423        update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
     1424     case 'cluster' %NOT YET READY
     1425        switch batch_mode
     1426            case 'sge' %at the moment only psmn ENS Lyon uses it
     1427                for p=1:length(batch_file_list)
     1428                    cmd=['!qsub -q piv1,piv2,piv3 '...
     1429                        '-e ' regexprep(batch_file_list{p},'.bat','.errors') ' -o ' regexprep(batch_file_list{p},'.bat','.log ')...
     1430                        ' -v ' 'LD_LIBRARY_PATH=/home/sjoubaud/matlab_sylvain/civx/lib ' batch_file_list{p}];
     1431                    display(cmd);eval(cmd);
     1432                end
     1433            case 'oar'
     1434                max_walltime=3600*12; % 12h max
     1435                oar_modes={'oar-parexec','oar-dispatch','mpilauncher'};
     1436                text={'Batch processing on servcalcul3 LEGI';...
     1437                    'Please choose one of the followint modes';...
     1438                    '* oar-parexec : default and best choice';...
     1439                    '* oar-dispatch : jobs in a container of several cores';...
     1440                    '* mpilauncher : one single parallel mpi job using several cores';...
     1441                    '**********************************'...
     1442                    };
     1443                [S,v]=listdlg('PromptString',text,'ListString',oar_modes,...
     1444                    'SelectionMode','single','ListSize',[400 100],'Name','LEGI job mode');
     1445                switch oar_modes{S}
     1446                    case 'oar-parexec' %oar-dispatch.pl
     1447%                         if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
     1448%                             ncores=1;% one core used only (limitation of Matlab licences)
     1449%                             msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
     1450%                         else
     1451%                         answer=inputdlg({'Number of cores (max 36)','extra oar options'},'oarsub parameter',1,{'12',''});
     1452%                         ncores=str2double(answer{1});
     1453%                         end
     1454
     1455                        extra_oar=answer{2};
     1456                        walltime_onejob=600;%seconds
     1457                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1458                        fid=fopen(filename_joblist,'w');
     1459                        for p=1:length(batch_file_list)
     1460                            fprintf(fid,[batch_file_list{p} '\n']);% list of exe files (TODO: create them)
     1461                        end
     1462                        fclose(fid);
     1463                        oar_command=['oarsub -n CIVX '...
     1464                            '-t idempotent --checkpoint ' num2str(walltime_onejob+60) ' '...
     1465                            '-l /core=' num2str(ncores) ','...
     1466                            'walltime=' datestr(min(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,max_walltime/86400),13) ' '...
     1467                            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
     1468                            '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
     1469                            extra_oar ' '...
     1470                            '"oar-parexec -s -f ' filename_joblist ' '...
     1471                            '-l ' filename_joblist '.log"\n'];
     1472                        filename_oarcommand=fullfile(RootBat,'oar_command');
     1473                        fid=fopen(filename_oarcommand,'w');
     1474                        fprintf(fid,oar_command);
     1475                        fclose(fid);
     1476                        fprintf(oar_command);% display in command line
     1477                        system(oar_command);
     1478                    case 'oar-dispatch' %oar-dispatch.pl
     1479                        ncores=str2double(...
     1480                            inputdlg('Number of cores (max 36)','oarsub parameter',1,{'6'})...
     1481                            );
     1482                        walltime_onejob=600;%seconds
     1483                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1484                        fid=fopen(filename_joblist,'w');
     1485                        for p=1:length(batch_file_list)
     1486                            oar_command=['oarsub -n CIVX '...
     1487                                '-E ' regexprep(batch_file_list{p},'\.bat\>','.stderr') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.stdout ')...
     1488                                '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '"   ' batch_file_list{p}];
     1489                            fprintf(fid,[oar_command '\n']);
     1490                        end
     1491                        fclose(fid);
     1492                        oar_command=['oarsub -t container -n civx-container '...
     1493                            '-l /core=' num2str(ncores)...
     1494                            ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '...
     1495                            '-E ' regexprep(filename_joblist,'\.txt\>','.stderr') ' '...
     1496                            '-O ' regexprep(filename_joblist,'\.txt\>','.stdout') ' '...
     1497                            '"oar-dispatch -f ' filename_joblist '"'];
     1498                        filename_oarcommand=fullfile(RootBat,'oar_command');
     1499                        fid=fopen(filename_oarcommand,'w');
     1500                        fprintf(fid,[oar_command '\n']);
     1501                        fclose(fid);
     1502                        display(oar_command);
     1503                        eval(['! . ' filename_oarcommand])
     1504                    case 'mpilauncher'
     1505                        filename_joblist=fullfile(RootBat,'job_list.txt');
     1506                        fid=fopen(filename_joblist,'w');
     1507                       
     1508                        for p=1:length(batch_file_list)
     1509                            fprintf(fid,[batch_file_list{p} '\n']);
     1510                        end
     1511                        fclose(fid)
     1512                        text_oarscript=[...
     1513                            '#!/bin/bash \n'...
     1514                            '#OAR -n Mylauncher \n'...
     1515                            '#OAR -l node=4/core=5,walltime=0:15:00 \n'...
     1516                            '#OAR -E ' fullfile(RootBat,'stderrfile.log') ' \n'...
     1517                            '#OAR -O ' fullfile(RootBat,'stdoutfile.log') ' \n'...
     1518                            '# ========================================================= \n'...
     1519                            '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'...
     1520                            '# application for coriolis PIV post-processing. \n'...
     1521                            '# OAR uses oarshmost wrapper to propagate the user environement. \n'...
     1522                            '# This wrapper assert that the user has the same environment on all the \n'...
     1523                            '# allocated nodes (basic behavior needed by most MPI applications).  \n'...
     1524                            '# \n'...
     1525                            '# REQUIREMENT: \n'...
     1526                            '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'...
     1527                            '# If a different location is used, change the line following the comment "Bidouille" \n'...
     1528                            '# ========================================================= \n'...
     1529                            '#   USER should only modify these 2 lines  \n'...
     1530                            'WORKDIR=' pwd ' \n'...
     1531                            'COMMANDE="mpilauncher  -f ' filename_joblist '" \n'...
     1532                            '# ========================================================= \n'...
     1533                            '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'...
     1534                            'echo "job starting on: "`hostname` \n'...
     1535                            'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'...
     1536                            'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'...
     1537                            '#========== Bidouille ============== \n'...
     1538                            'export OMPI_MCA_plm_rsh_agent=oar-envsh \n'...%                     'cd $WORKDIR \n'...
     1539                            'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'...
     1540                            'echo "I run: $CMD"  \n'...
     1541                            '$CMD \n'...
     1542                            'echo "job ending" \n'...
     1543                            ];
     1544                        filename_oarscript=fullfile(RootBat,'oar_command');
     1545                        fid=fopen(filename_oarscript,'w');
     1546                        fprintf(fid,[text_oarscript]);
     1547                        fclose(fid);
     1548                        eval(['!chmod +x  ' filename_oarscript]);
     1549                        eval(['!oarsub -S ' filename_oarscript]);
     1550                end
     1551        end
    13651552end
    13661553
    13671554set(handles.RUN, 'Enable','On')
    13681555set(handles.RUN,'BackgroundColor',[1 0 0])
     1556set(handles.RUN, 'Value',0)
    13691557
    13701558%------------------------------------------------------------------------
     
    13741562set(handles.RUN,'BackgroundColor',[1 0 0])
    13751563set(handles.RUN,'enable','on')
     1564set(handles.RUN, 'Value',0)
    13761565
    13771566% %------------------------------------------------------------------------
     
    13871576%------------------------------------------------------------------------
    13881577% --- Main launch command, called by RUN and BATCH
     1578
    13891579function [h_fun,Series,filexml,errormsg]=prepare_jobs(handles,run)
    13901580%INPUT:
     
    14031593Series=read_GUI(handles.series);
    14041594if isfield(Series,'Pairs')
    1405 Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
     1595    Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
    14061596end
    14071597
     
    14321622end
    14331623
    1434 if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
     1624if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    14351625    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
    14361626
     
    14621652index=get(handles.ActionName,'Value');
    14631653action= list_action{index}; % selected string
    1464 Series.hseries=handles.series; % handles to the series GUI
     1654%Series.hseries=handles.series; % handles to the series GUI
    14651655path_series=which('series');
    1466 list_path=get(handles.ActionName,'UserData');
    1467 fct_path=list_path{index}; %path stored for the function ACTION
    1468 if ~isequal(fct_path,path_series)
     1656ActionPathList=get(handles.ActionName,'UserData');
     1657ActionPath=ActionPathList{index}; %path stored for the function ACTION
     1658if ~isequal(ActionPath,path_series)
    14691659    eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
    1470     if ~exist(fct_path,'dir')
    1471         errormsg=['The prescribed function path ' fct_path ' does not exist'];
     1660    if ~exist(ActionPath,'dir')
     1661        errormsg=['The prescribed function path ' ActionPath ' does not exist'];
    14721662        return
    14731663    end
    1474     if ~isequal(spath,fct_path)
    1475         addpath(fct_path)% add the prescribed path if not the current one
     1664    if ~isequal(spath,ActionPath)
     1665        addpath(ActionPath)% add the prescribed path if not the current one
    14761666    end
    14771667end
    14781668eval(['h_fun=@' action ';'])%create a function handle for ACTION
    1479 if ~isequal(fct_path,path_series)
    1480         rmpath(fct_path)% add the prescribed path if not the current one   
     1669if ~isequal(ActionPath,path_series)
     1670        rmpath(ActionPath)% add the prescribed path if not the current one   
    14811671end
    14821672
    14831673%% create the output data directory and write in it the xml file from the GUI config
    14841674%determine the root file corresponding to the first sub dir
    1485 if isfield(Series,'OutputSubDir')
    1486     SubDirOut=[Series.OutputSubDir Series.OutputDirExt];
     1675if get(handles.RUN,'value') && isfield(Series,'OutputSubDir')
     1676    SubDirOut=[get(handles.OutputSubDir,'String') Series.OutputDirExt];
    14871677    SubDirOutNew=SubDirOut;
    14881678    iview=1;
    14891679    SeriesData=get(handles.series,'UserData');
    1490     if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort)
     1680    if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort
    14911681        [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order
    14921682        Series.InputTable=Series.InputTable(iview,:);
     
    15291719Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex');
    15301720%removes empty lines of InputTable
    1531 empty_line=zeros(size(Series.InputTable,1),1);
     1721empty_line=false(size(Series.InputTable,1),1);
    15321722for iline=1:size(Series.InputTable,1)
    15331723    empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''});
    15341724end
    1535 Series.InputTable(find(empty_line),:)=[];
     1725Series.InputTable(empty_line,:)=[];
    15361726
    15371727%------------------------------------------------------------------------
     
    15391729function ActionName_Callback(hObject, eventdata, handles)
    15401730%------------------------------------------------------------------------
    1541 global nb_builtin_ACTION
    1542 list_ACTION=get(handles.ActionName,'String');% list menu fields
    1543 index_ACTION=get(handles.ActionName,'Value');% selected string index
    1544 ACTION= list_ACTION{index_ACTION}; % selected function name
    1545 path_series=which('series');%path to series.m
    1546 list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION
    1547 default_file=fullfile(list_path{end},ACTION);
    1548 % add a new function to the menu if the selected item is 'more...'
    1549 if isequal(ACTION,'more...')
    1550     pathfct=fileparts(path_series);
    1551     [FileName, PathName, filterindex] = uigetfile( ...
    1552        {'*.m', ' (*.m)';
     1731%% stop any ongoing series processing
     1732if isequal(get(handles.RUN,'Value'),1)
     1733    answer= msgbox_uvmat('INPUT_Y-N','stop current Action process?');
     1734    if strcmp(answer,'Yes')
     1735        STOP_Callback(hObject, eventdata, handles)
     1736    else
     1737        return
     1738    end
     1739end
     1740
     1741%% get Action name and path
     1742nb_builtin_ACTION=4; %nbre of functions initially proposed in the menu ActionName (as defined in the Opening fct of series)
     1743ActionList=get(handles.ActionName,'String');% list menu fields
     1744ActionIndex=get(handles.ActionName,'Value');
     1745if ~isequal(ActionIndex,1)
     1746    InputTable=get(handles.InputTable,'Data');
     1747    if isempty(InputTable{1,4})
     1748        msgbox_uvmat('ERROR','no input file available: use Open in the menu bar')
     1749        return
     1750    end
     1751end
     1752ActionName= ActionList{get(handles.ActionName,'Value')}; % selected function name
     1753ActionPathList=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ActionName
     1754
     1755%% add a new function to the menu if 'more...' has been selected in the menu ActionName
     1756if isequal(ActionName,'more...')
     1757    [FileName, PathName] = uigetfile( ...
     1758        {'*.m', ' (*.m)';
    15531759        '*.m',  '.m files '; ...
    15541760        '*.*', 'All Files (*.*)'}, ...
    1555         'Pick a file',default_file);
     1761        'Pick a series processing function ',get(handles.ActionPath,'String'));
    15561762    if length(FileName)<2
    15571763        return
    1558     end
    1559     [pp,ACTION,ext_fct]=fileparts(FileName);%(end-1:end);
    1560     if ~isequal(ext_fct,'.m')
    1561         msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
    1562         return
    1563     end
     1764    end
     1765    [ActionPath,ActionName,ActionExt]=fileparts(FileName);
     1766    % insert the choice in the menu
     1767    ActionIndex=find(strcmp(ActionName,ActionList),1);% look for the selected function in the menu Action
     1768    if isempty(ActionIndex)%the input string does not exist in the menu
     1769        ActionIndex= length(ActionList);
     1770        ActionList=[ActionList(1:end-1);{ActionName};ActionList(end)];% the selected function is appended in the menu, before the last item 'more...'
     1771        set(handles.ActionName,'String',ActionList)
     1772    end
     1773    %set(handles.ActionName,'Value',ActionIndex)
     1774    %list_path{ActionIndex}=PathName;
     1775    % remove old Action options in the menu (keeping a menu length <nb_builtin_ACTION+5)
     1776    if length(ActionList)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu
     1777        nbremove=length(ActionList)-nb_builtin_ACTION-5;
     1778        ActionList(nb_builtin_ACTION+1:end-5)=[];
     1779        ActionPathList(nb_builtin_ACTION+1:end-4)=[];
     1780        ActionIndex=ActionIndex-nbremove;
     1781    end
     1782    set(handles.ActionName,'Value',ActionIndex)
     1783    set(handles.ActionName,'String',ActionList)
     1784    ActionPathList{ActionIndex}=PathName;
     1785    set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off')
    15641786   
    1565    % insert the choice in the actionname menu
    1566    menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed
    1567    index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list
    1568    list_path{index_ACTION}=PathName;
    1569    if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu
    1570        nbremove=length(menu_str)-nb_builtin_ACTION-5;
    1571        menu_str(nb_builtin_ACTION+1:end-5)=[];
    1572        list_path(nb_builtin_ACTION+1:end-4)=[];
    1573        index_ACTION=index_ACTION-nbremove;
    1574        set(handles.ActionName,'Value',index_ACTION)
    1575        set(handles.ActionName,'String',menu_str)
    1576    end
    1577    list_path{index_ACTION}=PathName;
    1578    set(handles.ActionName,'UserData',list_path);
    1579    set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off')
    1580    
    1581    %record the current menu in personal file profil_perso
    1582    dir_perso=prefdir;
    1583    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    1584    for ilist=nb_builtin_ACTION+1:length(menu_str)-1
    1585        series_fct{ilist-nb_builtin_ACTION}=fullfile(list_path{ilist},[menu_str{ilist} '.m']);     
    1586    end
    1587    if nb_builtin_ACTION+1<=length(menu_str)-1
    1588        if exist(profil_perso,'file')% && nb_builtin_ACTION+1>=length(menu_str)-1
    1589            save(profil_perso,'series_fct','-append')
    1590        else
    1591            txt=ver('MATLAB');
    1592            Release=txt.Release;
    1593            relnumb=str2num(Release(3:4));
    1594            if relnumb >= 14%recent relaese of Matlab
    1595                save(profil_perso,'series_fct','-V6')
    1596            else
    1597                save(profil_perso, 'series_fct')
    1598            end
    1599        end
    1600    end
    1601 end
    1602 
    1603 %check the current ActionPath to the selected function
    1604 PathName=list_path{index_ACTION};%current recorded path
     1787    % record the file extension and update the paths in userdata
     1788    ActionExtList=get(handles.ActionExt,'String');
     1789    ActionExtIndex=find(strcmp(ActionExt,ActionExtList), 1);
     1790    if isempty(ActionExtIndex)
     1791        set(handles.ActionExt,'String',[ActionExtList;{ActionExt}])
     1792        set(handles.ActionExt,'Value',numel(ActionExtList)+1)
     1793        ActionPathNew=cell(size(ActionPathList,1),1);%new column of ActionPath
     1794        ActionPathNew{ActionIndex}=ActionPath;
     1795        ActionPathList=[ActionPathList ActionPathNew];
     1796    end
     1797    set(handles.ActionName,'UserData',ActionPathList);
     1798   
     1799    %record the current menu in personal file profil_perso
     1800    dir_perso=prefdir;
     1801    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     1802    if nb_builtin_ACTION+1<=length(ActionList)-1
     1803        ActionListUser=ActionList(nb_builtin_ACTION+1:numel(ActionList)-1);
     1804        ActionPathListUser=ActionPathList(nb_builtin_ACTION+1:numel(ActionList)-1,:);
     1805        ActionExtListUser={};
     1806        if numel(ActionExtList)>2
     1807            ActionExtListUser=ActionExtList(3:end);
     1808        end
     1809        if exist(profil_perso,'file')
     1810            save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-append')
     1811        else
     1812            save(profil_perso,'ActionListUser','ActionPathListUser','ActionExtListUser','-V6')
     1813        end
     1814    end
     1815end
     1816
     1817%% check the current ActionPath to the selected function
     1818PathName=ActionPathList{ActionIndex};%current recorded path
    16051819set(handles.ActionPath,'String',PathName); %show the path to the senlected function
    16061820
    1607 %reinitialise the waitbar
     1821%% reinitialise the waitbar
    16081822update_waitbar(handles.Waitbar,0)
    16091823
    1610 %default setting for the visibility of the GUI elements
    1611 set(handles.num_NbSlice,'Visible','off')
    1612 set(handles.NbSlice_title,'Visible','off')
    1613 set(handles.VelType,'Visible','off');
    1614 set(handles.VelType_text,'Visible','off');
    1615 set(handles.VelType_1,'Visible','off');
    1616 set(handles.VelType_text_1,'Visible','off');
    1617 set(handles.InputFields,'Visible','off')
    1618 set(handles.FieldName_1,'Visible','off')
    1619 %view_FieldMenu_1(handles,'off')
     1824%% default setting for the visibility of the GUI elements
    16201825set(handles.FieldTransform,'Visible','off')
    16211826set(handles.CheckObject,'Visible','off');
     
    16231828set(handles.CheckMask,'Visible','off')
    16241829set(handles.Mask,'Visible','off')
    1625 set(handles.OutputDirExt,'Visible','off')
    1626 set(handles.OutputSubDir,'Visible','off')
    1627 set(handles.OutputDir_title,'Visible','off')
    1628 %set the displayed GUI item needed for input parameters
    1629 if ~isequal(path_series,PathName)
    1630     addpath(PathName)
    1631 end
    1632 eval(['h_function=@' ACTION ';']);
     1830
     1831%% run the current action function to prepare the input GUI
     1832[h_fun,Series,tild,errormsg]=prepare_jobs(handles);
     1833if ~isempty(errormsg)
     1834    msgbox_uvmat('ERROR',errormsg)
     1835    return
     1836end
     1837ParamOut=h_fun(Series);
     1838
     1839%% Put the first line of the selected Action fct as tootip help
    16331840try
    1634     [fid,errormsg] =fopen([ACTION '.m']);
     1841    [fid,errormsg] =fopen([ActionName '.m']);
    16351842    InputText=textscan(fid,'%s',1,'delimiter','\n');
    16361843    fclose(fid);
    16371844    set(handles.ActionName,'ToolTipString',InputText{1}{1})% put the first line of the selected function as tooltip help
    16381845end
    1639 if ~isequal(path_series,PathName)
    1640     rmpath(PathName)
    1641 end
    1642 varargout=h_function();
     1846% if ~isequal(path_series,PathName)
     1847%     rmpath(PathName)
     1848% end
    16431849Param_list={};
    16441850
    1645 InputTable=get(handles.InputTable,'Data');
    1646 nbview=size(InputTable,1);
     1851%% Detect the types of input files
    16471852SeriesData=get(handles.series,'UserData');
    1648 nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)));
    1649 nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType)));
    1650 for ilist=1:length(varargout)-1
    1651     switch varargout{ilist}
    1652         case 'AllowInputSort'
    1653             if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir
    1654                 SeriesData.AllowInputSort=1;
    1655                 set(handles.series,'UserData',SeriesData)
    1656             end                     
    1657         case 'WholeIndexRange'
    1658             if isequal(lower(varargout{ilist+1}),'on')% set by default the input index range from min to max
    1659                 MinIndex=get(handles.MinIndex,'Data');
    1660                 MaxIndex=get(handles.MaxIndex,'Data');
    1661                 if ~isempty(MinIndex)
    1662                     set(handles.num_first_i,'String',num2str(MinIndex{1}))
    1663                     set(handles.num_last_i,'String',num2str(MaxIndex{1}))
    1664                     set(handles.num_incr_i,'String','1')
    1665                     if size(MinIndex,2)>=2
    1666                         set(handles.num_first_j,'String',num2str(MinIndex{1,2}))
    1667                         set(handles.num_last_j,'String',num2str(MaxIndex{1,2}))
    1668                         set(handles.num_incr_j,'String','1')
    1669                     end
    1670                 end
    1671             end           
    1672         case 'NbSlice'   %hidden by default
    1673             if isequal(lower(varargout{ilist+1}),'on')
    1674                 set(handles.num_NbSlice,'Visible','on')
    1675                 set(handles.NbSlice_title,'Visible','on')
    1676             end
    1677         case 'VelType'   %hidden by default
    1678              if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two')
    1679                 if nb_civ>=1
    1680                     set(handles.VelType,'Visible','on')
    1681                     set(handles.VelType_text,'Visible','on');
    1682                 end
    1683              end
    1684             if isequal(lower(varargout{ilist+1}),'two')
    1685                 if nb_civ>=2
    1686                     set(handles.VelType_1,'Visible','on')
    1687                     set(handles.VelType_text_1,'Visible','on');
    1688                 end
    1689             end
    1690         case 'FieldName'   %hidden by default
    1691             if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two')
    1692                 if (nb_civ+nb_netcdf)>=1
    1693                  set(handles.FieldName,'Visible','on') % test for MenuBorser
    1694                  set(handles.InputFields,'Visible','on')
    1695                 end
    1696             end
    1697             if isequal(lower(varargout{ilist+1}),'two')
    1698                 if (nb_civ+nb_netcdf)>=1
    1699                 set(handles.FieldName_1,'Visible','on')
    1700                 end
    1701             end
    1702         case 'FieldTransform'   %hidden by default
    1703             if isequal(lower(varargout{ilist+1}),'on')
    1704                 set(handles.TransformName,'Enable','on')
    1705                 set(handles.FieldTransform,'Visible','on')
    1706                 TransformName_Callback([],[], handles)
    1707             end
    1708         case 'ProjObject'   %hidden by default
    1709             if isequal(lower(varargout{ilist+1}),'on')   
    1710                 set(handles.CheckObject,'Visible','on')
    1711                 set(handles.ProjObject,'Visible','on')
    1712             end
    1713         case 'Mask'   %hidden by default
    1714             if isequal(lower(varargout{ilist+1}),'on')   
    1715                 set(handles.Mask,'Visible','on')
    1716                  set(handles.CheckMask,'Visible','on');
    1717             end 
    1718         case 'OutputDirExt'
    1719             if ~isempty(varargout{ilist+1})
    1720             set(handles.OutputDirExt,'String',varargout{ilist+1})
    1721             set(handles.OutputDirExt,'Visible','on')
    1722             set(handles.OutputSubDir,'Visible','on')
    1723             set(handles.OutputDir_title,'Visible','on') 
    1724             end
    1725     end
    1726 end
    1727 if ~isempty(Param_list)
    1728     set(handles.ParamKey,'String',Param_list)
    1729     set(handles.ParamVal,'Visible','on')
    1730 end
     1853nb_civ=0;nb_netcdf=0;
     1854if ~isempty(SeriesData)
     1855    nb_civ=numel(find(strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType)));
     1856    nb_netcdf=numel(find(strcmp('netcdf',SeriesData.FileType)));
     1857end
     1858
     1859%% Check whether alphabetical sorting of input Subdir is alowed by the Action fct  (for multiples series entries)
     1860SeriesData.AllowInputSort=0;%default
     1861if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')
     1862    SeriesData.AllowInputSort=1;
     1863end
     1864
     1865%% Impose the whole input file index range if requested
     1866if isfield(ParamOut,'WholeIndexRange')&&isequal(ParamOut.WholeIndexRange,'on')
     1867    MinIndex=get(handles.MinIndex,'Data');
     1868    MaxIndex=get(handles.MaxIndex,'Data');
     1869    if ~isempty(MinIndex)
     1870        set(handles.num_first_i,'String',num2str(MinIndex{1}))
     1871        set(handles.num_last_i,'String',num2str(MaxIndex{1}))
     1872        set(handles.num_incr_i,'String','1')
     1873        if size(MinIndex,2)>=2
     1874            set(handles.num_first_j,'String',num2str(MinIndex{1,2}))
     1875            set(handles.num_last_j,'String',num2str(MaxIndex{1,2}))
     1876            set(handles.num_incr_j,'String','1')
     1877        end
     1878    end
     1879end
     1880
     1881%% NbSlice visibility
     1882NbSliceVisible='off';%default
     1883if isfield(ParamOut,'NbSlice') && isequal(ParamOut.NbSlice,'on')
     1884    NbSliceVisible='on';
     1885    set(handles.num_NbProcess,'String',get(handles.num_NbSlice,'String'))% the nbre of processes is imposed as the nbre of slices
     1886else
     1887    set(handles.num_NbProcess,'String','')% free nbre of processes
     1888end
     1889set(handles.num_NbSlice,'Visible',NbSliceVisible)
     1890set(handles.NbSlice_title,'Visible',NbSliceVisible)
     1891
     1892%% Visibility of VelType and VelType_1 menus
     1893VelTypeVisible='off';  %hidden by default
     1894VelType_1Visible='off';
     1895InputFieldsVisible='off';%visibility of the frame Fields
     1896if isfield(ParamOut,'VelType')
     1897    if strcmp( ParamOut.VelType,'one')||strcmp( ParamOut.VelType,'two')
     1898        if nb_civ>=1
     1899            VelTypeVisible='on';
     1900            InputFieldsVisible='on';
     1901        end
     1902    end
     1903    if strcmp( ParamOut.VelType,'two')
     1904        if nb_civ>=2
     1905            VelType_1Visible='on';
     1906        end
     1907    end
     1908end
     1909set(handles.VelType,'Visible',VelTypeVisible)
     1910set(handles.VelType_text,'Visible',VelTypeVisible);
     1911set(handles.VelType_1,'Visible',VelType_1Visible)
     1912set(handles.VelType_text_1,'Visible',VelType_1Visible);
     1913
     1914%% Visibility of FieldName and FieldName_1 menus
     1915FieldNameVisible='off';  %hidden by default
     1916FieldName_1Visible='off';  %hidden by default
     1917if isfield(ParamOut,'FieldName')
     1918    if strcmp( ParamOut.FieldName,'one')||strcmp( ParamOut.FieldName,'two')
     1919        if (nb_civ+nb_netcdf)>=1
     1920            InputFieldsVisible='on';
     1921            FieldNameVisible='on';
     1922        end
     1923    end
     1924    if strcmp( ParamOut.FieldName,'two')
     1925        if (nb_civ+nb_netcdf)>=1
     1926            FieldName_1Visible='on';
     1927        end
     1928    end
     1929end
     1930set(handles.InputFields,'Visible',InputFieldsVisible)
     1931set(handles.FieldName,'Visible',FieldNameVisible) % test for MenuBorser
     1932set(handles.FieldName_1,'Visible',FieldName_1Visible)
     1933
     1934%% Visibility of FieldTransform menu
     1935FieldTransformVisible='off';  %hidden by default
     1936if isfield(ParamOut,'FieldTransform')
     1937    FieldTransformVisible=ParamOut.FieldTransform; 
     1938    TransformName_Callback([],[], handles)
     1939end
     1940set(handles.FieldTransform,'Visible',FieldTransformVisible)
     1941
     1942%% Visibility of projection object
     1943ProjObjectVisible='off';  %hidden by default
     1944if isfield(ParamOut,'ProjObject')
     1945    ProjObjectVisible=ParamOut.ProjObject;
     1946end
     1947set(handles.CheckObject,'Visible',ProjObjectVisible)
     1948if ~get(handles.CheckObject,'Value')
     1949    ProjObjectVisible='off';
     1950end
     1951set(handles.ProjObject,'Visible',ProjObjectVisible)
     1952set(handles.DeleteObject,'Visible',ProjObjectVisible)
     1953set(handles.ViewObject,'Visible',ProjObjectVisible)
     1954
     1955
     1956%% Visibility of mask input
     1957MaskVisible='off';  %hidden by default
     1958if isfield(ParamOut,'Mask')
     1959    MaskVisible=ParamOut.Mask;
     1960end
     1961set(handles.Mask,'Visible',MaskVisible)
     1962set(handles.CheckMask,'Visible',MaskVisible);
     1963
     1964%% definition of the directory containing the output files
     1965OutputDirVisible='off';
     1966if isfield(ParamOut,'OutputDirExt')&&~isempty(ParamOut.OutputDirExt)
     1967    set(handles.OutputDirExt,'String',ParamOut.OutputDirExt)
     1968    OutputDirVisible='on';
     1969end
     1970set(handles.OutputDirExt,'Visible',OutputDirVisible)
     1971set(handles.OutputSubDir,'Visible',OutputDirVisible)
     1972set(handles.OutputDir_title,'Visible',OutputDirVisible)
     1973set(handles.RunMode,'Visible',OutputDirVisible)
     1974set(handles.ActionExt,'Visible',OutputDirVisible)
     1975set(handles.RunMode_title,'Visible',OutputDirVisible)
     1976set(handles.ActionExt_title,'Visible',OutputDirVisible)
     1977
     1978%% definition of an additional parameter set, determined by an ancillary GUI
     1979if isfield(ParamOut,'ActionInput')
     1980    set(handles.ActionInput,'Visible','on')
     1981    set(handles.ActionInput_title,'Visible','on')
     1982    set(handles.ActionInput,'String',ActionName)
     1983    SeriesData.ActionInput=ParamOut.ActionInput;
     1984else
     1985    set(handles.ActionInput,'Visible','off')
     1986    set(handles.ActionInput_title,'Visible','off')
     1987    if isfield(SeriesData,'ActionInput')
     1988    SeriesData=rmfield(SeriesData,'ActionInput');
     1989    end
     1990end   
     1991set(handles.series,'UserData',SeriesData)
    17311992
    17321993%------------------------------------------------------------------------
     
    18852146        hset_object=set_object(data);% call the set_object interface
    18862147     end
    1887      Object=read_GUI(hset_object);
    1888      set(handles.ProjObject,'String',Object.Name);%display the object name
     2148     ProjObject=read_GUI(hset_object);
     2149     set(handles.ProjObject,'String',ProjObject.Name);%display the object name
     2150     SeriesData=get(handles.series,'UserData');
     2151     SeriesData.ProjObject=ProjObject;
     2152     set(handles.series,'UserData',SeriesData);
     2153     set(handles.DeleteObject,'Visible','on');
     2154     set(handles.ViewObject,'Visible','on');
    18892155else
    18902156    set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
     
    19262192% --- Executes on selection change in TransformName.
    19272193function TransformName_Callback(hObject, eventdata, handles)
    1928 %-------------------------------------------------------------------
    1929 global nb_transform
    1930 
    1931 menu=get(handles.TransformName,'String');
    1932 ind_coord=get(handles.TransformName,'Value');
    1933 coord_option=menu{ind_coord};
    1934 list_transform=get(handles.TransformName,'UserData');
    1935 ff=functions(list_transform{end});
    1936 if isequal(coord_option,'more...');
    1937     coord_fct='';
    1938     prompt = {'Enter the name of the transform function'};
    1939     dlg_title = 'user defined transform';
    1940     num_lines= 1;
    1941     [FileName, PathName, filterindex] = uigetfile( ...
     2194%----------------------------------------------------------------------
     2195TransformList=get(handles.TransformName,'String');
     2196TransformIndex=get(handles.TransformName,'Value');
     2197TransformName=TransformList{TransformIndex};
     2198TransformPathList=get(handles.TransformName,'UserData');
     2199nb_builtin_transform=4;
     2200% ff=functions(list_transform{end});
     2201if isequal(TransformName,'more...');
     2202%     coord_fct='';
     2203%     prompt = {'Enter the name of the transform function'};
     2204%     dlg_title = 'user defined transform';
     2205%     num_lines= 1;
     2206    [FileName, PathName] = uigetfile( ...
    19422207       {'*.m', ' (*.m)';
    19432208        '*.m',  '.m files '; ...
    19442209        '*.*', 'All Files (*.*)'}, ...
    1945         'Pick a file', ff.file);
     2210        'Pick a transform function',get(handles.TransformPath,'String'));
     2211    if isequal(FileName,0)
     2212        return     %browser closed without choice
     2213    end
    19462214    if isequal(PathName(end),'/')||isequal(PathName(end),'\')
    19472215        PathName(end)=[];
    19482216    end
    1949     transform_selected =fullfile(PathName,FileName);
    1950     if ~exist(transform_selected,'file')
    1951           return
    1952     end
    1953     [ppp,transform,xt_fct]=fileparts(FileName);% removes extension .m
    1954     if ~isequal(ext_fct,'.m')
     2217    [TransformPath,TransformName,TransformExt]=fileparts(FileName);% removes extension .m
     2218    if ~strcmp(TransformExt,'.m')
    19552219        msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
    19562220        return
    19572221    end
    1958    menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu
    1959    ind_coord=get(handles.TransformName,'Value');
    1960    addpath(PathName)
    1961    list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
    1962    set(handles.TransformName,'UserData',list_transform)
    1963    rmpath(PathName)
     2222     % insert the choice in the menu
     2223    TransformIndex=find(strcmp(TransformName,TransformList),1);% look for the selected function in the menu Action
     2224    if isempty(TransformIndex)%the input string does not exist in the menu
     2225        TransformIndex= length(TransformList);
     2226        TransformList=[TransformList(1:end-1);{TransformnName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...'
     2227        set(handles.TransformName,'String',TransformList)
     2228        TransformPathList=[TransformPathList;{TransformPath}];
     2229    end
    19642230   % save the new menu in the personal file 'uvmat_perso.mat'
    19652231   dir_perso=prefdir;%personal Matalb directory
    19662232   profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    19672233   if exist(profil_perso,'file')
    1968        for ilist=nb_transform+1:numel(list_transform)
    1969            ff=functions(list_transform{ilist});
    1970            transform_fct{ilist-nb_transform}=ff.file;
     2234       for ilist=nb_builtin_transform+1:numel(TransformPathList)
     2235           TransformListUser{ilist-nb_builtin_transform}=TransformList{ilist};
     2236           TransformPathListUser{ilist-nb_builtin_transform}=TransformPathList{ilist};
    19712237       end
    1972         save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
     2238       save (profil_perso,'TransformPathListUser','TransformListUser','-append'); %store the root name for future opening of uvmat
    19732239   end
    19742240end
    19752241
    1976 %check the current ActionPath to the selected function
    1977 if ~isempty(list_transform{ind_coord})
    1978     func=functions(list_transform{ind_coord});
    1979     set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function
    1980 else
    1981     set(handles.TransformPath,'String',''); %show the path to the senlected function
    1982 end
    1983 
     2242%display the current function path
     2243set(handles.TransformPath,'String',TransformPathList{TransformIndex}); %show the path to the senlected function
     2244set(handles.TransformName,'UserData',TransformPathList);
    19842245
    19852246
     
    20502311function status_Callback(hObject, eventdata, handles)
    20512312val=get(handles.status,'Value');
     2313
     2314%% delete current display fig if selection is off
    20522315if val==0
    20532316    set(handles.status,'BackgroundColor',[0 1 0])
     
    20862349%     civ_files=filecell.nc.civ1;
    20872350% end
     2351% InputTable=get(handles.InputTable,'Data');
     2352% OutputDir=fullfile(InputTable{1,1},[get(handles.OutputSubDir,'String') get(handles.OutputDirExt,'String')]);
     2353StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
     2354% StatusData.option_civ=option_civ;
     2355Param=read_GUI(handles.series);
     2356RootPath=Param.InputTable{1,1};
     2357%SubDir=Param.InputTable{1,2};
     2358OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
     2359OutputDir=fullfile(RootPath,OutputSubDir);
     2360% set(hlist,'UserData',OutputDir)
    20882361hfig=findobj(allchild(0),'name','series_status');
    20892362if isempty(hfig)
     
    20942367    set(hfig,'tag','series_status')
    20952368%    set(hfig,'UserData',civ_files)
    2096     hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list');
    2097     uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...');
     2369    hlist= uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', {'open_uvmat'},'tag','list','UserData',OutputDir);
     2370    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String',OutputDir);
    20982371    uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    2099     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI);
    2100     hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@refresh_GUI);
     2372    %uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@close_GUI);
     2373    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@stop_status);
     2374    hrefresh=uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',11,'Callback',@refresh_GUI);
     2375    set(hrefresh,'UserData',StatusData)
    21012376    BarPosition=[0.05 0.81 0.01 0.05];
    21022377    uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar');
    21032378    drawnow
    21042379end
    2105 StatusData.time_ref=get(handles.RUN,'UserData');% get the time of launch
    2106 % StatusData.option_civ=option_civ;
    2107 set(hrefresh,'UserData',StatusData)
    2108 Param=read_GUI(handles.series);
    2109 RootPath=Param.InputTable{1,1};
    2110 SubDir=Param.InputTable{1,2};
    2111 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
    2112 OutputDir=fullfile(RootPath,SubDir,OutputSubDir);
    2113 set(hlist,'UserData',OutputDir)
    2114 %refresh_GUI(hrefresh,[])
     2380
     2381refresh_GUI(hrefresh,[])
     2382%------------------------------------------------------------------------   
     2383% launched by refreshing the status figure
     2384function refresh_GUI(hObject, eventdata)
     2385%------------------------------------------------------------------------
     2386% Tabchar={};
     2387% BarPosition=[0.05 0.81 0.01 0.05];
     2388hfig=get(hObject,'parent');
     2389hmsgbox=findobj(hfig,'tag','msgbox');
     2390hlist=findobj(hfig,'tag','list');
     2391% StatusData=get(hObject,'UserData');
     2392OutputDir=get(hmsgbox,'String');
     2393ListFiles=dir(OutputDir);
     2394ListDisplay=cell(numel(ListFiles),1);
     2395for ilist=1:numel(ListDisplay)
     2396    ListDisplay{ilist}=ListFiles(ilist).name;
     2397end
     2398set(hlist,'String',ListDisplay)
     2399% civ_files=get(hfig,'UserData');
     2400
     2401% [filepath,filename,ext]=fileparts(civ_files{1});
     2402% [tild,SubDir,extdir]=fileparts(filepath);
     2403% SubDir=[SubDir extdir];
     2404% option_civ=StatusData.option_civ;
     2405% nbfiles=numel(civ_files);
     2406% testrecent=0;
     2407% count=0;
     2408% datnum=zeros(1,nbfiles);
     2409% filefound=cell(1,nbfiles);
     2410% for ifile=1:nbfiles
     2411%     detect=exist(civ_files{ifile},'file'); % check the existence of the file
     2412%     option=0;
     2413%     if detect==0
     2414%         option_str='not created';
     2415%     else
     2416%         datfile=dir(civ_files{ifile});
     2417%         if isfield(datfile,'datenum')
     2418%             datnum(ifile)=datfile.datenum;%only available in recent matlab versions
     2419%             testrecent=1;
     2420%         end
     2421%         filefound(ifile)={datfile.name};
     2422%         
     2423%         % check the content  netcdf file
     2424%         Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
     2425%         option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
     2426%         if ~isempty(Data.CivStage)
     2427%             option=Data.CivStage;%case of Matlab civ
     2428%         else
     2429%             if ~isempty(Data.patch2) && isequal(Data.patch2,1)
     2430%                 option=6;
     2431%             elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
     2432%                 option=5;
     2433%             elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
     2434%                 option=4;
     2435%             elseif ~isempty(Data.patch) && isequal(Data.patch,1);
     2436%                 option=3;
     2437%             elseif ~isempty(Data.fix) && isequal(Data.fix,1);
     2438%                 option=2;
     2439%             else
     2440%                 option=1;
     2441%             end
     2442%         end
     2443%         option_str=option_list{option};
     2444%         if datnum(ifile)<StatusData.time_ref
     2445%             option_str=[option_str '  --OLD--'];
     2446%         end
     2447%     end
     2448%     if option >= option_civ
     2449%         count=count+1;
     2450%     end
     2451%     [filepath,filename,ext]=fileparts(civ_files{ifile});
     2452%     Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
     2453% end
     2454% datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     2455% if isempty(datnum)
     2456%     if testrecent
     2457%         message='no civ result created yet';
     2458%     else
     2459%         message='';
     2460%     end
     2461% else
     2462%     datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     2463%     [first,ind]=min(datnum);
     2464%     [last,indlast]=max(datnum);
     2465%     message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
     2466%         ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
     2467% end
     2468% hlist=findobj(hfig,'tag','list');
     2469% hmsgbox=findobj(hfig,'tag','msgbox');
     2470% hwaitbar=findobj(hfig,'tag','waitbar');
     2471% set(hlist,'String',Tabchar)
     2472% set(hmsgbox,'String', message)
     2473% if count>0 %&& ~test_new
     2474%     BarPosition(3)=0.9*count/nbfiles;
     2475%     set(hwaitbar,'Position',BarPosition)
     2476% end
     2477%------------------------------------------------------------------------   
     2478% launched by deleting the status figure
     2479function stop_status(hObject, eventdata)
     2480%------------------------------------------------------------------------
     2481hciv=findobj(allchild(0),'tag','series');
     2482hhciv=guidata(hciv);
     2483set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
     2484set(hhciv.status,'BackgroundColor',[0 1 0])
     2485delete(gcbf)
     2486
     2487% --- Executes on selection change in ActionExt.
     2488function ActionExt_Callback(hObject, eventdata, handles)
     2489ActionExtList=get(handles.ActionExt,'String');
     2490ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
     2491ActionList=get(handles.ActionName,'String');
     2492ActionName=ActionList{get(handles.ActionName,'Value')};
     2493if strcmp(ActionExt,'.sh')
     2494    ActionFullName=fullfile(get(handles.ActionPath,'String'),[ActionName ActionExt]);
     2495    if ~exist(ActionFullName,'file')
     2496        answer=msgbox_uvmat('INPUT_Y-N','compiled version has not been created: compile now?');
     2497        if strcmp(answer,'Yes')
     2498            currentdir=pwd;
     2499            cd(get(handles.ActionPath,'String'))
     2500            compile(ActionName)
     2501            cd(currentdir)
     2502        end
     2503    end
     2504end
     2505
     2506
     2507function ActionInput_Callback(hObject, eventdata, handles)
     2508
     2509
     2510% --- Executes on button press in DeleteObject.
     2511function DeleteObject_Callback(hObject, eventdata, handles)
     2512if get(handles.DeleteObject,'Value')
     2513        SeriesData=get(handles.series,'UserData');
     2514    SeriesData.ProjObject=[];
     2515    set(handles.series,'UserData',SeriesData)
     2516    set(handles.ProjObject,'String','')
     2517    set(handles.CheckObject,'Value',0)
     2518    set(handles.DeleteObject,'Visible','off')
     2519    set(handles.ViewObject,'Visible','off')
     2520end
     2521
     2522% --- Executes on button press in ViewObject.
     2523function ViewObject_Callback(hObject, eventdata, handles)
     2524if get(handles.ViewObject,'Value')
     2525        UserData=get(handles.series,'UserData');
     2526    set_object(UserData.ProjObject)
     2527else
     2528    hset_object=findobj(allchild(0),'Tag','set_object');
     2529    if ~isempty(hset_object)
     2530        delete(hset_object)
     2531    end
     2532end
     2533
     2534
     2535function num_NbProcess_Callback(hObject, eventdata, handles)
     2536
     2537
     2538function num_NbSlice_Callback(hObject, eventdata, handles)
     2539NbSlice=str2num(get(handles.num_NbSlice,'String'));
     2540set(handles.num_NbProcess,'String',num2str(NbSlice))
  • trunk/src/set_grid.m

    r576 r591  
    102102    Input.YMin=(Mesh/2)*ceil(InputField.YMin/(Mesh/2))-0.5*check_pixel;
    103103    Input.YMax=Input.YMin+Mesh*floor((InputField.YMax-Input.YMin)/Mesh)-0.5*check_pixel;
    104     errormsg=fill_GUI(Input,handles);
     104    errormsg=fill_GUI(Input,handles.set_grid);
    105105end
    106106
  • trunk/src/set_object.m

    r589 r591  
    100100        set(handles.ProjMode,'UserData',data.ProjModeMenu)% data.ProjModeMenu as default menu (used in Type_Callback)
    101101    end
    102     errormsg=fill_GUI(data,handles);
     102    errormsg=fill_GUI(data,handles.set_object);
    103103    if ~isempty(errormsg)
    104104        msgbox_uvmat('ERROR','bad data input in set_object')
     
    510510            hhview_field=guidata(hview_field);
    511511            [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing  plot in view_field
    512             errormsg=fill_GUI(PlotParam,hhview_field);
     512            errormsg=fill_GUI(PlotParam,hview_field);
    513513            if ~isempty(errormsg)
    514514                msgbox_uvmat('ERROR',errormsg)
  • trunk/src/uvmat.m

    r589 r591  
    3434%                       .PosSetObject: position of set_object
    3535%                       .PosGeometryCalib: size of set_object
    36 %                       .NbBuiltin: nbre of functions always displayed in transform_fct menu
     36%                       .NbBuiltin: nbre of functions always displayed in TransformName menu
    3737%          .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default
    3838%          .NewSeries: =0/1 flag telling whether a new field series has been opened
     
    215215end
    216216
    217 %% load the list of previously browsed files in menus Open, Open_1 and transform_fct
     217%% load the list of previously browsed files in menus Open, Open_1 and TransformName
    218218 dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user
    219219 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab
     
    240240 end
    241241transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu
    242 set(handles.transform_fct,'String',transform_menu)% display the menu of transform fcts
    243 set(handles.transform_fct,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct
    244 set(handles.path_transform,'String','')
    245 set(handles.path_transform,'UserData',[])
     242set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts
     243set(handles.TransformName,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct
     244set(handles.TransformPath,'String','')
     245set(handles.TransformPath,'UserData',[])
    246246
    247247%% case of an input argument for uvmat
     
    973973        set(handles.pxcm,'String','')
    974974        set(handles.pycm,'String','')
    975         set(handles.transform_fct,'Value',1); %  no transform by default
     975        set(handles.TransformName,'Value',1); %  no transform by default
    976976    else
    977977        if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
     
    986986        end
    987987        if ~get(handles.CheckFixLimits,'Value')
    988             set(handles.transform_fct,'Value',3); % phys transform by default if fixedLimits is off
     988            set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off
    989989        end
    990990        if isfield(GeometryCalib,'SliceCoord')           
     
    11081108
    11091109%% apply the effect of the transform fct and view the field 
    1110 transform=get(handles.path_transform,'UserData');
     1110transform=get(handles.TransformPath,'UserData');
    11111111if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3)
    1112     set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
    1113 end
    1114 transform_fct_Callback([],[],handles)
     1112    set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields
     1113end
     1114TransformName_Callback([],[],handles)
    11151115mask_test=get(handles.CheckMask,'value');
    11161116if mask_test
     
    14131413        end
    14141414        %px to phys or other transform on field
    1415          menu_transform=get(handles.transform_fct,'String');
    1416         choice_value=get(handles.transform_fct,'Value');
     1415         menu_transform=get(handles.TransformName,'String');
     1416        choice_value=get(handles.TransformName,'Value');
    14171417        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
    1418         transform=get(handles.path_transform,'UserData');
     1418        transform=get(handles.TransformPath,'UserData');
    14191419        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
    14201420            if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
     
    19471947
    19481948%px to phys or other transform on field
    1949 transform=get(handles.path_transform,'UserData');
     1949transform=get(handles.TransformPath,'UserData');
    19501950if  ~isempty(transform)
    19511951    if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority
     
    24202420
    24212421%% apply coordinate transform or other user fct
    2422 transform=get(handles.path_transform,'UserData');
     2422transform=get(handles.TransformPath,'UserData');
    24232423if isempty(transform)
    24242424    UvData.Field=Field{1};
     
    24322432        end
    24332433    end
    2434     transform=get(handles.path_transform,'UserData');
     2434    transform=get(handles.TransformPath,'UserData');
    24352435    switch nargin(transform)
    24362436        case 4
     
    29992999    end
    30003000    set(handles.uvmat,'UserData',UvData);
    3001     transform_fct_list=get(handles.transform_fct,'String');
    3002     transform_fct=transform_fct_list(get(handles.transform_fct,'Value'));
     3001    transform_fct_list=get(handles.TransformName,'String');
     3002    transform_fct=transform_fct_list(get(handles.TransformName,'Value'));
    30033003    if strcmp(transform_fct,'sub_field')
    3004         set(handles.transform_fct,'Value',1)%suppress the sub_field transform
     3004        set(handles.TransformName,'Value',1)%suppress the sub_field transform
    30053005        transform_fct_Callback(hObject, eventdata, handles);
    30063006    else
     
    33013301            UvData.FileType{2}=UvData.FileType{1};
    33023302            UvData.XmlData{2}= UvData.XmlData{1};
    3303             transform=get(handles.path_transform,'UserData');
     3303            transform=get(handles.TransformPath,'UserData');
    33043304             if (~isa(transform,'function_handle')||nargin(transform)<3)
    33053305                set(handles.uvmat,'UserData',UvData)
    3306                 set(handles.transform_fct,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
     3306                set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
    33073307                transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
    33083308                 check_refresh=0;
     
    34003400     UvData.XmlData{2}= UvData.XmlData{1};
    34013401     set(handles.SubField,'Value',1)
    3402      transform=get(handles.path_transform,'UserData');
     3402     transform=get(handles.TransformPath,'UserData');
    34033403     if (~isa(transform,'function_handle')||nargin(transform)<3)
    34043404        set(handles.uvmat,'UserData',UvData)
    3405         set(handles.transform_fct,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
     3405        set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
    34063406        transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
    34073407     else
     
    36063606%------------------------------------------------------------------
    36073607%-------------------------------------------------------------
    3608 % --- Executes on selection change in transform_fct.
    3609 
    3610 function transform_fct_Callback(hObject, eventdata, handles)
     3608% --- Executes on selection change in TransformName.
     3609
     3610function TransformName_Callback(hObject, eventdata, handles)
    36113611%-------------------------------------------------------------
    36123612UvData=get(handles.uvmat,'UserData');
    3613 menu=get(handles.transform_fct,'String');refresh
    3614 ichoice=get(handles.transform_fct,'Value');%item number in the menu
     3613menu=get(handles.TransformName,'String');refresh
     3614ichoice=get(handles.TransformName,'Value');%item number in the menu
    36153615transform_name=menu{ichoice};% choice of the transform fct
    3616 list_path=get(handles.transform_fct,'UserData');
     3616list_path=get(handles.TransformName,'UserData');
    36173617
    36183618%% add a new item to the menu if the option 'more...' has been selected
    3619 prev_path=fullfile(get(handles.path_transform,'String'));
     3619prev_path=fullfile(get(handles.TransformPath,'String'));
    36203620if ~exist(prev_path,'dir')
    36213621    prev_path=fullfile(fileparts(which('uvmat')),'transform_field');
     
    36413641    end
    36423642    list_path{ichoice}=PathName;%update the list fo fct paths
    3643     set(handles.transform_fct,'String',menu)
    3644     set(handles.transform_fct,'Value',ichoice)
     3643    set(handles.TransformName,'String',menu)
     3644    set(handles.TransformName,'Value',ichoice)
    36453645   
    36463646    % save the new menu in the personal file 'uvmat_perso.mat'
     
    36723672    cd(current_dir)
    36733673end
    3674 set(handles.path_transform,'String',list_path{ichoice})
    3675 set(handles.path_transform,'UserData',transform_handle)
    3676 set(handles.transform_fct,'UserData',list_path)
    3677 
    3678 %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file
     3674set(handles.TransformPath,'String',list_path{ichoice})
     3675set(handles.TransformPath,'UserData',transform_handle)
     3676set(handles.TransformName,'UserData',list_path)
     3677
     3678%% update the ToolTip string of the menu TransformName with the first line of the selected fct file
    36793679if isempty(list_path{ichoice})% case of no selected fct
    3680     set(handles.transform_fct,'ToolTipString','transform_fct:choose a transform function')
     3680    set(handles.TransformName,'ToolTipString','transform_fct:choose a transform function')
    36813681else
    36823682    try
     
    36843684        InputText=textscan(fid,'%s',1,'delimiter','\n');
    36853685        fclose(fid)
    3686         set(handles.transform_fct,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help
     3686        set(handles.TransformName,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help
    36873687    end
    36883688end
     
    50665066FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    50675067UvData=get(handles.uvmat,'UserData');
    5068 % CoordList=get(handles.transform_fct,'String');
    5069 % val=get(handles.transform_fct,'Value');
     5068% CoordList=get(handles.TransformName,'String');
     5069% val=get(handles.TransformName,'Value');
    50705070set_grid(FileName,UvData.Field);% call the set_object interface
    50715071
     
    50895089function MenuSeries_Callback(hObject, eventdata, handles)
    50905090%------------------------------------------------------------------------
    5091 series; %first display of the GUI to fill waiting time
    50925091[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    50935092Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name
     
    51285127end
    51295128Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index
    5130 Param.transform_str=get(handles.transform_fct,'String');
    5131 Param.transform_val=get(handles.transform_fct,'Value');
     5129TransformList=get(handles.TransformName,'String');
     5130Param.TransformName=TransformList{get(handles.TransformName,'Value')};
    51325131Param.Coord_x_str=get(handles.Coord_x,'String');
    51335132Param.Coord_x_val=get(handles.Coord_x,'Value');
     
    51655164% --- Executes on button press in CheckColorBar.
    51665165function CheckColorBar_Callback(hObject, eventdata, handles)
     5166
     5167
     5168
     5169function TransformPath_Callback(hObject, eventdata, handles)
     5170% hObject    handle to TransformPath (see GCBO)
     5171% eventdata  reserved - to be defined in a future version of MATLAB
     5172% handles    structure with handles and user data (see GUIDATA)
     5173
     5174% Hints: get(hObject,'String') returns contents of TransformPath as text
     5175%        str2double(get(hObject,'String')) returns contents of TransformPath as a double
  • trunk/src/view_field.m

    r569 r591  
    8383        set(handles.Vectors,'Visible','on')
    8484    end
    85     errormsg=fill_GUI(PlotParamOut,handles);
     85    errormsg=fill_GUI(PlotParamOut,hObject);
    8686    if ~isempty(errormsg)
    8787        msgbox_uvmat('ERROR',errormsg)
     
    780780PlotParam=read_GUI(handles.view_field);
    781781[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
    782 errormsg=fill_GUI(PlotParamOut,handles);
     782errormsg=fill_GUI(PlotParamOut,handles.view_field);
    783783    if ~isempty(errormsg)
    784784        msgbox_uvmat('ERROR',errormsg)
Note: See TracChangeset for help on using the changeset viewer.