Changeset 446 for trunk/src


Ignore:
Timestamp:
Jun 11, 2012, 9:33:54 AM (12 years ago)
Author:
sommeria
Message:

series rationalized. TO BE TESTED.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r444 r446  
    10211021
    10221022
    1023 %--------------orm----------------------------------------------------------
     1023%------------------------------------------------------------------------
    10241024% --- Main lauch command, called by RUN and BATCH
    10251025function errormsg=launch_jobs(hObject, eventdata, handles, batch)
    1026 %-----------------------------------------------------------------------
     1026%------------------------------------------------------------------------
    10271027errormsg='';%default
    10281028
     
    10761076if isfield(handles,'status')
    10771077    set(handles.status,'Value',0);%suppress status display
    1078     status_Callback(hObject, eventdata, handles)
     1078    status_Callback([], [], handles)
    10791079end
    10801080
     
    21002100                detect=exist(filename,'file')==2;
    21012101                if detect% if a netcdf file already exists
    2102                     r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
    2103                     if isempty(r)
    2104                         r(1).root=[subdir_civ1_new '_'];
    2105                         r(1).num1='0';
     2102                    answer=msgbox_uvmat('INPUT_Y-N',['delete files in ' subdir_civ1_new]);
     2103                    if ~strcmp(answer,'Yes')
     2104                        r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
     2105                        if isempty(r)
     2106                            r(1).root=[subdir_civ1_new '_'];
     2107                            r(1).num1='0';
     2108                        end
     2109                        subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
     2110                        subdir_civ2=subdir_civ1_new;
    21062111                    end
    2107                     subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
    2108 %                     indstr=regexp(subdir_civ1_new,'\D');
    2109 %                     if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
    2110 %                         vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
    2111 %                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
    2112 %                     else
    2113 %                         vers=vers+1;
    2114 %                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
    2115 %                     end
    2116                     subdir_civ2=subdir_civ1_new;
    21172112                    break
    21182113                end
  • trunk/src/get_file_series.m

    r440 r446  
    44%
    55% OUTPUT:
    6 % filecell{i,j}: cell array with the two reference indices i and j representing the list of file names
    7 % i1_series,i2_series,j1_series,j2_series: corresponding arrays of indices i1,i2,j1,j2.
    8 %
     6% filecell{iview,fileindex}: cell array representing the list of file names
     7%        iview: line in the table corresponding to a given file series
     8%        fileindex: file index within  the file series,
     9% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
     10% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
     11
    912% INPUT:
    1013% Param: structure of input parameters as read from the GUI series (by the function read_GUI)
     
    2528    ref_j=first_j:incr_j:last_j;
    2629end
    27 % Pairs=Param.Pairs;
    28 
    2930
    3031%% determine the list of input file names
     
    4647        r(1).mode='';
    4748    end
    48     [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode);
     49    [i1_series_iview,i2_series_iview,j1_series_iview,j2_series_iview]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode);
    4950    %case of pairs (.nc files)
    5051    i2=[];j1=[];j2=[];
    51     for ifile=1:numel(i1_series{iview})
    52         i1=i1_series{iview}(ifile);
    53         if ~isempty(i2_series{iview})
    54             i2=i2_series{iview}(ifile);
     52    for ifile=1:numel(i1_series_iview)
     53        i1=i1_series_iview(ifile);
     54        if ~isempty(i2_series_iview)
     55            i2=i2_series_iview(ifile);
    5556        end
    56         if ~isempty(j1_series{iview})
    57             j1=j1_series{iview}(ifile);
     57        if ~isempty(j1_series_iview)
     58            j1=j1_series_iview(ifile);
    5859        end
    59         if ~isempty(j2_series{iview})
    60             j2=j2_series{iview}(ifile);
     60        if ~isempty(j2_series_iview)
     61            j2=j2_series_iview(ifile);
    6162        end
    6263        filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4}...
    6364            ,i1,i2,j1,j2);
    6465    end
     66    i1_series(iview,:,:)=i1_series_iview;
     67    i2_series(iview,:,:)=i2_series_iview;
     68    j1_series(iview,:,:)=j1_series_iview;
     69    j2_series(iview,:,:)=j2_series_iview;
    6570end
    6671
     
    7075j1_series=[];
    7176if ~isempty(ref_j)
    72 %      i1_series=meshgrid(ref_i,ones(size(ref_j)));
    73 % %     j1_series=meshgrid(ref_i,ones(size(ref_j)));
    74 %     j1_series=meshgrid(ones(size(ref_i)),ref_j);
    7577    [i1_series,j1_series]=meshgrid(ref_i,ref_j);
    7678end
  • trunk/src/get_file_type.m

    r435 r446  
    3232                if length(imainfo) >1 %case of image with multiple frames
    3333                    FileType='multimage';
     34                    FileInfo=imainfo{1};%take info from the first frame
    3435                    FileInfo.NbFrame=length(imainfo);
     36                else
     37                    FileInfo=imainfo;
    3538                end
    3639            end
  • trunk/src/series.m

    r441 r446  
    66%INPUT
    77% param: structure with input parameters (link with the GUI uvmat)
    8 %      .menu_coord_str: string for the transform_fct (menu for coordinate transforms)
    9 %      .menu_coord_val: value for transform_fct (menu for coordinate transforms)
     8%      .menu_coord_str: string for the TransformName (menu for coordinate transforms)
     9%      .menu_coord_val: value for TransformName (menu for coordinate transforms)
    1010%      .FileName: input file name
    1111%      .FileName_1: second input file name
     
    8383     h=load (profil_perso);
    8484     test_profil_perso=1;
    85      if isfield(h,'MenuFile_1')
     85     if isfield(h,'MenuFile_1') && exist(h.MenuFile_1,'file')
    8686          set(handles.MenuFile_1,'Label',h.MenuFile_1);
    8787          set(handles.MenuFile_insert_1,'Label',h.MenuFile_1);
    8888     end
    89      if isfield(h,'MenuFile_1')
     89     if isfield(h,'MenuFile_2')&& exist(h.MenuFile_2,'file')
    9090          set(handles.MenuFile_2,'Label',h.MenuFile_2);
    9191          set(handles.MenuFile_insert_2,'Label',h.MenuFile_2);
    9292     end
    93      if isfield(h,'MenuFile_1')
     93     if isfield(h,'MenuFile_3')&& exist(h.MenuFile_3,'file')
    9494          set(handles.MenuFile_3,'Label',h.MenuFile_3);
    9595          set(handles.MenuFile_insert_3,'Label',h.MenuFile_3);
    9696     end
    97      if isfield(h,'MenuFile_1')
     97     if isfield(h,'MenuFile_4')&& exist(h.MenuFile_4,'file')
    9898          set(handles.MenuFile_4,'Label',h.MenuFile_4);
    9999          set(handles.MenuFile_insert_4,'Label',h.MenuFile_4);
    100100     end
    101      if isfield(h,'MenuFile_1')
     101     if isfield(h,'MenuFile_5')&& exist(h.MenuFile_5,'file')
    102102          set(handles.MenuFile_5,'Label',h.MenuFile_5);
    103103          set(handles.MenuFile_insert_5,'Label',h.MenuFile_5);
     
    112112%% file name and browser initialisation
    113113if isfield(param,'menu_coord_str')
    114     set(handles.transform_fct,'String',param.menu_coord_str)
     114    set(handles.TransformName,'String',param.menu_coord_str)
    115115end
    116116if isfield(param,'menu_coord_val')
    117     set(handles.transform_fct,'Value',param.menu_coord_val);
    118 else
    119      set(handles.transform_fct,'Value',1);%default
     117    set(handles.TransformName,'Value',param.menu_coord_val);
     118else
     119     set(handles.TransformName,'Value',1);%default
    120120end
    121121if isfield(param,'FileName')
     
    130130%% fields input initialisation
    131131if isfield(param,'list_fields')&& isfield(param,'index_fields') &&~isempty(param.list_fields) &&~isempty(param.index_fields)
    132     set(handles.FieldMenu,'String',param.list_fields);% list menu fields
    133     set(handles.FieldMenu,'Value',param.index_fields);% selected string index
     132    set(handles.FieldName,'String',param.list_fields);% list menu fields
     133    set(handles.FieldName,'Value',param.index_fields);% selected string index
    134134    FieldCell{1}=param.list_fields{param.index_fields};
    135135end
    136136
    137 %loads the information stored in prefdir to initiate  the list of ACTION functions
     137%loads the information stored in prefdir to initiate  the list of ActionName functions
    138138fct_menu={'check_data_files';'aver_stat';'time_series';'merge_proj';'clean_civ_cmx'};
    139139transform_menu={'';'phys';'px';'phys_polar'};
     
    192192end
    193193fct_menu=[fct_menu;{'more...'}];
    194 set(handles.ACTION,'String',fct_menu)
    195 set(handles.ACTION,'UserData',fct_path)% store the list of path in UserData of ACTION
     194set(handles.ActionName,'String',fct_menu)
     195set(handles.ActionName,'UserData',fct_path)% store the list of path in UserData of ACTION
    196196menu_str=menu_str(find(testexist));
    197197fct_handle=fct_handle(find(testexist));
    198198menu_str=[menu_str;{'more...'}];
    199 set(handles.transform_fct,'String',menu_str)
    200 set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    201 
    202 % display the GUI for the default action 'check_data_files'
    203 ACTION_Callback(hObject, eventdata, handles)
     199set(handles.TransformName,'String',menu_str)
     200set(handles.TransformName,'UserData',fct_handle)% store the list of path in UserData of ACTION
     201
     202% display the GUI for the default actionname 'check_data_files'
     203ActionName_Callback(hObject, eventdata, handles)
    204204
    205205%------------------------------------------------------------------------
     
    218218%  II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
    219219% automatically sets the global properties when the rootfile name is introduced
    220 % then activate the view-field action if selected
     220% then activate the view-field actionname if selected
    221221% it is activated either by clicking on the RootPath window or by the
    222222% browser
     
    267267    display_file_name(handles,fileinput,0)
    268268     %update list of recent files in the menubar
    269     MenuFile_1=fileinput;
    270     MenuFile_2=get(handles.MenuFile_1,'Label');
    271     MenuFile_3=get(handles.MenuFile_2,'Label');
    272     MenuFile_4=get(handles.MenuFile_3,'Label');
    273     MenuFile_5=get(handles.MenuFile_4,'Label');
    274     set(handles.MenuFile_1,'Label',MenuFile_1)
    275     set(handles.MenuFile_2,'Label',MenuFile_2)
    276     set(handles.MenuFile_3,'Label',MenuFile_3)
    277     set(handles.MenuFile_4,'Label',MenuFile_4)
    278     set(handles.MenuFile_5,'Label',MenuFile_5)
    279     set(handles.MenuFile_insert_1,'Label',MenuFile_1)
    280     set(handles.MenuFile_insert_2,'Label',MenuFile_2)
    281     set(handles.MenuFile_insert_3,'Label',MenuFile_3)
    282     set(handles.MenuFile_insert_4,'Label',MenuFile_4)
    283     set(handles.MenuFile_insert_5,'Label',MenuFile_5)
    284     dir_perso=prefdir;
    285     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    286     if exist(profil_perso,'file')
    287         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    288     else
    289     txt=ver('MATLAB');
    290     Release=txt.Release;
    291         relnumb=str2num(Release(3:4));
    292         if relnumb >= 14
    293             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    294         else
    295             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    296         end
    297     end
     269%     MenuFile_1=fileinput;
     270%     MenuFile_2=get(handles.MenuFile_1,'Label');
     271%     MenuFile_3=get(handles.MenuFile_2,'Label');
     272%     MenuFile_4=get(handles.MenuFile_3,'Label');
     273%     MenuFile_5=get(handles.MenuFile_4,'Label');
     274%     set(handles.MenuFile_1,'Label',MenuFile_1)
     275%     set(handles.MenuFile_2,'Label',MenuFile_2)
     276%     set(handles.MenuFile_3,'Label',MenuFile_3)
     277%     set(handles.MenuFile_4,'Label',MenuFile_4)
     278%     set(handles.MenuFile_5,'Label',MenuFile_5)
     279%     set(handles.MenuFile_insert_1,'Label',MenuFile_1)
     280%     set(handles.MenuFile_insert_2,'Label',MenuFile_2)
     281%     set(handles.MenuFile_insert_3,'Label',MenuFile_3)
     282%     set(handles.MenuFile_insert_4,'Label',MenuFile_4)
     283%     set(handles.MenuFile_insert_5,'Label',MenuFile_5)
     284%     dir_perso=prefdir;
     285%     profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     286%     if exist(profil_perso,'file')
     287%         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
     288%     else
     289%     txt=ver('MATLAB');
     290%     Release=txt.Release;
     291%         relnumb=str2num(Release(3:4));
     292%         if relnumb >= 14
     293%             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
     294%         else
     295%             save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
     296%         end
     297%     end
    298298end
    299299
     
    329329SubDirCell=InputTable(:,3);
    330330RootFileCell=InputTable(:,2);
    331 % RootPathCell=get(handles.RootPath,'String');
    332 % RootFileCell=get(handles.RootFile,'String');
    333331oldfile=''; %default
    334332if isempty(RootPathCell)||isequal(RootPathCell,{''})%loads the previously stored file name and set it as default in the file_input box
     
    404402iview=eventdata.Indices(1);
    405403InputTable=get(handles.InputTable,'Data');
    406 filename=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}])
     404fileinput=fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]);
    407405display_file_name(handles,fileinput,0)
    408 
    409 % hObject    handle to InputTable (see GCBO)
    410 % eventdata  structure with the following fields (see UITABLE)
    411 %       Indices: row and column indices of the cell(s) edited
    412 %       PreviousData: previous data for the cell(s) edited
    413 %       EditData: string(s) entered by the user
    414 %       NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
    415 %       Error: error string when failed to convert EditData to appropriate value for Data
    416 % handles    structure with handles and user data (see GUIDATA)
    417 % check_lines=get(handles.REFRESH_INDICES,'UserData');
    418 % check_lines(eventdata.Indices(1))=1; %select the edited line for refresh
    419 % set(handles.REFRESH_INDICES,'UserData',check_lines);
    420 % set(handles.REFRESH_INDICES,'Visible','on')
    421 %InputTable=get(handles.InputTable,'Data')
     406%update the output dir
     407SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order
     408SubDirOut=SubDir{1};
     409if numel(SubDir)>1
     410    for ilist=2:numel(SubDir)
     411        SubDirOut=[SubDirOut '-' SubDir{ilist}];
     412    end
     413end
     414set(handles.OutputSubDir,'String',SubDirOut)
    422415
    423416%------------------------------------------------------------------------
     
    445438set(handles.RUN, 'Enable','On')
    446439set(handles.RUN,'BackgroundColor',[1 0 0])% set RUN button to red
    447 % set(handles.RootPath,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
    448440set(handles.InputTable,'BackgroundColor',[1 1 0]) % set RootPath edit box  to yellow
    449441drawnow
    450 
    451442
    452443%% detect root name, nomenclature and indices in the input file name:
     
    467458    set(handles.ListView,'String',[get(handles.ListView,'String');{num2str(lastview)}])
    468459    set(handles.ListView,'Value',lastview)
    469 %     check_lines=get(handles.REFRESH_INDICES,'UserData');
     460
    470461else % or re-initialise the list of  input  file series
    471462    lastview=1;
     
    478469end
    479470set(handles.InputTable,'Data',InputTable)
    480 % check_lines(lastview)=1; %select the edited line for refresh
    481 % set(handles.REFRESH_INDICES,'UserData',check_lines);
    482 
    483 %% refresh menus with info from the new series: TODO:check
    484 %REFRESH_INDICES_Callback([],[], handles)
     471
     472%update the output dir
     473SubDir=sort(InputTable(:,2)); %set of subdirectories sorted in alphabetical order
     474SubDirOut=SubDir{1};
     475if numel(SubDir)>1
     476    for ilist=2:numel(SubDir)
     477        SubDirOut=[SubDirOut '-' SubDir{ilist}];
     478    end
     479end
     480set(handles.OutputSubDir,'String',SubDirOut)
    485481
    486482%% determine the selected reference field indices for pair display
     
    502498set(handles.num_ref_j,'String',num2str(ref_j));
    503499
    504 %% update list of recent files in the menubar and save it for future opening
     500%% update the list of recent files in the menubar and save it for future opening
    505501MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
    506502    {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
    507 str_find=strcmp(FileName,MenuFile);
     503str_find=strcmp(fileinput,MenuFile);
    508504if isempty(find(str_find,1))
    509     MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list
     505    MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list
    510506end
    511507for ifile=1:min(length(MenuFile),5)
     
    543539MinIndex=get(handles.MinIndex,'Data');%retrieve the min indices in the table MinIndex
    544540MaxIndex=get(handles.MaxIndex,'Data');%retrieve the max indices in the table MaxIndex
    545 % MinIndex_i=min(i1_series(i1_series>0));
    546 % if ~isempty(i2_series)
    547 %     MaxIndex_i=max(i2_series(i2_series>0));
    548 % else
    549 %     MaxIndex_i=max(i1_series(i1_series>0));
    550 % end
    551 % MinIndex_j=min(j1_series(j1_series>0));
    552 % if ~isempty(j2_series)
    553 %     MaxIndex_j=max(j2_series(j2_series>0));
    554 % else
    555 %     MaxIndex_j=max(j1_series(j1_series>0));
    556 % end
    557541i_sum=sum(sum(i1_series,2),3);
    558542MaxIndex_i=max(find(i_sum>0))-1;
     
    626610
    627611%%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
    628 
    629612ext_imadoc='';
    630613if exist([FileBase '.xml'],'file')
     
    744727    enable='off';
    745728end
    746 set(handles.VelTypeMenu,'Visible',enable)
     729set(handles.VelType,'Visible',enable)
    747730set(handles.VelType_text,'Visible',enable)
    748731if check_civ>=2
     
    751734    enable='off';
    752735end
    753 set(handles.VelTypeMenu_1,'Visible',enable)
     736set(handles.VelType_1,'Visible',enable)
    754737set(handles.VelType_text_1,'Visible',enable)
    755738if check_civ || check_netcdf
     
    758741    enable='off';
    759742end
    760 set(handles.FieldMenu,'Visible',enable)
     743set(handles.FieldName,'Visible',enable)
    761744set(handles.Field_text,'Visible',enable)
    762745if check_civ+ check_netcdf>=2
     
    765748    enable='off';
    766749end
    767 set(handles.FieldMenu_1,'Visible',enable)
     750set(handles.FieldName_1,'Visible',enable)
    768751set(handles.Field_text_1,'Visible',enable)
    769752FieldString={''};
     
    773756    FieldString={'get_field...'};
    774757end
    775 set(handles.FieldMenu,'String',FieldString)
     758set(handles.FieldName,'String',FieldString)
    776759FieldString={''};
    777760if check_civ>=2
     
    780763    FieldString={'get_field...'};
    781764end
    782 set(handles.FieldMenu_1,'String',{'get_field...'})
    783 % testfield=isequal(get(handles.FieldMenu,'enable'),'on');
    784 % testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
    785 % testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
    786 % testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
    787 % testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
    788 % testnc=0;
    789 % testnc_1=0;
    790 % testcivx=0;
    791 % testcivx_1=0;
    792 % testima=0; %test for image input
    793 % if isequal(lower(FileExt),'.avi') %.avi file
    794 %     testima=1;
    795 % elseif ~isempty(imformats(FileExt(2:end)))
    796 %     testima=1;
    797 % elseif isequal(FileExt,'.vol')
    798 %      testima=1;
    799 % end
    800 %TODO: update
    801 % if length(FileExtCell)==1 || length(FileExtCell)>2
    802 %     for iview=1:length(FileExtCell)
    803 %         if isequal(FileExtCell{iview},'.nc')
    804 %             testnc=1;
    805 %         end
    806 %         if isequal(FileTypeCell{iview},'civx')
    807 %             testcivx=1;
    808 %         end
    809 %     end
    810 % elseif length(FileExtCell)==2
    811 %     testnc=isequal(FileExtCell{1},'.nc');
    812 %     testnc_1=isequal(FileExtCell{2},'.nc');
    813 %     testcivx=isequal(FileTypeCell{1},'civx');
    814 %     testcivx_1=isequal(FileTypeCell{2},'civx');
    815 % end
    816 % switch FileType
    817 %     case {'civx','civdata'}
    818 %     view_FieldMenu(handles,'on')
    819 %     menustr=get(handles.FieldMenu,'String');
    820 %     if isequal(menustr,{'get_field...'})
    821 %         set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    822 %     end
    823 %     set(handles.VelTypeMenu,'Visible','on')
    824 %     set(handles.FieldTransform,'Visible','on')
    825 %     %      view_TRANSFORM(handles,'on')
    826 %     %     TODO: second menu
    827 %     %           view_FieldMenu_1(handles,'on')
    828 %     %     if testcivx_1
    829 %     %         menustr=get(handles.FieldMenu_1,'String');
    830 %     %         if isequal(menustr,{'get_field...'})
    831 %     %             set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    832 %     %         end
    833 %     %     else
    834 %     %         set(handles.FieldMenu_1,'Value',1)
    835 %     %         set(handles.FieldMenu_1,'String',{'get_field...'})
    836 %     %     set(handles.VelTypeMenu_1,'Visible','on')
    837 %     %     set(handles.VelType_text_1,'Visible','on');
    838 %     %     end
    839 %     %     view_FieldMenu_1(handles,'off')
    840 %     case 'netcdf'
    841 %     view_FieldMenu(handles,'on')
    842 %     set(handles.FieldMenu,'Value',1)
    843 %     set(handles.FieldMenu,'String',{'get_field...'})
    844 %     set(handles.FieldTransform,'Visible','off')
    845 %     %     view_TRANSFORM(handles,'off')
    846 %     case {'image','multimage','video'}
    847 %     view_FieldMenu(handles,'off')
    848 %     view_FieldMenu_1(handles,'off')
    849 %     set(handles.VelTypeMenu,'Visible','off')
    850 %     set(handles.VelType_text,'Visible','off');
    851 % end
    852 
     765set(handles.FieldName_1,'String',{'get_field...'})
    853766
    854767
     
    1003916enable_j(handles,state_j)
    1004917
     918%------------------------------------------------------------------------
     919function num_first_i_Callback(hObject, eventdata, handles)
     920%------------------------------------------------------------------------
     921num_last_i_Callback(hObject, eventdata, handles)
     922
     923%------------------------------------------------------------------------
     924function num_last_i_Callback(hObject, eventdata, handles)
     925%------------------------------------------------------------------------
     926SeriesData=get(handles.series,'UserData');
     927if ~isfield(SeriesData,'Time')
     928    SeriesData.Time{1}=[];
     929end
     930displ_time(handles);
     931
     932%------------------------------------------------------------------------
     933function num_first_j_Callback(hObject, eventdata, handles)
     934%------------------------------------------------------------------------
     935 num_last_j_Callback(hObject, eventdata, handles)
     936
     937%------------------------------------------------------------------------
     938function num_last_j_Callback(hObject, eventdata, handles)
     939%------------------------------------------------------------------------
     940first_j=str2num(get(handles.num_first_j,'String'));
     941last_j=str2num(get(handles.num_last_j,'String'));
     942ref_j=ceil((first_j+last_j)/2);
     943set(handles.num_ref_j,'String', num2str(ref_j))
     944num_ref_j_Callback(hObject, eventdata, handles)
     945SeriesData=get(handles.series,'UserData');
     946if ~isfield(SeriesData,'Time')
     947    SeriesData.Time{1}=[];
     948end
     949displ_time(handles);
     950
     951%------------------------------------------------------------------------
     952% ---- find the times corresponding to the first and last indices of a series
     953function displ_time(handles)
     954%------------------------------------------------------------------------
     955SeriesData=get(handles.series,'UserData');%
     956ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))];
     957ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))];
     958% last_i=str2num(get(handles.num_last_i,'String'));
     959% last_j=str2num(get(handles.num_last_j,'String'));
     960TimeTable=get(handles.TimeTable,'Data');
     961Pairs=get(handles.PairString,'Data');
     962for iview=1:size(TimeTable,1)
     963    if size(SeriesData.Time,1)<iview
     964        break
     965    end
     966    i1=ref_i;
     967    j1=ref_j;
     968    i2=ref_i;
     969    j2=ref_j;
     970    % case of pairs
     971    if ~isempty(Pairs{iview,1})
     972        r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     973        if isempty(r)
     974            r=regexp(Pairs{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
     975        end
     976        switch r.mode
     977            case 'Di='  %  case 'series(Di)')
     978                i1=ref_i-str2num(r.num1);
     979                i2=ref_i+str2num(r.num2);
     980            case 'Dj='  %  case 'series(Dj)'
     981                j1=ref_j-str2num(r.num1);
     982                j2=ref_j+str2num(r.num2);
     983            case '-'  % case 'bursts'
     984                j1=str2num(r.num1)*ones(size(ref_i));
     985                j2=str2num(r.num2)*ones(size(ref_i));
     986        end
     987    end
     988    TimeTable{iview,2}=[];
     989    TimeTable{iview,3}=[];
     990    if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2)
     991        if isempty(ref_j)
     992            time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
     993            time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
     994        else
     995            time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
     996            time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
     997        end
     998        TimeTable{iview,2}=time_first; %TODO: take into account pairs
     999        TimeTable{iview,3}=time_last; %TODO: take into account pairs
     1000    end
     1001end
     1002set(handles.TimeTable,'Data',TimeTable)
    10051003
    10061004%------------------------------------------------------------------------
     
    10761074iview=get(handles.ListView,'Value');
    10771075fill_ListPair(handles,SeriesData.i1_series{iview},SeriesData.i2_series{iview},...
    1078     SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.time{iview});% update the menu of pairs depending on the available netcdf files
     1076    SeriesData.j1_series{iview},SeriesData.j2_series{iview},SeriesData.Time{iview});% update the menu of pairs depending on the available netcdf files
    10791077ListPairs_Callback([],[],handles)
    10801078
     
    12171215end
    12181216set(handles.ListPairs,'String',displ_pair)
    1219 % if isempty(displ_pair)
    1220 %     msgbox_uvmat('ERROR',['no file available for the selected subdirectory' ])
    1221 % end
    1222 
    1223 
    1224 
    1225 % return
    1226 % %%%%%%%%
    1227 % %update num_first_i and num_last_i according to the chosen image pairstring
    1228 % testupdate=0;
    1229 %
    1230 % SeriesData=get(handles.series,'UserData');
    1231 % NomType=SeriesData.NomType{Val};
    1232 % list_pair=get(handles.ListPairs,'String');%get the menu of image pairs
    1233 % index_pair=get(handles.ListPairs,'Value');
    1234 % str_pair=list_pair{index_pair};
    1235 % ind_equ=strfind(str_pair,'=');%find '='
    1236 % ind_sep=strfind(str_pair,'|');%find pair separator '|'
    1237 % ind_com=strfind(str_pair,':');%find ':'
    1238 % test_bursts=0;
    1239 % if isempty(ind_sep)
    1240 %     ind_sep=strfind(str_pair,'-');%find pair separator if it is not '|'
    1241 %     test_bursts=1;% we are in the case of bursts
    1242 % end
    1243 % displ_num=[0 0 0 0]; %default
    1244 % if ~isempty(ind_sep)&& ~strcmp(str_pair(ind_sep-1),'*')% if there is a pair separator ('|' or '-')
    1245 %     num1_str=str_pair(ind_equ(1)+1:ind_sep-1);
    1246 %     num2_str=str_pair(ind_sep+1:ind_com-1);
    1247 %     num1=str2double(num1_str);
    1248 %     num2=str2double(num2_str);
    1249 %     if isequal(num1_str(1),' ')
    1250 %         num1_str(1)=[];
    1251 %     end   
    1252 %     if isequal(num2_str(end),' ')
    1253 %         num2_str(end)=[];
    1254 %     end
    1255 %     switch NomType
    1256 %        case {'_1-2_1'}
    1257 %            if isequal(num1_str(1),'0')
    1258 %                IndexCell{Val}=['_(i-(i+' num2_str ')_j'];
    1259 %            else
    1260 %                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j'];
    1261 %            end
    1262 %            displ_num(3)=num1;
    1263 %            displ_num(4)=num2;
    1264 %        case {'_1-2'}
    1265 %            if isequal(num1_str(1),'0')
    1266 %                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
    1267 %            else
    1268 %                IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
    1269 %            end
    1270 %            displ_num(3)=num1;
    1271 %            displ_num(4)=num2;
    1272 %        case '_1_1-2'
    1273 %           if test_bursts
    1274 %               IndexCell{Val}=['_i_' num1_str '-' num2_str ];
    1275 %           else
    1276 %               if isequal(num1_str(1),'0')
    1277 %                  IndexCell{Val}=['_i_j-(j+' num2_str ')'];
    1278 %               else
    1279 %                  IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')'];
    1280 %               end
    1281 %           end
    1282 %           displ_num(1)=num1;
    1283 %           displ_num(2)=num2;
    1284 %        case {'#_ab'} %TO COMPLETE
    1285 %            IndexCell{Val}=['_i_' num1_str '-' num2_str ];
    1286 %
    1287 %     end
    1288 % end
    1289 % set(handles.NomType,'String',IndexCell)
    1290 % SeriesData.displ_num(Val,:)=displ_num;
    1291 % set(handles.series,'UserData',SeriesData)
    1292 % % set(handles.NomType,'Value',Val)
    1293 %
    1294 % if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*')
    1295 %       mode_list=get(handles.mode,'String');
    1296 %     mode_value=get(handles.mode,'Value');
    1297 %     mode=mode_list{mode_value};
    1298 %       if isequal(mode,'series(Di)')
    1299 %         first_i=str2num(get(handles.num_first_i,'String'));
    1300 %         last_i=str2num(get(handles.num_last_i,'String'));
    1301 %         incr_i=str2num(get(handles.num_incr_i,'String'));
    1302 %         num1=first_i:incr_i:last_i;
    1303 %         lastfieldCell=get(handles.num_MaxIndex_i,'String');
    1304 %         lastfield=str2num(lastfieldCell{1});
    1305 %         if ~isempty(lastfield)
    1306 %             ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
    1307 %             num1=num1(ind);       
    1308 %         end
    1309 %         if ~isempty(num1)
    1310 %             set(handles.num_first_i,'String',num2str(num1(1)));
    1311 %             set(handles.num_last_i,'String',num2str(num1(end)));
    1312 %         end
    1313 %         testupdate=1;
    1314 %       elseif isequal(mode,'series(Dj)')
    1315 %         first_j=str2num(get(handles.num_first_j,'String'));
    1316 %         last_j=str2num(get(handles.num_last_j,'String'));
    1317 %         incr_j=str2num(get(handles.num_incr_j,'String'));
    1318 %         num_j=first_j:incr_j:last_j;
    1319 %         lastfieldCell=get(handles.num_MaxIndex_j,'String');
    1320 %         if ~isempty(lastfieldCell)
    1321 %             lastfield2=lastfieldCell{1};
    1322 %             ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1323 %                  (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
    1324 %         end
    1325 %         testupdate=1;
    1326 %       end
    1327 %       
    1328 %       %update the first and last times of the series
    1329 %       if testupdate && isfield(SeriesData,'Time')
    1330 %         if ~isempty(SeriesData.Time{1})
    1331 %             displ_time(handles);
    1332 %         end
    1333 %       end
    1334 % end
    13351217
    13361218%-------------------------------------
     
    13571239%-----------------------------------
    13581240function view_FieldMenu(handles,state)
    1359 % set(handles.FieldMenu,'Visible',state)
     1241% set(handles.FieldName,'Visible',state)
    13601242% set(handles.Field_text,'Visible',state)
    13611243set(handles.InputFields,'Visible',state)
     
    13631245%-----------------------------------
    13641246function view_FieldMenu_1(handles,state)
    1365 set(handles.FieldMenu_1,'Visible',state)
     1247set(handles.FieldName_1,'Visible',state)
    13661248set(handles.Field_text_1,'Visible',state)
    13671249
    1368 % %-----------------------------------
    1369 % function view_TRANSFORM(handles,state)
    1370 % set(handles.TRANSFORM_frame,'Visible',state)
    1371 % set(handles.transform_fct,'Visible',state);
    1372 % set(handles.TRANSFORM_title,'Visible',state)
    1373 
    1374 
    1375 %list_pair_civ_Callback([],[],handles)
    1376 
    1377 
    1378 
     1250
     1251%%%%%%%%%%%%%%%%%%%%
     1252%%  MAIN ActionName FUNCTIONS
     1253%%%%%%%%%%%%%%%%%%%%
    13791254%------------------------------------------------------------------------
    13801255% --- Executes on button press in RUN.
    13811256function RUN_Callback(hObject, eventdata, handles)
    13821257%------------------------------------------------------------------------
    1383 %% Read parameters from series
    1384 Series=read_GUI(handles.series);%TODO: extend to all input param
    1385 Series.hseries=handles.series; % handles to the series GUI
    1386 
    1387 %% read root name and field type
    13881258set(handles.RUN,'BusyAction','queue');
    13891259set(0,'CurrentFigure',handles.series)
    1390 if isequal(get(handles.GetObject,'Visible'),'on') && isequal(get(handles.GetObject,'Value'),1)
    1391     Series.GetObject=1;
    1392     GetObject_Callback(hObject, eventdata, handles)
    1393 else
    1394     Series.GetObject=0;
    1395 end
    1396 % SeriesData=get(handles.series,'UserData');
    1397 
    1398 % Series.hseries=handles.series; % handles to the series GUI
    1399    first_i=1;
    1400    last_i=1;
    1401    incr_i=1;
    1402        first_j=1;
    1403     last_j=1;
    1404     incr_j=1;
     1260set(handles.RUN, 'Enable','Off')
     1261set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
     1262[h_fun,Series,errormsg]=prepare_jobs(handles);
     1263if ~isempty(errormsg)
     1264    msgbox_uvmat('ERROR',errormsg)
     1265else
     1266    h_fun(Series);
     1267end
     1268set(handles.RUN, 'Enable','On')
     1269set(handles.RUN,'BackgroundColor',[1 0 0])
     1270
     1271%------------------------------------------------------------------------
     1272function STOP_Callback(hObject, eventdata, handles)
     1273%------------------------------------------------------------------------
     1274set(handles.RUN, 'BusyAction','cancel')
     1275set(handles.RUN,'BackgroundColor',[1 0 0])
     1276set(handles.RUN,'enable','on')
     1277
     1278%------------------------------------------------------------------------
     1279% --- Executes on button press in BATCH.
     1280function BATCH_Callback(hObject, eventdata, handles)
     1281%------------------------------------------------------------------------   
     1282set(handles.BATCH, 'Enable','Off')
     1283set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])
     1284[h_fun,errormsg]=prepare_jobs(handles);
     1285set(handles.BATCH, 'Enable','On')
     1286set(handles.BATCH,'BackgroundColor',[1 0 0])
     1287path_civ=fileparts(which('civ'));
     1288filename_bat=[OutputFile '.bat'];
     1289[fid,message]=fopen(filename_bat,'w');
     1290if isequal(fid,-1)
     1291    errormsg= ['creation of .bat file: ' message];
     1292    return
     1293end
     1294text_matlabscript=[...
     1295    '#!/bin/bash \n'...
     1296    '. /etc/sysprofile \n'...
     1297    'matlab -nodisplay -nosplash -nojvm <<END_MATLAB \n'...
     1298    'cd(''' path_civ '''); \n'...
     1299    'civ_matlab(''' filename_xml ''',''' OutputFile '.nc''); \n'...
     1300    'exit \n'...
     1301    'END_MATLAB \n'];
     1302fprintf(fid,text_matlabscript);
     1303fclose(fid);
     1304if isunix
     1305    system(['chmod +x ' filename_bat]);
     1306end
     1307
     1308%------------------------------------------------------------------------
     1309% --- Executes on button press in BIN.
     1310function BIN_Callback(hObject, eventdata, handles)
     1311%------------------------------------------------------------------------
     1312    cmd=['#!/bin/bash \n '...
     1313        '#$ -cwd \n '...
     1314        'hostname && date \n '...
     1315        'umask 002 \n'...
     1316        Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc'];
     1317   
     1318%------------------------------------------------------------------------
     1319% --- Main lauch command, called by RUN and BATCH
     1320function [h_fun,Series,errormsg]=prepare_jobs(handles)
     1321%------------------------------------------------------------------------
     1322errormsg='';
     1323%% Read parameters from series
     1324Series=read_GUI(handles.series);
     1325if isfield(Series,'Pairs')
     1326Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
     1327end
     1328
     1329%% read root name and field type
     1330first_i=1;
     1331last_i=1;
     1332incr_i=1;
     1333first_j=1;
     1334last_j=1;
     1335incr_j=1;
    14051336if isfield(Series.IndexRange,'first_i')
    14061337    first_i=Series.IndexRange.first_i;
     
    14151346
    14161347%% read input file parameters and set menus
    1417 Series.PathProject=get(handles.PathCampaign,'String');
    1418 % InputTable=get(handles.InputTable,'Data');
    1419 % RootPath=Series.InputTable(:,1);
    1420 % SubDir=Series.InputTable(:,2);
    1421 % RootFile=Series.InputTable(:,3);
    1422 % NomType=Series.InputTable(:,4);
    1423 % FileExt=Series.InputTable(:,5);
    1424 % if isempty(SeriesData)
    1425 %     msgbox_uvmat('ERROR','no input file series')
    1426 %     return
    1427 % end
    1428 % NomType=SeriesData.NomType;
    1429 % if length(RootPath)==1 %string character input for user fct
    1430 %     Series.RootPath=RootPath{1};
    1431 %     Series.RootFile=RootFile{1};
    1432 %     Series.SubDir=SubDir{1};
    1433 %     Series.FileExt=FileExt{1};
    1434 %     Series.NomType=NomType{1};
    1435 % else %cell input for user fct
    1436 %     Series.RootPath=RootPath;
    1437 %     Series.RootFile=RootFile;
    1438 %     Series.SubDir=SubDir;
    1439 %     Series.FileExt=FileExt;
    1440 %     Series.NomType=NomType;
    1441 % end
    1442 % if isequal(get(handles.FieldMenu,'Visible'),'on')
    1443 %     FieldMenu=get(handles.FieldMenu,'String');
    1444 %     FieldValue=get(handles.FieldMenu,'Value');
    1445 %     Series.Field=FieldMenu(FieldValue);
    1446 % end
    1447 menu_coord_state=get(handles.transform_fct,'Visible');
    1448 Series.CoordType='';%default
     1348menu_coord_state=get(handles.TransformName,'Visible');
    14491349if isequal(menu_coord_state,'on')
    1450 %     menu_coord=get(handles.transform_fct,'String');
    1451     menu_index=get(handles.transform_fct,'Value');
    1452     transform_list=get(handles.transform_fct,'UserData');
    1453     Series.FieldTransform.fct_handle=transform_list{menu_index};% transform function handles
    1454 end
    1455 
    1456 %reinitiate waitbar position
    1457 Series.WaitbarPos=get(handles.waitbar_frame,'Position');%TO SUPPRESS
    1458 waitbarpos=Series.WaitbarPos;
    1459 waitbarpos(4)=0.005;%reinitialize waitbar to zero height
    1460 waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005;
    1461 % set(handles.waitbar,'Position',waitbarpos)
    1462 
    1463 if isfield(Series.IndexRange,'NbSlice')
    1464 Series.NbSlice=Series.IndexRange.NbSlice;
    1465 end
     1350    menu_index=get(handles.TransformName,'Value');
     1351    transform_list=get(handles.TransformName,'UserData');
     1352    Series.FieldTransform.TransformHandle=transform_list{menu_index};% transform function handles
     1353end
     1354
    14661355if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    14671356    set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
    1468 num_i=first_i:incr_i:last_i;
    1469 num_j=first_j:incr_j:last_j;
    1470 % nbfield_cell=get(handles.num_MaxIndex_i,'String');
    1471 nbfield=cell2mat(Series.IndexRange.MaxIndex);
    1472 nb=min(nbfield,1);
    1473 % nbfield=nb(1);
    1474 % nbfield2=nb(2);
    1475 
    1476 %get complementary information from the 'series' interface
    1477 list_action=get(handles.ACTION,'String');% list menu action
    1478 index_action=get(handles.ACTION,'Value');% selected string index
    1479 action= list_action{index_action}; % selected string
    1480 mode_list=get(handles.mode,'String');
    1481 index_mode=get(handles.mode,'Value');
    1482 mode=mode_list{index_mode};
    1483 ind_shift=0;%default
    1484 
    1485 
    1486 %% defining the ACTION function handle
     1357
     1358%% projection object
     1359if isfield(Series,'CheckObject')
     1360    if Series.CheckObject
     1361        hset_object=findobj(allchild(0),'tag','set_object');
     1362        Series.ProjObject=read_GUI(hset_object);
     1363        GetObject_Callback([], [], handles)
     1364    end
     1365else
     1366    Series.CheckObject=0;
     1367end
     1368
     1369%% get_field GUI
     1370if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field')
     1371    if strcmp(Series.InputFields.Field,'get_field...')
     1372        hget_field=findobj(allchild(0),'name','get_field');
     1373        Series.GetField=read_GUI(hget_field);
     1374    end
     1375end
     1376
     1377%% defining the ActionName function handle
     1378list_action=get(handles.ActionName,'String');% list menu action
     1379index=get(handles.ActionName,'Value');
     1380action= list_action{index}; % selected string
     1381Series.Action=action;%name of the processing programme
     1382Series.hseries=handles.series; % handles to the series GUI
    14871383path_series=which('series');
    1488 list_path=get(handles.ACTION,'UserData');
    1489 index=get(handles.ACTION,'Value');
     1384list_path=get(handles.ActionName,'UserData');
    14901385fct_path=list_path{index}; %path stored for the function ACTION
    14911386if ~isequal(fct_path,path_series)
    14921387    eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
    14931388    if ~exist(fct_path,'dir')
    1494         msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist'])
     1389        errormsg=['The prescibed function path ' fct_path ' does not exist'];
    14951390        return
    14961391    end
     
    15041399end
    15051400
    1506 %% RUN ACTION
    1507 Series.Action=action;%name of the processing programme
    1508 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
    1509 h_fun(Series);
    1510 % if length(RootPath)>1
    1511 %     h_fun(i1_series_cell,i2_series_cell,j1_series_cell,j2_series_cell,Series);
    1512 % else
    1513 %     h_fun(i1_series,i2_series,j1_series,j2_series,Series);
    1514 % end
    1515 set(handles.RUN,'BackgroundColor',[1 0 0])
    1516 
    1517 % %save the current interface setting as figure namefig, append .0 to the name if it already exists
    1518 % detect=1;
    1519 % while detect==1
    1520 %     namefigfull=[namedoc '.fig'];
    1521 %     hh=dir(namefigfull);
    1522 %     if ~isempty(hh)
    1523 %         detect=1;
    1524 %         namedoc=[namedoc '.0'];
    1525 %     else
    1526 %         detect=0;
    1527 %     end
    1528 % end
    1529 % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER  .xml)
    1530 
    1531 %------------------------------------------------------------------------
    1532 function STOP_Callback(hObject, eventdata, handles)
    1533 %------------------------------------------------------------------------
    1534 set(handles.RUN, 'BusyAction','cancel')
    1535 set(handles.RUN,'BackgroundColor',[1 0 0])
    1536 
    1537 
    1538 %------------------------------------------------------------------------
    1539 function num_first_i_Callback(hObject, eventdata, handles)
    1540 %------------------------------------------------------------------------
    1541 num_last_i_Callback(hObject, eventdata, handles)
    1542 
    1543 %------------------------------------------------------------------------
    1544 function num_last_i_Callback(hObject, eventdata, handles)
    1545 %------------------------------------------------------------------------
    1546 SeriesData=get(handles.series,'UserData');
    1547 if ~isfield(SeriesData,'Time')
    1548     SeriesData.Time{1}=[];
    1549 end
    1550 displ_time(handles);
    1551 
    1552 %------------------------------------------------------------------------
    1553 function num_first_j_Callback(hObject, eventdata, handles)
    1554 %------------------------------------------------------------------------
    1555  num_last_j_Callback(hObject, eventdata, handles)
    1556 
    1557 %------------------------------------------------------------------------
    1558 function num_last_j_Callback(hObject, eventdata, handles)
    1559 %------------------------------------------------------------------------
    1560 first_j=str2num(get(handles.num_first_j,'String'));
    1561 last_j=str2num(get(handles.num_last_j,'String'));
    1562 ref_j=ceil((first_j+last_j)/2);
    1563 set(handles.num_ref_j,'String', num2str(ref_j))
    1564 num_ref_j_Callback(hObject, eventdata, handles)
    1565 SeriesData=get(handles.series,'UserData');
    1566 if ~isfield(SeriesData,'Time')
    1567     SeriesData.Time{1}=[];
    1568 end
    1569 displ_time(handles);
    1570 
    1571 
    1572 % NomTypeCell=SeriesData.NomType;
    1573 % if ~isempty(NomTypeCell)
    1574 %     Val=get(handles.NomType,'Value');
    1575 %     NomType=NomTypeCell{Val};
    1576 %     if isequal(NomType,'_1_1-2')|| isequal(NomType,'_1-2_1')|| isequal(NomType,'_1-2')
    1577 %         if isequal(mode,'series(Dj)')
    1578 %             fill_ListPair(handles,Val);% update the menu of pairstring depending on the available netcdf files
    1579 %         end
    1580 %     end
    1581 % end
    1582 %------------------------------------------------------------------------
    1583 % ---- find the times corresponding to the first and last indices of a series
    1584 function displ_time(handles)
    1585 %------------------------------------------------------------------------
    1586 SeriesData=get(handles.series,'UserData');%
    1587 ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))];
    1588 ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))];
    1589 % last_i=str2num(get(handles.num_last_i,'String'));
    1590 % last_j=str2num(get(handles.num_last_j,'String'));
    1591 TimeTable=get(handles.TimeTable,'Data');
    1592 Pairs=get(handles.PairString,'Data');
    1593 for iview=1:size(TimeTable,1)
    1594     if size(SeriesData.Time,1)<iview
    1595         break
    1596     end
    1597     i1=ref_i;
    1598     j1=ref_j;
    1599     i2=ref_i;
    1600     j2=ref_j;
    1601     % case of pairs
    1602     if ~isempty(Pairs{iview,1})
    1603         r=regexp(Pairs{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     1401%% create the output data directory and write in it the xml file from the GUI config
     1402%determine the root file corresponding to the first sub dir
     1403if isfield(Series,'OutputSubDir')
     1404    SubDirOut=[Series.OutputSubDir Series.OutputDirExt];
     1405    SubDirOutNew=SubDirOut;
     1406    iview=1;
     1407    SeriesData=get(handles.series,'UserData');
     1408    if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && isfield(SeriesData.AllowInputSort)
     1409        [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order
     1410        Series.InputTable=Series.InputTable(iview,:);
     1411    end
     1412    detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'file')==2;% test if  the dir  already exist
     1413    while detect
     1414        r=regexp(SubDirOut,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
    16041415        if isempty(r)
    1605             r=regexp(Pairs.list_pair_civ,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
    1606         end
    1607         switch r.mode
    1608             case 'Di='  %  case 'series(Di)')
    1609                 i1=ref_i-str2num(r.num1);
    1610                 i2=ref_i+str2num(r.num2);
    1611             case 'Dj='  %  case 'series(Dj)'
    1612                 j1=ref_j-str2num(r.num1);
    1613                 j2=ref_j+str2num(r.num2);
    1614             case '-'  % case 'bursts'
    1615                 j1=str2num(r.num1)*ones(size(ref_i));
    1616                 j2=str2num(r.num2)*ones(size(ref_i));
    1617         end
    1618     end
    1619     TimeTable{iview,2}=[];
    1620     TimeTable{iview,3}=[];
    1621     if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2)
    1622         if isempty(ref_j)
    1623             time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
    1624             time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
    1625         else
    1626             time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
    1627             time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
    1628         end
    1629         TimeTable{iview,2}=time_first; %TODO: take into account pairs
    1630         TimeTable{iview,3}=time_last; %TODO: take into account pairs
    1631     end
    1632 end
    1633 set(handles.TimeTable,'Data',TimeTable)
    1634 
    1635 
    1636 %
    1637 % NomType=InputTable(:,4);
    1638 % mode_list=get(handles.mode,'String');
    1639 % index_mode=get(handles.mode,'Value');
    1640 %
    1641 % mode=mode_list{index_mode};
    1642 %
    1643 % time_first=[];
    1644 % time_last=[];
    1645 % if ~isfield(SeriesData,'Time')
    1646 %     SeriesData.Time{1}=[];
    1647 % end
    1648 % TimeTable=get(handles.TimeTable,'Data');
    1649 % for iview=1:size(TimeTable,1)
    1650 %     time_first_cell{iview}='?';
    1651 %     time_last_cell{iview}='?';%default
    1652 %     time=SeriesData.Time{iview};
    1653 %     if isequal(NomType{iview},'_1-2_1')|isequal(NomType{iview},'_1_1-2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_1-2')
    1654 %         if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
    1655 %             ind_shift=SeriesData.displ_num(iview,:);
    1656 %             if isequal(mode,'bursts')
    1657 %                 first_j=0;
    1658 %                 last_j=0;
    1659 %             end
    1660 %             first_i1=first_i +ind_shift(3);
    1661 %             first_i2 =first_i +ind_shift(4);
    1662 %             first_j1 =first_j +ind_shift(1);
    1663 %             first_j2 =first_j +ind_shift(2);
    1664 %             last_i1=last_i +ind_shift(3);
    1665 %             last_i2 =last_i +ind_shift(4);   
    1666 %             last_j1 =last_j +ind_shift(1);
    1667 %             last_j2 =last_j +ind_shift(2);
    1668 %             siz=size(SeriesData.Time{1});
    1669 %             if first_i1>=1 && first_j1>=1 && siz(1)>=last_i2 && siz(2)>=last_j2
    1670 %                 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
    1671 %                 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
    1672 %             else%read the time in the nc files
    1673 %                 RootPath=get(handles.RootPath,'String');
    1674 %                 RootFile=get(handles.RootFile,'String');
    1675 %                 SubDir=get(handles.SubDir,'String');
    1676 %                 %VelType=get(handles.VelType,'String');
    1677 %                 VelType_str=get(handles.VelTypeMenu,'String');
    1678 %                 VelType_val=get(handles.VelTypeMenu,'Value');
    1679 %                 VelType=VelType_str{VelType_val};
    1680 %                 filebase=fullfile(RootPath{1},RootFile{1});
    1681 %                 [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
    1682 %                 if  exist(filefirst,'file')
    1683 %                     Attrib=nc2struct(filefirst,[]);
    1684 %                     if isfield(Attrib,'Time')
    1685 %                         time_first=Attrib.Time;
    1686 %                     else
    1687 %                         if isfield(Attrib,'absolut_time_T0')
    1688 %                             time_first=Attrib.absolut_time_T0;
    1689 %                         end
    1690 %                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1691 %                             time_first=Attrib.absolut_time_T0_2;
    1692 %                         end
    1693 %                     end
    1694 %                 end
    1695 %                 [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
    1696 %                 if exist(filelast,'file')
    1697 %                    Attrib=nc2struct(filelast,[]);
    1698 %                     if isfield(Attrib,'Time')
    1699 %                         time_last=Attrib.Time;
    1700 %                     else
    1701 %                         if isfield(Attrib,'absolut_time_T0')
    1702 %                             time_last=Attrib.absolut_time_T0;
    1703 %                         end
    1704 %                         if isfield(Attrib,'absolut_time_T0_2')&&~(isequal(VelType,'civ1')||isequal(VelType,'interp1')||isequal(VelType,'filter1'))
    1705 %                             time_last=Attrib.absolut_time_T0_2;
    1706 %                         end
    1707 %                     end
    1708 %                 end
    1709 %             end
    1710 %         end
    1711 %     else
    1712 %         siz=size(time);
    1713 %         if siz(1)>=last_i && siz(2)>=last_j && first_i>=1 && first_j>=1
    1714 %             time_first=times(first_i,first_j);
    1715 %             time_last=times(last_i,last_j);
    1716 %         end
    1717 %     end
    1718 %     time_first_cell{iview}=num2str(time_first,4);
    1719 %     time_last_cell{iview}=num2str(time_last,4);
    1720 % end
    1721 %
    1722 
    1723 %------------------------------------------------------------------------
    1724 % --- Executes on selection change in ACTION.
    1725 function ACTION_Callback(hObject, eventdata, handles)
     1416            r(1).root=[SubDirOut '_'];
     1417            r(1).num1='0';
     1418        end
     1419        SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
     1420        detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'file')==2;% test if  the dir  already exists
     1421    end
     1422    Series.OutputSubDir=SubDirOutNew;
     1423    Series.OutputDir=fullfile(Series.InputTable{1,1},Series.OutputSubDir);%directory set for output results
     1424    Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output
     1425    Series=rmfield(Series,'OutputDirExt');%removes redondant information
     1426    % create output directory
     1427    answer='No';
     1428    if exist(Series.OutputDir,'dir')
     1429        answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' Series.OutputDir ', possibly delete previous data']);
     1430    end
     1431    if ~isequal(answer,'Yes')
     1432        [tild,msg1]=mkdir(Series.OutputDir);
     1433        if ~strcmp(msg1,'')
     1434            errormsg=['cannot create ' Series.OutputDir ': ' msg1];%error message for directory creation
     1435            return
     1436        end
     1437    end
     1438    filexml=fullfile(Series.OutputDir,[Series.InputTable{1,3} '.xml']);% name of the parameter xml file set in this directory
     1439    t=struct2xml(Series);
     1440    save(t,filexml);
     1441end
     1442
     1443%------------------------------------------------------------------------
     1444% --- Executes on selection change in ActionName.
     1445function ActionName_Callback(hObject, eventdata, handles)
    17261446%------------------------------------------------------------------------
    17271447global nb_builtin_ACTION
    1728 list_ACTION=get(handles.ACTION,'String');% list menu fields
    1729 index_ACTION=get(handles.ACTION,'Value');% selected string index
     1448list_ACTION=get(handles.ActionName,'String');% list menu fields
     1449index_ACTION=get(handles.ActionName,'Value');% selected string index
    17301450ACTION= list_ACTION{index_ACTION}; % selected function name
    17311451path_series=which('series');%path to series.m
    1732 list_path=get(handles.ACTION,'UserData');%list of recorded paths to functions of the list ACTION
     1452list_path=get(handles.ActionName,'UserData');%list of recorded paths to functions of the list ACTION
    17331453default_file=fullfile(list_path{end},ACTION);
    17341454% add a new function to the menu if the selected item is 'more...'
     
    17491469    end
    17501470   
    1751    % insert the choice in the action menu
    1752    menu_str=update_menu(handles.ACTION,ACTION);%new action menu in which the new item has been appended if needed
    1753    index_ACTION=get(handles.ACTION,'Value');% currently selected index in the list
     1471   % insert the choice in the actionname menu
     1472   menu_str=update_menu(handles.ActionName,ACTION);%new action menu in which the new item has been appended if needed
     1473   index_ACTION=get(handles.ActionName,'Value');% currently selected index in the list
    17541474   list_path{index_ACTION}=PathName;
    17551475   if length(menu_str)>nb_builtin_ACTION+5; %nb_builtin=nbre of functions always remaining in the initial menu
     
    17581478       list_path(nb_builtin_ACTION+1:end-4)=[];
    17591479       index_ACTION=index_ACTION-nbremove;
    1760        set(handles.ACTION,'Value',index_ACTION)
    1761        set(handles.ACTION,'String',menu_str)
     1480       set(handles.ActionName,'Value',index_ACTION)
     1481       set(handles.ActionName,'String',menu_str)
    17621482   end
    17631483   list_path{index_ACTION}=PathName;
    1764    set(handles.ACTION,'UserData',list_path);
    1765    set(handles.path,'enable','inactive')% indicate that the current path is accessible (not 'off')
     1484   set(handles.ActionName,'UserData',list_path);
     1485   set(handles.ActionPath,'enable','inactive')% indicate that the current path is accessible (not 'off')
    17661486   
    17671487   %record the current menu in personal file profil_perso
     
    17871507end
    17881508
    1789 %check the current path to the selected function
     1509%check the current ActionPath to the selected function
    17901510PathName=list_path{index_ACTION};%current recorded path
    1791 set(handles.path,'String',PathName); %show the path to the senlected function
     1511set(handles.ActionPath,'String',PathName); %show the path to the senlected function
    17921512
    17931513%default setting for the visibility of the GUI elements
    1794 % set(handles.RootPath,'UserData','many')
    1795 % set(handles.SubDir,'Visible','on')
    1796 % set(handles.RootFile,'Visible','on')
    1797 % set(handles.NomType,'Visible','on')
    1798 % set(handles.FileExt,'Visible','on')
    17991514set(handles.num_NbSlice,'Visible','off')
    18001515set(handles.NbSlice_title,'Visible','off')
    1801 set(handles.VelTypeMenu,'Visible','off');
     1516set(handles.VelType,'Visible','off');
    18021517set(handles.VelType_text,'Visible','off');
    1803 set(handles.VelTypeMenu_1,'Visible','off');
     1518set(handles.VelType_1,'Visible','off');
    18041519set(handles.VelType_text_1,'Visible','off');
    18051520view_FieldMenu(handles,'off')
    18061521view_FieldMenu_1(handles,'off')
    18071522set(handles.FieldTransform,'Visible','off')
    1808 % view_TRANSFORM(handles,'off')Visible','off')
    1809 set(handles.Objects,'Visible','off');
    1810 set(handles.GetMask,'Visible','off')
     1523set(handles.CheckObject,'Visible','off');
     1524set(handles.ProjObject,'Visible','off');
     1525set(handles.CheckMask,'Visible','off')
    18111526set(handles.Mask,'Visible','off')
    1812 % set(handles.GetObject,'Visible','off');
    1813 set(handles.OutputDir,'Visible','off');
    1814 % set(handles.PARAMETERS_frame,'Visible','off');
    1815 % set(handles.PARAMETERS_title,'Visible','off');
     1527% set(handles.OutputDirExt,'Visible','off');
    18161528set(handles.ParamKey,'Visible','off')
    18171529set(handles.ParamVal,'Visible','off')
    18181530ParamKey={};
    1819 set(handles.FieldMenu,'Enable','off')
    1820 set(handles.VelTypeMenu,'Enable','off')
    1821 set(handles.FieldMenu_1,'Enable','off')
    1822 set(handles.VelTypeMenu_1,'Enable','off')
    1823 set(handles.transform_fct,'Enable','off')
     1531set(handles.FieldName,'Enable','off')
     1532set(handles.VelType,'Enable','off')
     1533set(handles.FieldName_1,'Enable','off')
     1534set(handles.VelType_1,'Enable','off')
     1535set(handles.TransformName,'Enable','off')
     1536set(handles.OutputDirExt,'Visible','off')
     1537set(handles.OutputSubDir,'Visible','off')
     1538set(handles.OutputDir_title,'Visible','off')
    18241539%set the displayed GUI item needed for input parameters
    18251540if ~isequal(path_series,PathName)
     
    18311546    InputText=textscan(fid,'%s',1,'delimiter','\n');
    18321547    fclose(fid)
    1833     set(handles.ACTION,'ToolTipString',InputText{1}{1})
     1548    set(handles.ActionName,'ToolTipString',InputText{1}{1})
    18341549end
    18351550if ~isequal(path_series,PathName)
     
    18391554Param_list={};
    18401555
    1841 %nb_series=length(RootFile);
    1842 % FileExt=get(handles.FileExt,'String');
    1843 % nb_series=length(FileExt);
    18441556InputTable=get(handles.InputTable,'Data');
    18451557nb_series=size(InputTable,1);
    1846 % if ~isempty(checkcell)
    1847 % nb_series=checkcell(end);
    1848 % end
    1849 % nb_series=size(InputFiles,1)
    18501558testima_series=1; %test for a list of images only
    18511559testima=1;
     
    18701578for ilist=1:length(varargout)-1
    18711579    switch varargout{ilist}
    1872 
    1873                        %RootFile always visible
    1874 %          case 'RootPath'   %visible by default
    1875 %             value=lower(varargout{ilist+1});
    1876 %             if isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
    1877 %                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
    1878 %             end
    1879 %         case 'SubDir' %visible by default
    1880 %             if isequal(lower(varargout{ilist+1}),'off')
    1881 %                 set(handles.SubDir,'Visible','off')
    1882 %             end
    1883 %         case 'RootFile'   %visible by default
    1884 %             value=lower(varargout{ilist+1});
    1885 %             if isequal(value,'off')
    1886 %                 set(handles.RootFile,'Visible','off')
    1887 %             elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
    1888 %                 set(handles.RootFile,'Visible','on')
    1889 %                 set(handles.RootFile,'UserData',value)% for use in menu Open_insert
    1890 %             end
    1891 %         case 'NomType'   %visible by default
    1892 %             if isequal(lower(varargout{ilist+1}),'off')
    1893 %                 set(handles.NomType,'Visible','off')
    1894 %             end
    1895 %         case 'FileExt'   %visible by default
    1896 %             if isequal(lower(varargout{ilist+1}),'off')
    1897 %                 set(handles.FileExt,'Visible','off')
    1898 %             end
     1580        case 'NbViewMax'
     1581            if ~isempty (varargout{ilist+1})
     1582                if size(InputTable,1)>varargout{ilist+1}
     1583                InputTable=InputTable(1:varargout{ilist+1},:);
     1584                set(handles.InputTable,'Data',InputTable)
     1585                end
     1586            end
     1587        case 'AllowInputSort'
     1588            if isequal(lower(varargout{ilist+1}),'on')% sort the input table by alphabetical order of the SubDir
     1589                SeriesData=get(handles.series,'UserData');
     1590                SeriesData.AllowInputSort=1;
     1591                set(handles.series,'UserData',SeriesData)
     1592            end             
    18991593        case 'NbSlice'   %hidden by default
    19001594            if isequal(lower(varargout{ilist+1}),'on')
     
    19021596                set(handles.NbSlice_title,'Visible','on')
    19031597            end
    1904         case 'VelTypeMenu'   %hidden by default
     1598        case 'VelType'   %hidden by default
    19051599             if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two')
    1906                 set(handles.VelTypeMenu,'Enable','on')
     1600                set(handles.VelType,'Enable','on')
    19071601                if nb_series >=1 && ~testima_series
    1908                     set(handles.VelTypeMenu,'Visible','on')
     1602                    set(handles.VelType,'Visible','on')
    19091603                    set(handles.VelType_text,'Visible','on');
    1910 %                     set(handles.Field_frame,'Visible','on')
    19111604                end
    19121605             end
    19131606            if isequal(lower(varargout{ilist+1}),'two')
    1914                 set(handles.VelTypeMenu_1,'Enable','on')
     1607                set(handles.VelType_1,'Enable','on')
    19151608                if nb_series >=2 && ~testima_series
    1916                     set(handles.VelTypeMenu_1,'Visible','on')
     1609                    set(handles.VelType_1,'Visible','on')
    19171610                    set(handles.VelType_text_1,'Visible','on');
    19181611                end
    19191612            end
    1920         case 'FieldMenu'   %hidden by default
     1613        case 'FieldName'   %hidden by default
    19211614            if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two')
    1922                 set(handles.FieldMenu,'Enable','on') % test for MenuBorser
     1615                set(handles.FieldName,'Enable','on') % test for MenuBorser
    19231616                if nb_series >=1 && ~testima_series
    19241617                    view_FieldMenu(handles,'on')
     
    19261619            end
    19271620            if isequal(lower(varargout{ilist+1}),'two')
    1928                 set(handles.FieldMenu_1,'Enable','on')
     1621                set(handles.FieldName_1,'Enable','on')
    19291622                if nb_series >=2 && ~testima_1
    19301623                    view_FieldMenu_1(handles,'on')
    19311624                end
    19321625            end
    1933         case 'CoordType'   %hidden by default
     1626        case 'FieldTransform'   %hidden by default
    19341627            if isequal(lower(varargout{ilist+1}),'on')
    1935                 set(handles.transform_fct,'Enable','on')
     1628                set(handles.TransformName,'Enable','on')
    19361629                set(handles.FieldTransform,'Visible','on')
    1937 %                 view_TRANSFORM(handles,'on')
    19381630            end
    1939         case 'GetObject'   %hidden by default
     1631        case 'ProjObject'   %hidden by default
    19401632            if isequal(lower(varargout{ilist+1}),'on')   
    1941                 set(handles.Objects,'Visible','on')
    1942 %                 set(handles.GetObject,'Visible','on');
     1633                set(handles.CheckObject,'Visible','on')
     1634                set(handles.ProjObject,'Visible','on')
    19431635            end
    19441636        case 'Mask'   %hidden by default
    19451637            if isequal(lower(varargout{ilist+1}),'on')   
    1946                 set(handles.Objects,'Visible','on')
    1947 %                 set(handles.GetMask,'Visible','on');
     1638                set(handles.Mask,'Visible','on')
     1639                 set(handles.CheckMask,'Visible','on');
    19481640            end
    1949         case 'PARAMETER' 
     1641        case 'PARAMETER'  % NOT USED
    19501642            set(handles.PARAMETERS_frame,'Visible','on')
    19511643            set(handles.PARAMETERS_title,'Visible','on')
     
    19531645            %set(handles.ParamVal,'Visible','on')
    19541646            Param_str=varargout{ilist+1};
    1955             Param_list=[Param_list; {Param_str}];         
     1647            Param_list=[Param_list; {Param_str}];   
     1648        case 'OutputDirExt'
     1649            if ~isempty(varargout{ilist+1})
     1650            set(handles.OutputDirExt,'String',varargout{ilist+1})
     1651            set(handles.OutputDirExt,'Visible','on')
     1652            set(handles.OutputSubDir,'Visible','on')
     1653            set(handles.OutputDir_title,'Visible','on') 
     1654            end
    19561655    end
    19571656end
     
    19621661
    19631662%------------------------------------------------------------------------
    1964 % --- Executes on selection change in FieldMenu.
    1965 function FieldMenu_Callback(hObject, eventdata, handles)
    1966 %------------------------------------------------------------------------
    1967 field_str=get(handles.FieldMenu,'String');
    1968 field_index=get(handles.FieldMenu,'Value');
     1663% --- Executes on selection change in FieldName.
     1664function FieldName_Callback(hObject, eventdata, handles)
     1665%------------------------------------------------------------------------
     1666field_str=get(handles.FieldName,'String');
     1667field_index=get(handles.FieldName,'Value');
    19691668field=field_str{field_index(1)};
    19701669if isequal(field,'get_field...')   
     
    19821681                'SelectionMode','single',...
    19831682                'ListString',str);
    1984        % edit the choice in the fields and action menu
     1683       % edit the choice in the fields and actionname menu
    19851684     scalar=cell2mat(str(ind_answer));
    1986      update_menu(handles.FieldMenu,scalar)
    1987 end
    1988 
    1989 %------------------------------------------------------------------------
    1990 % --- Executes on selection change in FieldMenu_1.
    1991 function FieldMenu_1_Callback(hObject, eventdata, handles)
    1992 %------------------------------------------------------------------------
    1993 field_str=get(handles.FieldMenu_1,'String');
    1994 field_index=get(handles.FieldMenu_1,'Value');
     1685     update_menu(handles.FieldName,scalar)
     1686end
     1687
     1688%------------------------------------------------------------------------
     1689% --- Executes on selection change in FieldName_1.
     1690function FieldName_1_Callback(hObject, eventdata, handles)
     1691%------------------------------------------------------------------------
     1692field_str=get(handles.FieldName_1,'String');
     1693field_index=get(handles.FieldName_1,'Value');
    19951694field=field_str{field_index};
    19961695if isequal(field,'get_field...')   
     
    20101709                'SelectionMode','single',...
    20111710                'ListString',str);
    2012        % edit the choice in the fields and action menu
     1711       % edit the choice in the fields and actionname menu
    20131712     scalar=cell2mat(str(ind_answer));
    2014      update_menu(handles.FieldMenu_1,scalar)
     1713     update_menu(handles.FieldName_1,scalar)
    20151714end   
    20161715
     
    20801779end
    20811780
    2082 
    2083 % set(handles.time_first,'Value',1)
    2084 % set(handles.time_last,'Value',1)
    2085 % set(handles.time_first,'String',time_first_cell);
    2086 % set(handles.time_last,'String',time_last_cell);
    2087 
    2088 %------------------------------------------------------------------------
    2089 % --- Executes on button press in GetObject.
    2090 function GetObject_Callback(hObject, eventdata, handles)
    2091 %------------------------------------------------------------------------
    2092 SeriesData=get(handles.series,'UserData');
    2093 value=get(handles.GetObject,'Value');
     1781%------------------------------------------------------------------------
     1782% --- Executes on button press in CheckObject.
     1783function CheckObject_Callback(hObject, eventdata, handles)
     1784%------------------------------------------------------------------------
     1785% SeriesData=get(handles.series,'UserData');
     1786value=get(handles.CheckObject,'Value');
    20941787if value
    2095      set(handles.GetObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
     1788     set(handles.CheckObject,'BackgroundColor',[1 1 0])%put unactivated buttons to yellow
    20961789     hset_object=findobj(allchild(0),'tag','set_object');%find the set_object interface handle
    20971790     if ishandle(hset_object)
     
    21141807        %read the file
    21151808        data=xml2struct(fileinput);
    2116 %         t=xmltree(fileinput);
    2117 %         data=convert(t);
    2118         if ~isfield(data,'Style')
    2119              data.Style='points';
     1809        if ~isfield(data,'Type')
     1810             msgbox_uvmat('ERROR',[fileinput ' is not an object xml file'])
     1811             return
    21201812        end
    21211813        if ~isfield(data,'ProjMode')
    2122              data.ProjMode='projection';
    2123         end
    2124 %         data.desable_plot=1;
    2125         [SeriesData.hset_object,SeriesData.sethandles]=set_object(data);% call the set_object interface
     1814             data.ProjMode='none';
     1815        end
     1816        hset_object=set_object(data);% call the set_object interface
    21261817     end
    2127 else
    2128     set(handles.GetObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
    2129 end
    2130 set(handles.series,'UserData',SeriesData)
     1818     Object=read_GUI(hset_object);
     1819     set(handles.ProjObject,'String',Object.Name);%display the object name
     1820else
     1821    set(handles.CheckObject,'BackgroundColor',[0.7 0.7 0.7])%put activated buttons to green
     1822end
     1823%set(handles.series,'UserData',SeriesData)
    21311824
    21321825%--------------------------------------------------------------
    2133 function GetMask_Callback(hObject, eventdata, handles)
    2134 value=get(handles.GetMask,'Value');
     1826function CheckMask_Callback(hObject, eventdata, handles)
     1827value=get(handles.CheckMask,'Value');
    21351828if value
    21361829    msgbox_uvmat('ERROR','not implemented yet')
     
    21621855
    21631856%-------------------------------------------------------------------
    2164 % --- Executes on selection change in transform_fct.
    2165 function transform_fct_Callback(hObject, eventdata, handles)
     1857% --- Executes on selection change in TransformName.
     1858function TransformName_Callback(hObject, eventdata, handles)
    21661859%-------------------------------------------------------------------
    21671860global nb_transform
    21681861
    2169 menu=get(handles.transform_fct,'String');
    2170 ind_coord=get(handles.transform_fct,'Value');
     1862menu=get(handles.TransformName,'String');
     1863ind_coord=get(handles.TransformName,'Value');
    21711864coord_option=menu{ind_coord};
    2172 list_transform=get(handles.transform_fct,'UserData');
     1865list_transform=get(handles.TransformName,'UserData');
    21731866ff=functions(list_transform{end});
    21741867if isequal(coord_option,'more...');
     
    21941887        return
    21951888    end
    2196    menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
    2197    ind_coord=get(handles.transform_fct,'Value');
     1889   menu=update_menu(handles.TransformName,transform);%add the selected fct to the menu
     1890   ind_coord=get(handles.TransformName,'Value');
    21981891   addpath(PathName)
    21991892   list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
    2200    set(handles.transform_fct,'UserData',list_transform)
     1893   set(handles.TransformName,'UserData',list_transform)
    22011894   rmpath(PathName)
    22021895   % save the new menu in the personal file 'uvmat_perso.mat'
     
    22121905end
    22131906
    2214 %check the current path to the selected function
     1907%check the current ActionPath to the selected function
    22151908if ~isempty(list_transform{ind_coord})
    22161909func=functions(list_transform{ind_coord});
    2217 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
    2218 else
    2219    set(handles.path_transform,'String',''); %show the path to the senlected function
    2220 end
    2221 
    2222 %------------------------------------------------------------------------
    2223 % --- Executes on button press in REFRESH_INDICES.
    2224     function REFRESH_INDICES_Callback(hObject, eventdata, handles)
    2225 %------------------------------------------------------------------------       
    2226 % hObject    handle to REFRESH_INDICES (see GCBO)
    2227 % eventdata  reserved - to be defined in a future version of MATLAB
    2228 % handles    structure with handles and user data (see GUIDATA)
    2229 set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
    2230 InputTable=get(handles.InputTable,'Data');
    2231 check_lines=get(handles.REFRESH_INDICES,'UserData');
    2232 
    2233 %% check the indices and FileTypes for each series (limited to the new ones to save time)
    2234 for ind_list=1:length(check_lines)
    2235     if  check_lines(ind_list)
    2236         InputLine=InputTable(ind_list,:);
    2237         detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
    2238         detect_idem=detect_idem(detect_idem>0);
    2239         if ~isempty (detect_idem)
    2240             InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
    2241             set(handles.InputTable,'Data',InputTable)
    2242         end
    2243         fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
    2244         %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
    2245         %update file series defined by the selected line
    2246         [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
    2247         if ~isempty(errormsg)
    2248                 msgbox_uvmat('ERROR',errormsg)
    2249                 return
    2250         end
    2251     end
    2252 end
    2253 set(handles.InputTable,'Data',InputTable)
    2254 SeriesData=get(handles.series,'UserData');
    2255 
    2256 state_j='off';
    2257 state_Pairs='off';
    2258 state_InputFields='off';
    2259 val=get(handles.ListView,'Value');
    2260 ListViewString={''};
    2261 if ~isempty(SeriesData)
    2262 %     ListViewString={};
    2263     for iview=1:size(InputTable,1)
    2264         if ~isempty(SeriesData.j1_series{iview})
    2265             state_j='on';
    2266         end
    2267         if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
    2268             state_Pairs='on';
    2269             ListViewString{iview}=num2str(iview);
    2270             if check_lines(iview)
    2271                 val=iview;%select the last pair if it is a new entry
    2272             end
    2273         end
    2274         if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata')
    2275             state_InputFields='on';
    2276         end
    2277     end
    2278 end
    2279 set(handles.ListView,'Value',val)
    2280 set(handles.ListView,'String',ListViewString)
    2281 if strcmp(state_Pairs,'on')
    2282     ListView_Callback(hObject,eventdata,handles)
    2283 end
    2284 set(handles.PairString,'Visible',state_Pairs)
    2285 enable_j(handles,state_j)
    2286 set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
    2287 set(handles.REFRESH_INDICES,'visible','off')
     1910set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function
     1911else
     1912   set(handles.TransformPath,'String',''); %show the path to the senlected function
     1913end
     1914
     1915% %------------------------------------------------------------------------
     1916% % --- Executes on button press in REFRESH_INDICES.
     1917%     function REFRESH_INDICES_Callback(hObject, eventdata, handles)
     1918% %------------------------------------------------------------------------       
     1919% % hObject    handle to REFRESH_INDICES (see GCBO)
     1920% % eventdata  reserved - to be defined in a future version of MATLAB
     1921% % handles    structure with handles and user data (see GUIDATA)
     1922% set(handles.REFRESH_INDICES,'BackgroundColor',[0.7 0.7 0.7])
     1923% InputTable=get(handles.InputTable,'Data');
     1924% check_lines=get(handles.REFRESH_INDICES,'UserData');
     1925%
     1926% %% check the indices and FileTypes for each series (limited to the new ones to save time)
     1927% for ind_list=1:length(check_lines)
     1928%     if  check_lines(ind_list)
     1929%         InputLine=InputTable(ind_list,:);
     1930%         detect_idem=strcmp('"',InputLine);% look for '" (repeat of previous data)
     1931%         detect_idem=detect_idem(detect_idem>0);
     1932%         if ~isempty (detect_idem)
     1933%             InputLine(detect_idem)=InputTable(ind_list-1,detect_idem);
     1934%             set(handles.InputTable,'Data',InputTable)
     1935%         end
     1936%         fileinput=fullfile_uvmat(InputLine{1},InputLine{2},InputLine{3},InputLine{5},InputLine{4},1,2,1,2);
     1937%         %fileinput=name_generator(fullfile(InputLine{1},InputLine{3}),1,1,InputLine{5},InputLine{4},1,2,2,InputLine{2})
     1938%         %update file series defined by the selected line
     1939%         [InputTable{ind_list,3},InputTable{(ind_list),4},errormsg]=update_indices(handles,fileinput,ind_list);
     1940%         if ~isempty(errormsg)
     1941%                 msgbox_uvmat('ERROR',errormsg)
     1942%                 return
     1943%         end
     1944%     end
     1945% end
     1946% set(handles.InputTable,'Data',InputTable)
     1947% SeriesData=get(handles.series,'UserData');
     1948%
     1949% state_j='off';
     1950% state_Pairs='off';
     1951% state_InputFields='off';
     1952% val=get(handles.ListView,'Value');
     1953% ListViewString={''};
     1954% if ~isempty(SeriesData)
     1955% %     ListViewString={};
     1956%     for iview=1:size(InputTable,1)
     1957%         if ~isempty(SeriesData.j1_series{iview})
     1958%             state_j='on';
     1959%         end
     1960%         if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
     1961%             state_Pairs='on';
     1962%             ListViewString{iview}=num2str(iview);
     1963%             if check_lines(iview)
     1964%                 val=iview;%select the last pair if it is a new entry
     1965%             end
     1966%         end
     1967%         if strcmp(SeriesData.FileType{iview},'civx')||strcmp(SeriesData.FileType{iview},'civdata')
     1968%             state_InputFields='on';
     1969%         end
     1970%     end
     1971% end
     1972% set(handles.ListView,'Value',val)
     1973% set(handles.ListView,'String',ListViewString)
     1974% if strcmp(state_Pairs,'on')
     1975%     ListView_Callback(hObject,eventdata,handles)
     1976% end
     1977% set(handles.PairString,'Visible',state_Pairs)
     1978% enable_j(handles,state_j)
     1979% set(handles.REFRESH_INDICES,'BackgroundColor',[1 0 0])
     1980% set(handles.REFRESH_INDICES,'visible','off')
    22881981
    22891982% -----------------------------------------------------------------------
     
    23602053
    23612054%% enable field and veltype menus
    2362 testfield=isequal(get(handles.FieldMenu,'enable'),'on');
    2363 testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
    2364 testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
    2365 testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
    2366 testtransform=isequal(get(handles.transform_fct,'Enable'),'on');
     2055testfield=isequal(get(handles.FieldName,'enable'),'on');
     2056testfield_1=isequal(get(handles.FieldName_1,'enable'),'on');
     2057testveltype=isequal(get(handles.VelType,'enable'),'on');
     2058testveltype_1=isequal(get(handles.VelType_1,'enable'),'on');
     2059testtransform=isequal(get(handles.TransformName,'Enable'),'on');
    23672060% testnc=0;
    23682061% testnc_1=0;
     
    23962089    case {'civx','civdata'}
    23972090    view_FieldMenu(handles,'on')
    2398     menustr=get(handles.FieldMenu,'String');
     2091    menustr=get(handles.FieldName,'String');
    23992092    if isequal(menustr,{'get_field...'})
    2400         set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    2401     end
    2402     set(handles.VelTypeMenu,'Visible','on')
     2093        set(handles.FieldName,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     2094    end
     2095    set(handles.VelType,'Visible','on')
    24032096    set(handles.FieldTransform,'Visible','on')
    24042097    %      view_TRANSFORM(handles,'on')
     
    24062099    %           view_FieldMenu_1(handles,'on')
    24072100    %     if testcivx_1
    2408     %         menustr=get(handles.FieldMenu_1,'String');
     2101    %         menustr=get(handles.FieldName_1,'String');
    24092102    %         if isequal(menustr,{'get_field...'})
    2410     %             set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
     2103    %             set(handles.FieldName_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
    24112104    %         end
    24122105    %     else
    2413     %         set(handles.FieldMenu_1,'Value',1)
    2414     %         set(handles.FieldMenu_1,'String',{'get_field...'})
    2415     %     set(handles.VelTypeMenu_1,'Visible','on')
     2106    %         set(handles.FieldName_1,'Value',1)
     2107    %         set(handles.FieldName_1,'String',{'get_field...'})
     2108    %     set(handles.VelType_1,'Visible','on')
    24162109    %     set(handles.VelType_text_1,'Visible','on');
    24172110    %     end
     
    24192112    case 'netcdf'
    24202113    view_FieldMenu(handles,'on')
    2421     set(handles.FieldMenu,'Value',1)
    2422     set(handles.FieldMenu,'String',{'get_field...'})
     2114    set(handles.FieldName,'Value',1)
     2115    set(handles.FieldName,'String',{'get_field...'})
    24232116    set(handles.FieldTransform,'Visible','off')
    24242117    %     view_TRANSFORM(handles,'off')
     
    24262119    view_FieldMenu(handles,'off')
    24272120    view_FieldMenu_1(handles,'off')
    2428     set(handles.VelTypeMenu,'Visible','off')
     2121    set(handles.VelType,'Visible','off')
    24292122    set(handles.VelType_text,'Visible','off');
    24302123end
     
    24812174
    24822175%% update time table
    2483 TimeTable=get(handles.TimeTable,'Data')
     2176TimeTable=get(handles.TimeTable,'Data');
    24842177TimeTable{iview,1}=time(MinIndex_i,MinIndex_j);
    24852178TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j);
     
    25152208
    25162209
    2517 
    2518 % --- Executes on button press in BATCH.
    2519 function BATCH_Callback(hObject, eventdata, handles)
    2520 % hObject    handle to BATCH (see GCBO)
    2521 % eventdata  reserved - to be defined in a future version of MATLAB
    2522 % handles    structure with handles and user data (see GUIDATA)
    2523 Series=read_GUI(handles.series);
    2524 t=struct2xml(Series);
    2525 save(t); %TODO: determine a xml file name
    2526 
    2527 % list_action=get(handles.ACTION,'String');% list menu action
    2528 % index_action=get(handles.ACTION,'Value');% selected string index
    2529 % action= list_action{index_action}; % selected string
    2530 
    2531 %% defining the ACTION function handle
    2532 path_series=which('series');
    2533 list_path=get(handles.ACTION,'UserData');
    2534 index=get(handles.ACTION,'Value');
    2535 fct_path=list_path{index}; %path stored for the function ACTION
    2536 if ~isequal(fct_path,path_series)
    2537     eval(['spath=which(''' action ''');']) %spath = current path of the selected function ACTION
    2538     if ~exist(fct_path,'dir')
    2539         msgbox_uvmat('ERROR',['The prescibed function path ' fct_path ' does not exist'])
    2540         return
    2541     end
    2542     if ~isequal(spath,fct_path)
    2543         addpath(fct_path)% add the prescribed path if not the current one
    2544     end
    2545 end
    2546 eval(['h_fun=@' action ';'])%create a function handle for ACTION
    2547 if ~isequal(fct_path,path_series)
    2548         rmpath(fct_path)% add the prescribed path if not the current one   
    2549 end
    2550 
    2551 h_fun('BATCH');% TODO modify the called function to read the xml file as input parameter
     2210% --------------------------------------------------------------------
     2211function MenuExportConfig_Callback(hObject, eventdata, handles)
     2212global Series
     2213[tild,Series,errormsg]=prepare_jobs(handles);
     2214% Series=read_GUI(handles.series);
     2215
     2216evalin('base','global Series')%make CurData global in the workspace
     2217display('current series config :')
     2218evalin('base','Series') %display CurData in the workspace
     2219commandwindow; %brings the Matlab command window to the front
  • trunk/src/uvmat.m

    r445 r446  
    22902290    end
    22912291    siz=size(UvData.XmlData{1}.Time);
    2292     if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
     2292    if ~isempty(num_i1)&& ~isempty(num_i2)&&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
    22932293        abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files
    22942294        dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1));
Note: See TracChangeset for help on using the changeset viewer.