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

Last change on this file since 348 was 340, checked in by sommeria, 13 years ago

small corrections to fit with the new GUI series;fig

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_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
51% NbSlice=str2num(get(hseries.NbSlice,'String'));
52% if isempty(NbSlice)
53%     NbSlice=1;
54NbSlice=Series.IndexRange.NbSlice
55NbSlice_name=num2str(Series.IndexRange.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            filefound={};
98            for index=1:nbfield*nbfield2
99                stopstate=get(hseries.RUN,'BusyAction');
100                if isequal(stopstate,'queue')% enable STOP command
101                    update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield*nbfield2))
102                    ifile=indselect(index);               
103                    file=...
104                       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});               
105                    [Path,Name,ext]=fileparts(file);
106                    detect=exist(file,'file'); % check the existence of the file
107                    if detect==0
108                        count=count+1;
109                        lastfield='not found';
110                    else
111                        datfile=dir(file);
112                        if isfield(datfile,'datenum')
113                            datnum(ifile)=datfile.datenum;
114                        end
115                        filefound(ifile)={datfile.name};
116                        lastfield='';
117                        if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf')
118                            % check the content  netcdf file
119                            Data=nc2struct(file,'ListGlobalAttribute','patch2','fix2','civ2','patch','fix','absolut_time_T0','hart');
120                            if ~isempty(Data.patch2) && isequal(Data.patch2,1)
121                                lastfield='patch2';
122                            elseif ~isempty(Data.fix2) && isequal(Data.fix2,1)
123                                lastfield='fix2';
124                            elseif ~isempty(Data.civ2) && isequal(Data.civ2,1);
125                                lastfield='civ2';
126                            elseif ~isempty(Data.patch) && isequal(Data.patch,1);
127                                lastfield='patch1';
128                            elseif ~isempty(Data.fix) && isequal(Data.fix,1);
129                                lastfield='fix1';
130                            elseif ~isempty(Data.absolut_time_T0) && ~isempty(Data.hart)
131                                lastfield='civ1';
132                            end                         
133                        end
134                    end
135                    Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
136                    Tabchar(index+1,i_slice)={[file '   ' lastfield]};
137                end
138            end
139        end
140%         if isempty(datnum)||isempty(filefound)
141        if isempty(filefound)
142            if NbSlice>1
143                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
144            else
145                 message='no file found';
146            end
147        else
148            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
149            [first,ind]=min(datnum);
150            [last,indlast]=max(datnum);
151            message={['oldest modification:  ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
152                ['latest modification:  ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
153        end
154        if ~isempty(Tabchar)
155          Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1);
156        end
157    end
158    hfig=figure(iview);
159    clf
160    if iview>1
161        pos=get(iview-1,'Position');
162        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
163        set(hfig,'Position',pos)
164    end
165    set(hfig,'name',['view= ' num2str(iview)])
166   
167    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', @ncbrowser_uvmat);
168    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
169end
Note: See TracBrowser for help on using the repository browser.