source: trunk/src/get_file_series.m @ 418

Last change on this file since 418 was 408, checked in by sommeria, 12 years ago

various bugs corrected in series and uvmat.

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