[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'); |
---|
[537] | 43 | end |
---|
[408] | 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=''; |
---|
[540] | 50 | if isfield (Param.IndexRange,'PairString') && strcmp(Param.IndexRange.PairString{iview,1},'j=*-*') |
---|
[537] | 51 | r(1).mode='*-*'; |
---|
| 52 | else |
---|
[440] | 53 | r(1).mode=''; |
---|
[537] | 54 | end |
---|
[408] | 55 | end |
---|
[537] | 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,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 | |
---|
[373] | 72 | %case of pairs (.nc files) |
---|
| 73 | i2=[];j1=[];j2=[]; |
---|
[453] | 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); |
---|
[373] | 78 | end |
---|
[453] | 79 | if ~isempty(j1_series{iview}) |
---|
| 80 | j1=j1_series{iview}(ifile); |
---|
[373] | 81 | end |
---|
[453] | 82 | if ~isempty(j2_series{iview}) |
---|
| 83 | j2=j2_series{iview}(ifile); |
---|
[373] | 84 | end |
---|
[537] | 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); |
---|
[373] | 86 | end |
---|
| 87 | end |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode) |
---|
| 91 | i1_series=ref_i;%default |
---|
| 92 | j1_series=[]; |
---|
| 93 | if ~isempty(ref_j) |
---|
[400] | 94 | [i1_series,j1_series]=meshgrid(ref_i,ref_j); |
---|
[373] | 95 | end |
---|
[393] | 96 | i2_series=i1_series; |
---|
| 97 | j2_series=j1_series; |
---|
[391] | 98 | |
---|
[373] | 99 | switch mode |
---|
[393] | 100 | case 'Di=' % case 'series(Di)') |
---|
[373] | 101 | i1_series=i1_series-num1; |
---|
| 102 | i2_series=i2_series+num2; |
---|
[393] | 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)); |
---|
[373] | 109 | end |
---|