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