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