source: trunk/src/get_file_series.m @ 378

Last change on this file since 378 was 376, checked in by sommeria, 13 years ago

introduce get_file_type to get easily the type of file (image, multimage, civdata...)
a few bugs corrected in series

File size: 3.0 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{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
12function [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
13
14filecell={};
15InputTable=Param.InputTable;
16first_i=Param.IndexRange.first_i;
17incr_i=Param.IndexRange.incr_i;
18last_i=Param.IndexRange.last_i;
19ref_i=first_i:incr_i:last_i;
20ref_j=[];
21if 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;
26end
27Pairs=Param.Pairs;
28r.mode='';
29if 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');
36end
37
38%% determine the list of input file names
39nbmissing=0;
40
41for 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
59end
60
61
62function [i1_series,i2_series,j1_series,j2_series]=find_file_indices(ref_i,ref_j,num1,num2,mode)
63i1_series=ref_i;%default
64j1_series=[];
65if ~isempty(ref_j)
66    i1_series=meshgrid(ref_i,ones(size(ref_j)));
67    j1_series=meshgrid(ref_i,ones(size(ref_j)));
68end
69i2_series=[];
70j2_series=[];
71switch 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
85end
Note: See TracBrowser for help on using the repository browser.