source: trunk/src/get_file_series.m @ 529

Last change on this file since 529 was 453, checked in by sommeria, 12 years ago

series adapted to BATCH mode. Tests still needed.

File size: 3.3 KB
Line 
1%'get_file_series': determine the list of file names and file indices for functions called by 'series'.
2%------------------------------------------------------------------------
3% [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
4%
5% OUTPUT:
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
12% INPUT:
13% Param: structure of input parameters as read from the GUI series (by the function read_GUI)
14
15function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
16
17filecell={};
18InputTable=Param.InputTable;
19first_i=Param.IndexRange.first_i;
20incr_i=Param.IndexRange.incr_i;
21last_i=Param.IndexRange.last_i;
22ref_i=first_i:incr_i:last_i;
23ref_j=[];
24if isfield(Param.IndexRange,'first_j')
25    first_j=Param.IndexRange.first_j;
26    incr_j=Param.IndexRange.incr_j;
27    last_j=Param.IndexRange.last_j;
28    ref_j=first_j:incr_j:last_j;
29end
30
31%% determine the list of input file names
32nbmissing=0;
33
34for iview=1:size(InputTable,1)
35    r.mode='';
36    if isfield (Param.IndexRange,'PairString')
37        if ischar(Param.IndexRange.PairString)
38            Param.IndexRange.PairString={Param.IndexRange.PairString};
39        end
40        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
41        if isempty(r)
42            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
43        end       
44        % TODO case of free pairs:
45        %r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names');
46    end
47    if isempty(r)||isempty(r.mode)
48        r(1).num1='';
49        r(1).num2='';
50        r(1).mode='';
51    end
52    [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);
53    %case of pairs (.nc files)
54    i2=[];j1=[];j2=[];
55    for ifile=1:numel(i1_series{iview})
56        i1=i1_series{iview}(ifile);
57        if ~isempty(i2_series{iview})
58            i2=i2_series{iview}(ifile);
59        end
60        if ~isempty(j1_series{iview})
61            j1=j1_series{iview}(ifile);
62        end
63        if ~isempty(j2_series{iview})
64            j2=j2_series{iview}(ifile);
65        end
66        filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4}...
67            ,i1,i2,j1,j2);
68    end
69end
70
71
72function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode)
73i1_series=ref_i;%default
74j1_series=[];
75if ~isempty(ref_j)
76    [i1_series,j1_series]=meshgrid(ref_i,ref_j);
77end
78i2_series=i1_series;
79j2_series=j1_series;
80
81switch mode
82    case 'Di='  %  case 'series(Di)')
83        i1_series=i1_series-num1;
84        i2_series=i2_series+num2;
85    case 'Dj='  %  case 'series(Dj)'
86        j1_series=j1_series-num1;
87        j2_series=j2_series+num2;
88    case '-'  % case 'bursts'
89        j1_series=num1*ones(size(i1_series));
90        j2_series=num2*ones(size(i1_series));
91end
Note: See TracBrowser for help on using the repository browser.