source: trunk/src/series/check_data_files.m @ 374

Last change on this file since 374 was 374, checked in by sommeria, 12 years ago

fgunctions under series adapted to the renovated GUI series

File size: 8.5 KB
Line 
1%'check_files': check the existence and status of the files selected by series.fig
2%------------------------------------------------------------------------
3% function GUI_input=check_data_files(num_i1,num_i2,num_j1,num_j2,Series)
4%
5%OUTPUT
6% GUI_input=list of options in the GUI series.fig needed for the function
7%
8%INPUT:
9%num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
10%num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
11%num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
12%num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
13%Series: Matlab structure containing information set by the series interface
14%
15function GUI_input=check_data_files(Param) %(filecell,filecell_1,num_i,num_j,vel_type,field,param);
16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %detect the chosen series of files and check their date of modification:
18%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19%INPUT:
20%num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
21%num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
22%num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
23%num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
24%OTHER INPUTS given by the structure Series
25
26%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
27if ~exist('num_i1_cell','var')
28    GUI_input={'RootPath';'many';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
29        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
30        'RootFile';'on';... %root input file name ('on' by default)
31        'FileExt';'on';... %input file extension ('on' by default)
32        'NomType';'on';...%type of file indexing ('on' by default)
33        'NbSlice';'on'; ...%nbre of slices ('off' by default)
34        %'VelTypeMenu';'on';...% menu for selecting the velocity type (civ1,..) 'off' by default)
35        %'FieldMenu';'on';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
36        %'CoordType';'on'...%can use a transform function 'off' by default
37        %'GetObject';'on'...%can use projection object ,'off' by default
38        %'GetMask';'on'...%can use mask option   ,'off' by default
39        %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter
40               ''};
41    return %exit the function
42end
43
44%% input parameters
45% read the xml file for batch case
46if ischar(Param) && ~isempty(find(regexp('Param','.xml$')))
47    Param=xml2struct(Param);
48else %  RUN case: parameters introduced as the input structure Param
49    hseries=guidata(Param.hseries);%handles of the GUI series
50    WaitbarPos=get(hseries.waitbar_frame,'Position');
51end
52[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
53
54
55%%%%%%%%%%%%%%%%%%%%%%%%
56
57% number of slices
58NbSlice=Param.NbSlice;
59if isempty(NbSlice),NbSlice=1; end; %default
60
61%% root input file and type
62    RootPath=Param.InputTable(:,1);
63    RootFile=Param.InputTable(:,3);
64    SubDir=Param.InputTable(:,2);
65    NomType=Param.InputTable(:,4);
66    FileExt=Param.InputTable(:,5);
67% number of views
68count=0; 
69nbview=length(RootFile);
70
71for iview=1:nbview
72    filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});%root file name
73    if testcell
74        num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview};
75    else
76        num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell;
77    end
78    siz=size(num_i1);
79    nbfield2=siz(1); %nb of consecutive fields at each level(burst
80    nbfield=siz(1)*siz(2);
81    nbfield=floor(nbfield/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices)
82    if isequal(lower(Series.FileExt{iview}),'.avi')
83        info=aviinfo([filebase Series.FileExt{iview}]);
84        message{1}=info.Filename;
85        message{2}=info.FileModDate;
86        message{3}=[num2str(info.FramesPerSecond) ' frames/s '];
87        message{4}=info.ImageType;
88        message{5}=['  compression' info.VideoCompression];
89        message{6}=[ 'quality ' num2str(info.Quality)];   
90        Tabchar=message;
91    else
92        datnum=zeros(1,nbfield);
93        Tabchar={};
94        %LOOP ON SLICES
95        for i_slice=1:NbSlice
96            for ifield=1:nbfield
97                indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice
98            end
99            filefound={};
100            for index=1:nbfield*nbfield2
101                stopstate=get(hseries.RUN,'BusyAction');
102                if isequal(stopstate,'queue')% enable STOP command
103                    update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield*nbfield2))
104                    ifile=indselect(index);               
105                    file=...
106                       name_generator(filebase,num_i1(ifile),num_j1(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2(ifile),num_j2(ifile),Series.SubDir{iview});               
107                    [Path,Name,ext]=fileparts(file);
108                    detect=exist(file,'file'); % check the existence of the file
109                    if detect==0
110                        count=count+1;
111                        lastfield='not found';
112                    else
113                        datfile=dir(file);
114                        if isfield(datfile,'datenum')
115                            datnum(ifile)=datfile.datenum;
116                        end
117                        filefound(ifile)={datfile.name};
118                        lastfield='';
119                        if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf')
120                            % check the content  netcdf file
121                            Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart');
122                            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
123                                lastfield='patch2';
124                            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
125                                lastfield='fix2';
126                            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
127                                lastfield='civ2';
128                            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
129                                lastfield='patch1';
130                            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
131                                lastfield='fix1';
132                            elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
133                                lastfield='civ1';
134                            end                         
135                        end
136                    end
137                    Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
138                    Tabchar(index+1,i_slice)={[file '...' lastfield]};
139                end
140            end
141        end
142%         if isempty(datnum)||isempty(filefound)
143        if isempty(filefound)
144            if NbSlice>1
145                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
146            else
147                 message='no file found';
148            end
149        else
150            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
151            [first,ind]=min(datnum);
152            [last,indlast]=max(datnum);
153            message={['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
154                ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
155        end
156        if ~isempty(Tabchar)
157          Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1);
158        end
159    end
160    hfig=figure(iview);
161    clf
162    if iview>1
163        pos=get(iview-1,'Position');
164        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
165        set(hfig,'Position',pos)
166    end
167    set(hfig,'name',['view= ' num2str(iview)])
168   
169    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'});
170    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
171end
Note: See TracBrowser for help on using the repository browser.