0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 function varargout = series(varargin)
0033
0034
0035 gui_Singleton = 1;
0036 gui_State = struct('gui_Name', mfilename, ...
0037 'gui_Singleton', gui_Singleton, ...
0038 'gui_OpeningFcn', @series_OpeningFcn, ...
0039 'gui_OutputFcn', @series_OutputFcn, ...
0040 'gui_LayoutFcn', [] , ...
0041 'gui_Callback', []);
0042 if nargin & ischar(varargin{1})
0043 gui_State.gui_Callback = str2func(varargin{1});
0044 end
0045
0046 if nargout
0047 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0048 else
0049 gui_mainfcn(gui_State, varargin{:});
0050 end
0051
0052
0053
0054
0055
0056 function series_OpeningFcn(hObject, eventdata, handles,param)
0057
0058
0059 handles.output = hObject;
0060
0061 guidata(hObject, handles);
0062
0063
0064
0065 dir_perso=prefdir;
0066 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0067 if exist(profil_perso,'file')
0068 h=load (profil_perso);
0069 if isfield(h,'MenuFile_1')
0070 set(handles.MenuFile_1,'Label',h.MenuFile_1);
0071 set(handles.MenuFile_insert_1,'Label',h.MenuFile_1);
0072 end
0073 if isfield(h,'MenuFile_1')
0074 set(handles.MenuFile_2,'Label',h.MenuFile_2);
0075 set(handles.MenuFile_insert_2,'Label',h.MenuFile_2);
0076 end
0077 if isfield(h,'MenuFile_1')
0078 set(handles.MenuFile_3,'Label',h.MenuFile_3);
0079 set(handles.MenuFile_insert_3,'Label',h.MenuFile_3);
0080 end
0081 if isfield(h,'MenuFile_1')
0082 set(handles.MenuFile_4,'Label',h.MenuFile_4);
0083 set(handles.MenuFile_insert_4,'Label',h.MenuFile_4);
0084 end
0085 if isfield(h,'MenuFile_1')
0086 set(handles.MenuFile_5,'Label',h.MenuFile_5);
0087 set(handles.MenuFile_insert_5,'Label',h.MenuFile_5);
0088 end
0089 end
0090
0091
0092 if ~exist('param','var')
0093 param=[];
0094 end
0095
0096
0097 if isfield(param,'menu_coord_str')
0098 set(handles.CoordType,'String',param.menu_coord_str)
0099 end
0100 if isfield(param,'menu_coord_val')
0101 set(handles.CoordType,'Value',param.menu_coord_val);
0102 else
0103 set(handles.CoordType,'Value',1);
0104 end
0105
0106 if isfield(param,'FileName')
0107 if isfield(param,'FileName_1')
0108 update_file(hObject, eventdata, handles,param.FileName_1,0)
0109 update_file(hObject, eventdata, handles,param.FileName,1)
0110 else
0111 update_file(hObject, eventdata, handles,param.FileName,0)
0112 end
0113 end
0114
0115
0116 if isfield(param,'list_fields')& isfield(param,'index_fields') &~isempty(param.list_fields) &~isempty(param.index_fields)
0117 set(handles.FieldMenu,'String',param.list_fields);
0118 set(handles.FieldMenu,'Value',param.index_fields);
0119 FieldCell{1}=param.list_fields{param.index_fields};
0120 end
0121 if isfield(param,'civ1')& islogical(param.civ1) & isfield(param,'civ2')& islogical(param.civ2)&...
0122 isfield(param,'interp1')& islogical(param.interp1)&isfield(param,'interp2')& islogical(param.interp2)&...
0123 isfield(param,'filter1')& islogical(param.filter1)&isfield(param,'filter2')& islogical(param.filter2)
0124 set(handles.civ1,'Value',param.civ1);
0125 set(handles.civ2,'Value',param.civ1);
0126 set(handles.interp1,'Value',param.interp1);
0127 set(handles.interp2,'Value',param.interp2);
0128 set(handles.filter1,'Value',param.filter1);
0129 set(handles.filter2,'Value',param.filter2);
0130 end
0131
0132 set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
0133 NomType_Callback(hObject, eventdata, handles)
0134
0135
0136
0137 menu_str=get(handles.ACTION,'String');
0138 menu_str(end)=[];
0139 path_series=which('series');
0140 for ilist=1:length(menu_str)
0141 fct_path{ilist,1}=path_series;
0142 end
0143 dir_perso=prefdir;
0144 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0145 if exist(profil_perso,'file')
0146 h=load (profil_perso);
0147 if isfield(h,'series_fct') && iscell(h.series_fct)
0148 for ilist=1:length(h.series_fct)
0149 [path,file]=fileparts(h.series_fct{ilist});
0150 fct_path=[fct_path; {path}];
0151 menu_str=[menu_str; {file}];
0152 end
0153 menu_str=[menu_str;{'more...'}];
0154 set(handles.ACTION,'String',menu_str)
0155 end
0156 end
0157 set(handles.ACTION,'UserData',fct_path)
0158
0159
0160 ACTION_Callback(hObject, eventdata, handles)
0161
0162
0163
0164
0165 function varargout = series_OutputFcn(hObject, eventdata, handles)
0166
0167
0168
0169
0170
0171 varargout{1} = handles.output;
0172
0173
0174
0175 function MenuBrowse_Callback(hObject, eventdata, handles)
0176
0177 RootPathCell=get(handles.RootPath,'String');
0178 SubDirCell=get(handles.SubDir,'String');
0179 RootFileCell=get(handles.RootFile,'String');
0180 oldfile='';
0181 if isempty(RootPathCell)|isequal(RootPathCell,{''})
0182 dir_perso=prefdir;
0183 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0184 if exist(profil_perso,'file')
0185 h=load (profil_perso);
0186 if isfield(h,'filebase')&ischar(h.filebase)
0187 oldfile=h.filebase;
0188 end
0189 if isfield(h,'RootPath')&ischar(h.RootPath)
0190 oldfile=h.RootPath;
0191 end
0192 end
0193 else
0194 oldfile=fullfile(RootPathCell{1},SubDirCell{1},RootFileCell{1});
0195 end
0196 [FileName, PathName, filterindex] = uigetfile( ...
0197 {'*.xml;*.xls;*.png;*.tif;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png,*.tif, *.avi,*.nc)';
0198 '*.xml', '.xml files '; ...
0199 '*.xls', '.xls files '; ...
0200 '*.png','.png image files'; ...
0201 '*.tif','.tif image files'; ...
0202 '*.avi;*.AVI','.avi movie files'; ...
0203 '*.nc','.netcdf files'; ...
0204 '*.*', 'All Files (*.*)'}, ...
0205 'Pick a file',oldfile);
0206 fileinput=[PathName FileName];
0207 testblank=findstr(fileinput,' ');
0208 if ~isempty(testblank)
0209 errordlg('forbidden input file name: contain blanks')
0210 return
0211 end
0212 sizf=size(fileinput);
0213 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
0214 [path,name,ext]=fileparts(fileinput);
0215 SeriesData=[];
0216 if isequal(ext,'.xml')
0217 errordlg('input file type not implemented')
0218 elseif isequal(ext,'.xls')
0219 errordlg('input file type not implemented')
0220 else
0221 update_file(hObject, eventdata, handles,fileinput,0)
0222
0223 MenuFile_1=fileinput;
0224 MenuFile_2=get(handles.MenuFile_1,'Label');
0225 MenuFile_3=get(handles.MenuFile_2,'Label');
0226 MenuFile_4=get(handles.MenuFile_3,'Label');
0227 MenuFile_5=get(handles.MenuFile_4,'Label');
0228 set(handles.MenuFile_1,'Label',MenuFile_1)
0229 set(handles.MenuFile_2,'Label',MenuFile_2)
0230 set(handles.MenuFile_3,'Label',MenuFile_3)
0231 set(handles.MenuFile_4,'Label',MenuFile_4)
0232 set(handles.MenuFile_5,'Label',MenuFile_5)
0233 set(handles.MenuFile_insert_1,'Label',MenuFile_1)
0234 set(handles.MenuFile_insert_2,'Label',MenuFile_2)
0235 set(handles.MenuFile_insert_3,'Label',MenuFile_3)
0236 set(handles.MenuFile_insert_4,'Label',MenuFile_4)
0237 set(handles.MenuFile_insert_5,'Label',MenuFile_5)
0238 dir_perso=prefdir;
0239 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0240 if exist(profil_perso,'file')
0241 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append');
0242 else
0243 txt=ver;
0244 Release=txt(1).Release;
0245 relnumb=str2num(Release(3:4));
0246 if relnumb >= 14
0247 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6');
0248 else
0249 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5');
0250 end
0251 end
0252 end
0253
0254
0255
0256
0257
0258
0259
0260
0261 function MenuFile_1_Callback(hObject, eventdata, handles)
0262 fileinput=get(handles.MenuFile_1,'Label');
0263 update_file(hObject, eventdata, handles,fileinput,0)
0264
0265
0266 function MenuFile_2_Callback(hObject, eventdata, handles)
0267 fileinput=get(handles.MenuFile_2,'Label');
0268 update_file(hObject, eventdata, handles,fileinput,0)
0269
0270
0271 function MenuFile_3_Callback(hObject, eventdata, handles)
0272 fileinput=get(handles.MenuFile_3,'Label');
0273 update_file(hObject, eventdata, handles,fileinput,0)
0274
0275
0276 function MenuFile_4_Callback(hObject, eventdata, handles)
0277 fileinput=get(handles.MenuFile_4,'Label');
0278 update_file(hObject, eventdata, handles,fileinput,0)
0279
0280
0281 function MenuFile_5_Callback(hObject, eventdata, handles)
0282 fileinput=get(handles.MenuFile_5,'Label');
0283 update_file(hObject, eventdata, handles,fileinput,0)
0284
0285
0286 function MenuBrowse_insert_Callback(hObject, eventdata, handles)
0287
0288
0289 RootPathCell=get(handles.RootPath,'String');
0290
0291 RootFileCell=get(handles.RootFile,'String');
0292 oldfile='';
0293 if isempty(RootPathCell)|isequal(RootPathCell,{''})
0294 dir_perso=prefdir;
0295 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0296 if exist(profil_perso,'file')
0297 h=load (profil_perso);
0298 if isfield(h,'filebase')&ischar(h.filebase)
0299 oldfile=h.filebase;
0300 end
0301 if isfield(h,'RootPath')&ischar(h.RootPath)
0302 oldfile=h.RootPath;
0303 end
0304 end
0305 else
0306 oldfile=fullfile(RootPathCell{1},RootFileCell{1});
0307 end
0308 [FileName, PathName, filterindex] = uigetfile( ...
0309 {'*.xml;*.xls;*.png;*.avi;*.AVI;*.nc', ' (*.xml,*.xls, *.png, *.avi,*.nc)';
0310 '*.xml', '.xml files '; ...
0311 '*.xls', '.xls files '; ...
0312 '*.png','.png image files'; ...
0313 '*.avi;*.AVI','.avi movie files'; ...
0314 '*.nc','.netcdf files'; ...
0315 '*.*', 'All Files (*.*)'}, ...
0316 'Pick a file',oldfile);
0317 fileinput=[PathName FileName];
0318 testblank=findstr(fileinput,' ');
0319 if ~isempty(testblank)
0320 errordlg('forbidden input file name: contain blanks')
0321 return
0322 end
0323 sizf=size(fileinput);
0324 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
0325 [path,name,ext]=fileparts(fileinput);
0326 SeriesData=[];
0327 if isequal(ext,'.xml')
0328 errordlg('input file type not implemented')
0329 elseif isequal(ext,'.xls')
0330 errordlg('input file type not implemented')
0331 else
0332 update_file(hObject, eventdata, handles,fileinput,1)
0333
0334 MenuFile_1=fileinput;
0335 MenuFile_2=get(handles.MenuFile_1,'Label');
0336 MenuFile_3=get(handles.MenuFile_2,'Label');
0337 MenuFile_4=get(handles.MenuFile_3,'Label');
0338 MenuFile_5=get(handles.MenuFile_4,'Label');
0339 set(handles.MenuFile_1,'Label',MenuFile_1)
0340 set(handles.MenuFile_2,'Label',MenuFile_2)
0341 set(handles.MenuFile_3,'Label',MenuFile_3)
0342 set(handles.MenuFile_4,'Label',MenuFile_4)
0343 set(handles.MenuFile_5,'Label',MenuFile_5)
0344 set(handles.MenuFile_insert_1,'Label',MenuFile_1)
0345 set(handles.MenuFile_insert_2,'Label',MenuFile_2)
0346 set(handles.MenuFile_insert_3,'Label',MenuFile_3)
0347 set(handles.MenuFile_insert_4,'Label',MenuFile_4)
0348 set(handles.MenuFile_insert_5,'Label',MenuFile_5)
0349 dir_perso=prefdir;
0350 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0351 if exist(profil_perso,'file')
0352 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append');
0353 else
0354 txt=ver;
0355 Release=txt(1).Release;
0356 relnumb=str2num(Release(3:4));
0357 if relnumb >= 14
0358 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6');
0359 else
0360 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5');
0361 end
0362 end
0363 end
0364
0365
0366
0367 function MenuFile_insert_1_Callback(hObject, eventdata, handles)
0368 fileinput=get(handles.MenuFile_insert_1,'Label');
0369 update_file(hObject, eventdata, handles,fileinput,1)
0370
0371
0372 function MenuFile_insert_2_Callback(hObject, eventdata, handles)
0373 fileinput=get(handles.MenuFile_insert_2,'Label');
0374 update_file(hObject, eventdata, handles,fileinput,1)
0375
0376
0377 function MenuFile_insert_3_Callback(hObject, eventdata, handles)
0378 fileinput=get(handles.MenuFile_insert_3,'Label');
0379 update_file(hObject, eventdata, handles,fileinput,1)
0380
0381
0382 function MenuFile_insert_4_Callback(hObject, eventdata, handles)
0383 fileinput=get(handles.MenuFile_insert_4,'Label');
0384 update_file(hObject, eventdata, handles,fileinput,1)
0385
0386
0387 function MenuFile_insert_5_Callback(hObject, eventdata, handles)
0388 fileinput=get(handles.MenuFile_insert_5,'Label');
0389 update_file(hObject, eventdata, handles,fileinput,1)
0390
0391
0392
0393 function update_file(hObject, eventdata, handles,fileinput,addtest)
0394 hseries=get(handles.RootPath,'parent');
0395
0396 [RootPath,RootFile,field_count,str2,str_a,str_b,FileExt,NomType,SubDir]=name2display(fileinput);
0397
0398 if ~isempty(imformats(FileExt(2:end)))
0399 imainfo=imfinfo(fileinput);
0400 if length(imainfo) >1
0401 NomType='*';
0402 [RootPath,RootFile]=fileparts(fileinput);
0403 end
0404 end
0405 NcType='none';
0406 if isequal(FileExt,'.nc')
0407 Data=nc2struct(fileinput,[]);
0408 if isfield(Data,'absolut_time_T0')
0409 NcType='civx';
0410 end
0411 end
0412
0413 set(handles.RootPath,'Value',1)
0414 set(handles.SubDir,'Value',1)
0415 set(handles.RootFile,'Value',1)
0416 set(handles.NomType,'Value',1)
0417 set(handles.FileExt,'Value',1)
0418 set(handles.nb_field,'Value',1)
0419 set(handles.nb_field2,'Value',1)
0420 if addtest
0421 SeriesData=get(hseries,'UserData');
0422 SeriesData.displ_num=[0 0 0 0;SeriesData.displ_num];
0423 SeriesData.CurrentInputFile_1=SeriesData.CurrentInputFile;
0424 RootPathCell=[{RootPath}; get(handles.RootPath,'String')] ;
0425 SubDirCell=[{SubDir}; get(handles.SubDir,'String')];
0426 RootFileCell=[{RootFile}; get(handles.RootFile,'String')];
0427 NomTypeCell=[{NomType}; SeriesData.NomType];
0428 FileExtCell=[{FileExt}; get(handles.FileExt,'String')];
0429 NcTypeCell=[{NcType};SeriesData.NcType];
0430 set(handles.NomType,'String',[{};get(handles.NomType,'String')])
0431 else
0432 SeriesData=[];
0433 SeriesData.displ_num=[0 0 0 0];
0434 RootPathCell={RootPath};
0435 SubDirCell={SubDir};
0436 RootFileCell={RootFile};
0437 NomTypeCell={NomType};
0438 FileExtCell={FileExt};
0439 NcTypeCell={NcType};
0440 end
0441
0442 SeriesData.NomType=NomTypeCell;
0443 SeriesData.NcType=NcTypeCell;
0444 SeriesData.CurrentInputFile=fileinput;
0445 set(handles.RootPath,'String',RootPathCell);
0446 set(handles.SubDir,'String',SubDirCell);
0447 set(handles.RootFile,'String',RootFileCell);
0448 set(handles.NomType,'String',NomTypeCell);
0449 set(handles.FileExt,'String',FileExtCell);
0450
0451
0452 ref_i=1;
0453 if ~isempty(str2num(field_count))
0454 ref_i=str2num(field_count);
0455 if ~isempty(str2num(str2))
0456 ref_i=floor((ref_i+str2num(str2))/2);
0457 SeriesData.browse_Di=str2num(str2)-str2num(field_count);
0458 end
0459 end
0460 set(handles.ref_i,'String',num2str(ref_i));
0461 set(handles.first_i,'String',num2str(ref_i));
0462 set(handles.last_i,'String',num2str(ref_i));
0463 ref_j=1;
0464 if ~isempty(str2num(str_a))
0465 ref_j=str2num(str_a);
0466 if ~isempty(str2num(str_b))
0467 ref_j=floor((str2num(str_a)+str2num(str_b))/2);
0468 SeriesData.browse_Dj=str2num(str_b)-str2num(str_a);
0469 end
0470 end
0471 set(handles.ref_j,'String',num2str(ref_j));
0472 set(handles.first_j,'String',num2str(ref_j))
0473 set(handles.last_j,'String',num2str(ref_j));
0474
0475
0476
0477 set(handles.MenuOpen_insert,'Enable','on')
0478 set(handles.MenuFile_insert_1,'Enable','on')
0479 set(handles.MenuFile_insert_2,'Enable','on')
0480 set(handles.MenuFile_insert_3,'Enable','on')
0481 set(handles.MenuFile_insert_4,'Enable','on')
0482 set(handles.MenuFile_insert_5,'Enable','on')
0483 set(handles.RUN, 'Enable','On')
0484 set(handles.RUN,'BackgroundColor',[1 0 0])
0485 set(handles.RootPath,'BackgroundColor',[1 1 0])
0486 drawnow
0487
0488
0489
0490
0491
0492
0493
0494 TimeUnit='';
0495
0496 time=[];
0497 GeometryCalib=[];
0498 nb_field=[];
0499 nb_field2=[];
0500
0501
0502 SeriesData.PathCampaign=get(handles.PathCampaign,'String');
0503
0504
0505
0506 FileBase=fullfile(RootPath,RootFile);
0507
0508
0509
0510 testima=0;
0511 if isequal(lower(FileExt),'.avi')
0512 testima=1;
0513 info=aviinfo([FileBase FileExt]);
0514 time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
0515 nb_field=info.NumFrames;
0516 nb_field2=1;
0517 elseif ~isempty(imformats(FileExt(2:end)))
0518 testima=1;
0519 if isequal(NomType,'*')
0520 imainfo=imfinfo([FileBase FileExt]);
0521 if length(imainfo) >1
0522 nb_field=length(imainfo);
0523 nb_field2=1;
0524 end
0525 end
0526 elseif isequal(FileExt,'.vol')
0527 testima=1;
0528 end
0529
0530
0531 testfield=isequal(get(handles.FieldMenu,'enable'),'on');
0532 testfield_1=isequal(get(handles.FieldMenu_1,'enable'),'on');
0533 testveltype=isequal(get(handles.VelTypeMenu,'enable'),'on');
0534 testveltype_1=isequal(get(handles.VelTypeMenu_1,'enable'),'on');
0535 testtransform=isequal(get(handles.CoordType,'Enable'),'on');
0536
0537 testnc=0;
0538 testnc_1=0;
0539 testcivx=0;
0540 testcivx_1=0;
0541 if length(FileExtCell)==1 || length(FileExtCell)>2
0542 for iview=1:length(FileExtCell)
0543 if isequal(FileExtCell{iview},'.nc')
0544 testnc=1;
0545 end
0546 if isequal(NcTypeCell{iview},'civx')
0547 testcivx=1;
0548 end
0549 end
0550 elseif length(FileExtCell)==2
0551 testnc=isequal(FileExtCell{1},'.nc');
0552 testnc_1=isequal(FileExtCell{2},'.nc');
0553 testcivx=isequal(NcTypeCell{1},'civx');
0554 testcivx_1=isequal(NcTypeCell{2},'civx');
0555 end
0556 if testfield && testnc
0557 view_FieldMenu(handles,'on')
0558 if testcivx
0559 menustr=get(handles.FieldMenu,'String');
0560 if isequal(menustr,{'get_field...'})
0561 set(handles.FieldMenu,'String',{'get_field...';'velocity';'vort';'div';'more...'})
0562 end
0563 else
0564 set(handles.FieldMenu,'Value',1)
0565 set(handles.FieldMenu,'String',{'get_field...'})
0566 end
0567 else
0568 view_FieldMenu(handles,'off')
0569 end
0570 if testfield_1 && testnc_1
0571 view_FieldMenu_1(handles,'on')
0572 if testcivx_1
0573 menustr=get(handles.FieldMenu_1,'String');
0574 if isequal(menustr,{'get_field...'})
0575 set(handles.FieldMenu_1,'String',{'get_field...';'velocity';'vort';'div';'more...'})
0576 end
0577 else
0578 set(handles.FieldMenu_1,'Value',1)
0579 set(handles.FieldMenu_1,'String',{'get_field...'})
0580 end
0581 else
0582 view_FieldMenu_1(handles,'off')
0583 end
0584 if testveltype && testcivx
0585 set(handles.VelTypeMenu,'Visible','on')
0586 set(handles.VelType_text,'Visible','on');
0587 else
0588 set(handles.VelTypeMenu,'Visible','off')
0589 set(handles.VelType_text,'Visible','off');
0590 end
0591 if testveltype_1 && testcivx_1
0592 set(handles.VelTypeMenu_1,'Visible','on')
0593 set(handles.VelType_text_1,'Visible','on');
0594 else
0595 set(handles.VelTypeMenu_1,'Visible','off')
0596 set(handles.VelType_text_1,'Visible','off');
0597 end
0598 if testtransform && (testcivx || testima)
0599 view_TRANSFORM(handles,'on')
0600 else
0601 view_TRANSFORM(handles,'off')
0602 end
0603 if ~isequal(FileExt,'.nc') && ~isequal(FileExt,'.cdf') && ~testima
0604 msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
0605 return
0606 end
0607
0608
0609
0610 ext_imadoc='';
0611 if isequal(FileExt,'.xml')||isequal(FileExt,'.civ')
0612 ext_imadoc=FileExt;
0613 elseif exist([FileBase '.xml'],'file')
0614 ext_imadoc='.xml';
0615 elseif exist([FileBase '.civ'],'file')
0616 ext_imadoc='.civ';
0617 end
0618
0619
0620
0621 if isequal(ext_imadoc,'.xml')
0622 [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
0623 if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName')
0624 [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
0625 end
0626 if isfield(XmlData,'Time')
0627 time=XmlData.Time;
0628 end
0629 if isfield(XmlData,'Camera')
0630 if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
0631 NbSlice=XmlData.Camera.NbSlice;
0632 end
0633 if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
0634 TimeUnit=XmlData.Camera.TimeUnit;
0635 end
0636 end
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646 if ~isempty(warntext)
0647 warndlg_uvmat(warntext,'WARNING')
0648 end
0649 elseif isequal(ext_imadoc,'.civ')
0650 [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
0651 time=XmlData.Time;
0652 size(time)
0653 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
0654 GeometryCalib.Tx=0;
0655 GeometryCalib.Ty=0;
0656 GeometryCalib.Tz=1;
0657 GeometryCalib.dpx=1;
0658 GeometryCalib.dpy=1;
0659 GeometryCalib.sx=1;
0660 GeometryCalib.Cx=0;
0661 GeometryCalib.Cy=0;
0662 GeometryCalib.f=1;
0663 GeometryCalib.kappa1=0;
0664 GeometryCalib.CoordUnit='cm';
0665 XmlData.GeometryCalib=GeometryCalib;
0666 if error==2, warntext=['no file ' FileBase '.civ'];
0667 elseif error==1, warntext='inconsistent number of fields in the .civ file';
0668 end
0669
0670
0671
0672
0673
0674
0675
0676
0677 end
0678 if addtest
0679 SeriesData.Time=[{time} SeriesData.Time];
0680 else
0681 SeriesData.Time={time};
0682 end
0683
0684 if ~isempty(time)
0685 siztime=size(time);
0686 nb_field=siztime(1);
0687 nb_field2=siztime(2);
0688 end
0689 set(handles.TimeUnit,'String',TimeUnit)
0690 if isempty(nb_field)
0691 nb_field_str='?';
0692 nb_field_str2='?';
0693 else
0694 nb_field_str=num2str(nb_field);
0695 nb_field_str2=num2str(nb_field2);
0696 end
0697 if addtest
0698 nb_field_cell=[{nb_field_str} ;get(handles.nb_field,'String')];
0699 nb_field2_cell=[{nb_field_str2} ;get(handles.nb_field2,'String')];
0700 else
0701 nb_field_cell={nb_field_str};
0702 nb_field2_cell={nb_field_str2};
0703 end
0704 set(handles.nb_field,'String',nb_field_cell);
0705 set(handles.nb_field2,'String',nb_field2_cell);
0706 set(hseries,'UserData',SeriesData);
0707
0708
0709 if isfield(GeometryCalib,'PlanePos')
0710 siz=size(GeometryCalib.PlanePos);
0711 if siz(1)>1
0712 NbSlice=length(GeometryCalib.PlanePos);
0713 else
0714 NbSlice=1;
0715 end
0716 set(handles.NbSlice,'String',num2str(NbSlice))
0717 end
0718
0719
0720 NomType_Callback(hObject, eventdata, handles)
0721
0722 dir_perso=prefdir;
0723 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
0724
0725 if exist(profil_perso,'file')
0726 save (profil_perso,'RootPath','SubDir','RootFile','NomType', '-append');
0727 else
0728 txt=ver;
0729 Release=txt(1).Release;
0730 relnumb=str2num(Release(3:4));
0731 if relnumb >= 14
0732 save (profil_perso,'RootPath','SubDir','RootFile','NomType','-V6')
0733 else
0734 save(profil_perso,'RootPath','SubDir','RootFile','NomType')
0735 end
0736 end
0737 set(handles.RootPath,'BackgroundColor',[1 1 1])
0738 set(handles.PathCampaign,'String',SeriesData.PathCampaign)
0739 last_j_Callback(hObject, eventdata, handles)
0740 last_i_Callback(hObject, eventdata, handles)
0741
0742
0743 function RootPath_Callback(hObject, eventdata, handles)
0744 Val=get(handles.RootPath,'Value');
0745 synchronise_view(handles,Val)
0746 NomType_Callback(hObject, eventdata, handles)
0747
0748
0749 function synchronise_view(handles,Val)
0750 set(handles.RootPath,'Value',Val)
0751 set(handles.SubDir,'Value',Val)
0752 set(handles.RootFile,'Value',Val)
0753 set(handles.NomType,'Value',Val)
0754 set(handles.FileExt,'Value',Val)
0755 set(handles.nb_field,'Value',Val)
0756 set(handles.nb_field2,'Value',Val)
0757 set(handles.time_first,'Value',Val)
0758 set(handles.time_last,'Value',Val)
0759
0760
0761
0762
0763
0764 function SubDir_Callback(hObject, eventdata, handles)
0765
0766 Val=get(handles.SubDir,'Value');
0767 synchronise_view(handles,Val)
0768 NomType_Callback(hObject, eventdata, handles)
0769
0770
0771
0772
0773 function RootFile_Callback(hObject, eventdata, handles)
0774 Val=get(handles.RootFile,'Value');
0775 synchronise_view(handles,Val)
0776 NomType_Callback(hObject, eventdata, handles)
0777
0778
0779
0780
0781 function FileExt_Callback(hObject, eventdata, handles)
0782 Val=get(handles.FileExt,'Value');
0783 synchronise_view(handles,Val)
0784
0785
0786
0787
0788 function nb_field_Callback(hObject, eventdata, handles)
0789 Val=get(handles.nb_field,'Value');
0790 synchronise_view(handles,Val)
0791
0792
0793
0794
0795 function nb_field2_Callback(hObject, eventdata, handles)
0796 Val=get(handles.nb_field2,'Value');
0797 synchronise_view(handles,Val)
0798
0799
0800
0801
0802 function time_first_Callback(hObject, eventdata, handles)
0803 Val=get(handles.time_first,'Value');
0804 synchronise_view(handles,Val)
0805
0806
0807
0808
0809 function time_last_Callback(hObject, eventdata, handles)
0810 Val=get(handles.time_last,'Value');
0811 synchronise_view(handles,Val)
0812
0813
0814
0815
0816 NomType_Callback(hObject, eventdata, handles)
0817
0818 function NomType_Callback(hObject, eventdata, handles)
0819 hseries=get(handles.ProjObject,'Parent');
0820 SeriesData=get(hseries,'UserData');
0821 if isfield(SeriesData,'NomType')
0822 NomTypeCell=SeriesData.NomType;
0823 else
0824 NomTypeCell={};
0825 end
0826 nbfield2_cell=get(handles.nb_field2,'String');
0827 val=get(handles.nb_field2,'Value');
0828 if iscell(nbfield2_cell)
0829 nbfield2=str2num(nbfield2_cell{val});
0830 else
0831 nbfield2=str2num(nbfield2_cell);
0832 end
0833 nbfield_cell=get(handles.nb_field,'String');
0834 if iscell(nbfield_cell)
0835 nbfield=str2num(nbfield_cell{val});
0836 else
0837 nbfield=str2num(nbfield_cell);
0838 end
0839
0840 set(handles.mode,'Visible','off')
0841 set(handles.list_pair_civ,'Visible','off')
0842 set(handles.ref_i,'Visible','off')
0843 set(handles.ref_i_text,'Visible','off')
0844 testpair=0;
0845 state_j='off';
0846
0847
0848 Val=get(handles.NomType,'Value');
0849 synchronise_view(handles,Val)
0850 if ~isempty(NomTypeCell)
0851 NomType=NomTypeCell{Val};
0852 switch NomType
0853 case {'_i1-i2_j', '_i1-i2'}
0854 set(handles.mode,'String',{'series(Di)'})
0855 set(handles.mode,'Value',1);
0856 set(handles.mode,'Visible','on')
0857 testpair=1;
0858 case {'#_ab'}
0859 set(handles.mode,'String',{'bursts'})
0860 set(handles.mode,'Value',1);
0861 testpair=1;
0862 case '_i_j1-j2'
0863 set(handles.mode,'String',{'bursts';'series(Dj)'})
0864 if ~isempty(nbfield) && ~isempty(nbfield2) && ((nbfield2>10) || (nbfield==1))
0865 set(handles.mode,'Value',2);
0866 else
0867 set(handles.mode,'Value',1);
0868 end
0869 set(handles.mode,'Visible','on')
0870 testpair=1;
0871 end
0872 switch NomType
0873 case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},
0874 state_j='on';
0875 end
0876 end
0877 if testpair
0878 mode_Callback(hObject, eventdata, handles)
0879 else
0880 set(handles.NomType,'String',NomTypeCell)
0881 end
0882 set(handles.first_j,'Visible',state_j)
0883 set(handles.incr_j,'Visible',state_j)
0884 set(handles.last_j,'Visible',state_j)
0885 set(handles.nb_field2,'Visible',state_j)
0886
0887
0888
0889
0890 function mode_Callback(hObject, eventdata, handles)
0891 hseries=get(handles.mode,'parent');
0892 SeriesData=get(hseries,'UserData');
0893 mode_list=get(handles.mode,'String');
0894 mode_value=get(handles.mode,'Value');
0895 mode=mode_list{mode_value};
0896 NomType=[];
0897 test_find_pair=0;
0898 if isfield(SeriesData,'NomType')
0899 NomTypeCell=SeriesData.NomType;
0900 Val=get(handles.NomType,'Value');
0901 NomType=NomTypeCell{Val};
0902 test_find_pair=isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')|| isequal(NomType,'#_ab');
0903 end
0904
0905
0906
0907 time=[];
0908 if isfield(SeriesData,'Time')
0909 time=SeriesData.Time{1};
0910 end
0911 siztime=size(time);
0912 nbfield=siztime(1);
0913 nbfield2=siztime(2);
0914 indchosen=1;
0915 if isequal(mode,'bursts')
0916 enable_i(handles,'On')
0917 enable_j(handles,'Off')
0918 elseif isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')
0919 enable_i(handles,'On')
0920 enable_j(handles,'On')
0921 else
0922 enable_i(handles,'On')
0923 enable_j(handles,'Off')
0924 end
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941 set(handles.list_pair_civ,'Value',indchosen);
0942
0943 set(hseries,'UserData',SeriesData)
0944
0945
0946 if test_find_pair
0947 find_netcpair_civ(hObject, eventdata, handles,Val)
0948 end
0949
0950
0951 function enable_i(handles,state)
0952 set(handles.i_txt,'Visible',state)
0953 set(handles.first_i,'Visible',state)
0954 set(handles.last_i,'Visible',state)
0955 set(handles.incr_i,'Visible',state)
0956 set(handles.nb_field,'Visible',state)
0957 set(handles.ref_i,'Visible',state)
0958 set(handles.ref_i_text,'Visible',state)
0959
0960
0961 function enable_j(handles,state)
0962 set(handles.j_txt,'Visible',state)
0963 set(handles.first_j,'Visible',state)
0964 set(handles.last_j,'Visible',state)
0965 set(handles.incr_j,'Visible',state)
0966 set(handles.nb_field2,'Visible',state)
0967 set(handles.ref_j,'Visible',state)
0968 set(handles.ref_j_text,'Visible',state)
0969
0970
0971 function view_FieldMenu(handles,state)
0972 set(handles.FieldMenu,'Visible',state)
0973 set(handles.Field_text,'Visible',state)
0974 set(handles.Field_frame,'Visible',state)
0975
0976
0977 function view_FieldMenu_1(handles,state)
0978 set(handles.FieldMenu_1,'Visible',state)
0979 set(handles.Field_text_1,'Visible',state)
0980
0981
0982 function view_TRANSFORM(handles,state)
0983 set(handles.TRANSFORM_frame,'Visible',state)
0984 set(handles.CoordType,'Visible',state);
0985 set(handles.TRANSFORM_title,'Visible',state)
0986
0987
0988
0989
0990
0991 function find_netcpair_civ(hObject, eventdata, handles,Val)
0992 hseries=get(handles.list_pair_civ,'parent');
0993 SeriesData=get(hseries,'UserData');
0994
0995 NomTypeCell=SeriesData.NomType;
0996 NomType=NomTypeCell{Val};
0997 set(handles.list_pair_civ,'Visible','on')
0998
0999 RootPathCell=get(handles.RootPath,'String');
1000 filepath=RootPathCell{Val};
1001 RootFileCell=get(handles.RootFile,'String');
1002 filename=RootFileCell{Val};
1003 filebase=fullfile(filepath,filename);
1004 SubDirCell=get(handles.SubDir,'String');
1005 subdir=SubDirCell{Val};
1006 if ~exist(fullfile(filepath,subdir),'dir')
1007 msgbox_uvmat('ERROR',['no civ file available: subdirectory ' subdir ' does not exist'])
1008 set(handles.list_pair_civ,'String',{''});
1009 return
1010 end
1011 mode_list=get(handles.mode,'String');
1012 mode_value=get(handles.mode,'Value');
1013 mode=mode_list{mode_value};
1014
1015
1016 ref_i=str2num(get(handles.ref_i,'String'));
1017 ref_j=str2num(get(handles.ref_j,'String'));
1018
1019
1020 ref_time=0;
1021 if isfield(SeriesData,'Time')&~isempty(SeriesData.Time{Val})&~isequal(SeriesData.Time{Val},0)
1022 time=SeriesData.Time{Val};
1023 siztime=size(time);
1024 nbfield=siztime(1);
1025 nbfield2=siztime(2);
1026
1027 else
1028
1029 nbfield=50;
1030 nbfield2=50;
1031 end
1032
1033
1034 displ_pair={''};
1035 displ_num=[];
1036 ind_exist=0;
1037 TimeUnit=get(handles.TimeUnit,'String');
1038 if length(TimeUnit)>=1
1039 dtunit=['m' TimeUnit];
1040 else
1041 dtunit='e-03';
1042 end
1043 if isequal(mode,'series(Di)')
1044 for index=1:min(nbfield-1,50)
1045 [filename]=name_generator(filebase,ref_i-floor(index/2),ref_j,'.nc',NomType,1,ref_i+ceil(index/2),ref_j,subdir);
1046 select=(exist(filename,'file')==2);
1047 if select==1
1048 ind_exist=ind_exist+1;
1049 displ_num(1,ind_exist)=0;
1050 displ_num(2,ind_exist)=0;
1051 displ_num(3,ind_exist)=-floor(index/2);
1052 displ_num(4,ind_exist)=ceil(index/2);
1053
1054 [Cte,var_detect,ichoice]=nc2struct(filename,{});
1055 if isfield(Cte,'dt2')
1056 dt=Cte.dt2;
1057 elseif isfield(Cte,'dt')
1058 dt=Cte.dt;
1059 end
1060 if isfield(Cte,'absolut_time_TO_2')
1061 ref_time(ind_exist)=Cte.absolut_time_TO_2;
1062 elseif isfield(Cte,'absolut_time_TO')
1063 ref_time(ind_exist)=Cte.absolut_time_TO;
1064 elseif isfield(Cte,'Time')
1065 ref_time(ind_exist)=Cte.Time;
1066 end
1067 displ_pair{ind_exist}=['Di= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit];
1068 end
1069 end
1070 set(handles.list_pair_civ,'String',[displ_pair';{'Di=*|*'}]);
1071 elseif isequal(mode,'series(Dj)')
1072 for index=1:min(nbfield2-1,50)
1073 [filename]=name_generator(filebase,ref_i,ref_j-floor(index/2),'.nc',NomType,1,ref_i,ref_j+ceil(index/2),subdir);
1074 select=(exist(filename,'file')==2);
1075 if select==1
1076 ind_exist=ind_exist+1;
1077 displ_num(1,ind_exist)=-floor(index/2);
1078 displ_num(2,ind_exist)=ceil(index/2);
1079 displ_num(3,ind_exist)=0;
1080 displ_num(4,ind_exist)=0;
1081
1082 [Cte,var_detect,ichoice]=nc2struct(nc,{});
1083 if isfield(Cte,'dt2')
1084 dt=Cte.dt2;
1085 elseif isfield(Cte,'dt')
1086 dt=Cte.dt;
1087 end
1088 if isfield(Cte,'absolut_time_TO_2')
1089 ref_time(ind_exist)=Cte.absolut_time_TO_2;
1090 elseif isfield(Cte,'absolut_time_TO')
1091 ref_time(ind_exist)=Cte.absolut_time_TO;
1092 elseif isfield(Cte,'Time')
1093 ref_time(ind_exist)=Cte.Time;
1094 end
1095
1096
1097
1098
1099
1100
1101
1102 displ_pair{ind_exist}=['Dj= ' num2str(-floor(index/2)) '|' num2str(ceil(index/2)) ' :dt= ' num2str(dt*1000) dtunit];
1103 end
1104 end
1105 set(handles.list_pair_civ,'String',[displ_pair';{'Dj=*|*'}]);
1106 elseif isequal(mode,'bursts')
1107 for numod_a=1:nbfield2-1
1108 for numod_b=(numod_a+1):nbfield2
1109 [filename]=name_generator(filebase,ref_i,numod_a,'.nc',NomType,1,ref_i,numod_b,subdir);
1110 select=(exist(filename,'file')==2);
1111 if select==1
1112 ind_exist=ind_exist+1;
1113 numlist_a(ind_exist)=numod_a;
1114 numlist_b(ind_exist)=numod_b;
1115 Attr=nc2struct(filename,[]);
1116 isfield(Attr,'absolut_time_T0_2')
1117 if isfield(Attr,'dt2')
1118 dt(ind_exist)=Attr.dt2;
1119 ref_time(ind_exist)=Attr.absolut_time_T0_2;
1120 elseif isfield(Attr,'dt')& isfield(Attr,'absolut_time_T0')
1121 dt(ind_exist)=Attr.dt;
1122 ref_time(ind_exist)=Attr.absolut_time_T0;
1123 else
1124 dt(ind_exist)=NaN;
1125 end
1126
1127 switch NomType
1128 case {'#ab'}
1129 nom_type_ima='#a';
1130 case {'#AB'}
1131 nom_type_ima='#A';
1132 otherwise
1133 nom_type_ima='_i_j';
1134 end
1135 displ_pair{ind_exist}=['j= ' num2stra(numod_a,nom_type_ima,2) '-' num2stra(numod_b,nom_type_ima,2) ...
1136 ' :dt= ' num2str(dt(ind_exist)*1000)];
1137 end
1138 end
1139 set(handles.list_pair_civ,'String',[displ_pair';{'j=*-*'}]);
1140 end
1141 if exist('dt','var') & ~isempty(dt)
1142 [dtsort,indsort]=sort(dt);
1143 displ_num(1,:)=numlist_a(indsort);
1144 displ_num(2,:)=numlist_b(indsort);
1145 displ_num(3,:)=0;
1146 displ_num(4,:)=0;
1147 displ_pair=displ_pair(indsort);
1148 ref_time=ref_time(indsort);
1149 end
1150 end
1151 if ind_exist==0
1152 if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)')
1153 msgbox_uvmat('ERROR',['no .nc file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir])
1154 else
1155 msgbox_uvmat('ERROR',['no .nc file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir])
1156 end
1157 if isequal(mode,'bursts')
1158 set(handles.list_pair_civ,'String',{'j=*-*'});
1159 elseif isequal(mode,'series(Di)')
1160 set(handles.list_pair_civ,'String',{'Di=*|*'});
1161 elseif isequal(mode,'series(Dj)')
1162 set(handles.list_pair_civ,'String',{'Dj=*|*'});
1163 end
1164 end
1165
1166 val=get(handles.list_pair_civ,'Value');
1167 if val > length(displ_pair)
1168 set(handles.list_pair_civ,'Value',1);
1169 val=1;
1170 end
1171 iview=get(handles.NomType,'Value');
1172 SeriesData.displ_num(iview,:)=(displ_num(:,val))';
1173 SeriesData.ref_time=ref_time;
1174 set(hseries,'UserData',SeriesData)
1175 list_pair_civ_Callback(hObject, eventdata, handles)
1176
1177
1178
1179 function list_pair_civ_Callback(hObject, eventdata, handles)
1180
1181
1182
1183 testupdate=0;
1184 Val=get(handles.RootPath,'Value');
1185 IndexCell=get(handles.NomType,'String');
1186 hseries=get(handles.list_pair_civ,'parent');
1187 SeriesData=get(hseries,'UserData');
1188 NomType=SeriesData.NomType{Val};
1189 list_pair=get(handles.list_pair_civ,'String');
1190 index_pair=get(handles.list_pair_civ,'Value');
1191 str_pair=list_pair{index_pair};
1192 ind_equ=strfind(str_pair,'=');
1193 ind_sep=strfind(str_pair,'|');
1194 ind_com=strfind(str_pair,':');
1195 test_bursts=0;
1196 if isempty(ind_sep)
1197 ind_sep=strfind(str_pair,'-');
1198 test_bursts=1;
1199 end
1200 displ_num=[0 0 0 0];
1201 if ~isempty(ind_sep)
1202 num1_str=str_pair(ind_equ(1)+1:ind_sep-1);
1203 num2_str=str_pair(ind_sep+1:ind_com-1);
1204 num1=str2double(num1_str);
1205 num2=str2double(num2_str);
1206 if isequal(num1_str(1),' ')
1207 num1_str(1)=[];
1208 end
1209 if isequal(num2_str(end),' ')
1210 num2_str(end)=[];
1211 end
1212 switch NomType
1213 case {'_i1-i2_j'}
1214 if isequal(num1_str(1),'0')
1215 IndexCell{Val}=['_(i-(i+' num2_str ')_j'];
1216 else
1217 IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')_j'];
1218 end
1219 displ_num(3)=num1;
1220 displ_num(4)=num2;
1221 case {'_i1-i2'}
1222 if isequal(num1_str(1),'0')
1223 IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
1224 else
1225 IndexCell{Val}=['_(i' num1_str ')-(i+' num2_str ')'];
1226 end
1227 displ_num(3)=num1;
1228 displ_num(4)=num2;
1229 case '_i_j1-j2'
1230 if test_bursts
1231 IndexCell{Val}=['_i_' num1_str '-' num2_str ];
1232 else
1233 if isequal(num1_str(1),'0')
1234 IndexCell{Val}=['_i_j-(j+' num2_str ')'];
1235 else
1236 IndexCell{Val}=['_i_(j' num1_str ')-(j+' num2_str ')'];
1237 end
1238 end
1239 displ_num(1)=num1;
1240 displ_num(2)=num2;
1241 case {'#_ab'}
1242 IndexCell{Val}=['_i_' num1_str '-' num2_str ];
1243
1244 end
1245 end
1246 set(handles.NomType,'String',IndexCell)
1247 size(SeriesData.displ_num)
1248 size(displ_num)
1249 SeriesData.displ_num(Val,:)=displ_num;
1250 set(hseries,'UserData',SeriesData)
1251
1252
1253 if ~isequal(str_pair,'Dj=*|*')&~isequal(str_pair,'Di=*|*')
1254 mode_list=get(handles.mode,'String');
1255 mode_value=get(handles.mode,'Value');
1256 mode=mode_list{mode_value};
1257 if isequal(mode,'series(Di)')
1258 first_i=str2num(get(handles.first_i,'String'));
1259 last_i=str2num(get(handles.last_i,'String'));
1260 incr_i=str2num(get(handles.incr_i,'String'));
1261 num1=first_i:incr_i:last_i;
1262 lastfieldCell=get(handles.nb_field,'String');
1263 lastfield=str2num(lastfieldCell{1});
1264 if ~isempty(lastfield)
1265 ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield));
1266 num1=num1(ind);
1267 end
1268 set(handles.first_i,'String',num2str(num1(1)));
1269 set(handles.last_i,'String',num2str(num1(end)));
1270 testupdate=1;
1271 elseif isequal(mode,'series(Dj)')
1272 first_j=str2num(get(handles.first_j,'String'));
1273 last_j=str2num(get(handles.last_j,'String'));
1274 incr_j=str2num(get(handles.incr_j,'String'));
1275 num_j=first_j:incr_j:last_j;
1276 lastfieldCell=get(handles.nb_field2,'String');
1277 if ~isempty(lastfieldCell)
1278 lastfield2=lastfieldCell{1};
1279 ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
1280 (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2));
1281
1282
1283
1284
1285
1286 end
1287
1288
1289 testupdate=1;
1290 end
1291
1292
1293 if testupdate & isfield(SeriesData,'Time')
1294 if ~isempty(SeriesData.Time{1})
1295 displ_time(handles,SeriesData.Time{1});
1296 end
1297 end
1298 end
1299
1300
1301
1302 function RUN_Callback(hObject, eventdata, handles)
1303
1304
1305
1306
1307
1308 set(handles.RUN,'BusyAction','queue');
1309 hseries=get(handles.RUN,'parent');
1310 set(0,'CurrentFigure',hseries)
1311 if isequal(get(handles.GetObject,'Value'),1)
1312 Series.GetObject=1;
1313 GetObject_Callback(hObject, eventdata, handles)
1314 else
1315 Series.GetObject=0;
1316 end
1317 SeriesData=get(hseries,'UserData');
1318 if isfield(SeriesData,'sethandles')
1319 if iscell(SeriesData.sethandles)
1320 Series.sethandles=SeriesData.sethandles{1};
1321 else
1322 Series.sethandles=SeriesData.sethandles;
1323 end
1324 end
1325
1326 Series.WaitbarPos=get(handles.waitbar_frame,'Position');
1327 waitbarpos=Series.WaitbarPos;
1328 waitbarpos(4)=0.005;
1329 waitbarpos(2)=Series.WaitbarPos(2)+Series.WaitbarPos(4)-0.005;
1330 set(handles.waitbar,'Position',waitbarpos)
1331
1332
1333
1334 Series.PathProject=get(handles.PathCampaign,'String');
1335 RootPath=get(handles.RootPath,'String');
1336 RootFile=get(handles.RootFile,'String');
1337
1338 SubDir=get(handles.SubDir,'String');
1339 FileExt=get(handles.FileExt,'String');
1340
1341 if isempty(SeriesData)
1342 msgbox_uvmat('ERROR','no input file series')
1343 return
1344 end
1345 NomType=SeriesData.NomType;
1346 if length(RootPath)==1
1347 Series.RootPath=RootPath{1};
1348 Series.RootFile=RootFile{1};
1349 Series.SubDir=SubDir{1};
1350 Series.FileExt=FileExt{1};
1351 Series.NomType=NomType{1};
1352 else
1353 Series.RootPath=RootPath;
1354 Series.RootFile=RootFile;
1355 Series.SubDir=SubDir;
1356 Series.FileExt=FileExt;
1357 Series.NomType=NomType;
1358 end
1359 if isequal(get(handles.FieldMenu,'Visible'),'on')
1360 FieldMenu=get(handles.FieldMenu,'String');
1361 FieldValue=get(handles.FieldMenu,'Value');
1362 Series.Field=FieldMenu(FieldValue);
1363 end
1364 menu_coord_state=get(handles.CoordType,'Visible');
1365 Series.CoordType='';
1366 if isequal(menu_coord_state,'on')
1367 menu_coord=get(handles.CoordType,'String');
1368 menu_index=get(handles.CoordType,'Value');
1369 Series.CoordType=menu_coord{menu_index};
1370 end
1371 Series.hseries=get(hObject,'Parent');
1372 if isequal(get(handles.ParamVal,'Visible'),'on')
1373 ParamKey=get(handles.ParamKey,'String');
1374 if ischar(ParamKey)
1375 ParamKey{1}=ParamKey;
1376 end
1377 ParamString=get(handles.ParamVal,'String');
1378 if ischar(ParamString)
1379 for ilist=1:size(ParamString,1)
1380 ParamVal{ilist}=ParamString(ilist,:);
1381 end
1382 else
1383 ParamVal=ParamString;
1384 end
1385 end
1386
1387
1388 first_i=str2num(get(handles.first_i,'String'));
1389 last_i=str2num(get(handles.last_i,'String'));
1390 incr_i=str2num(get(handles.incr_i,'String'));
1391 first_j=str2num(get(handles.first_j,'String'));
1392 last_j=str2num(get(handles.last_j,'String'));
1393 incr_j=str2num(get(handles.incr_j,'String'));
1394 if ~isequal(get(handles.first_i,'Visible'),'on')
1395 first_i=1;
1396 last_i=1;
1397 incr_i=1;
1398 end
1399 if ~isequal(get(handles.first_j,'Visible'),'on')
1400 first_j=1;
1401 last_j=1;
1402 incr_j=1;
1403 end
1404 Series.NbSlice=str2num(get(handles.NbSlice,'String'));
1405 if isequal(first_i,[])|isequal(first_j,[]), msgbox_uvmat('ERROR','first field number not defined'),...
1406 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1407 if isequal(last_i,[])| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),...
1408 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1409 if isequal(incr_i,[])| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),...
1410 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1411 if last_i < first_i | last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
1412 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end;
1413 num_i=[first_i:incr_i:last_i];
1414 num_j=[first_j:incr_j:last_j];
1415 nbfield_cell=get(handles.nb_field,'String');
1416 nbfield=[];
1417 for iview=1:length(nbfield_cell)
1418 nb=str2num(nbfield_cell{iview});
1419 if ~isempty(nb)
1420 nbfield=[nbfield nb];
1421 end
1422 end
1423 nbfield=min(nbfield);
1424 nbfield2_cell=get(handles.nb_field2,'String');
1425 nbfield2=[];
1426 for iview=1:length(nbfield2_cell)
1427 nb=str2num(nbfield2_cell{iview});
1428 if ~isempty(nb)
1429 nbfield2=[nbfield2 nb];
1430 end
1431 end
1432 nbfield2=min(nbfield2);
1433
1434
1435
1436
1437 list_action=get(handles.ACTION,'String');
1438 index_action=get(handles.ACTION,'Value');
1439 action= list_action{index_action};
1440 mode_list=get(handles.mode,'String');
1441 index_mode=get(handles.mode,'Value');
1442 mode=mode_list{index_mode};
1443 ind_shift=0;
1444
1445
1446 nbmissing=0;
1447 for iview=1:length(RootPath)
1448
1449 if isequal(NomType{iview},'_i_j1-j2')| isequal(NomType{iview},'_i1-i2_j')| isequal(NomType{iview},'_i1-i2')| isequal(NomType{iview},'#_ab')
1450 ind_shift=SeriesData.displ_num(iview,:);
1451 if isequal(ind_shift,[0 0 0 0])
1452 if isequal(NomType{iview},'#_ab')
1453 mode='#_ab';
1454 end
1455 [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(fullfile(RootPath{iview},RootFile{iview}),SubDir{iview},mode,first_i,incr_i,last_i,first_j,incr_j,last_j);
1456 else
1457 [num_i1,num_i2,num_j1,num_j2,num_i,num_j]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode);
1458 if isempty(num_i)
1459 warndlg_uvmat('empty set of input files chosen','ERRROR')
1460 return
1461 end
1462 if num_i(1)>first_i
1463 set(handles.first_i,'String',num2str(num_i(1)))
1464 last_i_Callback(hObject, eventdata, handles)
1465 end
1466 if num_i(end)<last_i
1467 set(handles.last_i,'String',num2str(num_i(end)))
1468 last_i_Callback(hObject, eventdata, handles)
1469 end
1470 if num_j(1)>first_j
1471 set(handles.first_j,'String',num2str(num_j(1)))
1472 last_j_Callback(hObject, eventdata, handles)
1473 end
1474 if num_j(end)<last_j
1475 set(handles.last_j,'String',num2str(num_j(end)))
1476 last_j_Callback(hObject, eventdata, handles)
1477 end
1478 end
1479 else
1480 [num_i1,num_j1]=meshgrid(num_i,num_j);
1481 num_i2=num_i1;
1482 num_j2=num_j1;
1483 end
1484 if length(RootPath)>1
1485 num_i1_cell{iview}=num_i1;
1486 num_i2_cell{iview}=num_i2;
1487 num_j1_cell{iview}=num_j1;
1488 num_j2_cell{iview}=num_j2;
1489 end
1490 end
1491
1492
1493 path_series=which('series');
1494 list_path=get(handles.ACTION,'UserData');
1495 index=get(handles.ACTION,'Value');
1496 fct_path=list_path{index};
1497 if ~isequal(fct_path,path_series)
1498 eval(['spath=which(''' action ''');'])
1499 if ~isequal(spath,fct_path)& exist(fct_path,'dir')
1500 addpath(fct_path)
1501 end
1502 end
1503 Series.Action=action;
1504 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784])
1505 if length(RootPath)>1
1506 feval(action,num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series);
1507 else
1508 feval(action,num_i1,num_i2,num_j1,num_j2,Series);
1509 end
1510 set(handles.RUN,'BackgroundColor',[1 0 0])
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527 function STOP_Callback(hObject, eventdata, handles)
1528 set(handles.RUN, 'BusyAction','cancel')
1529 set(handles.RUN,'BackgroundColor',[1 0 0])
1530
1531
1532
1533
1534 function first_i_Callback(hObject, eventdata, handles)
1535 last_i_Callback(hObject, eventdata, handles)
1536
1537
1538 function last_i_Callback(hObject, eventdata, handles)
1539 hseries=get(handles.last_i,'parent');
1540 first_i=str2num(get(handles.first_i,'String'));
1541 last_i=str2num(get(handles.last_i,'String'));
1542 ref_i=ceil((first_i+last_i)/2);
1543 set(handles.ref_i,'String', num2str(ref_i))
1544 ref_i_Callback(hObject, eventdata, handles)
1545 SeriesData=get(hseries,'UserData');
1546 if ~isfield(SeriesData,'Time')
1547 SeriesData.Time{1}=[];
1548 end
1549 displ_time(handles,SeriesData.Time{1});
1550
1551
1552 function first_j_Callback(hObject, eventdata, handles)
1553 last_j_Callback(hObject, eventdata, handles)
1554
1555
1556 function last_j_Callback(hObject, eventdata, handles)
1557 hseries=get(handles.last_i,'parent');
1558 first_j=str2num(get(handles.first_j,'String'));
1559 last_j=str2num(get(handles.last_j,'String'));
1560 ref_j=ceil((first_j+last_j)/2);
1561 set(handles.ref_j,'String', num2str(ref_j))
1562
1563 ref_j_Callback(hObject, eventdata, handles)
1564 SeriesData=get(hseries,'UserData');
1565 if ~isfield(SeriesData,'Time')
1566 SeriesData.Time{1}=[];
1567 end
1568 displ_time(handles,SeriesData.Time{1});
1569
1570
1571
1572
1573
1574 function ref_i_Callback(hObject, eventdata, handles)
1575 mode_list=get(handles.mode,'String');
1576 mode_value=get(handles.mode,'Value');
1577 mode=mode_list{mode_value};
1578 hseries=get(handles.ref_i,'parent');
1579 SeriesData=get(hseries,'UserData');
1580
1581 NomTypeCell=SeriesData.NomType;
1582 if ~isempty(NomTypeCell)
1583 Val=get(handles.NomType,'Value');
1584 NomType=NomTypeCell{Val};
1585
1586 if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')
1587 if isequal(mode,'series(Di)')
1588 find_netcpair_civ(hObject, eventdata, handles,Val);
1589
1590 end
1591 end
1592 end
1593
1594
1595 function ref_j_Callback(hObject, eventdata, handles)
1596 mode_list=get(handles.mode,'String');
1597 mode_value=get(handles.mode,'Value');
1598 mode=mode_list{mode_value};
1599 hseries=get(handles.ref_i,'parent');
1600 SeriesData=get(hseries,'UserData');
1601
1602 NomTypeCell=SeriesData.NomType;
1603 if ~isempty(NomTypeCell)
1604 Val=get(handles.NomType,'Value');
1605 NomType=NomTypeCell{Val};
1606
1607 if isequal(NomType,'_i_j1-j2')|| isequal(NomType,'_i1-i2_j')|| isequal(NomType,'_i1-i2')
1608 if isequal(mode,'series(Dj)')
1609 find_netcpair_civ(hObject, eventdata, handles,Val);
1610
1611 end
1612 end
1613 end
1614
1615
1616
1617 function ACTION_Callback(hObject, eventdata, handles)
1618 list_ACTION=get(handles.ACTION,'String');
1619 index_ACTION=get(handles.ACTION,'Value');
1620 ACTION= list_ACTION{index_ACTION};
1621 path_series=which('series');
1622 list_path=get(handles.ACTION,'UserData');
1623 nb_builtin=0;
1624 for ilist=1:length(list_path)
1625 if isequal(list_path{ilist},path_series)
1626 nb_builtin=nb_builtin+1;
1627 else
1628 break
1629 end
1630 end
1631 if nb_builtin==0
1632 series_OpeningFcn(hObject, eventdata, handles)
1633 return
1634 end
1635
1636
1637 if isequal(ACTION,'more...')
1638 pathfct=fileparts(path_series);
1639 browse_name=fullfile(path_series,'SERIES_FCT');
1640 if length(list_path)>nb_builtin
1641 browse_name=list_path{end};
1642 end
1643 [FileName, PathName, filterindex] = uigetfile( ...
1644 {'*.m', ' (*.m)';
1645 '*.m', '.m files '; ...
1646 '*.*', 'All Files (*.*)'}, ...
1647 'Pick a file',browse_name);
1648 if length(FileName)<2
1649 return
1650 end
1651 ext_fct=FileName(end-1:end);
1652 if ~isequal(ext_fct,'.m')
1653 msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
1654 return
1655 end
1656 ACTION=FileName(1:end-2);
1657
1658
1659 menu_str=update_menu(handles.ACTION,ACTION);
1660 index_ACTION=get(handles.ACTION,'Value');
1661 list_path{index_ACTION}=PathName;
1662 if length(menu_str)>nb_builtin+5;
1663 nbremove=length(menu_str)-nb_builtin-5;
1664 menu_str(nb_builtin+1:end-5)=[];
1665 list_path(nb_builtin+1:end-4)=[];
1666 index_ACTION=index_ACTION-nbremove;
1667 set(handles.ACTION,'Value',index_ACTION)
1668 set(handles.ACTION,'String',menu_str)
1669 end
1670 list_path{index_ACTION}=PathName;
1671 set(handles.ACTION,'UserData',list_path);
1672 set(handles.path,'enable','inactive')
1673
1674
1675 dir_perso=prefdir;
1676 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
1677 for ilist=nb_builtin+1:length(menu_str)-1
1678 series_fct{ilist-nb_builtin}=fullfile(list_path{ilist},[menu_str{ilist} '.m']);
1679 end
1680 if exist(profil_perso,'file')
1681 save(profil_perso,'series_fct','-append')
1682 else
1683 txt=ver;
1684 Release=txt(1).Release;
1685 relnumb=str2num(Release(3:4));
1686 if relnumb >= 14
1687 save(profil_perso,'series_fct','-V6')
1688 else
1689 save(profil_perso, 'series_fct')
1690 end
1691 end
1692 end
1693
1694
1695 PathName=list_path{index_ACTION};
1696 if ~isequal(path_series,PathName)
1697 CurrentPath=fileparts(which(ACTION));
1698 if ~isequal(PathName,CurrentPath)
1699 addpath(PathName)
1700 errormsg=check_functions;
1701 msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
1702 end
1703 end
1704 set(handles.path,'String',PathName);
1705
1706
1707
1708 set(handles.RootPath,'UserData','many')
1709 set(handles.SubDir,'Visible','on')
1710 set(handles.RootFile,'Visible','on')
1711 set(handles.NomType,'Visible','on')
1712 set(handles.FileExt,'Visible','on')
1713 set(handles.NbSlice,'Visible','off')
1714 set(handles.NbSlice_title,'Visible','off')
1715 set(handles.VelTypeMenu,'Visible','off');
1716 set(handles.VelType_text,'Visible','off');
1717 set(handles.VelTypeMenu_1,'Visible','off');
1718 set(handles.VelType_text_1,'Visible','off');
1719 view_FieldMenu(handles,'off')
1720 view_FieldMenu_1(handles,'off')
1721 view_TRANSFORM(handles,'off')
1722 set(handles.ProjObject_frame,'Visible','off');
1723 set(handles.GetMask,'Visible','off')
1724 set(handles.Mask,'Visible','off')
1725 set(handles.GetObject,'Visible','off');
1726 set(handles.ProjObject,'Visible','off');
1727 set(handles.OutputDir,'Visible','off');
1728 set(handles.PARAMETERS_frame,'Visible','off');
1729 set(handles.PARAMETERS_title,'Visible','off');
1730 set(handles.ParamKey,'Visible','off')
1731 set(handles.ParamVal,'Visible','off')
1732 ParamKey={};
1733 set(handles.FieldMenu,'Enable','off')
1734 set(handles.VelTypeMenu,'Enable','off')
1735 set(handles.FieldMenu_1,'Enable','off')
1736 set(handles.VelTypeMenu_1,'Enable','off')
1737 set(handles.CoordType,'Enable','off')
1738
1739
1740 varargout=feval(ACTION);
1741 Param_list={};
1742
1743
1744
1745
1746 FileExt=get(handles.FileExt,'String');
1747 nb_series=length(FileExt);
1748 testima_series=1;
1749 testima=1;
1750 testima_1=1;
1751 testciv_series=1;
1752 for iview=1:nb_series
1753 ext=FileExt{iview};
1754 if length(ext)<2
1755 ext='.none';
1756 end
1757 testimaview=~isempty(imformats(ext(2:end))) || isequal(lower(ext),'.avi');
1758 if ~testimaview
1759 if iview==1
1760 testima=0;
1761 end
1762 if iview==2
1763 testima_1=0;
1764 end
1765 testima_series=0;
1766 end
1767 end
1768 for ilist=1:length(varargout)-1
1769 switch varargout{ilist}
1770
1771 case 'RootPath'
1772 value=lower(varargout{ilist+1});
1773 if isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
1774 set(handles.RootFile,'UserData',value)
1775 end
1776 case 'SubDir'
1777 if isequal(lower(varargout{ilist+1}),'off')
1778 set(handles.SubDir,'Visible','off')
1779 end
1780 case 'RootFile'
1781 value=lower(varargout{ilist+1});
1782 if isequal(value,'off')
1783 set(handles.RootFile,'Visible','off')
1784 elseif isequal(value,'one')||isequal(value,'two')||isequal(value,'many')
1785 set(handles.RootFile,'Visible','on')
1786 set(handles.RootFile,'UserData',value)
1787 end
1788 case 'NomType'
1789 if isequal(lower(varargout{ilist+1}),'off')
1790 set(handles.NomType,'Visible','off')
1791 end
1792 case 'FileExt'
1793 if isequal(lower(varargout{ilist+1}),'off')
1794 set(handles.FileExt,'Visible','off')
1795 end
1796 case 'NbSlice'
1797 if isequal(lower(varargout{ilist+1}),'on')
1798 set(handles.NbSlice,'Visible','on')
1799 set(handles.NbSlice_title,'Visible','on')
1800 end
1801 case 'VelTypeMenu'
1802 if isequal(lower(varargout{ilist+1}),'one') || isequal(lower(varargout{ilist+1}),'two')
1803 set(handles.VelTypeMenu,'Enable','on')
1804 if nb_series >=1 && ~testima_series
1805 set(handles.VelTypeMenu,'Visible','on')
1806 set(handles.VelType_text,'Visible','on');
1807 set(handles.Field_frame,'Visible','on')
1808 end
1809 end
1810 if isequal(lower(varargout{ilist+1}),'two')
1811 set(handles.VelTypeMenu_1,'Enable','on')
1812 if nb_series >=2 && ~testima_series
1813 set(handles.VelTypeMenu_1,'Visible','on')
1814 set(handles.VelType_text_1,'Visible','on');
1815 end
1816 end
1817 case 'FieldMenu'
1818 if isequal(lower(varargout{ilist+1}),'one')||isequal(lower(varargout{ilist+1}),'two')
1819 set(handles.FieldMenu,'Enable','on')
1820 if nb_series >=1 && ~testima_series
1821 view_FieldMenu(handles,'on')
1822 end
1823 end
1824 if isequal(lower(varargout{ilist+1}),'two')
1825 set(handles.FieldMenu_1,'Enable','on')
1826 if nb_series >=2 && ~testima_1
1827 view_FieldMenu_1(handles,'on')
1828 end
1829 end
1830 case 'CoordType'
1831 if isequal(lower(varargout{ilist+1}),'on')
1832 set(handles.CoordType,'Enable','on')
1833 view_TRANSFORM(handles,'on')
1834 end
1835 case 'GetObject'
1836 if isequal(lower(varargout{ilist+1}),'on')
1837 set(handles.ProjObject_frame,'Visible','on')
1838 set(handles.GetObject,'Visible','on');
1839 end
1840 case 'Mask'
1841 if isequal(lower(varargout{ilist+1}),'on')
1842 set(handles.ProjObject_frame,'Visible','on')
1843 set(handles.GetMask,'Visible','on');
1844 end
1845 case 'PARAMETER'
1846 set(handles.PARAMETERS_frame,'Visible','on')
1847 set(handles.PARAMETERS_title,'Visible','on')
1848 set(handles.ParamKey,'Visible','on')
1849
1850 Param_str=varargout{ilist+1};
1851 Param_list=[Param_list; {Param_str}];
1852 end
1853 end
1854 if ~isempty(Param_list)
1855 set(handles.ParamKey,'String',Param_list)
1856 set(handles.ParamVal,'Visible','on')
1857 end
1858
1859
1860
1861
1862 function FieldMenu_Callback(hObject, eventdata, handles)
1863
1864 field_str=get(handles.FieldMenu,'String');
1865 field_index=get(handles.FieldMenu,'Value');
1866 field=field_str{field_index(1)};
1867 if isequal(field,'get_field...')
1868 hget_field=findobj(allchild(0),'name','get_field');
1869 if ~isempty(hget_field)
1870 delete(hget_field)
1871 end
1872 hseries=get(handles.FieldMenu,'parent');
1873 SeriesData=get(hseries,'UserData');
1874 filename=SeriesData.CurrentInputFile;
1875 if exist(filename,'file')
1876 get_field(filename)
1877 end
1878 elseif isequal(field,'more...')
1879 str=calc_field;
1880 [ind_answer,v] = listdlg('PromptString','Select a file:',...
1881 'SelectionMode','single',...
1882 'ListString',str);
1883
1884 scalar=cell2mat(str(ind_answer));
1885 update_menu(handles.FieldMenu,scalar)
1886 end
1887
1888
1889
1890
1891 function FieldMenu_1_Callback(hObject, eventdata, handles)
1892 field_str=get(handles.FieldMenu_1,'String');
1893 field_index=get(handles.FieldMenu_1,'Value');
1894 field=field_str{field_index};
1895 if isequal(field,'get_field...')
1896 hget_field=findobj(allchild(0),'name','get_field_1');
1897 if ~isempty(hget_field)
1898 delete(hget_field)
1899 end
1900 hseries=get(handles.FieldMenu,'parent');
1901 SeriesData=get(hseries,'UserData');
1902 filename=SeriesData.CurrentInputFile_1;
1903 if exist(filename,'file')
1904 hget_field=get_field(filename);
1905 set(hget_field,'name','get_field_1')
1906 end
1907 elseif isequal(field,'more...')
1908 str=calc_field;
1909 [ind_answer,v] = listdlg('PromptString','Select a file:',...
1910 'SelectionMode','single',...
1911 'ListString',str);
1912
1913 scalar=cell2mat(str(ind_answer));
1914 update_menu(handles.FieldMenu_1,scalar)
1915 end
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927 function GUI_input=check_files(num_i1_cell,num_i2_cell,num_j1_cell,num_j2_cell,Series)
1928
1929
1930 if ~exist('num_i1_cell','var')
1931 GUI_input={'RootPath';'many';...
1932 'SubDir';'on';...
1933 'RootFile';'on';...
1934 'FileExt';'on';...
1935 'NomType';'on';...
1936 'NbSlice';'on'; ...
1937
1938
1939
1940
1941
1942
1943 ''};
1944 return
1945 end
1946
1947
1948 hseries=guidata(Series.hseries);
1949 WaitbarPos=get(hseries.waitbar_frame,'Position');
1950
1951
1952
1953
1954 NbSlice=str2num(get(hseries.NbSlice,'String'));
1955 if isempty(NbSlice)
1956 NbSlice=1;
1957 end
1958 NbSlice_name=num2str(NbSlice);
1959 if isequal(NbSlice,[]),NbSlice=1; end;
1960
1961
1962 count=0;
1963 testcell=iscell(Series.RootFile);
1964 if ~testcell
1965 Series.RootPath={Series.RootPath};
1966 Series.RootFile={Series.RootFile};
1967 Series.SubDir={Series.SubDir};
1968 Series.FileExt={Series.FileExt};
1969 Series.NomType={Series.NomType};
1970 end
1971 nbview=length(Series.RootFile);
1972 for iview=1:nbview
1973 filebase=fullfile(Series.RootPath{iview},Series.RootFile{iview});
1974 if testcell
1975 num_i1=num_i1_cell{iview}; num_i2=num_i2_cell{iview}; num_j1=num_j1_cell{iview}; num_j2=num_j2_cell{iview};
1976 else
1977 num_i1=num_i1_cell; num_i2=num_i2_cell; num_j1=num_j1_cell; num_j2=num_j2_cell;
1978 end
1979 siz=size(num_i1);
1980 nbfield2=siz(1);
1981 nbfield=siz(1)*siz(2);
1982 nbfield=floor(nbfield/(nbfield2*NbSlice));
1983 if isequal(lower(Series.FileExt{iview}),'.avi')
1984 info=aviinfo([filebase Series.FileExt{iview}]);
1985 message{1}=info.Filename;
1986 message{2}=info.FileModDate;
1987 message{3}=[num2str(info.FramesPerSecond) ' frames/s '];
1988 message{4}=info.ImageType;
1989 message{5}=[' compression' info.VideoCompression];
1990 message{6}=[ 'quality ' num2str(info.Quality)];
1991 Tabchar=message;
1992 else
1993 datnum=[];
1994 Tabchar={};
1995
1996 for i_slice=1:NbSlice
1997 for ifield=1:nbfield
1998 indselect(:,ifield)=((ifield-1)*NbSlice+(i_slice-1))*nbfield2+[1:nbfield2]';
1999 end
2000 for index=1:nbfield*nbfield2
2001 stopstate=get(hseries.RUN,'BusyAction');
2002 if isequal(stopstate,'queue')
2003
2004
2005
2006 update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
2007 ifile=indselect(index);
2008
2009 [file,idetect]=...
2010 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});
2011
2012 [Path,Name,ext]=fileparts(file);
2013 detect=exist(file,'file');
2014 if detect==0
2015 count=count+1;
2016 lastfield='not found';
2017 else
2018 datfile=dir(file);
2019 datnum(ifile)=datenum(datfile.date);
2020 filefound(ifile)={datfile.name};
2021 lastfield='';
2022 if isequal(Series.FileExt{iview},'.nc') || isequal(Series.FileExt{iview},'.cdf')
2023
2024 Data=nc2struct(file,[]);
2025
2026 if isfield(Data,'patch2') & isequal(Data.patch2,1);
2027 lastfield='patch2';
2028 elseif isfield(Data,'fix2') & isequal(Data.fix2,1);
2029 lastfield='fix2';
2030 elseif isfield(Data,'civ2') & isequal(Data.civ2,1);
2031 lastfield='civ2';
2032 elseif isfield(Data,'patch') & isequal(Data.patch,1);
2033 lastfield='patch1';
2034 elseif isfield(Data,'fix') & isequal(Data.fix,1);
2035 lastfield='fix1';
2036 elseif isfield(Data,'absolut_time_T0') & isfield(Data,'hart')
2037 lastfield='civ1';
2038 end
2039 end
2040 end
2041 Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
2042 Tabchar(index+1,i_slice)={[file ' ' lastfield]};
2043 end
2044 end
2045 end
2046 if isempty(datnum)
2047 if NbSlice>1
2048 message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
2049 else
2050 message='no file found';
2051 end
2052 else
2053 datnum=datnum(find(datnum));
2054 [first,ind]=min(datnum);
2055 [last,indlast]=max(datnum);
2056 message={['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];...
2057 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]};
2058 end
2059 if ~isempty(Tabchar)
2060 Tabchar=reshape(Tabchar,NbSlice*(nbfield*nbfield2+1),1);
2061 end
2062 end
2063 hfig=figure(iview);
2064 clf
2065 if iview>1
2066 pos=get(iview-1,'Position');
2067 pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
2068 set(hfig,'Position',pos)
2069 end
2070 set(hfig,'name',['view= ' num2str(iview)])
2071
2072 h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', @ncbrowser_uvmat);
2073 hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
2074 end
2075
2076
2077
2078 function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
2079 num_i1=num_i;
2080 num_i2=num_i;
2081 num_j1=num_j;
2082 num_j2=num_j;
2083 num_i_out=num_i;
2084 num_j_out=num_j;
2085 if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
2086 num_i1_line=num_i+ind_shift(3);
2087 num_i2_line=num_i+ind_shift(4);
2088
2089 indsel=find(num_i1_line >= 1);
2090 num_i_out=num_i(indsel);
2091 num_i1_line=num_i1_line(indsel);
2092 num_i2_line=num_i2_line(indsel);
2093 num_j1=meshgrid(num_j,ones(size(num_i1_line)));
2094 num_j2=meshgrid(num_j,ones(size(num_i1_line)));
2095 [xx,num_i1]=meshgrid(num_j,num_i1_line);
2096 [xx,num_i2]=meshgrid(num_j,num_i2_line);
2097 elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab')
2098 if isequal(mode,'bursts')
2099 num_j1=ind_shift(1)*ones(size(num_i));
2100 num_j2=ind_shift(2)*ones(size(num_i));
2101 else
2102 num_j1_col=num_j+ind_shift(1);
2103 num_j2_col=num_j+ind_shift(2);
2104
2105 indsel=find((num_j1_col >= 1));
2106 num_j_out=num_j(indsel);
2107 num_j1_col=num_j1_col(indsel);
2108 num_j2_col=num_j2_col(indsel);
2109 [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
2110 [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
2111 end
2112 end
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126 function GUI_input=aver_stat(num_i1,num_i2,num_j1,num_j2,Series)
2127
2128 if ~exist('num_i1','var')
2129 GUI_input={'RootPath';'two';...
2130 'SubDir';'on';...
2131 'RootFile';'on';...
2132 'FileExt';'on';...
2133 'NomType';'on';...
2134 'NbSlice';'on'; ...
2135 'VelTypeMenu';'two';...
2136 'FieldMenu';'two';...
2137 'CoordType'; 'on';...
2138 'GetObject';'on';...
2139
2140
2141 ''};
2142 return
2143 end
2144
2145
2146 hseries=guidata(Series.hseries);
2147 WaitbarPos=get(hseries.waitbar_frame,'Position');
2148
2149
2150
2151 if ~iscell(Series.RootPath)
2152 num_i1={num_i1};num_j1={num_j1};num_i2={num_i2};num_j2={num_j2};
2153 RootPath={Series.RootPath};
2154 RootFile={Series.RootFile};
2155 SubDir={Series.SubDir};
2156 FileExt={Series.FileExt};
2157 NomType={Series.NomType};
2158 else
2159 RootPath=Series.RootPath;
2160 RootFile=Series.RootFile;
2161 SubDir=Series.SubDir;
2162 NomType=Series.NomType;
2163 FileExt=Series.FileExt;
2164 end
2165 ext=FileExt{1};
2166 form=imformats(ext([2:end]));
2167 testima=0;
2168 if ~isempty(form)||isequal(lower(ext),'.avi')||isequal(lower(ext),'.vol')
2169 testima(1)=1;
2170 end
2171 if length(FileExt)>=2
2172 ext_1=FileExt{2};
2173 form=imformats(ext_1([2:end]));
2174 if ~isempty(form)||isequal(lower(ext_1),'.avi')||isequal(lower(ext_1),'.vol')
2175 testima(2)=1;
2176 end
2177 if testima(2)~=testima(1)
2178 warndlg_uvmat('images and netcdf files cannot be compared','ERROR')
2179 return
2180 end
2181 end
2182
2183
2184 nbview=length(RootPath);
2185 if nbview>2
2186 RootPath=RootPath(1:2);
2187 set(hseries.RootPath,'String',RootPath)
2188 SubDir=SubDir(1:2);
2189 set(hseries.SubDir,'String',SubDir)
2190 RootFile=RootFile(1:2);
2191 set(hseries.RootFile,'String',RootFile)
2192 NomType=NomType(1:2);
2193 FileExt=FileExt(1:2);
2194 set(hseries.FileExt,'String',FileExt)
2195 nbview=2;
2196 end
2197 hhh=which('mmreader');
2198 for iview=1:nbview
2199 test_movie(iview)=0;
2200 if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
2201 if isequal(lower(FileExt{iview}),'.avi')
2202 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}]));
2203 test_movie(iview)=1;
2204 end
2205 end
2206 end
2207
2208
2209 NbSlice=str2num(get(hseries.NbSlice,'String'));
2210 if isempty(NbSlice)
2211 NbSlice=1;
2212 end
2213 NbSlice_name=num2str(NbSlice);
2214
2215
2216 Field_str=get(hseries.FieldMenu,'String');
2217 FieldName=[];
2218 testfield=get(hseries.FieldMenu,'Visible');
2219 if isequal(testfield,'on')
2220 val=get(hseries.FieldMenu,'Value');
2221 FieldName=Field_str(val);
2222 if isequal(FieldName,{'get_field...'})
2223 hget_field=findobj(allchild(0),'name','get_field');
2224 if length(hget_field)>1
2225 delete(hget_field(2:end))
2226 elseif isempty(hget_field)
2227 [filename]=...
2228 name_generator(fullfile(RootPath{1},RootFile{1}),num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});
2229 get_field(filename);
2230 return
2231 end
2232 hhget_field=guidata(hget_field);
2233 SubField=read_var_names(hhget_field);
2234 if isequal(get(hhget_field.menu_coord,'Visible'),'on')
2235 list_transform=get(hhget_field.menu_coord,'String');
2236 val_list=get(hhget_field.menu_coord,'Value');
2237 transform=list_transform{val_list};
2238 end
2239 end
2240 end
2241
2242 testima=0;
2243 testvol=0;
2244 testcivx=0;
2245 testnc=0;
2246 FileExt=get(hseries.FileExt,'String');
2247
2248 for iview=1:nbview
2249 ext=FileExt{iview};
2250 form=imformats(ext([2:end]));
2251 if isequal(lower(ext),'.vol')
2252 testvol=testvol+1;
2253 elseif ~isempty(form)||isequal(lower(ext),'.avi')
2254 testima=testima+1;
2255 elseif isequal(ext,'.nc')
2256 testnc=testnc+1;
2257 end
2258 end
2259 if testvol
2260 warndlg_uvmat('volume images not implemented yet','ERROR')
2261 return
2262 end
2263 if testnc~=nbview && testima~=nbview && testvol~=nbview
2264 warndlg_uvmat('compare two image series or two netcdf files with the same fields as input','ERROR')
2265 return
2266 end
2267 if ~isequal(FieldName,{'get_field...'})
2268 testcivx=testnc;
2269 end
2270
2271 if testcivx
2272 VelType_str=get(hseries.VelTypeMenu,'String');
2273 VelType_val=get(hseries.VelTypeMenu,'Value');
2274 VelType{1}=VelType_str{VelType_val};
2275 if nbview==2
2276 VelType_str=get(hseries.VelTypeMenu_1,'String');
2277 VelType_val=get(hseries.VelTypeMenu_1,'Value');
2278 VelType{2}=VelType_str{VelType_val};
2279 end
2280 end
2281
2282
2283 mode='';
2284 timecell={};
2285 itime=0;
2286 for iview=1:nbview
2287 XmlData{iview}=[];
2288 filebase{iview}=fullfile(RootPath{iview},RootFile{iview});
2289 if exist([filebase{iview} '.xml'],'file')
2290 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']);
2291 if isfield(XmlData{iview},'Time')
2292 itime=itime+1;
2293 timecell{itime}=XmlData{iview}.Time;
2294 end
2295 elseif exist([filebase{iview} '.civ'],'file')
2296 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);
2297 itime=itime+1;
2298 timecell{itime}=time;
2299 XmlData{iview}.Time=time;
2300 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
2301 GeometryCalib.Tx=0;
2302 GeometryCalib.Ty=0;
2303 GeometryCalib.Tz=1;
2304 GeometryCalib.dpx=1;
2305 GeometryCalib.dpy=1;
2306 GeometryCalib.sx=1;
2307 GeometryCalib.Cx=0;
2308 GeometryCalib.Cy=0;
2309 GeometryCalib.f=1;
2310 GeometryCalib.kappa1=0;
2311 GeometryCalib.CoordUnit='cm';
2312 XmlData{iview}.GeometryCalib=GeometryCalib;
2313 if error==1
2314 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
2315 end
2316 end
2317 end
2318
2319
2320
2321
2322 multitime=0;
2323 if length(timecell)==0
2324 time=[];
2325 elseif length(timecell)==1
2326 time=timecell{1};
2327 elseif length(timecell)>1
2328 multitime=1;
2329 for icell=1:length(timecell)
2330 if ~isequal(size(timecell{icell}),size(timecell{1}))
2331 warndlg_uvmat('inconsistent time array dimensions in ImaDoc fields, the time for the first series is used','WARNING')
2332 time=timecell{1};
2333 multitime=0;
2334 break
2335 end
2336 end
2337 end
2338 if multitime
2339 for icell=1:length(timecell)
2340 time(icell,:,:)=timecell{icell};
2341 end
2342 diff_time=max(max(diff(time)));
2343 if diff_time>0
2344 warndlg_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
2345 end
2346 end
2347 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)
2348 time=[];
2349 end
2350
2351
2352 filebasesub=fullfile(RootPath{1},SubDir{1},RootFile{1});
2353 if isempty(SubDir{1})
2354 subdir_result='mean';
2355
2356 if ~exist(fullfile(RootPath{1},subdir_result),'dir')
2357 dircur=pwd;
2358 cd(RootPath{1})
2359 [m1,m2,m3]=mkdir(subdir_result);
2360 if ~isequal(m2,'')
2361 msgbox_uvmat('CONFIRMATION',m2);
2362 end
2363 cd(dircur)
2364 end
2365 filebase_out=filebase{1};
2366 else
2367 subdir_result=SubDir{1};
2368 filebase_out=[filebase{1} '_mean'];
2369 end
2370
2371 NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1));
2372
2373 if NbSlice==1
2374 filebase_out=[filebasesub '_mean'];
2375 else
2376 filebase_out=[filebasesub '_' NbSlice_name 'mean'];
2377 answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_out ' ...']});
2378 if ~isequal(answeryes,'Yes')
2379 return
2380 end
2381 end
2382
2383
2384 Coord_menu=get(hseries.CoordType,'String');
2385 menu_val=get(hseries.CoordType,'Value');
2386 usrfct=Coord_menu{menu_val};
2387 testfct=~isequal(usrfct,'');
2388
2389
2390 siz=size(num_i1{1});
2391 lengthtot=siz(1)*siz(2);
2392 nbfield=floor(lengthtot/(siz(1)*NbSlice));
2393 nbfield_slice=nbfield*siz(1);
2394
2395 for i_slice=1:NbSlice
2396 S=0;
2397 nbfiles=0;
2398 nbmissing=0;
2399
2400 for ifile=i_slice:NbSlice:lengthtot
2401 stopstate=get(hseries.RUN,'BusyAction');
2402 if isequal(stopstate,'queue')
2403 update_waitbar(hseries.waitbar,WaitbarPos,(ifile+(i_slice-1)*nbfield)/(lengthtot*NbSlice))
2404 for iview=1:nbview
2405 [filename,idetect(iview)]=...
2406 name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
2407 if testima
2408 Data{iview}.ListVarName={'A'};
2409 Data{iview}.AName='image';
2410 if test_movie(iview)
2411 Data{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile));
2412 else
2413 Data{iview}.A=read_image(filename,NomType{iview},num_i1{iview}(ifile));
2414 end
2415 Atype{iview}=class(Data{iview}.A);
2416 Data{iview}.A=double(Data{iview}.A);
2417 elseif testcivx
2418 [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
2419
2420 else
2421 [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName);
2422 Data{iview}.VarAttribute=SubField.VarAttribute;
2423 end
2424 end
2425 if ~isequal(Series.CoordType,'')
2426 if nbview==2
2427 [Data{1},Data{2}]=feval(Series.CoordType,Data{1},XmlData{1},Data{2},XmlData{2});
2428 if isempty(Data{2})
2429 Data(2)=[];
2430 end
2431 else
2432 Data{1}=feval(Series.CoordType,Data{1},XmlData);
2433 end
2434 end
2435 if testcivx
2436 Data{iview}=calc_field(FieldName,Data{iview});
2437 end
2438 if length(Data)==2
2439
2440 end
2441 if isfield(Series,'ProjObject')
2442 Data{1}=proj_field(Data{1},Series.ProjObject);
2443 end
2444 if min(idetect)>=1
2445
2446 Field=Data{1};
2447 nbfiles=nbfiles+1;
2448 if nbfiles==1
2449 time_1=[];
2450 if isfield(Field,'Time')
2451 time_1=Field.Time(1);
2452 end
2453 DataMean=Field;
2454 else
2455 for ivar=1:length(Field.ListVarName)
2456 VarName=Field.ListVarName{ivar};
2457 eval(['sizmean=size(DataMean.' VarName ');']);
2458 eval(['siz=size(Field.' VarName ');']);
2459 if ~isequal(siz,sizmean)
2460 warndlg_uvmat(['unequal size of input field ' VarName ', need to interpolate on a grid'],'WARNING')
2461 nbmissing=nbmissing+1;
2462 break
2463 else
2464 eval(['DataMean.' VarName '=DataMean.' VarName '+ Field.' VarName ';']);
2465 end
2466 end
2467 end
2468 else
2469 nbmissing=nbmissing+1;
2470 end
2471 end
2472 end
2473 for ivar=1:length(Field.ListVarName)
2474 VarName=Field.ListVarName{ivar};
2475 eval(['DataMean.' VarName '=DataMean.' VarName '/nbfiles;']);
2476 end
2477 if nbmissing~=0
2478 warndlg_uvmat([num2str(nbmissing) ' input files are missing or skipted'],'WARNING')
2479 end
2480 if isempty(time)
2481 time_end=[];
2482 if isfield(Field,'Time')
2483 time_end=Field.Time(1);
2484 if ~isempty(time_1)
2485 DataMean.Time=time_1;
2486 DataMean.Time_end=time_end;
2487 end
2488 end
2489 else
2490 DataMean.Time=time(1,num_i1{1}(1),num_j1{1}(1));
2491 DataMean.Time_end=time(end,num_i1{end}(end),num_j1{end}(end));
2492 end
2493
2494
2495 if testima
2496 [filemean]=name_generator(filebase_out,num_i1{1}(1,i_slice),num_j1{1}(1,1),'.png',NomTypeOut,1,num_i2{end}(end,end),num_j2{end}(end,end),subdir_result);
2497 if exist(filemean,'file')
2498 backupfile=filemean;
2499 testexist=2;
2500 while testexist==2
2501 backupfile=[backupfile(1:end-4) '~.png'];
2502 testexist=exist(backupfile,'file');
2503 end
2504 [success,message]=copyfile(filemean,backupfile);
2505 if ~isequal(success,1)
2506 warndlg_uvmat(['previous file result ' filemean ' already exists, problem in backup'],'ERROR')
2507 return
2508 end
2509 end
2510 if isequal(Atype{1},'uint16')
2511 imwrite(uint16(DataMean.A),filemean,'BitDepth',16);
2512 else
2513 imwrite(uint8(DataMean.A),filemean,'BitDepth',8);
2514 end
2515 display([filemean ' written']);
2516 else
2517 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {Series.Action}];
2518 ActionKey='Action';
2519 while isfield(DataMean,ActionKey)
2520 ActionKey=[ActionKey '_1'];
2521 end
2522 eval(['DataMean.' ActionKey '=Series.Action;'])
2523 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {ActionKey}];
2524 if isfield(DataMean,'Time')
2525 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {'Time','Time_end'}];
2526 end
2527 [filemean]=name_generator(filebase_out,num_i1{1}(1,i_slice),num_j1{1}(1,1),'.nc',NomTypeOut,1,num_i2{end}(end,end),num_j2{end}(end,end),subdir_result);
2528 if exist(filemean,'file')
2529 backupfile=filemean;
2530 testexist=2;
2531 while testexist==2
2532 backupfile=[backupfile(1:end-3) '~.nc'];
2533 testexist=exist(backupfile,'file');
2534 end
2535 [success,message]=copyfile(filemean,backupfile);
2536 if ~isequal(success,1)
2537 msgbox_uvmat('ERROR',['previous file result ' filemean ' already exists, problem in backup'])
2538 display(['previous file result ' filemean ' already exists, problem in backup'])
2539 return
2540 end
2541 end
2542 error=struct2nc(filemean,DataMean);
2543 if isequal(error,0)
2544 display([filemean ' written']);
2545 else
2546 warndlg_uvmat(error,'ERROR')
2547 end
2548 end
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571 end
2572 hget_field=findobj(allchild(0),'name','get_field');
2573 delete(hget_field)
2574 uvmat(filemean)
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908 function GUI_input=merge_proj(num_i1,num_i2,num_j1,num_j2,Series);
2909
2910
2911 if ~exist('num_i1','var')
2912 GUI_input={'RootPath';'two';...
2913 'SubDir';'on';...
2914 'RootFile';'on';...
2915 'FileExt';'on';...
2916 'NomType';'on';...
2917 'NbSlice';'on'; ...
2918 'VelTypeMenu';'one';...
2919 'FieldMenu';'one';...
2920 'CoordType';'on';...
2921 'GetObject';'on';...
2922
2923
2924 ''};
2925 return
2926 end
2927
2928
2929 hseries=guidata(Series.hseries);
2930 WaitbarPos=get(hseries.waitbar_frame,'Position');
2931
2932
2933
2934 testcell=iscell(Series.RootFile);
2935 if ~testcell
2936 Series.RootPath={Series.RootPath};
2937 Series.RootFile={Series.RootFile};
2938 Series.SubDir={Series.SubDir};
2939 Series.FileExt={Series.FileExt};
2940 Series.NomType={Series.NomType};
2941 num_i1={num_i1};
2942 num_i2={num_i2};
2943 num_j1={num_j1};
2944 num_j2={num_j2};
2945 end
2946 nbview=length(Series.RootFile);
2947 nbfield=size(num_i1{1},1)*size(num_i1{1},2);
2948 transform=Series.CoordType;
2949 hhh=which('mmreader');
2950 for iview=1:nbview
2951 test_movie(iview)=0;
2952 if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
2953 if isequal(lower(FileExt{iview}),'.avi')
2954 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}]));
2955 test_movie(iview)=1;
2956 end
2957 end
2958 end
2959
2960
2961 mode='';
2962 timecell={};
2963 itime=0;
2964 for iview=1:nbview
2965 XmlData{iview}=[];
2966 filebase{iview}=fullfile(RootPath{iview},RootFile{iview});
2967 if exist([filebase{iview} '.xml'],'file')
2968 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']);
2969 if isfield(XmlData{iview},'Time')
2970 itime=itime+1;
2971 timecell{itime}=XmlData{iview}.Time;
2972 end
2973 elseif exist([filebase{iview} '.civ'],'file')
2974 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);
2975 itime=itime+1;
2976 timecell{itime}=time;
2977 XmlData{iview}.Time=time;
2978 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
2979 GeometryCalib.Tx=0;
2980 GeometryCalib.Ty=0;
2981 GeometryCalib.Tz=1;
2982 GeometryCalib.dpx=1;
2983 GeometryCalib.dpy=1;
2984 GeometryCalib.sx=1;
2985 GeometryCalib.Cx=0;
2986 GeometryCalib.Cy=0;
2987 GeometryCalib.f=1;
2988 GeometryCalib.kappa1=0;
2989 GeometryCalib.CoordUnit='cm';
2990 XmlData{iview}.GeometryCalib=GeometryCalib;
2991 if error==1
2992 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
2993 end
2994 end
2995 end
2996
2997
2998 multitime=0;
2999 if length(timecell)==0
3000 time=[];
3001 elseif length(timecell)==1
3002 time=timecell{1};
3003 elseif length(timecell)>1
3004 multitime=1;
3005 for icell=1:length(timecell)
3006 if ~isequal(size(timecell{icell}),size(timecell{1}))
3007 warndlg_uvmat('inconsistent time array dimensions in ImaDoc fields, the time for the first series is used','WARNING')
3008 time=timecell{1};
3009 multitime=0;
3010 break
3011 end
3012 end
3013 end
3014 if multitime
3015 for icell=1:length(timecell)
3016 time(icell,:,:)=timecell{icell};
3017 end
3018 diff_time=max(max(diff(time)));
3019 if diff_time>0
3020 warndlg_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
3021 end
3022 end
3023 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)
3024 time=[];
3025 end
3026
3027
3028 Field_str=get(hseries.FieldMenu,'String');
3029 val=get(hseries.FieldMenu,'Value');
3030 FieldName=Field_str(val);
3031 VelType_str=get(hseries.VelTypeMenu,'String');
3032 VelType_val=get(hseries.VelTypeMenu,'Value');
3033 VelType=VelType_str{VelType_val};
3034 if isequal(FieldName,'get_field...')
3035 hget_field=findobj(allchild(0),'Name','get_field');
3036 hhget_field=guidata(hget_field);
3037 SubField=get_field('read_var_names',hObject,eventdata,hhget_field);
3038 if isequal(get(hhget_field.menu_coord,'Visible'),'on')
3039 list_transform=get(hhget_field.menu_coord,'String');
3040 val_list=get(hhget_field.menu_coord,'Value');
3041 transform=list_transform{val_list};
3042 end
3043 end
3044
3045 testima=0;
3046 testvol=0;
3047 testcivx=0;
3048 testnc=0;
3049 FileExt=get(hseries.FileExt,'String');
3050 for iview=1:nbview
3051 ext=FileExt{iview};
3052 form=imformats(ext([2:end]));
3053 if isequal(lower(ext),'.vol')
3054 testvol=testvol+1;
3055 elseif ~isempty(form)||isequal(lower(ext),'.avi')
3056 testima=testima+1;
3057 elseif isequal(ext,'.nc')
3058 testnc=testnc+1;
3059 end
3060 end
3061 if testvol
3062 warndlg_uvmat('volume images not implemented yet','ERROR')
3063 return
3064 end
3065 if testnc~=nbview && testima~=nbview && testvol~=nbview
3066 warndlg_uvmat('need a set of images or a set of netcdf files with the same fields as input','ERROR')
3067 return
3068 end
3069 if ~isequal(FieldName,'get_field...')
3070 testcivx=testnc;
3071 end
3072
3073
3074 ProjectDir=fileparts(fileparts(Series.RootPath{1}));
3075 prompt={['result directory (in' ProjectDir ')']};
3076 RootPath=get(hseries.RootPath,'String');
3077 SubDir=get(hseries.SubDir,'String');
3078 if isequal(length(RootPath),1)
3079 fulldir=RootPath{1};
3080 subdir='GRID';
3081 res_subdir=fullfile(fulldir,subdir);
3082 else
3083 def={fullfile(ProjectDir,'0_RESULTS')};
3084 dlgTitle='result directory';
3085 lineNo=1;
3086
3087 answer=msgbox_uvmat('INPUT_TXT',dlgTitle,def);
3088 fulldir=answer{1};
3089 subdir=[];
3090 dirlist=sort(Series.RootFile);
3091 for iview=1:nbview
3092 if ~isempty(subdir)
3093 subdir=[subdir '-'];
3094 end
3095 subdir=[subdir dirlist{iview}];
3096 end
3097 res_subdir=fullfile(fulldir,subdir);
3098 end
3099 ext=FileExt{1};
3100 if ~exist(fulldir,'dir')
3101 warndlg_uvmat(['directory ' fulldir ' needs to be created'],'ERROR')
3102 return
3103 end
3104 if ~exist(res_subdir,'dir')
3105 dircur=pwd;
3106 cd(fulldir)
3107 error=mkdir(subdir);
3108 cd(dircur)
3109 end
3110 filebasesub=fullfile(res_subdir,Series.RootFile{1});
3111 filebase_merge=fullfile(res_subdir,'merged');
3112
3113
3114 if isfield(Series,'sethandles')
3115 if ishandle(Series.sethandles.set_object)
3116 Series.ProjObject=read_set_object(Series.sethandles);
3117 if ~isfield(Series.ProjObject,'Style')
3118 warndlg_uvmat('Undefined projection object style','ERROR')
3119 return
3120 end
3121 if ~isequal(Series.ProjObject.Style,'plane')
3122 warndlg_uvmat('The projection object must be a plane','ERROR')
3123 return
3124 end
3125 end
3126 end
3127
3128
3129 for ifile=1:nbfield
3130 stopstate=get(hseries.RUN,'BusyAction');
3131 if isequal(stopstate,'queue')
3132 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
3133 Amerge=0;
3134
3135
3136 nbtime=0;
3137 for iview=1:nbview
3138
3139 [filename,idetect]=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
3140 if idetect==0
3141 warndlg_uvmat(['missing input file' filename],'ERROR')
3142 break
3143 end
3144
3145
3146 if testima
3147 if test_movie(iview)
3148 Field{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile));
3149 else
3150 Field{iview}.A=read_image(filename,Series.NomType{iview},num_i1{iview}(ifile));
3151 end
3152 npxy=size(Field{iview}.A);
3153 Field{iview}.AX=[0.5 npxy(2)-0.5];
3154 Field{iview}.AY=[npxy(1)-0.5 0.5];
3155 Field{iview}.CoordType='px';
3156 Field{iview}.AName='image';
3157 else
3158 if testcivx
3159 [Field{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
3160 else
3161 [Field{iview},var_detect]=nc2struct(filename,SubField.ListVarName);
3162 Field{iview}.VarAttribute=SubField.VarAttribute;
3163 end
3164 if isfield(Field{iview},'Time')
3165 timeread(iview)=Field{iview}.Time;
3166 nbtime=nbtime+1;
3167 end
3168 end
3169
3170 if ~isequal(transform,'')
3171 Field{iview}=feval(Series.CoordType,Field{iview},XmlData{iview});
3172 end
3173 if testcivx
3174 Field{iview}=calc_field(FieldName,Field{iview});
3175 end
3176
3177
3178 if isfield(Series,'ProjObject')
3179 Field{iview}=proj_field(Field{iview},Series.ProjObject);
3180 end
3181 end
3182
3183
3184
3185
3186 MergeData=merge_field(Field);
3187 if isfield(MergeData,'Txt')
3188 warndlg_uvmat(MergeData.Txt,'ERROR')
3189 return
3190 end
3191
3192
3193 mergename=name_generator(filebase_merge,num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile));
3194
3195
3196 time_i=0;
3197 if isempty(time)
3198 time_i=sum(timeread)/nbtime;
3199 else
3200 time_i=(time(iview,num_i1{iview}(ifile),num_j1{iview}(ifile))+time(iview,num_i2{iview}(ifile),num_j2{iview}(ifile)))/2;
3201 end
3202
3203
3204 if testima
3205 if isa(MergeData.A,'uint8')
3206 bitdepth=8;
3207 elseif isa(MergeData.A,'uint16')
3208 bitdepth=16;
3209 end
3210 imwrite(MergeData.A,mergename,'BitDepth',bitdepth);
3211
3212 siz=size(MergeData.A);
3213 npy=siz(1);
3214 npx=siz(2);
3215 if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1')
3216 Rangx=MergeData.VarAttribute{1}.Coord_2;
3217 Rangy=MergeData.VarAttribute{1}.Coord_1;
3218 elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY')
3219 Rangx=[MergeData.AX(1) MergeData.AX(end)];
3220 Rangy=[MergeData.AY(1) MergeData.AY(end)];
3221 else
3222 Rangx=[0.5 npx-0.5];
3223 Rangy=[npy-0.5 0.5];
3224 end
3225 pxcmx=(npx-1)/(Rangx(2)-Rangx(1));
3226 pxcmy=(npy-1)/(Rangy(1)-Rangy(2));
3227 T_x=-pxcmx*Rangx(1)+0.5;
3228 T_y=-pxcmy*Rangy(2)+0.5;
3229 GeometryCal.focal=1;
3230 GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1];
3231 GeometryCal.Tx_Ty_Tz=[T_x T_y 1];
3232 ImaDoc.GeometryCalib=GeometryCal;
3233 t=struct2xml(ImaDoc);
3234 t=set(t,1,'name','ImaDoc');
3235 save(t,[filebase_merge '.xml'])
3236 display([filebase_merge '.xml saved'])
3237 else
3238 MergeData.ListGlobalAttribute={'Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};
3239 MergeData.nb_coord=2;
3240 MergeData.nb_dim=2;
3241 MergeData.dt=1;
3242 MergeData.Time=time_i;
3243 error=struct2nc(mergename,MergeData);
3244 if isequal(error,0)
3245 display(['output file= ' mergename])
3246 end
3247 end
3248 end
3249 end
3250
3251
3252 function MergeData=merge_field(Data)
3253
3254 if isempty(Data)||~iscell(Data)
3255 MergeData=[];
3256 return
3257 end
3258 MergeData=Data{1};
3259 error=0;
3260 nbview=length(Data);
3261 if nbview==1
3262 return
3263 end
3264 for iview=1:nbview
3265 if ~isequal(MergeData.ListDimName,Data{iview}.ListDimName)
3266 error=1;
3267 end
3268 if ~isequal(MergeData.ListVarName,Data{iview}.ListVarName)
3269 error=1;
3270 end
3271 if ~isequal(MergeData.VarDimIndex,Data{iview}.VarDimIndex)
3272 error=1;
3273 end
3274 end
3275 if error
3276 MergeData.Txt='ERROR: attempt at merging fields of incompatible type';
3277 return
3278 end
3279
3280
3281 [CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1});
3282
3283
3284 ivar_new=0;
3285 icoord=0;
3286 for icell=1:length(CellVarIndex)
3287 if NbDim(icell)==1
3288 continue
3289 end
3290 VarIndex=CellVarIndex{icell};
3291 VarType=VarTypeCell{icell};
3292 ivar_X=VarType.coord_x;
3293 ivar_Y=VarType.coord_y;
3294 ivar_FF=VarType.errorflag;
3295 if isempty(ivar_X)
3296 test_grid=1;
3297 else
3298 if length(ivar_Y)~=1
3299 warndlg_uvmat('y coordinate missing in proj_field.m','ERROR')
3300 return
3301 end
3302 test_grid=0;
3303 end
3304 DimIndices=Data{1}.VarDimIndex{VarIndex(1)};
3305
3306 if ~test_grid
3307 for ivar=VarIndex
3308 VarName=MergeData.ListVarName{ivar};
3309 for iview=1:nbview
3310 eval(['MergeData.' VarName '=[MergeData.' VarName '; Data{iview}.' VarName ';'])
3311 end
3312 end
3313
3314 else
3315 DimValue=MergeData.DimValue(DimIndices);
3316 testFF=0;
3317 for iview=2:nbview
3318 if ~isequal(DimValue,Data{iview}.DimValue(DimIndices))
3319 MergeData.Txt='ERROR: attempt at merging structured fields with different sizes';
3320 return
3321 end
3322 for ivar=VarIndex
3323 VarName=MergeData.ListVarName{ivar};
3324 if isfield(MergeData,'VarAttribute')
3325 if length(MergeData.VarAttribute)>=ivar && isfield(MergeData.VarAttribute{ivar},'Role') && isequal(MergeData.VarAttribute{ivar}.Role,'errorflag')
3326 testFF=1;
3327 end
3328 end
3329 eval(['MergeData.' VarName '=MergeData.' VarName '+ Data{iview}.' VarName ';'])
3330 end
3331 end
3332 if testFF
3333 nbaver=nbview-MergeData.FF;
3334 indgood=find(nbaver>0);
3335 for ivar=VarIndex
3336 VarName=MergeData.ListVarName{ivar};
3337 eval(['MergeData.' VarName '(indgood)=double(MergeData.' VarName '(indgood))./nbaver(indgood);'])
3338 end
3339 else
3340 for ivar=VarIndex
3341 VarName=MergeData.ListVarName{ivar};
3342 eval(['MergeData.' VarName '=double(MergeData.' VarName ')./nbview;'])
3343 end
3344 end
3345 end
3346 end
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358 function GUI_input=clean_civ_cmx(num_i1,num_i2,num_j1,num_j2,Series)
3359
3360
3361 if ~exist('num_i1','var')
3362 GUI_input={'RootPath';'many';...
3363 'SubDir';'on';...
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374 ''};
3375 return
3376 end
3377
3378 hseries=guidata(Series.hseries);
3379 WaitbarPos=get(hseries.waitbar_frame,'Position');
3380
3381
3382 message='this function will delete all files with extensions .log, .bat, .cmx,.cmx2,.errors in the input directory(ies)';
3383 answer=msgbox_uvmat('INPUT_Y-N',message);
3384 if ~isequal(answer,'Yes')
3385 return
3386 end
3387 nbdelete=0;
3388 testcell=iscell(Series.RootFile);
3389 if ~testcell
3390 Series.RootPath={Series.RootPath};
3391 Series.RootFile={Series.RootFile};
3392 Series.SubDir={Series.SubDir};
3393 Series.FileExt={Series.FileExt};
3394 Series.NomType={Series.NomType};
3395 end
3396 for iview=1:length(Series.RootFile)
3397 hdir=dir(fullfile(Series.RootPath{iview},Series.SubDir{iview}));
3398 for ilist=1:length(hdir)
3399 update_waitbar(hseries.waitbar,WaitbarPos,ilist/length(hdir))
3400 FileName=hdir(ilist).name;
3401 [dd,ff,Ext]=fileparts(FileName);
3402 if isequal(Ext,'.log')||isequal(Ext,'.bat')||isequal(Ext,'.cmx')||isequal(Ext,'.cmx2')|| isequal(Ext,'.errors')
3403 delete(fullfile(Series.RootPath{iview},Series.SubDir{iview},FileName))
3404 nbdelete=nbdelete+1;
3405 end
3406 end
3407 end
3408 msgbox_uvmat('CONFIRMATION',['END: ' num2str(nbdelete) ' files deleted by clean_civ_cmx'])
3409
3410
3411
3412
3413
3414
3415 function mouse_up_gui(ggg,eventdata,handles)
3416 if isequal(get(ggg,'SelectionType'),'alt')
3417 display('global CurData, UserData of GUI series')
3418 global CurData
3419 CurData=get(ggg,'UserData');
3420 evalin('base','global CurData');
3421 evalin('base','CurData');
3422 commandwindow
3423
3424 end
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628 function GUI_input=time_series(num_i1,num_i2,num_j1,num_j2,Series)
3629
3630
3631 if ~exist('num_i1','var')
3632 GUI_input={'RootPath';'two';...
3633 'SubDir';'on';...
3634 'RootFile';'on';...
3635 'FileExt';'on';...
3636 'NomType';'on';...
3637 'NbSlice';'on'; ...
3638 'VelTypeMenu';'two';...
3639 'FieldMenu';'two';...
3640 'CoordType';'on';...
3641 'GetObject';'on';...
3642
3643
3644 ''};
3645 return
3646 end
3647
3648
3649 hseries=guidata(Series.hseries);
3650 WaitbarPos=get(hseries.waitbar_frame,'Position');
3651
3652
3653 if iscell(Series.RootPath)
3654 RootPath=Series.RootPath;
3655 RootFile=Series.RootFile;
3656 SubDir=Series.SubDir;
3657 FileExt=Series.FileExt;
3658 NomType=Series.NomType;
3659 else
3660 RootPath={Series.RootPath};
3661 RootFile={Series.RootFile};
3662 SubDir={Series.SubDir};
3663 FileExt={Series.FileExt};
3664 NomType={Series.NomType};
3665 num_i1={num_i1};
3666 num_i2={num_i2};
3667 num_j1={num_j1};
3668 num_j2={num_j2};
3669 end
3670 ext=FileExt{1};
3671 form=imformats(ext([2:end]));
3672 testima=0;
3673 if ~isempty(form)||isequal(lower(ext),'.avi')
3674 testima=1;
3675 end
3676 nbview=length(RootPath);
3677 nbfield=size(num_i1{1},1)*size(num_i1{1},2);
3678
3679
3680 nbview=length(RootPath);
3681 if nbview>2
3682 RootPath=RootPath(1:2);
3683 set(hseries.RootPath,'String',RootPath)
3684 SubDir=SubDir(1:2);
3685 set(hseries.SubDir,'String',SubDir)
3686 RootFile=RootFile(1:2);
3687 set(hseries.RootFile,'String',RootFile)
3688 NomType=NomType(1:2);
3689
3690 FileExt=FileExt(1:2);
3691 set(hseries.FileExt,'String',FileExt)
3692 nbview=2;
3693 end
3694 hhh=which('mmreader');
3695 for iview=1:nbview
3696 test_movie(iview)=0;
3697 if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
3698 if isequal(lower(FileExt{iview}),'.avi')
3699 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}]));
3700 test_movie(iview)=1;
3701 end
3702 end
3703 end
3704 filebase{1}=fullfile(RootPath{1},RootFile{1});
3705
3706
3707
3708 NbSlice=str2num(get(hseries.NbSlice,'String'));
3709 if isempty(NbSlice)
3710 NbSlice=1;
3711 end
3712 NbSlice_name=num2str(NbSlice);
3713
3714
3715 if isfield(Series,'Field')
3716 FieldName=Series.Field;
3717 else
3718 FieldName={''};
3719 end
3720 if isequal(FieldName,{'get_field...'})
3721 hget_field=findobj(allchild(0),'name','get_field');
3722 if length(hget_field)>1
3723 delete(hget_field(2:end))
3724 elseif isempty(hget_field)
3725 [filename,idetect(iview)]=...
3726 name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});
3727 hget_field=get_field(filename);
3728 return
3729 end
3730 hhget_field=guidata(hget_field);
3731 SubField=read_var_names(hhget_field);
3732 if isequal(get(hhget_field.menu_coord,'Visible'),'on')
3733 list_transform=get(hhget_field.menu_coord,'String');
3734 val_list=get(hhget_field.menu_coord,'Value');
3735 transform=list_transform{val_list};
3736 end
3737 end
3738
3739
3740 testima=0;
3741 testvol=0;
3742 testcivx=0;
3743 testnc=0;
3744 FileExt=get(hseries.FileExt,'String');
3745 for iview=1:nbview
3746 ext=FileExt{iview};
3747 form=imformats(ext([2:end]));
3748 if isequal(lower(ext),'.vol')
3749 testvol=testvol+1;
3750 elseif ~isempty(form)||isequal(lower(ext),'.avi')
3751 testima=testima+1;
3752 elseif isequal(ext,'.nc')
3753 testnc=testnc+1;
3754 end
3755 end
3756 if testvol
3757 warndlg_uvmat('volume images not implemented yet','ERROR')
3758 return
3759 end
3760 if testnc~=nbview && testima~=nbview && testvol~=nbview
3761 warndlg_uvmat('need a set of images or a set of netcdf files with the same fields as input','ERROR')
3762 return
3763 end
3764 if ~isequal(FieldName,{'get_field...'})
3765 testcivx=testnc;
3766 end
3767
3768
3769
3770 filebasesub=fullfile(RootPath{1},RootFile{1});
3771 if NbSlice==1
3772 filebase_out=[filebasesub '_time'];
3773 else
3774 filebase_out=[filebasesub '_' NbSlice_name 'mtim'];
3775 answeryes=questdlg({['will make average in ' num2str(NbSlice) ' slices'];['results stored as files ' filebase_out ' ...']});
3776 if ~isequal(answeryes,'Yes')
3777 return
3778 end
3779 end
3780 VelType_str=get(hseries.VelTypeMenu,'String');
3781 VelType_val=get(hseries.VelTypeMenu,'Value');
3782 VelType{1}=VelType_str{VelType_val};
3783 if nbview==2
3784 VelType_str=get(hseries.VelTypeMenu_1,'String');
3785 VelType_val=get(hseries.VelTypeMenu_1,'Value');
3786 VelType{2}=VelType_str{VelType_val};
3787 end
3788
3789
3790 mode='';
3791 timecell={};
3792 XmlData={};
3793 itime=0;
3794 for iview=1:nbview
3795 XmlData{iview}=[];
3796 filebase{iview}=fullfile(RootPath{iview},RootFile{iview});
3797 if exist([filebase{iview} '.xml'],'file')
3798 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']);
3799 if isfield(XmlData{iview},'Time')
3800 itime=itime+1;
3801 timecell{itime}=XmlData{iview}.Time;
3802 end
3803 elseif exist([filebase{iview} '.civ'],'file')
3804 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);
3805 itime=itime+1;
3806 timecell{itime}=time;
3807 XmlData{iview}.Time=time;
3808 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
3809 GeometryCalib.Tx=0;
3810 GeometryCalib.Ty=0;
3811 GeometryCalib.Tz=1;
3812 GeometryCalib.dpx=1;
3813 GeometryCalib.dpy=1;
3814 GeometryCalib.sx=1;
3815 GeometryCalib.Cx=0;
3816 GeometryCalib.Cy=0;
3817 GeometryCalib.f=1;
3818 GeometryCalib.kappa1=0;
3819 GeometryCalib.CoordUnit='cm';
3820 XmlData{iview}.GeometryCalib=GeometryCalib;
3821 if error==1
3822 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
3823 end
3824 end
3825 end
3826
3827
3828 multitime=0;
3829 if length(timecell)==0
3830 time=[];
3831 elseif length(timecell)==1
3832 time=timecell{1};
3833 elseif length(timecell)>1
3834 multitime=1;
3835 for icell=1:length(timecell)
3836 if ~isequal(size(timecell{icell}),size(timecell{1}))
3837 warndlg_uvmat('inconsistent time array dimensions in ImaDoc fields, the time for the first series is used','WARNING')
3838 time=timecell{1};
3839 multitime=0;
3840 break
3841 end
3842 end
3843 end
3844 if multitime
3845 for icell=1:length(timecell)
3846 time(icell,:,:)=timecell{icell};
3847 end
3848 diff_time=max(max(diff(time)));
3849 if diff_time>0
3850 warndlg_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
3851 end
3852 end
3853 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)
3854 time=[];
3855 end
3856
3857
3858 Coord_menu=get(hseries.CoordType,'String');
3859 menu_val=get(hseries.CoordType,'Value');
3860 usrfct=Coord_menu{menu_val};
3861 testfct=~isequal(usrfct,'');
3862
3863
3864 VelType_str=get(hseries.VelTypeMenu,'String');
3865 VelType_val=get(hseries.VelTypeMenu,'Value');
3866 VelType{1}=VelType_str{VelType_val};
3867 if nbview==2
3868 VelType_str=get(hseries.VelTypeMenu_1,'String');
3869 VelType_val=get(hseries.VelTypeMenu_1,'Value');
3870 VelType{2}=VelType_str{VelType_val};
3871 end
3872
3873
3874 test_object=get(hseries.GetObject,'Value');
3875 if test_object
3876 Series.ProjObject=read_set_object(Series.sethandles);
3877 answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]});
3878 if ~isequal(answeryes,'Yes')
3879 return
3880 end
3881 else
3882 warndlg_uvmat('a projection object is needed','ERROR');
3883 return
3884 end
3885
3886
3887 for i_slice=1:NbSlice
3888
3889 [filemean,idetect]=...
3890 name_generator(filebase_out,num_i1{1}(1,i_slice),num_j1{1}(1,1),'.nc','_i1-i2_j1-j2',1,num_i2{end}(end,end),num_j2{end}(end,end),SubDir{1});
3891 dt=[];
3892 nbmissing=0;
3893 nbfiles=0;
3894
3895 for ifile=i_slice:NbSlice:nbfield
3896 stopstate=get(hseries.RUN,'BusyAction');
3897 if isequal(stopstate,'queue')
3898 update_waitbar(hseries.waitbar,WaitbarPos,(ifile+(i_slice-1)*nbfield)/(nbfield*NbSlice))
3899 for iview=1:nbview
3900 [filename,idetect(iview)]=...
3901 name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
3902 Data{iview}=[];
3903 if testima
3904 Data{iview}.ListVarName={'A'};
3905 Data{iview}.AName='image';
3906 if test_movie(iview)
3907 Data{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile));
3908 else
3909 Data{iview}.A=double(read_image(filename,NomType{iview},num_i1{iview}(ifile)));
3910 end
3911 npy=size(Data{iview}.A,1);
3912 npx=size(Data{iview}.A,2);
3913 nbcolor=size(Data{iview}.A,3);
3914 if nbcolor==3
3915 Data{iview}.ListDimName={'coord_y','coord_x','rgb'};
3916 Data{iview}.DimValue=[npy npx 3];
3917 Data{iview}.VarDimIndex={[1 2 3]};
3918 else
3919 Data{iview}.ListDimName={'coord_y','coord_x'};
3920 Data{iview}.DimValue=[npy npx];
3921 Data{iview}.VarDimIndex={[1 2]};
3922 Data{iview}.VarAttribute{1}.Coord_1=[npy-0.5 0.5];
3923 Data{iview}.VarAttribute{1}.Coord_2=[0.5 npx-0.5];
3924 end
3925 Data{iview}.CoordType='px';
3926 elseif testcivx
3927 [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
3928 else
3929 [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName);
3930 Data{iview}.VarAttribute=SubField.VarAttribute;
3931 end
3932 end
3933 if ~isequal(Series.CoordType,'')
3934 if nbview==2
3935 [Data{1},Data{2}]=feval(Series.CoordType,Data{1},XmlData{1},Data{2},XmlData{2});
3936 if isempty(Data{2})
3937 Data(2)=[];
3938 end
3939 else
3940 Data{1}=feval(Series.CoordType,Data{1},XmlData{1});
3941 end
3942 end
3943 if testcivx
3944 Data{iview}=calc_field(FieldName,Data{iview});
3945 end
3946 if length(Data)==2
3947
3948 end
3949 if isfield(Series,'ProjObject')
3950 Data{1}=proj_field(Data{1},Series.ProjObject);
3951 if isfield(Data{1},'Txt')
3952 msgbox_uvmat('ERROR',Data{1}.Txt)
3953 return
3954 end
3955 end
3956 if min(idetect)==1
3957 Field=Data{1};
3958 nbfiles=nbfiles+1;
3959 if nbfiles==1
3960 RecordData=Field;
3961 RecordData.NbDim=Field.NbDim+1;
3962 nbvar=length(Field.ListVarName);
3963 if nbvar==0
3964 msgbox_uvmat('ERROR','no input variable selected in get_field')
3965 return
3966 end
3967 testsum=2*ones(1,nbvar);
3968 indexfalse=0;
3969 CoordName={};
3970 indexremove=[];
3971 if isfield(Field,'VarAttribute')
3972 for ivar=1:nbvar
3973 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
3974 var_role=Field.VarAttribute{ivar}.Role;
3975 if isequal(var_role,'errorflag')
3976 msgdlg_uvmat('ERROR','do not handle error flags in time series')
3977 return
3978 end
3979 if isequal(var_role,'warnflag')
3980 testsum(ivar)=0;
3981 eval(['RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);
3982 end
3983 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|...
3984 isequal(var_role,'coord_z')|isequal(var_role,'coord')
3985 testsum(ivar)=1;
3986 end
3987
3988 index=Field.VarDimIndex{ivar};
3989 if length(Field.ListDimName)>=index & isequal(Field.ListVarName{ivar},Field.ListDimName{index})
3990 testsum(ivar)=1;
3991 end
3992 end
3993 end
3994 end
3995 for ivar=1:nbvar
3996 if testsum(ivar)==2
3997 eval(['RecordData.' Field.ListVarName{ivar} '=[];'])
3998 end
3999 end
4000 RecordData.ListDimName=[{'Time'} RecordData.ListDimName];
4001 RecordData.ListVarName=[{'Time'} RecordData.ListVarName];
4002 end
4003 for ivar=1:length(Field.ListVarName)
4004 VarName=Field.ListVarName{ivar};
4005 eval(['VarVal=Field.' VarName ';']);
4006 if testsum(ivar)==2
4007 eval(['VarVal=Field.' VarName ';']);
4008 if isequal(Series.ProjObject.ProjMode,'inside')
4009 if isempty(VarVal)
4010 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(num_i1{iview}(ifile))])
4011 return
4012 end
4013 VarVal=mean(VarVal,1);
4014 dimindex=Field.VarDimIndex{ivar};
4015 RecordData.DimValue(dimindex(1))=1;
4016 end
4017 VarVal=shiftdim(VarVal,-1);
4018 eval(['RecordData.' VarName '=cat(1,RecordData.' VarName ',VarVal);']);
4019 elseif testsum(ivar)==1
4020 eval(['VarInit=RecordData.' VarName ';']);
4021 if ~isequal(VarVal,VarInit)
4022 warndlg_uvmat(['time series requires constant coordinates ' VarName],'ERROR')
4023 return
4024 end
4025 end
4026 end
4027
4028 if isempty(time)
4029 if isfield(Field,'Time')
4030 RecordData.Time(nbfiles,1)=Field.Time;
4031 else
4032 RecordData.Time(nbfiles,1)=nbfiles;
4033 end
4034 else
4035 RecordData.Time(nbfiles,1)=(time(1,num_i1{1}(ifile),num_j1{1}(ifile))+time(end,num_i2{end}(ifile),num_j2{end}(ifile)))/2;
4036 end
4037 else
4038 nbmissing=nbmissing+1;
4039 end
4040 end
4041 end
4042
4043 for iattr=1:numel(RecordData.ListGlobalAttribute)
4044 if strcmp(RecordData.ListGlobalAttribute{iattr},'Time')
4045 RecordData.ListGlobalAttribute(iattr)=[];
4046 break
4047 end
4048 end
4049
4050
4051 for ivar=1:length(Field.VarDimIndex)
4052 vardimindex=Field.VarDimIndex{ivar};
4053 if testsum(ivar)==2
4054 RecordData.VarDimIndex{ivar}=[1 vardimindex+1];
4055 elseif testsum(ivar)==1
4056 RecordData.VarDimIndex{ivar}=[vardimindex+1];
4057 end
4058 end
4059
4060 indexremove=find(~testsum);
4061 if ~isempty(indexremove)
4062 RecordData.ListVarName(1+indexremove)=[];
4063 RecordData.VarDimIndex(indexremove)=[];
4064 if isfield(RecordData,'Role')&~isempty(RecordData.Role{1})
4065 RecordData.Role(1+indexremove)=[];
4066 end
4067 end
4068 RecordData.VarDimIndex=[{[1]} RecordData.VarDimIndex];
4069
4070 if isfield(RecordData,'VarAttribute')
4071 RecordData.VarAttribute=[{[]} RecordData.VarAttribute];
4072 end
4073 RecordData.DimValue=[length(RecordData.Time) RecordData.DimValue];
4074 RecordData.Action=Series.Action;
4075 errormsg=struct2nc(filemean,RecordData);
4076 if isempty(errormsg)
4077 display([filemean ' written'])
4078 else
4079 msgbox_uvmat('ERROR',['error in Series/struct2nc' errormsg])
4080 end
4081 end
4082 figure
4083 haxes=axes;
4084
4085 plot_field(RecordData,haxes)
4086 hget_field=findobj(allchild(0),'name','get_field');
4087 if ~isempty(hget_field)
4088 delete(hget_field)
4089 end
4090 get_field(filemean,RecordData)
4091
4092
4093
4094 function CoordType_Callback(hObject, eventdata, handles)
4095 menu_str=get(handles.CoordType,'String');
4096 ind_coord=get(handles.CoordType,'Value');
4097 coord_option=menu_str{ind_coord};
4098 if isequal(coord_option,'more...');
4099 fct_name='';
4100 if exist('./TMP/current_usr_fct.mat','file')
4101 h=load('./TMP/current_usr_fct.mat');
4102 if isfield(h,'fct_name');
4103 fct_name=h.fct_name;
4104 end
4105 end
4106 prompt = {'Enter the name of the transform function'};
4107 dlg_title = 'user defined transform';
4108 num_lines= 1;
4109 [FileName, PathName, filterindex] = uigetfile( ...
4110 {'*.m', ' (*.m)';
4111 '*.m', '.m files '; ...
4112 '*.*', 'All Files (*.*)'}, ...
4113 'Pick a file', fct_name);
4114 fct_name=fullfile(PathName,FileName);
4115 addpath(PathName);
4116 [errormsg,date_str]=check_functions;
4117 if ~exist(fct_name,'file')
4118 warndlg(['image procesing fct ' fct_name ' not found'])
4119 else
4120 transform=FileName(1:end-2);
4121 update_menu(handles.CoordType,transform)
4122
4123
4124 end
4125 end
4126 ind_coord=get(handles.CoordType,'Value');
4127
4128
4129
4130 function ProjObject_Callback(hObject, eventdata, handles)
4131
4132 list_object=get(handles.ProjObject,'String');
4133 index=get(handles.ProjObject,'Value');
4134 hseries=get(handles.ProjObject,'Parent');
4135 SeriesData=get(hseries,'UserData');
4136 Obj=SeriesData.ProjObject{index};
4137 [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index});
4138 set(hseries,'UserData',SeriesData);
4139
4140
4141
4142
4143
4144
4145
4146 function [num_i1,num_i2,num_j1,num_j2,nbmissing]=netseries_generator(filebase,subdir,mode,first_i,incr_i,last_i,first_j,incr_j,last_j)
4147 [Path,Name]=fileparts(filebase);
4148 filebasesub=fullfile(Path,subdir,Name);
4149 filecell={};
4150 num_i1=[];
4151 num_i2=[];
4152 num_j1=[];
4153 num_j2=[];
4154 ind0_i=first_i:incr_i:last_i;
4155 nbcolumn=length(ind0_i);
4156 ind0_j=first_j:incr_j:last_j;
4157 nbline=length(ind0_j);
4158 if isequal(mode,'#_ab')
4159 dirpair=dir([filebasesub '*_*.nc']);
4160 elseif isequal(mode,'bursts')|isequal(mode,'series(Dj)')
4161 dirpair=dir([filebasesub '_*_*-*.nc']);
4162 elseif isequal(mode,'series(Di)')
4163 dirpair=dir([filebasesub '_*-*_*.nc']);
4164 else
4165 errordlg('option *|* not yet implemented')
4166 return
4167 end
4168 if isempty(dirpair)
4169 errordlg('no pair detected in the selected range')
4170 return
4171 end
4172
4173
4174
4175 if isequal(mode,'bursts')|isequal(mode,'#_ab')
4176 icount=0;
4177 for ifile=1:length(dirpair)
4178 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
4179
4180
4181
4182
4183 num1_r=str2num(str_1);
4184 if isequal(RootFile,Name) & ~isempty(num1_r)
4185 num_i1(ifile)=num1_r;
4186 num_a(ifile)=stra2num(str_a);
4187 num_b(ifile)=stra2num(str_b);
4188
4189 end
4190 end
4191 length(dirpair)
4192
4193 test_range= (num_i1 >=first_i)&(num_i1<= last_i);
4194 ind_i=((num_i1-first_i)/incr_i)+1;
4195 select=find(test_range &(floor(ind_i)==ind_i));
4196 ind_i=ind_i(select);
4197 [ind_i,indsort]=sort(ind_i);
4198 select=select(indsort);
4199 num_i1=num_i1(select);
4200 num_a=num_a(select);
4201 num_b=num_b(select);
4202 dirpair=dirpair(select);
4203 [ind_remove]=find_pairs(dirpair,ind_i,nbcolumn);
4204 ind_i(ind_remove)=[];
4205 num_a(ind_remove)=[];
4206 num_b(ind_remove)=[];
4207 num_j1=zeros(1,nbcolumn);
4208 num_j2=num_j1;
4209 num_j1(ind_i)=num_a;
4210 num_j2(ind_i)=num_b;
4211 num_i1=first_i:incr_i:last_i;
4212 num_i2=num_i1;
4213 nbmissing=nbcolumn-length(ind_i);
4214
4215 elseif isequal(mode,'series(Di)')
4216
4217
4218
4219
4220
4221 for ifile=1:length(dirpair)
4222 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
4223 num_i1_r(ifile)=str2num(str_1);
4224 num_i2_r(ifile)=str2num(str_2);
4225 num_j(ifile)=str2num(str_a);
4226 end
4227 num_i=floor((num_i1_r+num_i2_r)/2);
4228 test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);
4229 ind_i=((num_i-first_i)/incr_i)+1;
4230 ind_j=((num_j-first_j)/incr_j)+1;
4231 ind_ij=ind_j+nbline*(ind_i-1);
4232 select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));
4233 ind_ij=ind_ij(select);
4234 [ind_ij,indsort]=sort(ind_ij);
4235 select=select(indsort);
4236 num_i1_r=num_i1_r(select);
4237 num_i2_r=num_i2_r(select);
4238
4239 dirpair=dirpair(select);
4240 [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ;
4241 ind_ij(ind_remove)=[];
4242 num_i1_r(ind_remove)=[];
4243 num_i2_r(ind_remove)=[];
4244 num_i1=zeros(1,nbline*nbcolumn);
4245 num_i2=num_i1;
4246 num_i1(ind_ij)=num_i1_r;
4247 num_j2(ind_ij)=num_i2_r;
4248 num_i1=reshape(num_i1,nbline,nbcolumn);
4249 num_i2=reshape(num_i2,nbline,nbcolumn);
4250 num_j1=meshgrid(ind0_i,ind0_j);
4251 num_j2=num_j1;
4252 nbmissing=nbline*nbcolumn-length(ind_ij);
4253 elseif isequal(mode,'series(Dj)')
4254
4255
4256
4257
4258
4259 for ifile=1:length(dirpair)
4260 [RootPath,RootFile,str_1,str_2,str_a,str_b,ext,nom_type]=name2display(dirpair(ifile).name);
4261 num_i(ifile)=str2num(str_1);
4262 num_a(ifile)=str2num(str_a);
4263 num_b(ifile)=str2num(str_b);
4264 end
4265 num_j=floor((num_a+num_b)/2);
4266 test_range= (num_i >=first_i)&(num_i<= last_i)&(num_j >=first_j)&(num_j<= last_j);
4267 ind_i=((num_i-first_i)/incr_i)+1;
4268 ind_j=((num_j-first_j)/incr_j)+1;
4269 ind_ij=ind_j+nbline*(ind_i-1);
4270 select=find(test_range &(floor(ind_i)==ind_i)&(floor(ind_j)==ind_j));
4271 ind_ij=ind_ij(select);
4272 [ind_ij,indsort]=sort(ind_ij);
4273 select=select(indsort);
4274 num_i=num_i(select);
4275 num_a=num_a(select);
4276 num_b=num_b(select);
4277 dirpair=dirpair(select);
4278 [ind_remove]=find_pairs(dirpair,ind_ij,nbcolumn*nbline) ;
4279 ind_ij(ind_remove)=[];
4280 num_a(ind_remove)=[];
4281 num_b(ind_remove)=[];
4282 num_j1=zeros(1,nbline*nbcolumn);
4283 num_j2=num_j1;
4284 num_j1(ind_ij)=num_a;
4285 num_j2(ind_ij)=num_b;
4286 num_j1=reshape(num_j1,nbline,nbcolumn);
4287 num_j2=reshape(num_j2,nbline,nbcolumn);
4288 num_i1=meshgrid(ind0_i,ind0_j);
4289 num_i2=num_i1;
4290 nbmissing=nbline*nbcolumn-length(ind_ij);
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302 end
4303
4304
4305 function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
4306
4307 indsel=ind_i;
4308 indiff=diff(ind_i);
4309 indiff=[1 indiff last_i-ind_i(end)+1];
4310 if ~isempty(indiff)
4311 indiff2=diff(indiff);
4312 indiffp=[indiff2 1];
4313 indiffm=[1 indiff2];
4314 ind_multi_m=find((indiff==0)&(indiffm<0))-1;
4315 ind_multi_p=find((indiff==0)&(indiffp>0));
4316
4317 ind_remove=[];
4318 for i=1:length(ind_multi_m)
4319 ind_pairs=ind_multi_m(i):ind_multi_p(i);
4320 for imulti=1:length(ind_pairs)
4321 datepair(imulti)=datenum(dirpair(ind_pairs(imulti)).date);
4322 end
4323 [datenew,indsort2]=sort(datepair);
4324 ind_s=indsort2(1:end-1);
4325 ind_remove=[ind_remove ind_pairs(ind_s)];
4326 end
4327 end
4328
4329
4330
4331
4332
4333
4334
4335 function displ_time(handles,times)
4336 hseries=get(handles.last_i,'parent');
4337 SeriesData=get(hseries,'UserData');
4338 first_i=str2num(get(handles.first_i,'String'));
4339 first_j=str2num(get(handles.first_j,'String'));
4340 last_i=str2num(get(handles.last_i,'String'));
4341 last_j=str2num(get(handles.last_j,'String'));
4342
4343
4344 NomType=SeriesData.NomType;
4345 mode_list=get(handles.mode,'String');
4346 index_mode=get(handles.mode,'Value');
4347 mode=mode_list{index_mode};
4348
4349
4350 time_first=[];
4351 time_last=[];
4352 if ~isfield(SeriesData,'Time')
4353 SeriesData.Time{1}=[];
4354 end
4355 for iview=1:length(NomType)
4356 time_first_cell{iview}='?';
4357 time_last_cell{iview}='?';
4358 time=SeriesData.Time{iview};
4359 if isequal(NomType{iview},'_i1-i2_j')|isequal(NomType{iview},'_i_j1-j2')|isequal(NomType{iview},'#_ab')|isequal(NomType{iview},'_i1-i2')
4360 if isfield(SeriesData,'displ_num')& ~isempty(SeriesData.displ_num)
4361 ind_shift=SeriesData.displ_num(iview,:);
4362 if isequal(mode,'bursts')
4363 first_j=0;
4364 last_j=0;
4365 end
4366 first_i1=first_i +ind_shift(3);
4367 first_i2 =first_i +ind_shift(4);
4368 first_j1 =first_j +ind_shift(1);
4369 first_j2 =first_j +ind_shift(2);
4370 last_i1=last_i +ind_shift(3);
4371 last_i2 =last_i +ind_shift(4);
4372 last_j1 =last_j +ind_shift(1);
4373 last_j2 =last_j +ind_shift(2);
4374 siz=size(SeriesData.Time{1});
4375 if siz(1)>=last_i2 & siz(2)>=last_j2
4376 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
4377 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
4378 else
4379 RootPath=get(handles.RootPath,'String');
4380 RootFile=get(handles.RootFile,'String');
4381 SubDir=get(handles.SubDir,'String');
4382
4383 VelType_str=get(handles.VelTypeMenu,'String');
4384 VelType_val=get(handles.VelTypeMenu,'Value');
4385 VelType=VelType_str{VelType_val};
4386 filebase=fullfile(RootPath{1},RootFile{1});
4387 [filefirst]=name_generator(filebase,first_i1,first_j1,'.nc',NomType{iview},1,first_i2,first_j2,SubDir{iview});
4388 if exist(filefirst,'file')
4389 Attrib=nc2struct(filefirst,[]);
4390 if isfield(Attrib,'Time')
4391 time_first=Attrib.Time;
4392 else
4393 if isfield(Attrib,'absolut_time_T0')
4394 time_first=Attrib.absolut_time_T0;
4395 end
4396 if isfield(Attrib,'absolut_time_T0_2')&~(isequal(VelType,'civ1')|isequal(VelType,'interp1')|isequal(VelType,'filter1'))
4397 time_first=Attrib.absolut_time_T0_2;
4398 end
4399 end
4400 end
4401 [filelast]=name_generator(filebase,last_i1,last_j1,'.nc',NomType{iview},1,last_i2,last_j2,SubDir{iview});
4402 if exist(filelast,'file')
4403 Attrib=nc2struct(filelast,[]);
4404 if isfield(Attrib,'Time')
4405 time_last=Attrib.Time;
4406 else
4407 if isfield(Attrib,'absolut_time_T0')
4408 time_last=Attrib.absolut_time_T0;
4409 end
4410 if isfield(Attrib,'absolut_time_T0_2')&~(isequal(VelType,'civ1')|isequal(VelType,'interp1')|isequal(VelType,'filter1'))
4411 time_last=Attrib.absolut_time_T0_2;
4412 end
4413 end
4414 end
4415 end
4416 end
4417 else
4418 siz=size(times);
4419 if siz(1)>=last_i & siz(2)>=last_j
4420 time_first=times(first_i,first_j);
4421 time_last=times(last_i,last_j);
4422 end
4423 end
4424 time_first_cell{iview}=num2str(time_first,4);
4425 time_last_cell{iview}=num2str(time_last,4);
4426 end
4427 set(handles.time_first,'Value',1)
4428 set(handles.time_last,'Value',1)
4429 set(handles.time_first,'String',time_first_cell);
4430 set(handles.time_last,'String',time_last_cell);
4431
4432
4433
4434 function VelTypeMenu_Callback(hObject, eventdata, handles)
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444 function GetObject_Callback(hObject, eventdata, handles)
4445 hseries=get(handles.GetObject,'parent');
4446 SeriesData=get(hseries,'UserData');
4447 value=get(handles.GetObject,'Value');
4448 if value
4449 set(handles.GetObject,'BackgroundColor',[1 1 0])
4450 DataInit.ParentButton=handles.GetObject;
4451 hset_object=findobj(allchild(0),'Name','set_object');
4452 if ishandle(hset_object)
4453 [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit);
4454 else
4455 DataInit.TITLE='POINTS';
4456 [SeriesData.hset_object,SeriesData.sethandles]=set_object(DataInit);
4457 end
4458 else
4459 set(handles.GetObject,'BackgroundColor',[0 1 0])
4460 if isfield(SeriesData,'hset_object')&& ishandle(SeriesData.hset_object)
4461 close(SeriesData.hset_object)
4462 end
4463 end
4464 set(hseries,'UserData',SeriesData)
4465
4466
4467 function GetMask_Callback(hObject, eventdata, handles)
4468 value=get(handles.GetMask,'Value');
4469 if value
4470 errordlg('not implemented yet')
4471 end
4472
4473
4474
4475
4476 function ncbrowser_uvmat(hObject, eventdata)
4477 bla=get(gcbo,'String');
4478 ind=get(gcbo,'Value');
4479 filename=cell2mat(bla(ind));
4480 blank=find(filename==' ');
4481 filename=filename(1:blank-1);
4482 get_field(filename)
4483
4484
4485
4486
4487 function MenuHelp_Callback(hObject, eventdata, handles)
4488
4489 path_to_uvmat=which ('uvmat');
4490 pathelp=fileparts(path_to_uvmat);
4491 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
4492 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
4493 else
4494 web([helpfile '#series'])
4495 end
4496
4497
4498
4499
4500
4501