source: trunk/src/get_file_series.m @ 611

Last change on this file since 611 was 599, checked in by sommeria, 12 years ago

various bug corrections. Steps further for civ_series (still development needed)

File size: 4.4 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={};i1_series={};i2_series={};j1_series={};j2_series={};
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        if isfield (Param.IndexRange,'PairString') && strcmp(Param.IndexRange.PairString{iview,1},'j=*-*')
51            r(1).mode='*-*';
52        else
53        r(1).mode='';
54        end
55    end
56    if isequal(r(1).mode,'*-*')% free pairs
57        FilePath=fullfile(InputTable{iview,1},InputTable{iview,2});
58        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        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    else
69        [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);
70    end
71       
72    %case of pairs (.nc files)
73    i2=[];j1=[];j2=[];
74    for ifile=1:numel(i1_series{iview})
75        i1=i1_series{iview}(ifile);
76        if ~isempty(i2_series{iview})
77            i2=i2_series{iview}(ifile);
78        end
79        if ~isempty(j1_series{iview})
80            j1=j1_series{iview}(ifile);
81        end
82        if ~isempty(j2_series{iview})
83            j2=j2_series{iview}(ifile);
84        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);
86    end
87end
88
89
90function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode)
91i1_series=ref_i;%default
92j1_series=[];
93if ~isempty(ref_j)
94    [i1_series,j1_series]=meshgrid(ref_i,ref_j);
95end
96i2_series=i1_series;
97j2_series=j1_series;
98
99switch mode
100    case 'Di='  %  case 'series(Di)')
101        i1_series=i1_series-num1;
102        i2_series=i2_series+num2;
103    case 'Dj='  %  case 'series(Dj)'
104        j1_series=j1_series-num1;
105        j2_series=j2_series+num2;
106    case '-'  % case 'bursts'
107        j1_series=num1*ones(size(i1_series));
108        j2_series=num2*ones(size(i1_series));
109end
Note: See TracBrowser for help on using the repository browser.