- Timestamp:
- Nov 14, 2010, 9:58:15 PM (14 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r120 r122 67 67 ext=[]; 68 68 testall=0; 69 browse=[];70 69 %default input parameters: 71 70 num1=1; % set of field i numbers 72 num2= 2; % set of field i numbers71 num2=1; % set of field i numbers 73 72 num_a=1; % set of field j numbers (fields a) 74 73 num_b=1; % second set of field j numbers (fields b) … … 87 86 ext=param.ImaExt; 88 87 end 89 if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||... 90 strcmp(lower(ext),'.avi'));%if an image file has been opened by uvmat 88 browse.num_i1=num1; 89 browse.num_i2=num2; 90 browse.num_j1=num_a; 91 browse.num_j2=num_b; 92 if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat 91 93 set(handles.ImaExt,'String',ext) 92 94 if exist('nom_type_read','var') … … 102 104 set(handles.ImaDoc,'String',ext) 103 105 104 %read names of the .exe file to adjust the interface according to 105 %available binaries 106 %read names of the .exe file to adjust the interface according to available binaries 106 107 path_uvmat=which('uvmat');% check the path detected for source file uvmat 107 108 path_UVMAT=fileparts(path_uvmat); %path to UVMAT … … 315 316 browse=get(handles.browse_root,'UserData'); 316 317 end 317 if length(ext)>1 && (~isempty(imformats(ext(2:end)))||... 318 isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat 319 set(handles.ImaExt,'String',ext) 318 browse.num_i1=num_i1; 319 browse.num_i2=num_i2; 320 browse.num_j1=num_j1; 321 browse.num_j2=num_j2; 322 if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat 323 % set(handles.ImaExt,'String',ext) 320 324 browse.nom_type_ima=nom_type; 321 browse. field_count=num_i1;325 browse.ext_ima=ext; 322 326 end 323 327 set(handles.ImaDoc,'String',ext); … … 437 441 %------------------------------------------------------------------------ 438 442 set(handles.compare,'Visible','on') 439 ext_ima=get(handles.ImaExt,'String'); 443 %ext_ima=get(handles.ImaExt,'String'); 444 ext_ima='';%default 440 445 nom_type_ima=[];%default 441 446 field_count=1;%default … … 447 452 pxcmy_search=[];%default 448 453 filebase=get(handles.RootName,'String'); 449 450 454 ext=get(handles.ImaDoc,'String'); 451 455 browse=get(handles.browse_root,'UserData');%default 452 if ~isempty(browse) 453 if isfield(browse,'nom_type_ima') 454 nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name 455 end 456 if isfield(browse,'field_count') 457 field_count=browse.field_count;% get an image index type already determined by an input file 458 end 456 if isfield(browse,'nom_type_ima') 457 nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name 458 ext_ima=browse.ext_ima; 459 end 460 if isfield(browse,'nom_type_nc') 461 nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name 462 end 463 if isfield(browse,'num_i1') 464 field_count=browse.num_i1;% get an image index type already determined by an input file 459 465 end 460 466 … … 522 528 testima_xml=0; 523 529 if isequal(ext,'.civxml')%TO ABANDON 524 [nbfield,nb urst,time]=read_civxml([filebase '.civxml']);530 [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); 525 531 mode='pair j1-j2'; 526 532 if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat … … 541 547 time=XmlData.Time; 542 548 nbfield=size(time,1); 543 nb urst=size(time,2);549 nbfield2=size(time,2); 544 550 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 545 if isequal(nbfield,1) && ~isequal(nb urst,1)% .Time is a line vector551 if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector 546 552 if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%')) 547 553 time=time'; 548 nbfield=nb urst;549 nb urst=1;554 nbfield=nbfield2; 555 nbfield2=1; 550 556 end 551 557 end … … 572 578 end 573 579 if ~isempty(ext_ima_read) && ~isempty(nom_type_read) 574 if isempty(ext_ima)575 ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously576 else %keep the image extension577 if ~strcmp(ext_ima_read,ext_ima)578 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])579 end580 end580 % if isempty(ext_ima) 581 % ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously 582 % else %keep the image extension 583 % if ~strcmp(ext_ima_read,ext_ima) 584 % msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) 585 % end 586 % end 581 587 nom_type_ima=nom_type_read; 582 588 end 583 elseif isequal(ext,'.civ')% case of .civ image documentation file589 elseif strcmp(ext,'.civ')% case of .civ image documentation file 584 590 [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); 585 591 if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); … … 588 594 % ImaExt='.png'; 589 595 nom_type_ima='png_old'; 590 elseif isequal(lower(ext),'.avi')596 elseif strcmpi(ext,'.avi') 591 597 nom_type_ima='*'; 592 598 ext_ima=ext; … … 606 612 set(handles.ImaDoc,'BackgroundColor',[1 1 1]) 607 613 608 %get the imabe nomenclature type if not defiend by the input file nor by the xml file 614 %get the imabe nomenclature type if not defined by the input file nor by the xml file 615 dirima=[];%default 609 616 if isempty(nom_type_ima) 610 617 %look for double image series '_i_j' … … 616 623 % look for other images series 617 624 dirima=dir([filebase '*' num2str(first_i) '.*']); 618 if ~isempty(dirima) 619 [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 620 end 621 else 622 [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 623 end 624 else 625 [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 626 end 627 end 628 % no image documentation file found: look for a series of existing images or .nc files 629 if isempty(time) && ~isequal(ext,'.nc') && ~strcmp(nom_type_ima,'none') && ~strcmp(nom_type_ima,'') && ~strcmp(nom_type_ima,'*') 625 if isempty(dirima) 626 % look for other images series witth letter appendix 627 appendix=char(96+first_j); 628 dirima=dir([filebase '*' num2str(first_i) appendix '.*']); 629 % if ~isempty(dirima) 630 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 631 % end 632 % else 633 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 634 end 635 % else 636 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 637 end 638 % else 639 % [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); 640 end 641 end 642 for ilist=1:numel(dirima) 643 [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); 644 form=imformats(ext_list(2:end)); 645 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 646 ext_ima=ext_list; 647 nom_type_ima=nom_type_list; 648 break 649 end 650 end 651 % no image documentation file found: look for a series of existing files,images by priority or .nc files 652 if isempty(nom_type_ima) 653 ext_search=ext; 654 nom_type_search=nom_type_nc; 655 else 656 ext_search=ext_ima; 657 nom_type_search=nom_type_ima; 658 end 659 if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') 630 660 subdir=get(handles.subdir_civ1,'String'); 631 661 incr_pair=[0 0];%default … … 634 664 end 635 665 % nbdetect=0;%test of detected images 636 field_i= field_count;666 field_i=browse.num_i2; 637 667 idetect=1; 638 668 while idetect==1 %look for the maximum file number in the series 639 imagename=name_generator(filebase,field_i+1,1,ext_ ima,nom_type_ima);669 imagename=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); 640 670 idetect=(exist(imagename,'file')==2); 641 671 if idetect … … 645 675 % nbdetect=nbdetect+(exist(imagename,'file')==2); 646 676 end 647 nb _field=field_i;% last detected field number648 field_i= field_count;%look for the minimum file number in the series677 nbfield=field_i;% last detected field number 678 field_i=browse.num_i1;%look for the minimum file number in the series 649 679 idetect=1; 650 680 while idetect==1 651 imagename=name_generator(filebase,field_i-1,1,ext_ ima,nom_type_ima);681 imagename=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); 652 682 idetect=(exist(imagename,'file')==2); 653 683 if idetect … … 655 685 end 656 686 end 657 first_i=max(field_i,1); 658 659 switch nom_type_ima 660 case {'_i_j','%01dA','%02dA','%03dA','%04dA'} 661 field_i=field_count; 662 field_j=1; 687 first_i=max(field_i,1); 688 if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j 689 field_i=browse.num_i1; 690 field_j=browse.num_j2; 663 691 jdetect=1; 664 692 while jdetect==1 %look for the maximum file number in the series 665 imagename=name_generator(filebase,field_i,field_j,ext_ ima,nom_type_ima);693 imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); 666 694 jdetect=(exist(imagename,'file')==2); 667 695 if jdetect … … 671 699 % nbdetect=nbdetect+(exist(imagename,'file')==2); 672 700 end 673 nb _field_j=field_j-1;% last detected field number701 nbfield2=field_j;% last detected field number 674 702 end 675 676 677 703 678 704 %determine the set of times and possible intervals for CIV 679 705 % dt=(1/1000)*str2num(get(handles.dt,'String')); 680 time=(0:nb _field-1)';% time=file index -1 by default681 682 switch nom_type_ima 683 case {'_i_j','%01dA','%02dA','%03dA','%04dA'}706 time=(0:nbfield-1)';% time=file index -1 by default 707 if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j 708 % switch nom_type_search 709 % case {'_i_j','%01dA','%02dA','%03dA','%04dA'} 684 710 % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1 by default 685 [x,y]=meshgrid( [0:2-1],[0:152-1]);711 [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); 686 712 time=x+y; 687 713 % time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1 by default 688 714 end 689 690 691 set(handles.mode,'String',{'series(Di)'}) 692 end 693 % if isequal(nom_type_ima,'none')% no file numbering used 694 % first_i=1; 695 % last_i=1; 696 % first_j=1; 697 % last_j=1; 698 % end 715 % set(handles.mode,'String',{'series(Di)'}) 716 end 699 717 700 718 if exist('time','var') … … 722 740 723 741 %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% 724 if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) 742 test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D'));%images with single indexing 743 if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) 725 744 set(handles.mode,'String',{'series(Di)'}) 726 set(handles.mode,'Value',1)727 elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old')728 set(handles.mode,'String',{'pair j1-j2'})729 745 set(handles.mode,'Value',1) 730 746 elseif (nbfield==1)% simple series in j … … 733 749 else 734 750 set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 735 if nbfield2 <= 5751 if nbfield2 <= 10 736 752 set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst 737 753 end 738 % else739 % if isequal(mode,'volume')740 % set(handles.mode,'Value',3)741 % elseif nbfield2 <= 5742 % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts743 % else744 % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume745 % end746 754 end 747 755 … … 777 785 set(handles.RUN, 'Enable','On') 778 786 set(handles.RUN,'BackgroundColor',[1 0 0]) 779 780 787 set(handles.BATCH,'Enable','On') 788 set(handles.BATCH,'BackgroundColor',[1 0 0]) 781 789 782 790 %%%%% store the root input filename for future opening … … 2165 2173 end 2166 2174 end 2167 2168 2169 2170 2175 if batch 2171 2176 if isfield(sparam,'BatchMode') … … 2184 2189 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) 2185 2190 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) 2186 2187 2191 drawnow 2188 %get the filename root, nomenclature and numbers2189 2190 % for Windows system find the UBC path name if needed2191 % if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\')2192 % cur_dir=pwd;2193 % if ~isequal(cur_dir(2:3),':\')2194 % cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M:2195 % end2196 % [ss,ww]=dos(['net use ' filebase(1:2)]);2197 % if isequal(ss,0)2198 % rankpath=findstr(ww,'\\');2199 % if ~isempty(rankpath)2200 % wwrest=ww(rankpath:end);2201 % rankend=min(find(double(wwrest)==10))-1;2202 % filebase=[wwrest(1:rankend) filebase(3:end)];2203 % set(handles.RootName,'String',filebase);2204 % end2205 % else2206 % msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed');2207 % % set(handles.BATCH, 'Enable','On')2208 % % set(handles.BATCH,'BackgroundColor',[1 0 0])2209 % return2210 % end2211 % end2212 2192 2213 2193 % set the list of files and check them … … 2240 2220 [s,w]=unix('ps faux |grep civ|wc -l'); 2241 2221 w(end)=[]; 2242 str2num(w)+numel(num1_civ1)2243 2222 if str2num(w)+numel(num1_civ1)> MaxCivProcesses 2244 2223 msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) … … 2247 2226 end 2248 2227 end 2249 2250 2228 display('files OK, processing...') 2251 2229 nbfield=numel(num1_civ1); … … 2325 2303 %%%%%%%%%%%%%%%%%%% 2326 2304 end 2327 2328 2329 2305 2330 2306 %get patch2 parameters … … 2812 2788 ext_ima=get(handles.ImaExt,'String'); 2813 2789 nom_type_nc=browse.nom_type_nc; 2814 nom_type_ima2=browse.nom_type_ima; 2815 if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default 2816 if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default 2790 if isfield(browse,'nom_type_ima') 2791 nom_type_ima2=browse.nom_type_ima; 2792 end 2793 if isempty(nom_type_ima2),nom_type_ima2='1';end; %default 2794 if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default 2817 2795 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... 2818 2796 find_pair_indices(handles,mode); … … 2950 2928 if ~exist(file_ref,'file') 2951 2929 msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) 2952 filecell= [];2930 filecell={}; 2953 2931 return 2954 2932 end … … 2967 2945 if ~exist(Path_ima,'dir') 2968 2946 msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) 2969 filecell= [];2947 filecell={}; 2970 2948 return 2971 2949 end … … 2974 2952 m2=''; 2975 2953 [erread,message]=fileattrib(Path_ima); 2976 if ~isempty(message) & ~isequal(message.UserWrite,1)2954 if ~isempty(message) && ~isequal(message.UserWrite,1) 2977 2955 msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) 2978 filecell= [];2956 filecell={}; 2979 2957 cd(currentdir); 2980 2958 return … … 2986 2964 detect=1; 2987 2965 while detect==1 %create a new subdir if the netcdf files already exist 2988 for ifile=1:nbfield; 2966 vers=0; 2967 subdir_civ1_new=subdir_civ1; 2968 for ifile=1:nbfield 2989 2969 for j=1:nbslice 2990 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1 );2970 filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new); 2991 2971 detect=exist(filename,'file')==2; 2992 2972 if detect% if a netcdf file already exists 2993 subdir_civ1=[subdir_civ1 '.0']; 2973 vers=vers+1; 2974 subdir_civ1_new=[subdir_civ1 '_' num2str(vers)]; 2994 2975 subdir_civ2=subdir_civ1; 2995 2976 break … … 3001 2982 end 3002 2983 end 2984 subdir_civ1=subdir_civ1_new; 3003 2985 %create the new subdir_civ1 3004 2986 if ~exist(fullfile(Path_ima,subdir_civ1),'dir') 3005 2987 [m1,m2,m3]=mkdir(subdir_civ1); 3006 2988 if ~isequal(m2,'') 3007 msgbox_uvmat('ERROR', m2) 3008 %msgbox(m2);%error message for directory creation 2989 msgbox_uvmat('ERROR', m2)%error message for directory creation 2990 cd(currentdir) 2991 filecell={}; 2992 return 3009 2993 end 3010 2994 end 3011 2995 if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series 2996 vers=0; 2997 subdir_civ1_new=subdir_civ1; 3012 2998 for ifile=1:nbfield 3013 2999 for j=1:nbslice 3014 filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1 );%3000 filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);% 3015 3001 detect=exist(filename,'file')==2; 3016 3002 if detect% if a netcdf file already exists 3017 subdir_civ1=[subdir_civ1 '.0']; 3003 vers=vers+1; 3004 subdir_civ1_new=[subdir_civ1 '_' num2str(vers)]; 3018 3005 subdir_civ2=subdir_civ1; 3019 3006 break … … 3025 3012 end 3026 3013 end 3014 subdir_civ1=subdir_civ1_new; 3027 3015 %create the new subdir_civ1 3028 3016 if ~exist(fullfile(Path_ima,subdir_civ1),'dir') … … 3030 3018 if ~isequal(m2,'') 3031 3019 msgbox_uvmat('ERROR', m2) 3020 cd(currentdir) 3021 filecell={}; 3022 return 3032 3023 end 3033 3024 end … … 3047 3038 if idetectmin==0, 3048 3039 msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) 3049 filecell=[]; 3040 filecell={}; 3041 cd(currentdir) 3050 3042 return 3051 3043 end … … 3053 3045 if idetectmin==0, 3054 3046 msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) 3055 filecell= [];3047 filecell={}; 3056 3048 cd(currentdir) 3057 3049 return … … 3071 3063 if idetectmin==0, 3072 3064 msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) 3073 filecell= [];3065 filecell={}; 3074 3066 cd(currentdir) 3075 3067 return … … 3078 3070 if idetectmin==0, 3079 3071 msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) 3080 filecell= [];3072 filecell={}; 3081 3073 cd(currentdir) 3082 3074 return … … 3092 3084 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% 3093 3085 detect=exist(filename,'file')==2; 3086 if detect==0 3087 msgbox_uvmat('ERROR',[filename ' not found']) 3088 filecell={}; 3089 cd(currentdir) 3090 return 3091 end 3094 3092 filecell.nc.civ1(ifile,j)={filename}; 3095 3093 end … … 3104 3102 set(handles.RUN, 'Enable','On') 3105 3103 set(handles.RUN,'BackgroundColor',[1 0 0]) 3106 % set(handles.BATCH, 'Enable','On') 3107 % set(handles.BATCH,'BackgroundColor',[1 0 0]) 3108 filecell=[]; 3104 filecell={}; 3109 3105 cd(currentdir) 3110 3106 return … … 3141 3137 if ~isequal(m2,'') 3142 3138 msgbox_uvmat('ERROR', m2) 3139 filecell={}; 3140 cd(currentdir) 3141 return 3143 3142 end 3144 3143 end 3145 3144 if strcmp(compare,'stereo PIV')%check second nc series 3145 vers=0; 3146 subdir_civ2_new=subdir_civ2; 3146 3147 for ifile=1:nbfield 3147 3148 for j=1:nbslice 3148 3149 filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... 3149 nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2 );%3150 nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% 3150 3151 detect=exist(filename,'file')==2; 3151 3152 if detect% if a netcdf file already exists 3152 subdir_civ2=[subdir_civ2 '.0']; 3153 vers=vers+1; 3154 subdir_civ2_new=[subdir_civ2 '_' num2str(vers)]; 3153 3155 break 3154 3156 end … … 3159 3161 end 3160 3162 end 3163 subdir_civ2=subdir_civ2_new; 3161 3164 %create the new subdir_civ1 3162 3165 if ~exist(fullfile(Path_ima,subdir_civ2),'dir') 3163 3166 [m1,m2,m3]=mkdir(subdir_civ2); 3164 3167 if ~isequal(m2,'') 3165 msgbox_uvmat('ERROR', m2) 3166 %msgbox(m2);%error message for directory creation 3168 msgbox_uvmat('ERROR', m2)%error message for directory creation 3169 cd(currentdir) 3170 filecell={}; 3171 return 3167 3172 end 3168 3173 end … … 3171 3176 end 3172 3177 cd(currentdir);%come back to the current working directory 3173 3174 3178 3175 3179 %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% … … 3184 3188 if ~exist(filename,'file') 3185 3189 msgbox_uvmat('ERROR',['input file ' filename ' not found']) 3186 filecell= [];3190 filecell={}; 3187 3191 return 3188 3192 end … … 3216 3220 set(handles.RUN, 'Enable','On') 3217 3221 set(handles.RUN,'BackgroundColor',[1 0 0]) 3218 % set(handles.BATCH, 'Enable','On')3219 % set(handles.BATCH,'BackgroundColor',[1 0 0])3220 cd(currentdir)3221 3222 return 3222 3223 end … … 4233 4234 %------------------------------------------------------------------------ 4234 4235 % --- transform numbers to letters 4235 function str=num2stra(num,nom_type); 4236 %------------------------------------------------------------------------ 4237 if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') 4236 function str=num2stra(num,nom_type) 4237 %------------------------------------------------------------------------ 4238 if isempty(nom_type) 4239 str=''; 4240 elseif strcmp(nom_type(end),'a') 4238 4241 str=char(96+num); 4239 elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... 4240 |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') 4242 elseif strcmp(nom_type(end),'A') 4243 str=char(96+num); 4244 elseif isempty(nom_type(2:end))%a single index 4241 4245 str=''; 4242 4246 else … … 5065 5069 fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); 5066 5070 fprintf(fid, ['XX 1' '\n' ]); 5067 fprintf(fid, ['ShiftXY 0 0\n']);5071 fprintf(fid, 'ShiftXY 0 0\n'); 5068 5072 fprintf(fid, ['Grid ' par.gridflag '\n' ]); 5069 5073 fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); … … 5246 5250 fileinput=[PathName FileName]; 5247 5251 sizf=size(fileinput); 5248 if (~ischar(fileinput)| ~isequal(sizf(1),1)),return;end %stop if fileinput not a character string5252 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string 5249 5253 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); 5250 5254 ref.filebase=fullfile(Path,File); -
trunk/src/name2display.m
r120 r122 13 13 % nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined) 14 14 % nom_type='*':constant name for a file representing a series (e.g. avi movie) 15 % nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png'). 16 % nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif' 17 % nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') 18 % nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 15 % nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png'). 16 % nom_type='_1','_01','_001'...': series of files with a single index i with separator '_'(e.g. 'aa_045.png'). 17 % nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case) 18 % nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index 19 % nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') 20 % nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 19 21 % nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc') 20 22 % nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc') 21 % nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case) 22 % nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE 23 % nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2') 23 % nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc' 24 24 %subdir: name of the subdirectory for netcdf files 25 25 % … … 44 44 45 45 %recognize the name form 46 filerawascii=double(RootFile);%ascci code47 val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters48 indsel= find(val);% character indices of non numerical characters46 % filerawascii=double(RootFile);%ascci code 47 % val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters 48 indsel=regexp(RootFile,'\D');% character indices of non numerical characters 49 49 filelit=RootFile(indsel);% fileraw name with numbers removed 50 50 nbchar=length(indsel); … … 69 69 penult=double(RootFile(indcur-1));%ascii code of the penultimate character 70 70 testsub=0; %default 71 % case of an indexed series in a single file 71 72 if strcmpi(ext,'.avi') 72 73 nom_type='*'; 73 %case of old image nomenclature 74 elseif (strcmp(ext,'.png') || strcmp(ext,'')) && penult >= 48 && penult <= 57 && (last < 48 || last > 57) 75 % if the penultimate character is a number and the last a letter 76 % search the appendix a,b,c, 77 str_a=last_str; %put appendix a,b,c.... 78 indcur=indcur-1; 79 if strcmp(ext,'.png'), nom_type='#a'; end 80 if strcmp(ext,''), nom_type='raw_SMD'; end 81 num=1;count=0; % extract the numerical appendix 82 while num==1; 83 filascii=double(RootFile(indcur)); 84 if (48>filascii)||(filascii>57); % select the non-numerical characters 85 num=0; 86 else 87 indcur=indcur-1; count=count+1; 88 end 74 %case of a numerical index follewed by a lower case letter (e.g. a,b,c): 75 %the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122 76 % capital letter: last >= 65 && last <= 90) 77 elseif penult >= 48 && penult <= 57 && (last >= 65 && last <= 90)||(last >= 97 && last <= 122) 78 str_a=last_str; %extract appendix a,b,c... or A,B,C... as output. 79 ind_end=indcur-1; %current index just before the suffix letter 80 indices_root=regexp(RootFile(1:indcur-1),'\D');%detect non digit characters 81 indcur=max(indices_root); 82 field_count=RootFile(indcur+1:ind_end); 83 charstring=['%0' num2str(length(field_count)) 'd']; 84 nom_type=num2str(1,charstring); 85 if strcmp(RootFile(indcur),'_') 86 nom_type=['_' nom_type]; 87 indcur=indcur-1; 89 88 end 90 if count~=0 91 field_count=RootFile(indcur+1:indcur+count);% set the selected field number 92 end 93 elseif penult >= 48 && penult <= 57 && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW) 94 % if the penultimate character is a number and the last a letter 95 % search the appendix a,b,c, 96 str_a=last_str; %put appendix a,b,c.... 97 indcur=indcur-1; 98 num=1;count=0; % extract the numerical appendix 99 while num==1; 100 filascii=double(RootFile(indcur)); 101 if (48>filascii)||(filascii>57); % select the non-numerical characters 102 num=0; 103 else 104 indcur=indcur-1; count=count+1; 105 end 106 end 107 if strcmp('0',RootFile(indcur+1)); % select the non-numerical characters 108 nom_type=['%0' num2str(length(RootFile(indcur+1:end-1))) 'dA']; 89 if (last >= 65 && last <= 90) 90 nom_type=[nom_type 'A']; 109 91 else 110 nom_type='#A'; 111 end 112 113 if count~=0 114 field_count=RootFile(indcur+1:indcur+count);% set the selected field number 92 nom_type=[nom_type 'a']; 115 93 end 116 % indcur=indcur-1;117 94 elseif strcmp(filelit(end-2:end),'-_-_')%new nomenclature appendix num1-num2_num_a-num_b 118 95 field_count=num0; … … 149 126 str2=''; 150 127 str_a=num3; 151 nom_type='_ i_j';128 nom_type='_1_1'; 152 129 elseif strcmp(filelit(end),'_') 153 130 indcur=separ3-1; … … 157 134 %detect zeros before the number 158 135 % count=0; % extract the numerical appendix 159 if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters 160 nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd']; 161 else 162 nom_type='_i'; 163 end 164 field_count=RootFile(separ3+1:end);% set the selected field number'%03d' 136 field_count=RootFile(separ3+1:end);% set the selected field number'%03d' 137 charstring=['%0' num2str(length(field_count)) 'd']; 138 nom_type=['_' num2str(1,charstring)]; 139 % if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters 140 % nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd']; 141 % else 142 % nom_type='_i'; 143 % end 144 165 145 elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d 166 146 last=RootFile(indcur-1:indcur); 167 if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters 168 && double(last(2)) >= 97 && double(last(2)) <= 122 147 if isequal(length(last),2) 169 148 str_a=last(1);%put appendix a,b,c, ou d 170 149 str_b=last(2);%put appendix a,b,c, ou d 171 150 % indcur=indcur-3; 172 151 separ0=indsel(end-3); 173 num0=RootFile(separ0+1:separ1-1); 174 field_count=num0; 152 field_count=RootFile(separ0+1:separ1-1); 175 153 indcur=separ0; 176 nom_type='#_ab'; 177 testsub=1; 154 if double(last) >= 97 & double(last)<= 122 155 nom_type='_ab'; 156 testsub=1; 157 elseif double(last) >= 65 & double(last) <= 90 158 nom_type='_AB'; 159 testsub=1; 160 end 161 charstring=['%0' num2str(length(field_count)) 'd']; 162 nom_type=[num2str(1,charstring) nom_type]; 178 163 end 179 164 %search for other names with counter … … 191 176 if count~=0 192 177 field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d' 193 if isequal(field_count(1),'0') 194 nbfigures=length(field_count); 195 nom_type=['%0' num2str(nbfigures) 'd']; 196 else 197 nom_type='#'; 198 end 178 charstring=['%0' num2str(length(field_count)) 'd']; 179 nom_type=num2str(1,charstring); 180 % if isequal(field_count(1),'0') 181 % nbfigures=length(field_count); 182 % nom_type=['%0' num2str(nbfigures) 'd']; 183 % else 184 % nom_type='#'; 185 % end 199 186 end 200 187 end -
trunk/src/name_generator.m
r120 r122 1 1 %'name_generator': creates a file name from a root name and indices. 2 2 %------------------------------------------------------------------------ 3 % [filename, idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...3 % [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=... 4 4 % name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir); 5 5 %------------------------------------------------------------------------ … … 10 10 % OUTPUT: 11 11 % filename: string representing the file name (including path) 12 % idetect: =1 if the file is detected, 0 otherwise13 12 % num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected 14 13 % for free input (= to the corresponding input indices when comp_input=1) … … 19 18 % 'num_j1', first labelling index j 20 19 % 'ext': file name extension (e.g. '.png' or '.nc') 21 % 'nom_type': string defining the kind of nomenclature used: 22 % nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined) 23 % nom_type='*': the same file [filebase ext] contains successive fields (ex avi movies) 24 % nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif' 25 % nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png'). 26 % nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif' 27 % nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif' 28 % nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') 29 % nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 30 % nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc') 31 % nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc') 32 % nom_type='%3da','%3dA' with a numerical index and an index letter(e.g.'aa045b.png'), 33 % nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j') 34 % nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), 35 % nom_type='%3d_ab' from pairs of '%3da' images (e.g. 'aa045bc.nc') 20 %nom_type: char chain characterizing the file nomenclature: with values 21 % nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined) 22 % nom_type='*':constant name for a file representing a series (e.g. avi movie) 23 % nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png'). 24 % nom_type='_1','_01','_001'...': series of files with a single index i with separator '_'(e.g. 'aa_045.png'). 25 % nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case) 26 % nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index 27 % nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') 28 % nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 29 % nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc') 30 % nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc') 31 % nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc' 36 32 %'comp_input' (for nom_type involving index pairs (e.g. netc)) 37 33 % comp_input=1: the index pair is imposed, … … 45 41 % A FAIRE: si comp_inpu=0, si _i_j n'existe pas, chercher _i, 46 42 function [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=... 47 name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir) ;43 name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir) 48 44 sizf=size(filebase); 49 45 if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end … … 75 71 num_i2_out=num_i2;%default output 76 72 num_j2_out=num_j2;%default output 77 78 test_pairs=strcmp(nom_type,'netc_old')| strcmp(nom_type,'netc_2D') | strcmp(nom_type,'netc_3D')| strcmp(nom_type,'_i1-i2_j1-j2')| ... 79 strcmp(nom_type,'netc_series')| strcmp(nom_type,'#_ab')| strcmp(nom_type,'_i_j1-j2')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2'); 80 test_2D= strcmp(nom_type,'netc_old') |strcmp(nom_type,'netc_2D')|strcmp(nom_type,'#_ab') |strcmp(nom_type,'_i_j1-j2'); 81 test_3D=strcmp(nom_type,'netc_3D') |strcmp(nom_type,'netc_series')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2'); 82 if strcmp(nom_type,'series_i')| strcmp(nom_type,'_i'); 83 filename=[filebase '_' num2str(num_i1) ext]; 84 num_i2_out=num_i1; 85 num_j1_out=[]; 86 num_j2_out=[]; 87 elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d'); 88 filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext]; 89 num_i2_out=num_i1; 90 num_j2_out=num_j1; 91 elseif strcmp(nom_type,'series_i_j')| strcmp(nom_type,'_i_j') 92 filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext]; 93 num_i2_out=num_i1; 94 num_j2_out=num_j1; 95 elseif strcmp(nom_type,'png_old')| strcmp(nom_type,'#a')| strcmp(nom_type,'#A') 96 filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext]; 97 num_i2_out=num_i1; 98 num_j2_out=num_j1; 99 elseif length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d') %strcmp(nom_type,'_%04dA') %camera PCO Toulouse 100 filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext]; 101 num_i2_out=num_i1; 102 num_j2_out=num_j1; 103 elseif strcmp(nom_type,'raw_SMD') %suffix a, b, c without extension 104 filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)]; 105 num_i2_out=num_i1; 106 num_j2_out=num_j1; 107 elseif strcmp(nom_type,'ima_num')| strcmp(nom_type,'#') 108 filename=[filebase num2str(num_i1) ext]; 109 num_i2_out=num_i1; 110 num_j1_out=[]; 111 num_j2_out=[]; 112 elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d') 113 filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before 114 num_i2_out=num_i1; 115 num_j1_out=[]; 116 num_j2_out=[]; 117 elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end-1:end),'dA') 118 filename=[filebase num2str(num_i1,nom_type(1:end-1)) num2stra(num_j1,'#A') ext]; %test number with a 0 before 119 num_i2_out=num_i1; 120 num_j1_out=[]; 121 num_j2_out=[]; 122 73 test_pairs=numel(nom_type)>=2 &&(strcmp(nom_type,'_i1-i2_j1-j2')|| strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB')||... 74 strcmp(nom_type,'_i_j1-j2')|| strcmp(nom_type,'_i1-i2_j')||strcmp(nom_type,'_i1-i2')); 75 %test_2D= strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB') ||strcmp(nom_type,'_i_j1-j2'); 76 %test_3D=strcmp(nom_type,'_i1-i2_j')|| strcmp(nom_type,'_i1-i2'); 77 if ~isequal(subdir,'') && ~isequal(subdir,'?') 78 [Path,Name]=fileparts(filebase); 79 filename=fullfile(Path,subdir,Name); 80 else 81 filename=filebase;%default 82 end 83 if ~test_pairs%case of a single index i, and possibly j 84 numlength=numel(nom_type); 85 num_j_str=''; 86 if strcmp(nom_type(1),'_') 87 filename=[filename '_']; 88 nom_type(1)=[]; 89 end 90 if strcmp(nom_type(end),'a') 91 nom_type(end)=[]; 92 num_j_str=char(num_j1+96);% lower letter corresponding to the index 93 elseif strcmp(nom_type(end),'A') 94 nom_type(end)=[]; 95 num_j_str=char(num_j1+64);% lower letter corresponding to the index 96 elseif isequal(numel(regexp(nom_type(2:end),'_')),1)%if a separator '_' exists in nom_type 97 num_j_str=['_' num2str(num_j1)]; 98 nom_type(regexp(nom_type(2:end),'_'):end)=[]; 99 else 100 num_j1_out=[];%no index j 101 end 102 if ~isempty(str2num(nom_type)) 103 numtype=['%0' num2str(length(nom_type)) 'd'];%indicate the number of digits (0 before the number) 104 filename=[filename num2str(num_i1,numtype) num_j_str ext]; 105 num_i2_out=num_i1_out; 106 num_j2_out=num_j1_out; 107 else %fixed name , no indexing, for instance '*' 108 % filebasesub=filebase; 109 filename=[filename ext]; 110 end 111 % if strcmp(nom_type,'_i'); 112 % filename=[filebase '_' num2str(num_i1) ext]; 113 % num_i2_out=num_i1; 114 % num_j1_out=[]; 115 % num_j2_out=[]; 116 % elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d'); 117 % filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext]; 118 % num_i2_out=num_i1; 119 % num_j2_out=num_j1; 120 % elseif strcmp(nom_type,'_i_j') 121 % filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext]; 122 % num_i2_out=num_i1; 123 % num_j2_out=num_j1; 124 % elseif strcmp(nom_type,'#a')| strcmp(nom_type,'#A') 125 % filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext]; 126 % num_i2_out=num_i1; 127 % num_j2_out=num_j1; 128 % elseif length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d') %strcmp(nom_type,'_%04dA') %camera PCO Toulouse 129 % filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext]; 130 % num_i2_out=num_i1; 131 % num_j2_out=num_j1; 132 % elseif strcmp(nom_type,'#') 133 % filename=[filebase num2str(num_i1) ext]; 134 % num_i2_out=num_i1; 135 % num_j1_out=[]; 136 % num_j2_out=[]; 137 % elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d') 138 % filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before 139 % num_i2_out=num_i1; 140 % num_j1_out=[]; 141 % num_j2_out=[]; 142 % elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end-1:end),'dA') 143 % filename=[filebase num2str(num_i1,nom_type(1:end-1)) num2stra(num_j1,'#A') ext]; %test number with a 0 before 144 % num_i2_out=num_i1; 145 % num_j1_out=[]; 146 % num_j2_out=[]; 147 % end 123 148 %case of derived file indexing (e.g. netcdf files) 124 elseif test_pairs 125 filebasesub=filebase; 126 % get the root name filebasesub for the netcdf files 127 if ~strcmp(subdir,'') && ~strcmp(subdir,'?') 128 [Path,Name]=fileparts(filebase); 129 filebasesub=fullfile(Path,subdir,Name); 130 end 149 else 131 150 %inexistant pair if num_i2=0 or num_j2=0 132 151 % if strcmp(num_i2,0) … … 139 158 % end 140 159 % case of an imposed image pair (comp_input=1) 141 if (exist('comp_input','var') & isequal(comp_input,1)) 142 if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab') 160 if (exist('comp_input','var') && isequal(comp_input,1)) 161 if strcmp(nom_type(1),'_') 162 filename=[filename '_']; 163 nom_type(1)=[]; 164 end 165 if strcmp(nom_type(end-1:end),'AB')||strcmp(nom_type(end-1:end),'ab') 166 if strcmp(nom_type(end-1:end),'AB') 167 nchar=64; 168 else 169 nchar=96; 170 end 171 if isequal(num_j1,num_j2)% case of displacements at the same time 172 num_j_str=char(num_j1+nchar); 173 else 174 num_j_str=[char(num_j1+nchar) char(num_j2+nchar)]; 175 end 176 if strcmp(nom_type(end-2),'_') 177 numstr=['%0' num2str(numel(nom_type)-3) 'd']; 178 num_j_str=['_' num_j_str]; 179 else 180 numstr=['%0' num2str(numel(nom_type)-2) 'd']; 181 end 182 filename=[filename num2str(num_i1,numstr) num_j_str ext]; 183 num_i2_out=num_i1; 184 elseif isequal(nom_type,'i_j1-j2') 143 185 if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time 144 filename=[file basesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) ext];145 else 146 filename=[file basesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];186 filename=[filename num2str(num_i1) '_' num2str(num_j1) ext]; 187 else 188 filename=[filename num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext]; 147 189 end 148 190 num_i2_out=num_i1; 149 elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2') 150 if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time 151 filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext]; 152 else 153 filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext]; 154 end 155 num_i2_out=num_i1; 156 elseif isequal(nom_type,'netc_3D') || isequal(nom_type,'_i1-i2_j') 191 elseif isequal(nom_type,'i1-i2_j') 157 192 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time 158 filename=[file basesub '_'num2str(num_i1) '_' num2str(num_j1) ext];159 else 160 filename=[file basesub '_'num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];193 filename=[filename num2str(num_i1) '_' num2str(num_j1) ext]; 194 else 195 filename=[filename num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext]; 161 196 end 162 197 num_j2_out=num_j1; 163 elseif isequal(nom_type,'netc_series') || isequal(nom_type,'_i1-i2')198 elseif isequal(nom_type,'i1-i2') 164 199 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time 165 filename=[file basesub '_'num2str(num_i1) ext];166 else 167 filename=[file basesub '_'num2str(num_i1) '-' num2str(num_i2) ext];200 filename=[filename num2str(num_i1) ext]; 201 else 202 filename=[filename num2str(num_i1) '-' num2str(num_i2) ext]; 168 203 end 169 204 num_j2_out=num_j1; 170 elseif isequal(nom_type,' _i1-i2_j1-j2')205 elseif isequal(nom_type,'i1-i2_j1-j2') 171 206 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time 172 207 app1= [num2str(num_i1)]; … … 179 214 app2= [num2str(num_j1) '-' num2str(num_j2)]; 180 215 end 181 filename=[file basesub '_'app1 '_' app2 ext];216 filename=[filename app1 '_' app2 ext]; 182 217 end 183 218 idetect=1; … … 185 220 % case of an image pair to determine (comp_input=0) 186 221 else 187 [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);222 [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,idetect]=search_pair(filename,num_i1,num_j1,num_i2,nom_type); 188 223 end 189 224 … … 230 265 end 231 266 end 232 % elseif isequal(nom_type,'none')|isequal(nom_type,'')|isequal(nom_type,'*')233 else234 filebasesub=filebase;235 if ~isequal(subdir,'') && ~isequal(subdir,'?')236 [Path,Name]=fileparts(filebase);237 filebasesub=fullfile(Path,subdir,Name);238 end239 filename=[filebasesub ext];240 idetect=(exist(filename,'file')==2);241 267 end 242 268 if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end; -
trunk/src/num2stra.m
r19 r122 12 12 % see also: stra2num, name_generator, name2display 13 13 14 function str=num2stra(num,nom_type,index) ;14 function str=num2stra(num,nom_type,index) 15 15 if ~exist('index','var') 16 16 index=2; %index 1 or 2 of the file indices -
trunk/src/uvmat.m
r121 r122 823 823 set(handles.transform_fct,'Value',1); % no transform by default 824 824 else 825 if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) | ...825 if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... 826 826 (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) 827 827 set(handles.pxcm,'String','var') 828 828 set(handles.pycm,'String','var') 829 829 elseif isfield(GeometryCalib,'fx_fy') 830 pixcmx=GeometryCalib.fx_fy(1) %*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);831 pixcmy=GeometryCalib.fx_fy(2) %*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);830 pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); 831 pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); 832 832 set(handles.pxcm,'String',num2str(pixcmx)) 833 833 set(handles.pycm,'String',num2str(pixcmy)) … … 911 911 state_j='off'; %default 912 912 scan_option='i';%default 913 switch NomType 914 case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices 913 NomTypeRaw=regexprep(NomType(2:end), '-', ''); 914 if numel(regexp(NomTypeRaw,'\D'))>=1 915 % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices 915 916 state_j='on'; 916 917 if isequal(nbfield,1) 917 scan_option='j'; 918 scan_option='j'; %scan j index by default if nbfield=1 918 919 end 919 920 end 920 921 if ~isempty(NomType_1) 921 switch NomType_1 922 case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices 922 NomTypeRaw=regexprep(NomType_1(2:end), '-', ''); 923 if numel(regexp(NomTypeRaw,'\D'))>=1 924 % switch NomType_1 925 % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices 923 926 state_j='on'; 924 927 if isequal(nbfield,1) … … 1486 1489 ind_mask=findstr('mask',Name); 1487 1490 i=ind_mask-1; 1488 while val(i)==0 & i>01491 while val(i)==0 && i>0 1489 1492 i=i-1; 1490 1493 end … … 1668 1671 UvData=get(handles.uvmat,'UserData'); 1669 1672 1670 while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command1673 while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command 1671 1674 errormsg=runpm(hObject,eventdata,handles,increment); 1672 1675 if ~isempty(errormsg) … … 1902 1905 FileType='vol'; 1903 1906 else 1904 form=imformats(Ext( [2:end]));1907 form=imformats(Ext(2:end)); 1905 1908 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 1906 1909 if isequal(NomType,'*'); … … 2059 2062 FieldName='image'; 2060 2063 else 2061 form=imformats(Ext( [2:end]));2064 form=imformats(Ext(2:end)); 2062 2065 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2063 2066 if isequal(NomType,'*'); … … 2106 2109 FieldName_1='image'; 2107 2110 else 2108 form=imformats(Ext_1( [2:end]));2111 form=imformats(Ext_1(2:end)); 2109 2112 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2110 2113 if isequal(NomType_1,'*'); … … 2623 2626 %use of mask 2624 2627 if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2) 2625 if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')2628 if isfield(ObjectData,'Mask') && isfield(ObjectData,'A') 2626 2629 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions 2627 2630 AX=ObjectData.AX; … … 2629 2632 MaskX=ObjectData.MaskX; 2630 2633 MaskY=ObjectData.MaskY; 2631 if ~isequal(MaskX,AX)| ~isequal(MaskY,AY)2634 if ~isequal(MaskX,AX)||~isequal(MaskY,AY) 2632 2635 nxy=size(flag_mask); 2633 2636 sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel 2634 2637 sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); 2635 x_mask= [ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display2636 y_mask= [ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display2638 x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 2639 y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display 2637 2640 %project on the positions of the scalar 2638 2641 npxy=size(ObjectData.A); 2639 2642 dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y 2640 2643 dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x 2641 xi= [ObjectData.AX(1):dxy(2):ObjectData.AX(end)];2642 yi= [ObjectData.AY(1):dxy(1):ObjectData.AY(end)];2644 xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); 2645 yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); 2643 2646 [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates 2644 2647 flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); … … 2650 2653 if isfield(ObjectData,'ListVarName') 2651 2654 for ilist=1:length(ObjectData.ListVarName) 2652 if isequal(ObjectData.ListVarName{ilist},'Mask')| isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')2655 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2653 2656 ind_off=[ind_off ilist]; 2654 2657 end … … 2841 2844 Tabchar={''};%default 2842 2845 Tabcell=[]; 2843 if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)2846 if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute) 2844 2847 for iline=1:length(Field{2}.ListGlobalAttribute) 2845 2848 Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline}; … … 3801 3804 index_code=get(handles.col_vec,'Value');% selected string index 3802 3805 col_code= list_code{index_code(1)}; % selected field 3803 if isequal(col_code,'black') | isequal(col_code,'white')3806 if isequal(col_code,'black') || isequal(col_code,'white') 3804 3807 set(handles.slider1,'Visible','off') 3805 3808 set(handles.slider2,'Visible','off') … … 4439 4442 Data_uvmat=get(handles.uvmat,'UserData'); 4440 4443 evalin('base','global Data_uvmat')%make CurData global in the workspace 4441 display( ['current field :'])4444 display('current field :') 4442 4445 evalin('base','Data_uvmat') %display CurData in the workspace 4443 4446 commandwindow; %brings the Matlab command window to the front … … 4670 4673 npx=size(UvData.Field.A,2); 4671 4674 npy=size(UvData.Field.A,1); 4672 xi= [0.5:npx-0.5];4673 yi= [0.5:npy-0.5];4675 xi=0.5:npx-0.5; 4676 yi=0.5:npy-0.5; 4674 4677 [Xi,Yi]=meshgrid(xi,yi); 4675 4678 if isfield(UvData,'Object')
Note: See TracChangeset
for help on using the changeset viewer.