Changeset 177 for trunk/src/civ.m
- Timestamp:
- Jan 7, 2011, 1:53:05 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r174 r177 22 22 function varargout = civ(varargin) 23 23 24 % Last Modified by GUIDE v2.5 0 1-Dec-2010 23:19:1524 % Last Modified by GUIDE v2.5 05-Jan-2011 16:19:30 25 25 % Begin initialization code - DO NOT EDIT 26 26 gui_Singleton = 1; … … 335 335 browse.num_j2=num_j2; 336 336 if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat 337 % set(handles.ImaExt,'String',ext)338 337 browse.nom_type_ima=nom_type; 339 338 browse.ext_ima=ext; 339 set(handles.ImaExt,'String',ext) 340 340 end 341 341 set(handles.ImaDoc,'String',ext); … … 593 593 end 594 594 end 595 % if ~isempty(ext_ima_read) && ~isempty(nom_type_read)596 % % if isempty(ext_ima)597 % % ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously598 % % else %keep the image extension599 % % if ~strcmp(ext_ima_read,ext_ima)600 % % msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])601 % % end602 % % end603 % nom_type_ima=nom_type_read;604 % end605 595 elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file 606 596 [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); … … 612 602 nom_type_ima='*'; 613 603 ext_ima=ext_imadoc; 604 set(handles.mode,'Value',1); 614 605 set(handles.mode,'String',{'series(Di)'}) 615 606 dt=0.04;%default … … 620 611 end 621 612 time=(dt*(0:nbfield-1))';%list of image times 622 %set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images623 613 end 624 614 if isempty(time) … … 698 688 field_i=browse.num_i1; 699 689 field_j=browse.num_j2; 690 imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); 700 691 imagename_plus=''; 701 692 jdetect=1; … … 716 707 time=(0:nbfield-1)';% time=file index -1 by default 717 708 if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j 718 % switch nom_type_search719 % case {'_i_j','%01dA','%02dA','%03dA','%04dA'}720 % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1 by default721 709 [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); 722 710 time=x+y; 723 % time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1 by default 724 end 725 % set(handles.mode,'String',{'series(Di)'}) 711 end 726 712 end 727 713 … … 750 736 751 737 %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% 752 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D' ));%images with single indexing738 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing 753 739 if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) 754 set(handles.mode,'String',{'series(Di)'})755 740 set(handles.mode,'Value',1) 741 set(handles.mode,'String',{'series(Di)'}) 756 742 elseif (nbfield==1)% simple series in j 743 set(handles.mode,'Value',1) 757 744 set(handles.mode,'String',{'series(Dj)'}) 758 set(handles.mode,'Value',1)759 745 else 760 746 set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice … … 788 774 mode_Callback(hObject, eventdata, handles) 789 775 790 %% %%%% initialize waitbars and RUN button776 %% desable status and RUN button 791 777 % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) 792 778 % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) … … 797 783 set(handles.BATCH,'Enable','On') 798 784 set(handles.BATCH,'BackgroundColor',[1 0 0]) 799 800 %%%%% store the root input filename for future opening 785 set(handles.status,'Value',0);%suppress status display 786 status_Callback(hObject, eventdata, handles) 787 788 %% store the root input filename for future opening 801 789 dir_perso=prefdir; 802 790 profil_perso=fullfile(prefdir,'uvmat_perso.mat'); … … 814 802 end 815 803 end 816 % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat817 set(gcf,'Pointer','arrow')818 804 819 805 %------------------------------------------------------------------------ … … 1565 1551 end 1566 1552 1553 %------------------------------------------------------------------------ 1554 % --- Executes on button press in RUN: processing on local computer 1567 1555 function RUN_Callback(hObject, eventdata, handles) 1568 1556 %------------------------------------------------------------------------ 1569 % global civ1_exe civ2_exe patch_exe patch_new_exe sge1570 1557 set(handles.RUN, 'Enable','Off') 1571 1558 set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) … … 1575 1562 set(handles.RUN,'BackgroundColor',[1 0 0]) 1576 1563 1564 % start status callback to visualise results 1565 set(handles.status,'Value',1);%suppress status display 1566 status_Callback(hObject, eventdata, handles) 1567 1577 1568 %------------------------------------------------------------------------ 1578 1569 % --- Executes on button press in BATCH: remote processing 1579 1570 function BATCH_Callback(hObject, eventdata, handles) 1580 %% ----------------------------------------------------------------------- 1581 %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove 1571 % ----------------------------------------------------------------------- 1582 1572 set(handles.BATCH, 'Enable','Off') 1583 1573 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) … … 1587 1577 set(handles.BATCH,'BackgroundColor',[1 0 0]) 1588 1578 1579 % start status callback to visualise results 1580 set(handles.status,'Value',1);%suppress status display 1581 status_Callback(hObject, eventdata, handles) 1589 1582 %------------------------------------------------------------------------ 1590 1583 % --- Lauch command called by RUN and BATCH: remote processing … … 1613 1606 end 1614 1607 1615 % check mask if selecetd1608 %% check mask if selecetd 1616 1609 if isequal(get(handles.get_mask_civ1,'Value'),1) 1617 1610 maskname=get(handles.mask_civ1,'String'); … … 1639 1632 end 1640 1633 1641 %% initialize the waitbars: TO suppress, waitbar not used 1642 % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) 1643 % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) 1644 % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) 1645 % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) 1646 % drawnow 1634 %% reinitialise status callback 1635 set(handles.status,'Value',0);%suppress status display 1636 status_Callback(hObject, eventdata, handles) 1647 1637 1648 1638 %% set the list of files and check them … … 1651 1641 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... 1652 1642 set_civ_filenames(handles,box_test); 1643 set(handles.civ,'UserData',filecell);%store for futur use of status callback 1653 1644 if isempty(filecell)% (error message displayed in fct set_civ_filenames) 1654 1645 return … … 1879 1870 %filename_cur=filecell.nc.civ1{ifile,j};%output netcdf file 1880 1871 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) 1872 flname=fullfile(Rootbat,Filebat); 1881 1873 %filename_cmx(end-1:end+6)='civ1.cmx';%name of cmx file 1882 1874 if batch … … 1884 1876 filename_bat=fullfile(Rootbat,['job_' Filebat]); 1885 1877 else 1886 filename_bat=f ullfile(Rootbat,Filebat);1878 filename_bat=flname; 1887 1879 end 1888 1880 filename_bat=[filename_bat '.bat']; … … 1892 1884 par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; 1893 1885 par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; 1894 namelog=[fullfile(Rootbat,Filebat) '.civ1.log'];1886 %namelog=[fullfile(Rootbat,Filebat) '.civ1.log']; 1895 1887 par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); 1896 1888 par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); … … 2065 2057 %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension 2066 2058 [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) 2067 namelog=[fullfile(Rootbat,Filebat) '.civ2.log'];2059 %namelog=[fullfile(Rootbat,Filebat) '.civ2.log']; 2068 2060 par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); 2069 2061 par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); … … 2119 2111 %endTESTgrid 2120 2112 i_cmd=i_cmd+1; 2121 cmd_CIV2=CIV2_CMD(fullfile(Rootbat,Filebat),[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 2113 flname=fullfile(Rootbat,Filebat); 2114 cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] 2122 2115 if isequal(civAll,0) 2123 flname=fullfile(Rootbat,Filebat);2124 2116 if(isunix) 2125 2117 cmd=[cmd 'cp -f ' flname '.civ2.cmx ' flname '.cmx\n' cmd_CIV2 '\n']; … … 2253 2245 pvalue=num2str((1-ind_answer)*500); 2254 2246 %namelog=[filename_bat '.patch.log']; 2255 display(['!qsub -p ' pvalue ' -q civ.q -e ' f ilename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4)'.log' ' ' filename_bat]);2256 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' f ilename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4)'.log' ' ' filename_bat]);2247 display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2248 eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); 2257 2249 end 2258 2250 else … … 2305 2297 end 2306 2298 saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) 2299 2307 2300 2308 2301 … … 4417 4410 set(handles.RootName_1,'String',[]); 4418 4411 mode_store=get(handles.compare,'UserData'); 4412 set(handles.mode,'Value',1) 4419 4413 set(handles.mode,'String',mode_store) 4420 4414 set(handles.test_stereo1,'Value',0) … … 4603 4597 end 4604 4598 4605 4606 4607 4608 4609 4599 %------------------------------------------------------------------- 4600 % --- Executes on button press in status. 4601 function status_Callback(hObject, eventdata, handles) 4602 %------------------------------------------------------------------- 4603 val=get(handles.status,'Value'); 4604 if val==0 4605 hfig=findobj(allchild(0),'name','civ_status'); 4606 if ~isempty(hfig) 4607 delete(hfig) 4608 end 4609 return 4610 end 4611 listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; 4612 box_test(1)=get(handles.CIV1,'Value'); 4613 box_test(2)=get(handles.FIX1,'Value'); 4614 box_test(3)=get(handles.PATCH1,'Value'); 4615 box_test(4)=get(handles.CIV2,'Value'); 4616 box_test(5)=get(handles.FIX2,'Value'); 4617 box_test(6)=get(handles.PATCH2,'Value'); 4618 option=listtype{max(box_test(find(box_test)))}; 4619 filecell=get(handles.civ,'UserData'); 4620 if ~isfield(filecell,'nc') 4621 filecell=set_civ_filenames(handles,box_test);%determine the list of output files expected from the GUI status 4622 end 4623 4624 if ~isequal(box_test(4:6),[0 0 0]) 4625 civ_files=filecell.nc.civ2; 4626 else 4627 civ_files=filecell.nc.civ1; 4628 end 4629 [root,filename,ext]=fileparts(civ_files{1}); 4630 [rootroot,subdir,extdir]=fileparts(root); 4631 hfig=findobj(allchild(0),'name','civ_status'); 4632 if isempty(hfig) 4633 hfig=figure; 4634 set(hfig,'name','civ_status') 4635 hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.05 0.9 0.75], 'Callback', @open_view_field,'tag','list'); 4636 uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox'); 4637 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 4638 BarPosition=[0.05 0.81 0.01 0.05]; 4639 hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); 4640 end 4641 datnum=[]; 4642 Tabchar={}; 4643 nbfiles=numel(civ_files); 4644 count=0; 4645 while count<nbfiles 4646 count=0; 4647 for ifile=1:nbfiles 4648 detect=exist(civ_files{ifile},'file'); % check the existence of the file 4649 if detect==0 4650 lastfield='not created'; 4651 else 4652 datfile=dir(civ_files{ifile}); 4653 datnum(ifile)=datenum(datfile.date); 4654 filefound(ifile)={datfile.name}; 4655 lastfield=''; 4656 % check the content netcdf file 4657 Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); 4658 if ~isempty(Data.patch2) && isequal(Data.patch2,1) 4659 lastfield='patch2'; 4660 elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 4661 lastfield='fix2'; 4662 elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 4663 lastfield='civ2'; 4664 elseif ~isempty(Data.patch) && isequal(Data.patch,1); 4665 lastfield='patch1'; 4666 elseif ~isempty(Data.fix) && isequal(Data.fix,1); 4667 lastfield='fix1'; 4668 else 4669 lastfield='civ1'; 4670 end 4671 end 4672 if strcmp(lastfield,option) 4673 count=count+1; 4674 end 4675 [rr,filename,ext]=fileparts(civ_files{ifile}); 4676 Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' lastfield]; 4677 end 4678 if isempty(datnum) 4679 message='no civ result created yet'; 4680 else 4681 datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files 4682 [first,ind]=min(datnum); 4683 [last,indlast]=max(datnum); 4684 message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 4685 ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 4686 end 4687 hfig=findobj(allchild(0),'name','civ_status'); 4688 if isempty(hfig) 4689 set(handles.status,'Value',0)%stop program if the figure has been suppressed 4690 return 4691 else 4692 hlist=findobj(hfig,'tag','list'); 4693 hmsgbox=findobj(hfig,'tag','msgbox'); 4694 hwaitbar=findobj(hfig,'tag','waitbar'); 4695 set(hlist,'String',Tabchar) 4696 set(hmsgbox,'String', message) 4697 if count>0 4698 BarPosition(3)=0.9*count/nbfiles; 4699 set(hwaitbar,'Position',BarPosition) 4700 end 4701 end 4702 set(hlist,'UserData',rootroot) 4703 pause(5)% wait 5 seconds for next check 4704 end 4705 4706 4707 %------------------------------------------------------------------- 4708 % call 'view_field.fig' to display the selected field 4709 function open_view_field(hObject, eventdata) 4710 %------------------------------------------------------------------- 4711 list=get(gcbo,'String'); 4712 index=get(gcbo,'Value'); 4713 rootroot=get(gcbo,'UserData'); 4714 filename=list{index}; 4715 ind_dot=findstr(filename,'...'); 4716 filename=filename(1:ind_dot-1); 4717 filename=fullfile(rootroot,filename); 4718 if exist(filename,'file')%visualise the vel field if it exists 4719 [Field,VelTypeOut]=read_civxdata(filename); 4720 view_field(Field) 4721 end 4722 4723
Note: See TracChangeset
for help on using the changeset viewer.