source: trunk/src/series/check_files.m @ 198

Last change on this file since 198 was 190, checked in by sommeria, 14 years ago

various bug repairs and cleaning, pb of dates in french with check_files

File size: 8.4 KB
Line 
1%'check_files': check the existence and status of the files selected by series.fig
2%------------------------------------------------------------------------
3% function GUI_input=check_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_files(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series) %(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%standard parameters for waitbar and STOP action (do not modify)
45hseries=guidata(Series.hseries);%handles of the GUI series
46WaitbarPos=get(hseries.waitbar_frame,'Position');
47
48%%%%%%%%%%%%%%%%%%%%%%%%
49
50% number of slices
51NbSlice=str2num(get(hseries.NbSlice,'String'));
52if isempty(NbSlice)
53    NbSlice=1;
54end
55NbSlice_name=num2str(NbSlice);
56if isequal(NbSlice,[]),NbSlice=1; end; %default
57
58% number of views
59count=0;
60testcell=iscell(Series.RootFile);
61if ~testcell
62    Series.RootPath={Series.RootPath};
63    Series.RootFile={Series.RootFile};
64    Series.SubDir={Series.SubDir};
65    Series.FileExt={Series.FileExt};
66    Series.NomType={Series.NomType};
67end   
68nbview=length(Series.RootFile);
69for iview=1:nbview
70    filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});%root file name
71    if testcell
72        num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview};
73    else
74        num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell;
75    end
76    siz=size(num_i1);
77    nbfield2=siz(1); %nb of consecutive fields at each level(burst
78    nbfield=siz(1)*siz(2);
79    nbfield=floor(nbfield/(nbfield2*NbSlice));%total number of i indexes (adjusted to an integer number of slices)
80    if isequal(lower(Series.FileExt{iview}),'.avi')
81        info=aviinfo([filebase Series.FileExt{iview}]);
82        message{1}=info.Filename;
83        message{2}=info.FileModDate;
84        message{3}=[num2str(info.FramesPerSecond) ' frames/s '];
85        message{4}=info.ImageType;
86        message{5}=['  compression' info.VideoCompression];
87        message{6}=[ 'quality ' num2str(info.Quality)];   
88        Tabchar=message;
89    else
90        datnum=zeros(1,nbfield);
91        Tabchar={};
92        %LOOP ON SLICES
93        for i_slice=1:NbSlice
94            for ifield=1:nbfield
95                indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';%selected indices on the list of files of a slice
96            end
97            for index=1:nbfield*nbfield2
98                stopstate=get(hseries.RUN,'BusyAction');
99                if isequal(stopstate,'queue')% enable STOP command
100                    update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
101                    ifile=indselect(index);               
102                    file=...
103                       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});               
104                    [Path,Name,ext]=fileparts(file);
105                    detect=exist(file,'file'); % check the existence of the file
106                    if detect==0
107                        count=count+1;
108                        lastfield='not found';
109                    else
110                        datfile=dir(file);
111                        if isfield(datfile,'datenum')
112                            datnum(ifile)=datfile.datenum;
113                        end
114                        filefound(ifile)={datfile.name};
115                        lastfield='';
116                        if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf')
117                            % check the content  netcdf file
118                            Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart');
119                            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
120                                lastfield='patch2';
121                            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
122                                lastfield='fix2';
123                            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
124                                lastfield='civ2';
125                            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
126                                lastfield='patch1';
127                            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
128                                lastfield='fix1';
129                            elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
130                                lastfield='civ1';
131                            end                         
132                        end
133                    end
134                    Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
135                    Tabchar(index+1,i_slice)={[file '   ' lastfield]};
136                end
137            end
138        end
139        if isempty(datnum)
140            if NbSlice>1
141                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
142            else
143                 message='no file found';
144            end
145        else
146            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
147            [first,ind]=min(datnum);
148            [last,indlast]=max(datnum);
149            message={['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
150                ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
151        end
152        if ~isempty(Tabchar)
153          Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1);
154        end
155    end
156    hfig=figure(iview);
157    clf
158    if iview>1
159        pos=get(iview-1,'Position');
160        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
161        set(hfig,'Position',pos)
162    end
163    set(hfig,'name',['view= ' num2str(iview)])
164   
165    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', @ncbrowser_uvmat);
166    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
167end
Note: See TracBrowser for help on using the repository browser.