[376] | 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: |
---|
[446] | 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, |
---|
[453] | 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 |
---|
[446] | 11 | |
---|
[376] | 12 | % INPUT: |
---|
| 13 | % Param: structure of input parameters as read from the GUI series (by the function read_GUI) |
---|
| 14 | |
---|
[373] | 15 | function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param) |
---|
[376] | 16 | |
---|
[373] | 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=[]; |
---|
[400] | 24 | if isfield(Param.IndexRange,'first_j') |
---|
[373] | 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 |
---|
[391] | 30 | |
---|
[373] | 31 | %% determine the list of input file names |
---|
| 32 | nbmissing=0; |
---|
| 33 | |
---|
| 34 | for iview=1:size(InputTable,1) |
---|
[408] | 35 | r.mode=''; |
---|
| 36 | if isfield (Param.IndexRange,'PairString') |
---|
[450] | 37 | if ischar(Param.IndexRange.PairString) |
---|
| 38 | Param.IndexRange.PairString={Param.IndexRange.PairString}; |
---|
| 39 | end |
---|
[408] | 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 |
---|
[440] | 47 | if isempty(r)||isempty(r.mode) |
---|
| 48 | r(1).num1=''; |
---|
| 49 | r(1).num2=''; |
---|
| 50 | r(1).mode=''; |
---|
[408] | 51 | end |
---|
[453] | 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); |
---|
[373] | 53 | %case of pairs (.nc files) |
---|
| 54 | i2=[];j1=[];j2=[]; |
---|
[453] | 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); |
---|
[373] | 59 | end |
---|
[453] | 60 | if ~isempty(j1_series{iview}) |
---|
| 61 | j1=j1_series{iview}(ifile); |
---|
[373] | 62 | end |
---|
[453] | 63 | if ~isempty(j2_series{iview}) |
---|
| 64 | j2=j2_series{iview}(ifile); |
---|
[373] | 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 |
---|
| 69 | end |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode) |
---|
| 73 | i1_series=ref_i;%default |
---|
| 74 | j1_series=[]; |
---|
| 75 | if ~isempty(ref_j) |
---|
[400] | 76 | [i1_series,j1_series]=meshgrid(ref_i,ref_j); |
---|
[373] | 77 | end |
---|
[393] | 78 | i2_series=i1_series; |
---|
| 79 | j2_series=j1_series; |
---|
[391] | 80 | |
---|
[373] | 81 | switch mode |
---|
[393] | 82 | case 'Di=' % case 'series(Di)') |
---|
[373] | 83 | i1_series=i1_series-num1; |
---|
| 84 | i2_series=i2_series+num2; |
---|
[393] | 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)); |
---|
[373] | 91 | end |
---|