Changeset 635


Ignore:
Timestamp:
May 19, 2013, 11:37:49 PM (8 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r610 r635  
    250250    else
    251251        i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);
    252         i1_series=[i1_series(:,1) i1_series];
    253         j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames);
     252        i1_series=[zeros(size(i1_series,1),1) i1_series];
     253        j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames);
     254        j1_series=[zeros(size(i1_series,1),1) j1_series];
    254255        %  include the first index in the root name
    255256        r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
  • trunk/src/get_file_series.m

    r599 r635  
    2020incr_i=Param.IndexRange.incr_i;
    2121last_i=Param.IndexRange.last_i;
    22 ref_i=first_i:incr_i:last_i;
    23 ref_j=[];
     22% ref_i=first_i:incr_i:last_i;
     23%ref_j=[];
     24first_j=[];last_j=[];incr_j=1;%default
    2425if isfield(Param.IndexRange,'first_j')
    2526    first_j=Param.IndexRange.first_j;
    2627    incr_j=Param.IndexRange.incr_j;
    2728    last_j=Param.IndexRange.last_j;
    28     ref_j=first_j:incr_j:last_j;
    2929end
    3030
    3131%% determine the list of input file names
    3232nbmissing=0;
    33 
    34 for iview=1:size(InputTable,1)
     33NbView=size(InputTable,1);
     34i1_series=cell(NbView,1);% initiate index series with empty cells
     35i2_series=cell(NbView,1);
     36j1_series=cell(NbView,1);
     37j2_series=cell(NbView,1);
     38for iview=1:NbView
    3539    r.mode='';
    3640    if isfield (Param.IndexRange,'PairString')
     
    3842            Param.IndexRange.PairString={Param.IndexRange.PairString};
    3943        end
    40         r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
     44        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di
    4145        if isempty(r)
    42             r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
     46            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs
    4347        end
    4448        % TODO case of free pairs:
     
    5155            r(1).mode='*-*';
    5256        else
    53         r(1).mode='';
     57            r(1).mode='';
    5458        end
    5559    end
    56     if isequal(r(1).mode,'*-*')% free pairs
     60   
     61    if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')% free pairs
    5762        FilePath=fullfile(InputTable{iview,1},InputTable{iview,2});
    5863        fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}];
    59         [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);
    60         i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %first  pair index
    61         check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i;
    62         i1_series{iview}=i1_series{iview}(check_select);   
    63         i2_series{iview}=[]; %first  pair index
     64        [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,...
     65            i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);
     66        i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first  pair index as ordered by find_file_series
    6467        j1_series{iview}=squeeze(j1_series{iview}(1,:,:)); %first  pair index
    65         j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %first  pair index
    66         j1_series{iview}=j1_series{iview}(check_select);
    67         j2_series{iview}=j2_series{iview}(check_select);
     68        j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %second  pair index
     69        %check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i;
     70        if isempty(incr_i)
     71            if isempty(incr_j)
     72                [ref_j,ref_i]=find(i1_series{iview});
     73                ref_i=ref_i-1;
     74                ref_j=ref_j-1;
     75                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     76                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
     77            else
     78                ref_j=first_j:incr_j:last_j;
     79                [tild,ref_i]=find(i1_series{iview}(:,ref_j));
     80                ref_i=ref_i-1;
     81                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     82            end
     83        else
     84            ref_i=first_i:incr_i:last_i;%default
     85            if isempty(incr_j)
     86                [ref_j,tild]=find(i1_series{iview});
     87                ref_j=ref_j-1;
     88                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
     89            else
     90                ref_j=first_j:incr_j:last_j;
     91            end
     92        end
     93        i1_series{iview}=i1_series{iview}(ref_j,ref_i);
     94        j1_series{iview}=j1_series{iview}(ref_j,ref_i);
     95        if ~isempty(j2_series{iview})
     96        j2_series{iview}=j2_series{iview}(ref_j,ref_i);
     97        end
    6898    else
     99        ref_i=first_i:incr_i:last_i;%default
     100        ref_j=first_j:incr_j:last_j;%default
     101    end
     102    if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index
    69103        [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);
    70104    end
    71        
     105   
    72106    %case of pairs (.nc files)
    73107    i2=[];j1=[];j2=[];
     
    83117            j2=j2_series{iview}(ifile);
    84118        end
    85          filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2);
     119        filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2);
    86120    end
    87121end
  • trunk/src/read_field.m

    r595 r635  
    3434ParamOut=ParamIn;%default
    3535errormsg='';
     36if ~exist(FileName,'file')
     37    erromsg=['input file ' FileName ' does not exist'];
     38    return
     39end
    3640A=[];
    3741InputField={};
  • trunk/src/series.m

    r630 r635  
    524524    InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    525525    set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}])
    526     set(handles.MinIndex_i,'Data',[{[]}])
    527     set(handles.MaxIndex_i,'Data',[{[]}])
    528     set(handles.MinIndex_j,'Data',[{[]}])
    529     set(handles.MaxIndex_j,'Data',[{[]}])
     526    set(handles.MinIndex_i,'Data',[])
     527    set(handles.MaxIndex_i,'Data',[])
     528    set(handles.MinIndex_j,'Data',[])
     529    set(handles.MaxIndex_j,'Data',[])
    530530    set(handles.ListView,'Value',1)
    531531    set(handles.ListView,'String',{'1'})
     
    606606    MinIndex_j=1;% index j set to 1 by default
    607607    MaxIndex_j=1;
    608     MinIndex_i=find(i1_series(:,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
    609     MaxIndex_i=find(i1_series(:,2,:), 1, 'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
     608    MinIndex_i=find(i1_series(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
     609    MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series)
    610610else
    611     pair_max=squeeze(max(i1_series,[],1)); %max on pair index
    612     j_max=max(pair_max,[],1);
    613     MinIndex_i=find(j_max, 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
    614     MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
    615     diff_i_max=diff(j_max);
     611    ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i
     612    ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j
     613%     [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)));
     614%     [ref_j,ref_i]=find(squeeze(i1_series(1,:,:)))
     615     MinIndex_i=min(find(ref_i))-1;
     616     MaxIndex_i=max(find(ref_i))-1;
     617%         MinIndex_j=min(ref_j)-1;
     618     MaxIndex_j=max(find(ref_j))-1;
     619%     MinIndex_j=min(find(j1_series_j))-1;
     620%     MaxIndex_j=max(find(j1_series_j))-1;
     621%     MaxIndex_i=max(i1_series_i)-1;
     622%     MinIndex_j=min(i1_series_j)-1;
     623%     MaxIndex_j=max(i1_series_j)-1;
     624%     MaxIndex_i=max(ref_i)-1;
     625     MinIndex_j=min(find(ref_j))-1;
     626%     MaxIndex_j=max(ref_j)-1;
     627    diff_j_max=diff(ref_j);
     628    diff_i_max=diff(ref_i);
     629   
     630%     pair_max=squeeze(max(i1_series,[],1)); %max on pair index
     631%     j_max=max(pair_max,[],1);
     632%     MinIndex_i=find(j_max, 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
     633%     MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)
     634%     diff_i_max=diff(j_max);
    616635    if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
    617636        set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
    618637    end
    619     i_max=max(pair_max,[],2);
    620     MinIndex_j=min(find(i_max))-1;% min ref index j
    621     MaxIndex_j=max(find(i_max))-1;% max ref index j
    622     diff_j_max=diff(i_max);
     638%     i_max=max(pair_max,[],2);
     639%     MinIndex_j=min(find(i_max))-1;% min ref index j
     640%     MaxIndex_j=max(find(i_max))-1;% max ref index j
     641%     diff_j_max=diff(i_max);
    623642    if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max)))
    624643        set(handles.num_incr_j,'String',num2str(diff_j_max(1)))
     
    635654MaxIndex_i_cell=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex
    636655MaxIndex_j_cell=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex
    637 MinIndex_i_cell{iview,1}=MinIndex_i;
    638 MinIndex_j_cell{iview,1}=MinIndex_j;
    639 MaxIndex_i_cell{iview,1}=MaxIndex_i;
    640 MaxIndex_j_cell{iview,1}=MaxIndex_j;
     656MinIndex_i_cell(iview,1)=MinIndex_i;
     657MinIndex_j_cell(iview,1)=MinIndex_j;
     658MaxIndex_i_cell(iview,1)=MaxIndex_i;
     659MaxIndex_j_cell(iview,1)=MaxIndex_j;
    641660set(handles.MinIndex_i,'Data',MinIndex_i_cell)%display the min indices in the table MinIndex
    642661set(handles.MinIndex_j,'Data',MinIndex_j_cell)%display the max indices in the table MaxIndex
     
    13211340%------------------------------------------------------------------------
    13221341% --- Executes on button press in RUN.
     1342%------------------------------------------------------------------------
    13231343function RUN_Callback(hObject, eventdata, handles)
    1324 %------------------------------------------------------------------------
    1325 
    1326 set(handles.RUN,'BusyAction','queue');
    1327 set(0,'CurrentFigure',handles.series)
    1328 set(handles.RUN, 'Enable','Off')
    1329 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
     1344
     1345%% settings of the button RUN
     1346set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel'
     1347%set(0,'CurrentFigure',handles.series); % display the GUI series
     1348set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished
     1349set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color
    13301350drawnow
    13311351
    1332 %% read the input parameters and set the output dir and nomenclature
    1333 [Series,OutputDir,errormsg]=prepare_jobs(handles);% get parameters form the GUI series
    1334 if ~isempty(errormsg)
    1335     if ~strcmp(errormsg,'Cancel')
    1336     msgbox_uvmat('ERROR',errormsg)
    1337     end
    1338     STOP_Callback([],[], handles)
    1339     return
    1340 end
    1341 OutputNomType=nomtype2pair(Series.InputTable{1,4});% nomenclature for output files
    1342 DirXml=fullfile(OutputDir,'0_XML');
    1343 if ~exist(DirXml,'dir')
    1344     [tild,msg1]=mkdir(DirXml);
    1345     if ~strcmp(msg1,'')
    1346         msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation
    1347         return
    1348     end
    1349 end
    1350 
    1351 %% select the Action modes
    1352 RunMode='local';%default
    1353 if isfield(Series.Action,'RunMode')
    1354 RunMode=Series.Action.RunMode;
     1352%% read the data on the GUI series
     1353Param=read_GUI_series(handles);%displayed parameters
     1354SeriesData=get(handles.series,'UserData');%hidden parameters
     1355
     1356%% create the output data directory if needed
     1357if isfield(Param,'OutputSubDir')
     1358    SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
     1359    SubDirOutNew=SubDirOut;
     1360    detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exist
     1361    check_create=1; %need to create the result directory by default
     1362    while detect
     1363        answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']);
     1364        if strcmp(answer,'Cancel')
     1365            errormsg='Cancel';
     1366            return
     1367        elseif strcmp(answer,'Yes')
     1368            detect=0;
     1369            check_create=0;
     1370        else
     1371            r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
     1372            if isempty(r)
     1373                r(1).root=[SubDirOutNew '_'];
     1374                r(1).num1='0';
     1375            end
     1376            SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
     1377            detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exists
     1378            check_create=1;
     1379        end
     1380    end
     1381    Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,'');
     1382    Param.OutputRootFile=Param.InputTable{1,3};% the first sorted RootFile taken for output
     1383    set(handles.OutputDirExt,'String',Param.OutputDirExt)
     1384    OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);% full name (with path) of output directory
     1385    if check_create    % create output directory if it does not exist
     1386        [tild,msg1]=mkdir(OutputDir);
     1387        if ~strcmp(msg1,'')
     1388            errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation
     1389            return
     1390        end
     1391    end
     1392    OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files
     1393    DirXml=fullfile(OutputDir,'0_XML');
     1394    if ~exist(DirXml,'dir')
     1395        [tild,msg1]=mkdir(DirXml);
     1396        if ~strcmp(msg1,'')
     1397            msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation
     1398            return
     1399        end
     1400    end
     1401end
     1402
     1403%% select the Action mode, 'local', 'background' or 'cluster' (if available)
     1404RunMode='local';%default (needed for first opening of the GUI series)
     1405if isfield(Param.Action,'RunMode')
     1406    RunMode=Param.Action.RunMode;
    13551407end
    13561408ActionExt='.m';%default
    1357 if isfield(Series.Action,'ActionExt')
    1358     ActionExt=Series.Action.ActionExt;% '.m' or '.sh' (compiled)
    1359 end
    1360 ActionName=Series.Action.ActionName;
    1361 ActionPath=Series.Action.ActionPath;
     1409if isfield(Param.Action,'ActionExt')
     1410    ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled)
     1411end
     1412ActionName=Param.Action.ActionName;
     1413ActionPath=Param.Action.ActionPath;
    13621414path_series=fileparts(which('series'));
    13631415
     
    14111463        return
    14121464    end
    1413 %     Series.RunTime=RunTime;
    14141465end
    14151466
     
    14191470        NbCore=1;% no need to split the calculation
    14201471    case 'cluster_oar'
    1421         if strcmp(Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
     1472        if strcmp(Param.Action.ActionExt,'.m')% case of Matlab function (uncompiled)
    14221473            NbCore=1;% one core used only (limitation of Matlab licences)
    14231474            msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');
     
    14291480        end
    14301481end
    1431 if ~isfield(Series.IndexRange,'NbSlice')
    1432     Series.IndexRange.NbSlice=[];
    1433 end
    1434 if isempty(Series.IndexRange.NbSlice)
     1482if ~isfield(Param.IndexRange,'NbSlice')
     1483    Param.IndexRange.NbSlice=[];
     1484end
     1485if isempty(Param.IndexRange.NbSlice)
    14351486    NbProcess=NbCore;% choose one process per core
    14361487else
    1437     NbProcess=Series.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices
     1488    NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices
    14381489    NbCore=min(NbCore,NbProcess);% at least one process per core
    14391490end
    14401491       
    1441 
    1442 %% read index ranges
    1443 [first_i,incr_i,last_i,first_j,incr_j,last_j,errormsg]=get_index_range(Series.IndexRange);
    1444 if ~isempty(errormsg)
    1445     msgbox_uvmat('ERROR',['series/Run_Callback/get_index_range' errormsg])
     1492%% get the set of reference field indices
     1493first_i=1;
     1494last_i=1;
     1495incr_i=1;
     1496first_j=1;
     1497last_j=1;
     1498incr_j=1;
     1499if isfield(Param.IndexRange,'first_i')
     1500    first_i=Param.IndexRange.first_i;
     1501    incr_i=Param.IndexRange.incr_i;
     1502    last_i=Param.IndexRange.last_i;
     1503end
     1504if isfield(Param.IndexRange,'first_j')
     1505    first_j=Param.IndexRange.first_j;
     1506    last_j=Param.IndexRange.last_j;
     1507    incr_j=Param.IndexRange.incr_j;
     1508end
     1509if last_i < first_i || last_j < first_j
     1510    msgbox_uvmat('ERROR', 'series/Run_Callback:last field index must be larger or equal to the first one')
    14461511    set(handles.RUN, 'Enable','On'),
    14471512    set(handles.RUN,'BackgroundColor',[1 0 0])
    14481513    return
     1514end
     1515%incr_i must be defined, =1 by default, if NbSlice is active
     1516if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice)
     1517    incr_i=1;
     1518    set(handles.num_incr_i,'String','1')
     1519end
     1520if isempty(incr_i)
     1521    if isempty(incr_j)
     1522        [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
     1523        ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
     1524        ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     1525        ref_j=ref_j-1;
     1526        ref_i=ref_i-1;
     1527    else
     1528        ref_j=first_j:incr_j:last_j;
     1529        [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
     1530        ref_i=ref_i-1;
     1531        ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
     1532    end
    14491533else
    1450     BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess);
    1451 end
    1452 nbfield_j=numel(first_j:incr_j:last_j);
     1534    ref_i=first_i:incr_i:last_i;
     1535    if isempty(incr_j)
     1536    [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:)));
     1537    ref_j=ref_j-1;
     1538    ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
     1539    else
     1540        ref_j=first_j:incr_j:last_j;
     1541    end
     1542end
     1543BlockLength=ceil(numel(ref_i)/NbProcess);
     1544nbfield_j=numel(ref_j);
    14531545
    14541546%% record nbre of output files and starting time for computation for status
     
    14571549    switch StatusData.OutputFileMode
    14581550        case 'NbInput'
    1459             StatusData.NbOutputFile=numel(first_i:incr_i:last_i)*numel(first_j:incr_j:last_j);
     1551            StatusData.NbOutputFile=numel(ref_i)*nbfield_j;
    14601552        case 'NbInput_i'
    1461             StatusData.NbOutputFile=numel(first_i:incr_i:last_i);
     1553            StatusData.NbOutputFile=numel(ref_i);
    14621554        case 'NbSlice'   
    14631555            StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
     
    14691561%% direct processing on the current Matlab session
    14701562if strcmp (RunMode,'local')
    1471 %     Series.RUNHandle=handles.RUN;
    1472 %     Series.WaitbarHandle=handles.Waitbar;
    14731563    for iprocess=1:NbProcess
    1474         if isempty(Series.IndexRange.NbSlice)
    1475             Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
    1476             if Series.IndexRange.first_i>last_i
     1564        if isempty(Param.IndexRange.NbSlice)
     1565            %Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
     1566            Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength);
     1567            if Param.IndexRange.first_i>last_i
    14771568                break
    14781569            end
    1479             Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i);
    1480         else
    1481             Series.IndexRange.first_i= first_i+incr_i*(iprocess-1);
    1482             Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;
    1483         end
    1484         t=struct2xml(Series);
     1570            Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i);
     1571            %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i);
     1572        else %multislices (then incr_i is not empty)
     1573             Param.IndexRange.first_i= first_i+incr_i*(iprocess-1);
     1574             Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
     1575        end
     1576        if isfield(Param,'OutputSubDir')
     1577        t=struct2xml(Param);
    14851578        t=set(t,1,'name','Series');
    1486         filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,...
    1487             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1579        filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...
     1580            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
    14881581        save(t,filexml);
     1582        end
    14891583        switch ActionExt
    14901584            case '.m'
    1491                 h_fun(Series);
     1585                h_fun(Param);
    14921586            case '.sh'
    14931587                switch computer
     
    15061600    %% processing on a different session of the same computer (background) or cluster, create executable files
    15071601    batch_file_list=cell(NbProcess,1);% initiate the list of executable files
    1508     DirBat=fullfile(OutputDir,'0_BAT');
     1602    DirBat=fullfile(OutputDir,'0_EXE');
     1603    switch computer
     1604        case {'PCWIN','PCWIN64'} %Windows system
     1605            ExeExt='.bat';
     1606        case {'GLNX86','GLNXA64','MACI64'}%Linux  system
     1607           ExeExt='.sh';
     1608    end
    15091609    %create subdirectory for executable files
    15101610    if ~exist(DirBat,'dir')
     
    15251625    end
    15261626    for iprocess=1:NbProcess
    1527         if isempty(Series.IndexRange.NbSlice)% process by blocks of i index
    1528             Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
    1529             if Series.IndexRange.first_i>last_i
     1627        if isempty(Param.IndexRange.NbSlice)% process by blocks of i index
     1628            Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;
     1629            if Param.IndexRange.first_i>last_i
    15301630                NbProcess=iprocess-1;
    15311631                break% leave the loop, we are at the end of the calculation
    15321632            end
    1533             Series.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
     1633            Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);
    15341634        else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1
    1535             Series.IndexRange.first_i= first_i+iprocess-1;
    1536             Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;
     1635            Param.IndexRange.first_i= first_i+iprocess-1;
     1636            Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice;
    15371637        end
    15381638       
    15391639        % create, fill and save the xml parameter file
    1540         t=struct2xml(Series);
     1640        t=struct2xml(Param);
    15411641        t=set(t,1,'name','Series');
    1542         filexml=fullfile_uvmat(DirXml,'',Series.InputTable{1,3},'.xml',OutputNomType,...
    1543             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1642        filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,...
     1643            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
    15441644        save(t,filexml);% save the parameter file
    15451645       
    15461646        %create the executable file
    1547 %         filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.bat',OutputNomType,...
    1548 %             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
    1549          filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.sh',OutputNomType,...
    1550            Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1647         filebat=fullfile_uvmat(DirBat,'',Param.InputTable{1,3},ExeExt,OutputNomType,...
     1648           Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
    15511649        batch_file_list{iprocess}=filebat;
    15521650        [fid,message]=fopen(filebat,'w');% create the executable file
     
    15571655       
    15581656        % set the log file name
    1559         filelog=fullfile_uvmat(DirLog,'',Series.InputTable{1,3},'.log',OutputNomType,...
    1560             Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);
     1657        filelog=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,...
     1658            Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j);
    15611659       
    15621660        % fill and save the executable file
     
    15701668                            'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
    15711669                            'addpath(''' path_series '''); \n'...
    1572                             'addpath(''' Series.Action.ActionPath '''); \n'...
    1573                             '' Series.Action.ActionName  '( ''' filexml '''); \n'...
     1670                            'addpath(''' Param.Action.ActionPath '''); \n'...
     1671                            '' Param.Action.ActionName  '( ''' filexml '''); \n'...
    15741672                            'exit \n'...
    15751673                            'END_MATLAB \n'];
     
    15801678                        text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')...
    15811679                            ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
    1582                             'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'...
    1583                             '' Series.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
     1680                            'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'...
     1681                            '' Param.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
    15841682                        fprintf(fid,text_matlabscript);%fill the executable file with the  char string cmd
    15851683                        fclose(fid);% close the executable file
     
    16001698                        %                                 cmd=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')...
    16011699                        %                                     ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'...
    1602                         %                                     'addpath(''' regexprep(Series.Action.ActionPath,'\\','\\\\') ''');'...
    1603                         %                                     '' Series.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
     1700                        %                                     'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'...
     1701                        %                                     '' Param.Action.ActionName  '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];
    16041702                        fprintf(fid,cmd);
    16051703                        fclose(fid);
     
    16801778% --- Main launch command, called by RUN and BATCH
    16811779
    1682 function [Series,OutputDir,errormsg]=prepare_jobs(handles)
    1683 %INPUT:
    1684 % handles: handles of graphic objects on the GUI series
    1685 
    1686 %------------------------------------------------------------------------
    1687 OutputDir='';
    1688 errormsg='';
    1689 
    1690 %% Read parameters from series
    1691 Series=read_GUI(handles.series);
    1692 
    1693 %% get_field GUI
    1694 % if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field')
    1695 %     if strcmp(Series.InputFields.Field,'get_field...')
    1696 %         hget_field=findobj(allchild(0),'name','get_field');
    1697 %         Series.GetField=read_GUI(hget_field);
    1698 %     end
    1699 % end
    1700 
    1701 %% create the output data directory
    1702 %determine the root file corresponding to the first sub dir
    1703 if get(handles.RUN,'value') && isfield(Series,'OutputSubDir')
    1704     SubDirOut=[get(handles.OutputSubDir,'String') Series.OutputDirExt];
    1705     SubDirOutNew=SubDirOut;
    1706     SeriesData=get(handles.series,'UserData');
    1707 %     if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort
    1708 %         [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order
    1709 %         Series.InputTable=Series.InputTable(iview,:);
    1710 %     end
    1711     detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exist
    1712     check_create=1; %need to create the result directory by default
    1713     while detect
    1714         answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']);
    1715         if strcmp(answer,'Cancel')
    1716             errormsg='Cancel';
    1717             return
    1718         elseif strcmp(answer,'Yes')
    1719             detect=0;
    1720             check_create=0;
    1721         else
    1722             r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
    1723             if isempty(r)
    1724                 r(1).root=[SubDirOutNew '_'];
    1725                 r(1).num1='0';
    1726             end
    1727             SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
    1728             detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if  the dir  already exists   
    1729             check_create=1;
    1730         end
    1731     end
    1732     Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,'');
    1733     Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output
    1734     set(handles.OutputDirExt,'String',Series.OutputDirExt)
    1735     OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);% full name (with path) of output directory
    1736     if check_create    % create output directory if it does not exist
    1737         [tild,msg1]=mkdir(OutputDir);
    1738         if ~strcmp(msg1,'')
    1739             errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation
    1740             return
    1741         end
    1742     end
    1743    % RootOut=fullfile(OutputDir,Series.InputTable{1,3});% name of the parameter xml file set in this directory
    1744 end
    1745 
    1746 %% removes unused information on Series
    1747 if isfield(Series,'Pairs')
    1748     Series=rmfield(Series,'Pairs'); %info Pairs not needed for output
    1749 end
    1750 Series.IndexRange=rmfield(Series.IndexRange,'TimeTable');
    1751 % Series.IndexRange=rmfield(Series.IndexRange,'MinIndex_j');
    1752 % Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex_i');
    1753 empty_line=false(size(Series.InputTable,1),1);
    1754 for iline=1:size(Series.InputTable,1)
    1755     empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''});
    1756 end
    1757 Series.InputTable(empty_line,:)=[];
     1780%------------------------------------------------------------------------
     1781% --- read parameters from the GUI series
     1782%------------------------------------------------------------------------
     1783function Param=read_GUI_series(handles)
     1784
     1785%% read raw parameters from the GUI series
     1786Param=read_GUI(handles.series);
     1787
     1788%% clean the output structure by removing unused information
     1789if isfield(Param,'Pairs')
     1790    Param=rmfield(Param,'Pairs'); %info Pairs not needed for output
     1791end
     1792Param.IndexRange=rmfield(Param.IndexRange,'TimeTable');
     1793empty_line=false(size(Param.InputTable,1),1);
     1794for iline=1:size(Param.InputTable,1)
     1795    empty_line(iline)=isequal(Param.InputTable(iline,1:3),{'','',''});
     1796end
     1797Param.InputTable(empty_line,:)=[];
    17581798
    17591799%------------------------------------------------------------------------
     
    18821922
    18831923%% Activate the Action fct
    1884 [Series,tild,errormsg]=prepare_jobs(handles);% read the parameters from the GUI series
    1885 if ~isempty(errormsg)
    1886     if ~strcmp(errormsg,'Cancel')
    1887     msgbox_uvmat('ERROR',errormsg)
    1888     end
    1889     return
    1890 end
    1891 ParamOut=h_fun(Series);
     1924Param=read_GUI_series(handles);% read the parameters from the GUI series
     1925ParamOut=h_fun(Param);
    18921926
    18931927%% Put the first line of the selected Action fct as tooltip help
     
    19181952
    19191953%% Check whether alphabetical sorting of input Subdir is alowed by the Action fct  (for multiples series entries)
    1920 if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Series.InputTable,1)>1
     1954if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1
    19211955    [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order
    19221956    set(handles.InputTable,'Data',InputTable(iview,:));
     
    19411975    MaxIndex_i=get(handles.MaxIndex_i,'Data');
    19421976    MaxIndex_j=get(handles.MaxIndex_j,'Data');
    1943     set(handles.num_first_i,'String',num2str(MinIndex_i{1}))% set first as the min index (for the first line)
    1944     set(handles.num_last_i,'String',num2str(MaxIndex_i{1}))% set last as the max index (for the first line)
     1977    set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line)
     1978    set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line)
    19451979    set(handles.num_incr_i,'String','1')
    1946     set(handles.num_first_j,'String',num2str(MinIndex_j{1}))% set first as the min index (for the first line)
    1947     set(handles.num_last_j,'String',num2str(MaxIndex_j{1}))% set last as the max index (for the first line)
     1980    set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line)
     1981    set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line)
    19481982    set(handles.num_incr_j,'String','1')
    19491983else  % check index ranges
    19501984    first_i=1;last_i=1;first_j=1;last_j=1;
    1951     if isfield(Series.IndexRange,'first_i')
    1952         first_i=Series.IndexRange.first_i;
    1953        % incr_i=Series.IndexRange.incr_i;
    1954         last_i=Series.IndexRange.last_i;
    1955     end
    1956     if isfield(Series.IndexRange,'first_j')
    1957         first_j=Series.IndexRange.first_j;
    1958        % incr_j=Series.IndexRange.incr_j;
    1959         last_j=Series.IndexRange.last_j;
     1985    if isfield(Param.IndexRange,'first_i')
     1986        first_i=Param.IndexRange.first_i;
     1987       % incr_i=Param.IndexRange.incr_i;
     1988        last_i=Param.IndexRange.last_i;
     1989    end
     1990    if isfield(Param.IndexRange,'first_j')
     1991        first_j=Param.IndexRange.first_j;
     1992       % incr_j=Param.IndexRange.incr_j;
     1993        last_j=Param.IndexRange.last_j;
    19601994    end
    19611995    if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
     
    21202154        delete(hget_field)%delete opened versions of get_field
    21212155    end
    2122     Series=read_GUI(handles.series);
    2123     Series.InputTable=Series.InputTable(1,:);
    2124     filecell=get_file_series(Series);
     2156    Param=read_GUI(handles.series);
     2157    Param.InputTable=Param.InputTable(1,:);
     2158    filecell=get_file_series(Param);
    21252159    if exist(filecell{1,1},'file')
    21262160        GetFieldData=get_field(filecell{1,1});
     
    24312465    if isempty(TransformIndex)%the input string does not exist in the menu
    24322466        TransformIndex= length(TransformList);
    2433         TransformList=[TransformList(1:end-1);{TransformnName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...'
     2467        TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...'
    24342468        set(handles.TransformName,'String',TransformList)
    24352469        TransformPathList=[TransformPathList;{TransformPath}];
     
    24512485set(handles.TransformName,'UserData',TransformPathList);
    24522486
    2453 
    2454 % --------------------------------------------------------------------
     2487%------------------------------------------------------------------------
     2488% --- fct activated by the upper bar menu ExportConfig
     2489%------------------------------------------------------------------------
    24552490function MenuExportConfig_Callback(hObject, eventdata, handles)
    2456 global Series
    2457 [Series,errormsg]=prepare_jobs(handles);
    2458 
    2459 evalin('base','global Series')%make CurData global in the workspace
     2491
     2492global Param
     2493Param=read_GUI_series(handles);
     2494evalin('base','global Param')%make CurData global in the workspace
    24602495display('current series config :')
    2461 evalin('base','Series') %display CurData in the workspace
     2496evalin('base','Param') %display CurData in the workspace
    24622497commandwindow; %brings the Matlab command window to the front
    24632498
    2464 % --------------------------------------------------------------------
     2499%------------------------------------------------------------------------
     2500% --- fct activated by the upper bar menu InportConfig
     2501%------------------------------------------------------------------------
    24652502function MenuImportConfig_Callback(hObject, eventdata, handles)
    2466 % --------------------------------------------------------------------
     2503
    24672504InputTable=get(handles.InputTable,'Data');
    24682505[FileName, PathName] = uigetfile( ...
     
    24762513fill_GUI(Param,handles.series)
    24772514
    2478 % --- Executes on selection change in RunMode.
    2479 function RunMode_Callback(hObject, eventdata, handles)
    2480 
    2481 % --- Executes on selection change in Coord_x.
    2482 function Coord_x_Callback(hObject, eventdata, handles)
    2483 
    2484 % --- Executes on selection change in Coord_y.
    2485 function Coord_y_Callback(hObject, eventdata, handles)
    2486 
    2487 % --------------------------------------------------------------------
    2488 % --- Executes when series is resized.
     2515%------------------------------------------------------------------------
     2516% --- Executes when the GUI series is resized.
     2517%------------------------------------------------------------------------
    24892518function series_ResizeFcn(hObject, eventdata, handles)
    2490 % --------------------------------------------------------------------
     2519
    24912520%% input table
    24922521set(handles.InputTable,'Unit','pixel')
     
    26702699    set(hwaitbar,'Position',BarPosition)
    26712700end
    2672 %TODO: adjust waitbar
    2673 
    2674 % civ_files=get(hfig,'UserData');
    2675 
    2676 % [filepath,filename,ext]=fileparts(civ_files{1});
    2677 % [tild,SubDir,extdir]=fileparts(filepath);
    2678 % SubDir=[SubDir extdir];
    2679 % option_civ=StatusData.option_civ;
    2680 % nbfiles=numel(civ_files);
    2681 % testrecent=0;
    2682 % count=0;
    2683 % datnum=zeros(1,nbfiles);
    2684 % filefound=cell(1,nbfiles);
    2685 % for ifile=1:nbfiles
    2686 %     detect=exist(civ_files{ifile},'file'); % check the existence of the file
    2687 %     option=0;
    2688 %     if detect==0
    2689 %         option_str='not created';
    2690 %     else
    2691 %         datfile=dir(civ_files{ifile});
    2692 %         if isfield(datfile,'datenum')
    2693 %             datnum(ifile)=datfile.datenum;%only available in recent matlab versions
    2694 %             testrecent=1;
    2695 %         end
    2696 %         filefound(ifile)={datfile.name};
    2697 %         
    2698 %         % check the content  netcdf file
    2699 %         Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix');
    2700 %         option_list={'civ1','fix1','patch1','civ2','fix2','patch2'};
    2701 %         if ~isempty(Data.CivStage)
    2702 %             option=Data.CivStage;%case of Matlab civ
    2703 %         else
    2704 %             if ~isempty(Data.patch2) && isequal(Data.patch2,1)
    2705 %                 option=6;
    2706 %             elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
    2707 %                 option=5;
    2708 %             elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
    2709 %                 option=4;
    2710 %             elseif ~isempty(Data.patch) && isequal(Data.patch,1);
    2711 %                 option=3;
    2712 %             elseif ~isempty(Data.fix) && isequal(Data.fix,1);
    2713 %                 option=2;
    2714 %             else
    2715 %                 option=1;
    2716 %             end
    2717 %         end
    2718 %         option_str=option_list{option};
    2719 %         if datnum(ifile)<StatusData.time_ref
    2720 %             option_str=[option_str '  --OLD--'];
    2721 %         end
    2722 %     end
    2723 %     if option >= option_civ
    2724 %         count=count+1;
    2725 %     end
    2726 %     [filepath,filename,ext]=fileparts(civ_files{ifile});
    2727 %     Tabchar{ifile,1}=[fullfile(SubDir,filename) ext  '...' option_str];
    2728 % end
    2729 % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    2730 % if isempty(datnum)
    2731 %     if testrecent
    2732 %         message='no civ result created yet';
    2733 %     else
    2734 %         message='';
    2735 %     end
    2736 % else
    2737 %     datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    2738 %     [first,ind]=min(datnum);
    2739 %     [last,indlast]=max(datnum);
    2740 %     message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
    2741 %         ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
    2742 % end
    2743 % hlist=findobj(hfig,'tag','list');
    2744 % htitlebox=findobj(hfig,'tag','titlebox');
    2745 % hwaitbar=findobj(hfig,'tag','waitbar');
    2746 % set(hlist,'String',Tabchar)
    2747 % set(htitlebox,'String', message)
    2748 %
    2749 %------------------------------------------------------------------------   
    2750 % launched by deleting the status figure
    2751 function stop_status(hObject, eventdata)
    2752 %------------------------------------------------------------------------
    2753 hciv=findobj(allchild(0),'tag','series');
    2754 hhciv=guidata(hciv);
    2755 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    2756 set(hhciv.status,'BackgroundColor',[0 1 0])
    2757 delete(gcbf)
    2758 
     2701
     2702%------------------------------------------------------------------------
    27592703% --- Executes on selection change in ActionExt.
     2704%------------------------------------------------------------------------
    27602705function ActionExt_Callback(hObject, eventdata, handles)
     2706
    27612707ActionExtList=get(handles.ActionExt,'String');
    27622708ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
     
    27822728            compile(ActionName,TransformPath)
    27832729            cd(currentdir)
    2784         end
    2785        
     2730        end       
    27862731    else
    27872732        sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh']));
     
    28522797end
    28532798menu=menu(1:imax);
    2854 
  • trunk/src/series/aver_stat.m

    r633 r635  
    9494nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9595nbfield=nbfield_j*nbfield_i; %total number of fields
    96 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
    97 if ~isempty(errormsg),display(errormsg),return,end
    9896
    9997%% determine the file type on each line from the first input file
     
    140138elseif CheckNc{1}
    141139    FileExtOut='.nc';% write result as .nc files for netcdf inputs
    142 else 
     140else
    143141    msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
    144142    return
    145143end
    146144if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})
    147         msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')
     145    msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')
    148146    return
    149147end
    150 %NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
     148
     149%% settings for the output file
    151150NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file
     151first_i=i1_series{1}(1);
     152last_i=i1_series{1}(end);
     153if isempty(j1_series{1})% if there is no second index j
     154    first_j=1;last_j=1;
     155else
     156    first_j=j1_series{1}(1);
     157    last_j=j1_series{1}(end);
     158end
    152159
    153160%% Set field names and velocity types
     
    177184for index=1:nbfield
    178185    update_waitbar(WaitbarHandle,index/nbfield)
    179     if ~isempty(RUNHandle)&& ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     186    if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    180187        disp('program stopped by user')
    181188        break
     
    238245       
    239246        %%%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
    240         %update sum
    241247        if nbfiles==1 %first field
    242248            time_1=[];
     
    255261                siz=size(Field.(VarName));
    256262                if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean)
    257                     msgbox_uvmat('ERROR',['unequal size of input field ' VarName ', need to project  on a grid'])
     263                    displ_uvmat('ERROR',['unequal size of input field ' VarName ', need to project  on a grid'],checkrun)
    258264                    return
    259265                else
     
    285291    end
    286292else  % time from ImaDoc prevails if it exists
    287     %         j1=1;%default
    288     %         if ~isempty(j1_series{1})
    289     %             j1=j1_series{1};
    290     %         end
    291     %DataOut.Time=time(1,i1_series{1}(1),j1);
    292     %DataOut.Time_end=time(end,i1_series{end}(end),j1_series{end}(end));
    293293    DataOut.Time=time(1);
    294294    DataOut.Time_end=time(end);
  • trunk/src/series/check_data_files.m

    r626 r635  
    104104        Tabchar{2}='';
    105105        Tabchar{3}=[num2str(FileInfo.FrameRate) ' frames/s '];
     106        message='';
    106107        %         Tabchar{4}='';
    107108        %         Tabchar{5}=['  compression' FileInfo.VideoCompression];
  • trunk/src/series/civ_input.m

    r633 r635  
    195195%check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter
    196196%if  isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1)
    197 MaxIndex_i=Param.IndexRange.MaxIndex_i{1};
    198 MaxIndex_j=Param.IndexRange.MaxIndex_j{1};
    199 MinIndex_i=Param.IndexRange.MinIndex_i{1};
    200 MinIndex_j=Param.IndexRange.MinIndex_j{1};
     197MaxIndex_i=Param.IndexRange.MaxIndex_i(1);
     198MinIndex_i=Param.IndexRange.MinIndex_i(1);
     199MaxIndex_j=1;%default
     200MinIndex_j=1;
     201if isfield(Param.IndexRange,'MaxIndex_j')&&isfield(Param.IndexRange,'MinIndex_j')
     202MaxIndex_j=Param.IndexRange.MaxIndex_j(1);
     203MinIndex_j=Param.IndexRange.MinIndex_j(1);
     204end
    201205CivInputData.MaxIndex_i=MaxIndex_i;
    202206CivInputData.MaxIndex_j=MaxIndex_j;
     
    211215        set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large
    212216    end
    213 elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     217%elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     218else
    214219    set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
    215220    if strcmp(NomTypeNc,'_1-2_1')
     
    11311136Time=CivInputData.Time;
    11321137checkframe=strcmp(TimeUnit,'frame');
    1133 %displ_num=get(handles.ListPairCiv1,'UserData');
    1134 
    1135 %% eliminate the first pairs inconsistent with the position
    1136 % if isempty(displ_num)
    1137 %     nbpair=0;
    1138 % else
    1139 %     nbpair=length(displ_num(1,:));%nbre of displayed pairs
    1140 %     if  isequal(mode,'series(Di)')  %| isequal(mode,'st_series(Di)')
    1141 %         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
    1142 %     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    1143 %         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
    1144 %     end
    1145 % end
    1146 % nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    11471138
    11481139%% case with no Civ1 operation, netcdf files need to exist for reading
     
    12241215
    12251216%% determine the menu display in .ListPairCiv1
    1226 % the menu depends on the mode defined in ListPairMode_callback through the array displ_num:
    1227 % displ_num(1,:)=indices j1
    1228 % displ_num(2,:)=indices j2
    1229 % displ_num(3,:)=indices i1
    1230 % displ_num(4,:)=indices i2
    1231 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
    1232 % are relative to the reference indices ref_i and ref_j respectively.
    12331217testpair=0; %TODO: check
    12341218if isequal(mode,'series(Di)')
     
    12391223            if select(ipair)
    12401224                displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    1241                 %if ~checkframe && size(Time,1)>=ref_i+1+displ_num(4,ipair) && size(Time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1
    1242                  %   dt=Time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-Time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%Time interval dt
    1243                if ~checkframe && size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0
     1225               if ~checkframe
     1226                   if size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0
    12441227                 dt=Time(ref_i+1+ceil(ipair/2),ref_j+1)-Time(ref_i+1-floor(ipair/2),ref_j+1);%Time interval dtref_j+1
     1228                 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     1229                   end
    12451230                else
    1246                     dt=1;
    1247                 end
    1248                  displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     1231                    dt=ipair/1000;
     1232                      displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(ipair)];
     1233               end             
    12491234            else
    12501235                displ_pair{ipair}='...'; %pair not displayed in the menu
     
    12591244            if select(ipair)
    12601245                displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))];
    1261                 if ~checkframe && size(Time,1)>=ref_i+1+displ_num(4,ipair) && size(Time,2)>=ref_j+1+displ_num(2,ipair)
    1262                     dt=Time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-Time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%Time interval dt
     1246               if ~checkframe
     1247                   if size(Time,2)>=ref_j+1+ceil(ipair/2) && size(Time,1)>=ref_i+1 && ref_j-floor(ipair/2)>=0 && ref_i>=0
     1248                 dt=Time(ref_i+1,ref_j+1+ceil(ipair/2))-Time(ref_i+1,ref_j+1-floor(ipair/2));%Time interval dtref_j+1
     1249                  displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
     1250                   end
     1251                else
     1252                    dt=ipair/1000;
    12631253                    displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];
    1264                 end
     1254               end                 
    12651255            else
    12661256                displ_pair{ipair}='...'; %pair not displayed in the menu
  • trunk/src/series/civ_series.m

    r633 r635  
    7979%% input files and indexing
    8080NbField=1;
    81 MaxIndex=cell2mat(Param.IndexRange.MaxIndex);
    82 MinIndex=cell2mat(Param.IndexRange.MinIndex);
     81MaxIndex_i=Param.IndexRange.MaxIndex_i;
     82MinIndex_i=Param.IndexRange.MinIndex_i;
     83MaxIndex_j=1;MinIndex_j=1;
     84if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j')
     85    MaxIndex_j=Param.IndexRange.MaxIndex_j;
     86    MinIndex_j=Param.IndexRange.MinIndex_j;
     87end
    8388if isfield(Param,'InputTable')
    8489    [filecell,i_series,tild,j_series]=get_file_series(Param);
     
    120125    if iview_B==0
    121126        FileType_B=FileType_A;
    122 VideoObject_B=VideoObject_A;
     127        VideoObject_B=VideoObject_A;
    123128        PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1;
    124129        PairCiv2='';
     
    127132        end
    128133        [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
    129             find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex);
     134            find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
    130135        if ~isempty(PairCiv2)
    131136            [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
    132                 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex);
     137                find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
    133138            check_bounds=check_bounds | check_bounds_Civ2;
    134139        end
     
    158163        end
    159164    else
    160            [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1});
     165        [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1});
    161166        if isempty(find(strcmp(FileType_B,{'multimage','mmreader','video'})))
    162167            displ(['ERROR: the file line ' num2str(iview_B) ' must be an image'])
    163         end   
     168        end
    164169        %TODO : introduce the second file series if relevant: case %displacement
    165170    end
     
    217222%%%%% MAIN LOOP %%%%%%
    218223for ifield=1:NbField
    219     update_waitbar(WaitbarHandle,index/nbfield)
    220     if ~isempty(RUNHandle) && ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     224    update_waitbar(WaitbarHandle,ifield/NbField)
     225    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    221226        disp('program stopped by user')
    222227        break
     
    264269            j2=j2_series_Civ1(ifield);
    265270        end
    266         Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;
    267         Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);
     271        Data.Civ1_Time=(time(j2+1,i2+1)+time(j1+1,i1+1))/2;
     272        Data.Civ1_Dt=time(j2+1,i2+1)-time(j1+1,i1+1);
    268273        for ilist=1:length(list_param)
    269274            Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});
     
    400405        ImageName_A_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ2(ifield),[],j1_series_Civ2(ifield));
    401406
    402         if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2)
     407        if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
    403408            par_civ2.ImageA=par_civ1.ImageA;
    404409        else
    405             [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2);
     410            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield));
    406411        end
    407412        ImageName_B_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ2(ifield),[],j2_series_Civ2(ifield));
     
    409414            par_civ2.ImageB=par_civ1.ImageB;
    410415        else
    411             [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2);
     416            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
    412417        end     
    413418       
    414419        ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ2(ifield),i2_series_Civ2(ifield),...
    415420            j1_series_Civ2(ifield),j2_series_Civ2(ifield));
    416         par_civ2.ImageWidth=FileInfo.Width;
    417         par_civ2.ImageHeight=FileInfo.Height;
     421        par_civ2.ImageWidth=FileInfo_A.Width;
     422        par_civ2.ImageHeight=FileInfo_A.Height;
    418423       
    419424        if isfield(par_civ2,'Grid')% grid points set as input file
     
    935940% --- determine the list of index pairs of processing file
    936941function [i1_series,i2_series,j1_series,j2_series,check_bounds,NomTypeNc]=...
    937     find_pair_indices(str_civ,i_series,j_series,MinIndex,MaxIndex)
     942    find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j)
    938943%------------------------------------------------------------------------
    939944i1_series=i_series;% set of first image indexes
     
    973978    i1_series=i_series-ind1;% set of first image numbers
    974979    i2_series=i_series+ind2;
    975     check_bounds=i1_series<MinIndex(1,1) | i2_series>MaxIndex(1,1);
     980     check_bounds=i1_series<MinIndex_i | i2_series>MaxIndex_i;
    976981    if isempty(j_series)
    977982        NomTypeNc='_1-2';
     
    984989    j1_series=j_series-ind1;
    985990    j2_series=j_series+ind2;
    986     check_bounds=j1_series<MinIndex(1,2) | j2_series>MaxIndex(1,2);
     991    check_bounds=j1_series<MinIndex_j | j2_series>MaxIndex_j;
    987992    NomTypeNc='_1_1-2';
    988993else  %bursts
  • trunk/src/series/float_tracking.m

    r619 r635  
    115115nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    116116nbfield=nbfield_j*nbfield_i; %total number of fields
    117 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
    118 if ~isempty(errormsg),display(errormsg),return,end
    119117
    120118%% frame index for movie or multimage file input 
  • trunk/src/series/ima_levels.m

    r633 r635  
    151151for ifile=1:nbfield
    152152            update_waitbar(WaitbarHandle,ifile/nbfield)
    153     if ~isempty(RUNHandle) &&ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     153    if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    154154        disp('program stopped by user')
    155155        return
  • trunk/src/series/merge_proj.m

    r633 r635  
    5151    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only)
    5252    ParamOut.ProjObject='on';%can use projection object(option 'off'/'on',
    53     ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     53    ParamOut.Mask='on';%can use mask option   (option 'off'/'on', 'off' by default)
    5454    ParamOut.OutputDirExt='.mproj';%set the output dir extension
    5555    ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
     
    5858        msgbox_uvmat('WARNING','the first input file does not exist')
    5959    elseif isequal(size(Param.InputTable,1),1) && ~isfield(Param,'ProjObject')
    60         msgbox_uvmat('WARNING','a projection object of type plane needs to be introduced for merge_proj')
     60        msgbox_uvmat('WARNING','You may need a projection object of type plane for merge_proj')
    6161    end
    6262    return
  • trunk/src/series/particle_tracking.m

    r619 r635  
    115115nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    116116nbfield=nbfield_j*nbfield_i; %total number of fields
    117 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
    118 if ~isempty(errormsg),display(errormsg),return,end
    119117
    120118%% frame index for movie or multimage file input 
  • trunk/src/series/relabel_i_j.m

    r624 r635  
    226226for ifile=1:nbfield
    227227            update_waitbar(WaitbarHandle,ifile/nbfield)
    228     if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     228    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    229229        disp('program stopped by user')
    230230        break
  • trunk/src/series/time_series.m

    r633 r635  
    9898nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9999nbfield=nbfield_j*nbfield_i; %total number of fields
    100 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
    101 if ~isempty(errormsg),display(errormsg),return,end
     100% [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
     101% if ~isempty(errormsg),display(errormsg),return,end
    102102
    103103%% determine the file type on each line from the first input file
     
    153153    return
    154154end
     155
     156%% settings for the output file
    155157NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file
     158first_i=i1_series{1}(1);
     159last_i=i1_series{1}(end);
     160if isempty(j1_series{1})% if there is no second index j
     161    first_j=1;last_j=1;
     162else
     163    first_j=j1_series{1}(1);
     164    last_j=j1_series{1}(end);
     165end
    156166
    157167%% Set field names and velocity types
     
    210220for index=1:nbfield
    211221            update_waitbar(WaitbarHandle,index/nbfield)
    212     if ~isempty(RUNHandle) &&ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
     222    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    213223        disp('program stopped by user')
    214224        break % leave the loop if stop is ordered
  • trunk/src/uigetfile_uvmat.m

    r620 r635  
    6767    %set(hrefresh,'UserData',StatusData)
    6868    if strcmp(option,'status_display') %put a run advancement display
    69         set(hfig,'DeleteFcn',@stop_status)
    70         uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar');
    71         uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
     69        set(hfig,'DeleteFcn',@(src,event)close(option,src,event))
     70              uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.85 0.9 0.04]);
     71        uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar');
     72
    7273    else  %put a title and additional pushbuttons
    7374        uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.75 0.6 0.03],'BackgroundColor',BackgroundColor,...
     
    109110DirName=get(htitlebox,'String');
    110111hsort_option=findobj(hfig,'tag','sort_option');
    111 sort_option='name';
    112 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2)
    113     sort_option='date';
    114 end
    115 hcheck_date=findobj(hfig,'tag','check_date');
    116 ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content
    117 
    118 set(hlist,'String',ListFiles)
    119 Value=[];
    120 if ~isempty(InputFileName)
    121     Value=find(strcmp(InputFileName,ListFiles));
    122 end
    123 if isempty(Value)
    124     Value=1;
    125 end
    126 set(hlist,'Value',Value)
    127 set(hlist,'BackgroundColor',[0.7 0.7 0.7])
    128 if strcmp(get(hfig,'Tag'),'status_display')
     112if strcmp(get(hfig,'Tag'),'status_display')
    129113    hseries=findobj(allchild(0),'tag','series');
    130     hstatus=findobj(hseries,'tag','status_display');
     114    hstatus=findobj(hseries,'tag','status');
    131115    StatusData=get(hstatus,'UserData');
    132116    TimeStart=0;
    133117    if isfield(StatusData,'TimeStart')
    134118        TimeStart=StatusData.TimeStart;
    135     end 
     119    end
    136120    hlist=findobj(hfig,'tag','list');
    137     testrecent=0;
    138     datnum=zeros(numel(ListDisplay),1);
    139     for ilist=1:numel(ListDisplay)
    140         ListDisplay{ilist}=ListFiles(ilist).name;
    141         if ListFiles(ilist).isdir
    142             ListDisplay{ilist}=['/' ListDisplay{ilist}];
    143         elseif isfield(ListFiles(ilist),'datenum')
    144             datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions
    145             testrecent=1;
    146             if datnum(ilist)<TimeStart
    147                 ListDisplay{ilist}=[ListDisplay{ilist} '  --OLD--'];
    148             end
    149         end
    150     end
    151    
    152     %% Look at date of creation
    153     ListDisplay=ListDisplay(datnum~=0);
    154     datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
    155    
     121    testrecent=0;   
    156122    NbOutputFile=[];
    157     if isempty(datnum)
    158         if testrecent
    159             message='no result created yet';
    160         else
    161             message='';
    162         end
    163     else
    164         [first,indfirst]=min(datnum);
    165         [last,indlast]=max(datnum);
    166         NbOutputFile_str='?';
    167         if isfield(StatusData,'NbOutputFile')
    168             NbOutputFile=StatusData.NbOutputFile;
    169             NbOutputFile_str=num2str(NbOutputFile);
    170         end
    171         message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification:  ' ListDisplay{indfirst} ' : ' datestr(first)];...
    172             ['latest modification:  ' ListDisplay{indlast} ' : ' datestr(last)]};
    173     end
    174     set(htitlebox,'String', [DirName{1};message])
     123    if isfield(StatusData,'NbOutputFile')
     124        NbOutputFile=StatusData.NbOutputFile;
     125        NbOutputFile_str=num2str(NbOutputFile);
     126    end
     127    [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content
    175128   
    176129    %% update the waitbar
     
    178131    if ~isempty(NbOutputFile)
    179132        BarPosition=get(hwaitbar,'Position');
    180         BarPosition(3)=0.9*numel(datnum)/NbOutputFile;
     133        BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead
    181134        set(hwaitbar,'Position',BarPosition)
    182135    end
    183 end
    184 
     136else
     137    sort_option='name';
     138    if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2)
     139        sort_option='date';
     140    end
     141    hcheck_date=findobj(hfig,'tag','check_date');
     142    [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content
     143end
     144
     145set(hlist,'String',ListFiles)
     146Value=[];
     147if ~isempty(InputFileName)
     148    Value=find(strcmp(InputFileName,ListFiles));
     149end
     150if isempty(Value)
     151    Value=1;
     152end
     153set(hlist,'Value',Value)
     154set(hlist,'BackgroundColor',[0.7 0.7 0.7])
    185155%------------------------------------------------------------------------   
    186156% --- launched by selecting an item on the file list
     
    272242%-------------------------------------------------------------------------   
    273243% list the content of a directory
    274 function ListFiles=list_files(DirName,check_date,sort_option)
     244function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option)
    275245%-------------------------------------------------------------------------
    276246ListStruct=dir(DirName);% get structure of the current directory
     247NumFiles=0; %default
    277248if numel(ListStruct)<1  % case of empty dir
    278249    ListFiles={};
     
    283254check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    284255ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    285 if strcmp(sort_option,'date')
    286     ListDates=cell2mat(ListCells(5,:));%list of numerical dates
    287     ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front
     256ListDates=cell2mat(ListCells(5,:));%list of numerical dates
     257if isnumeric(sort_option)
     258    check_old=ListDates<sort_option-1;% -1 is put to account for a 1 s delay in the record of starting time
     259    NumFiles=numel(find(~check_old&~check_dir));
     260end
     261if ~isempty(find(~check_dir))
     262ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front
     263end
     264if isnumeric(sort_option)|| strcmp(sort_option,'date')
    288265    [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list
    289266else
     
    295272ListFiles=[{'+/..'} ListFiles(check_keep)];
    296273if check_date
    297 ListDateString=ListCells(2,:);%list of file dates
    298 ListDateString(check_dir)={''};
    299 ListDateString=ListDateString(index_sort);% sort the corresponding dates
    300 ListDateString=[{''} ListDateString(check_keep)];
    301 ListFiles=[ListFiles; ListDateString];
    302 ListFiles=cell2tab(ListFiles','...');
     274    ListDateString=ListCells(2,:);%list of file dates
     275    if isnumeric(sort_option)
     276        ListDateString(check_old)={'--OLD--'};
     277    end
     278    ListDateString(check_dir)={''};
     279    ListDateString=ListDateString(index_sort);% sort the corresponding dates
     280    ListDateString=[{''} ListDateString(check_keep)];
     281    ListFiles=[ListFiles; ListDateString];
     282    ListFiles=cell2tab(ListFiles','...');
    303283end
    304284
     
    343323%-------------------------------------------------------------------------
    344324if strcmp(option,'status_display')
    345     hseries=findobj(allchild(0),'tag','series');
    346     hstatus=findobj(hfig,'Tag','status_display');
    347     set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    348     set(hhciv.status,'BackgroundColor',[0 1 0])
     325    hseries=findobj(allchild(0),'Tag','series');
     326    hstatus=findobj(hseries,'Tag','status');
     327    set(hstatus,'value',0) %reset the status uicontrol in the GUI series
     328    set(hstatus,'BackgroundColor',[0 1 0])
    349329end
    350330delete(gcbf)
  • trunk/src/uvmat.m

    r627 r635  
    14651465function runplus_Callback(hObject, eventdata, handles)
    14661466%------------------------------------------------------------------------
     1467
    14671468set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
    14681469drawnow
    1469 %TODO: introduce the option: increment ='*' to move to the next available view
    1470 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d
    1471 % if isnan(increment)
    1472 %     set(handles.num_IndexIncrement,'String','1')%default value
    1473 %     increment=1;
    1474 % end
     1470increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     1471if isnan(increment)% case of free increment: move to next available field index
     1472    increment='+';
     1473end
    14751474errormsg=runpm(hObject,eventdata,handles,increment);
    14761475if ~isempty(errormsg)
     
    14851484function runmin_Callback(hObject, eventdata, handles)
    14861485%------------------------------------------------------------------------
     1486
    14871487set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
    14881488drawnow
    1489 increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d
    1490 % if isnan(increment)
    1491 %     set(handles.num_IndexIncrement,'String','1')%default value
    1492 %     increment=1;
    1493 % end
     1489increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     1490if isnan(increment)% case of free increment: move to previous available field index
     1491    increment='-';
     1492end
    14941493errormsg=runpm(hObject,eventdata,handles,increment);
    14951494if ~isempty(errormsg)
     
    15021501function Movie_Callback(hObject, eventdata, handles)
    15031502%------------------------------------------------------------------------
     1503
    15041504set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
    15051505drawnow
    1506 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d
    1507 % if isnan(increment)
    1508 %     set(handles.num_IndexIncrement,'String','1')%default value
    1509 %     increment=1;
    1510 % end
     1506increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     1507if isnan(increment)% case of free increment: move to next available field index
     1508    increment='+';
     1509end
    15111510set(handles.STOP,'Visible','on')
    15121511set(handles.speed,'Visible','on')
     
    15351534set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
    15361535drawnow
    1537 increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d
     1536increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
     1537if isnan(increment)% case of free increment: move to next available field index
     1538    increment='-';
     1539end
    15381540set(handles.STOP,'Visible','on')
    15391541set(handles.speed,'Visible','on')
     
    16071609
    16081610%% increment (or decrement) the field indices and update the input filename(s)
    1609 if isempty(increment)
     1611if ~isnumeric(increment)% undefined increment value
    16101612    set(handles.CheckFixPair,'Value',0)
    16111613end
     
    16171619        j1_1=j1;
    16181620        j2_1=j2;
    1619 if CheckFixPair
     1621if CheckFixPair && isnumeric(increment)
    16201622    if get(handles.scan_i,'Value')==1% case of scanning along index i
    16211623        i1=i1+increment;
     
    16241626            i1_1=i1_1+increment;
    16251627            i2_1=i2_1+increment;
    1626         end
    1627        
     1628        end       
    16281629    else % case of scanning along index j (burst numbers)
    16291630        j1=j1+increment;
     
    16491650        end
    16501651    end
    1651     if ~isempty(increment)
     1652    if isnumeric(increment)
    16521653        if get(handles.scan_i,'Value')==1% case of scanning along index i
    16531654            ref_i=ref_i+increment;% increment the current reference index i
     
    16571658    else % free increment
    16581659        runaction=get(gcbo,'tag');
    1659         if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated
     1660        if strcmp(increment,'+')% if runplus or movie is activated
    16601661            step=1;
    16611662        else
     
    17191720            end
    17201721        end
    1721         if ~isempty(increment)
     1722        if isnumeric(increment)
    17221723            if get(handles.scan_i,'Value')==1% case of scanning along index i
    17231724                ref_i_1=ref_i_1+increment;% increment the current reference index i
Note: See TracChangeset for help on using the changeset viewer.