Changeset 122


Ignore:
Timestamp:
Nov 14, 2010, 9:58:15 PM (13 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r120 r122  
    6767ext=[];
    6868testall=0;
    69 browse=[];
    7069%default input parameters:
    7170num1=1; % set of field i numbers
    72 num2=2; % set of field i numbers
     71num2=1; % set of field i numbers
    7372num_a=1; % set of field j numbers (fields a)
    7473num_b=1; % second set of field j numbers (fields b)
     
    8786    ext=param.ImaExt;
    8887end
    89 if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||...
    90         strcmp(lower(ext),'.avi'));%if an image file has been opened by uvmat
     88browse.num_i1=num1;
     89browse.num_i2=num2;
     90browse.num_j1=num_a;
     91browse.num_j2=num_b;
     92if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
    9193    set(handles.ImaExt,'String',ext)
    9294    if exist('nom_type_read','var')
     
    102104set(handles.ImaDoc,'String',ext)
    103105
    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
    106107path_uvmat=which('uvmat');% check the path detected for source file uvmat
    107108path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     
    315316    browse=get(handles.browse_root,'UserData');
    316317end
    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)
     318browse.num_i1=num_i1;
     319browse.num_i2=num_i2;
     320browse.num_j1=num_j1;
     321browse.num_j2=num_j2;
     322if 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)
    320324    browse.nom_type_ima=nom_type;
    321     browse.field_count=num_i1;
     325    browse.ext_ima=ext;
    322326end
    323327set(handles.ImaDoc,'String',ext);
     
    437441%------------------------------------------------------------------------
    438442set(handles.compare,'Visible','on')
    439 ext_ima=get(handles.ImaExt,'String');
     443%ext_ima=get(handles.ImaExt,'String');
     444ext_ima='';%default
    440445nom_type_ima=[];%default
    441446field_count=1;%default
     
    447452pxcmy_search=[];%default
    448453filebase=get(handles.RootName,'String');
    449 
    450454ext=get(handles.ImaDoc,'String');
    451455browse=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
     456if 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;
     459end
     460if 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
     462end
     463if isfield(browse,'num_i1')
     464    field_count=browse.num_i1;% get an image index type already determined by an input file
    459465end
    460466
     
    522528testima_xml=0;
    523529if isequal(ext,'.civxml')%TO ABANDON
    524     [nbfield,nburst,time]=read_civxml([filebase '.civxml']);
     530    [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']);
    525531    mode='pair j1-j2';
    526532    if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
     
    541547        time=XmlData.Time;
    542548        nbfield=size(time,1);
    543         nburst=size(time,2);
     549        nbfield2=size(time,2);
    544550        %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    545         if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
     551        if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector
    546552            if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%'))
    547553                time=time';
    548                 nbfield=nburst;
    549                 nburst=1;
     554                nbfield=nbfield2;
     555                nbfield2=1;
    550556            end
    551557        end
     
    572578    end
    573579    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 previously
    576         else   %keep the image extension
    577             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             end
    580         end
     580%         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
    581587        nom_type_ima=nom_type_read;
    582588    end
    583 elseif isequal(ext,'.civ')% case of .civ image documentation file
     589elseif strcmp(ext,'.civ')% case of .civ image documentation file
    584590    [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
    585591    if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
     
    588594    %         ImaExt='.png';
    589595    nom_type_ima='png_old';
    590 elseif isequal(lower(ext),'.avi')
     596elseif strcmpi(ext,'.avi')
    591597    nom_type_ima='*';
    592598    ext_ima=ext;
     
    606612set(handles.ImaDoc,'BackgroundColor',[1 1 1])
    607613
    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
     615dirima=[];%default
    609616if isempty(nom_type_ima)
    610617    %look for double image series '_i_j'
     
    616623            % look for other images series
    617624            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
     641end
     642for 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
     650end
     651% no image documentation file found: look for a series of existing files,images by priority or .nc files
     652if isempty(nom_type_ima)
     653    ext_search=ext;
     654    nom_type_search=nom_type_nc;
     655else
     656    ext_search=ext_ima;
     657    nom_type_search=nom_type_ima;
     658end
     659if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*')
    630660    subdir=get(handles.subdir_civ1,'String');
    631661    incr_pair=[0 0];%default
     
    634664    end
    635665    %     nbdetect=0;%test of detected images
    636     field_i=field_count;
     666    field_i=browse.num_i2;
    637667    idetect=1;
    638668    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);
    640670        idetect=(exist(imagename,'file')==2);
    641671        if idetect
     
    645675        %             nbdetect=nbdetect+(exist(imagename,'file')==2);
    646676    end
    647     nb_field=field_i;% last detected field number
    648     field_i=field_count;%look for the minimum file number in the series
     677    nbfield=field_i;% last detected field number
     678    field_i=browse.num_i1;%look for the minimum file number in the series
    649679    idetect=1;
    650680    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);
    652682        idetect=(exist(imagename,'file')==2);
    653683        if idetect
     
    655685        end
    656686    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;
    663691        jdetect=1;
    664692        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);
    666694            jdetect=(exist(imagename,'file')==2);
    667695            if jdetect
     
    671699            %             nbdetect=nbdetect+(exist(imagename,'file')==2);
    672700        end
    673         nb_field_j=field_j-1;% last detected field number
     701        nbfield2=field_j;% last detected field number
    674702     end
    675 
    676    
    677    
     703 
    678704    %determine the set of times and possible intervals for CIV
    679705    %   dt=(1/1000)*str2num(get(handles.dt,'String'));
    680     time=(0:nb_field-1)';% time=file index -1  by default
    681 
    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'}
    684710        % 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);
    686712        time=x+y;
    687713%         time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1  by default
    688714    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)'})
     716end
    699717
    700718if exist('time','var')
     
    722740
    723741%%%%%%%%%%%  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))
     742test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D'));%images with single indexing
     743if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1))
    725744    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'})
    729745    set(handles.mode,'Value',1)
    730746elseif (nbfield==1)% simple series in j
     
    733749else
    734750    set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
    735     if nbfield2 <= 5
     751    if nbfield2 <= 10
    736752        set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst
    737753    end
    738     %     else
    739     %     if isequal(mode,'volume')
    740     %         set(handles.mode,'Value',3)
    741     %     elseif nbfield2 <= 5
    742     %         set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts
    743     %     else
    744     %         set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume
    745     %     end
    746754end
    747755
     
    777785set(handles.RUN, 'Enable','On')
    778786set(handles.RUN,'BackgroundColor',[1 0 0])
    779   set(handles.BATCH,'Enable','On')
    780     set(handles.BATCH,'BackgroundColor',[1 0 0])
     787set(handles.BATCH,'Enable','On')
     788set(handles.BATCH,'BackgroundColor',[1 0 0])
    781789
    782790%%%%% store the root input filename for future opening
     
    21652173    end
    21662174end
    2167 
    2168 
    2169 
    21702175if batch
    21712176    if isfield(sparam,'BatchMode')
     
    21842189set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
    21852190set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
    2186 
    21872191drawnow
    2188 %get the filename root, nomenclature and numbers
    2189 
    2190 % for Windows system find the UBC path name if needed
    2191 % 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 %     end
    2196 %     [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 %         end
    2205 %     else
    2206 %          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 %          return
    2210 %     end
    2211 % end
    22122192
    22132193% set the list of files and check them
     
    22402220        [s,w]=unix('ps faux |grep civ|wc -l');
    22412221        w(end)=[];
    2242         str2num(w)+numel(num1_civ1)
    22432222        if str2num(w)+numel(num1_civ1)> MaxCivProcesses
    22442223            msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'})
     
    22472226    end
    22482227end
    2249 
    22502228display('files OK, processing...')
    22512229nbfield=numel(num1_civ1);
     
    23252303    %%%%%%%%%%%%%%%%%%%
    23262304end
    2327 
    2328 
    23292305
    23302306%get patch2 parameters
     
    28122788ext_ima=get(handles.ImaExt,'String');
    28132789nom_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
     2790if isfield(browse,'nom_type_ima')
     2791    nom_type_ima2=browse.nom_type_ima;
     2792end
     2793if isempty(nom_type_ima2),nom_type_ima2='1';end; %default
     2794if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default
    28172795[num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
    28182796    find_pair_indices(handles,mode);
     
    29502928                if ~exist(file_ref,'file')
    29512929                    msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2'])
    2952                     filecell=[];
     2930                    filecell={};
    29532931                    return
    29542932                end
     
    29672945if ~exist(Path_ima,'dir')
    29682946    msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
    2969     filecell=[];
     2947    filecell={};
    29702948    return
    29712949end
     
    29742952m2='';
    29752953[erread,message]=fileattrib(Path_ima);
    2976 if ~isempty(message) & ~isequal(message.UserWrite,1)
     2954if ~isempty(message) && ~isequal(message.UserWrite,1)
    29772955    msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
    2978     filecell=[];
     2956    filecell={};
    29792957    cd(currentdir);
    29802958    return
     
    29862964    detect=1;
    29872965    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
    29892969            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);
    29912971                detect=exist(filename,'file')==2;
    29922972                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)];
    29942975                    subdir_civ2=subdir_civ1;
    29952976                    break
     
    30012982            end
    30022983        end
     2984        subdir_civ1=subdir_civ1_new;
    30032985        %create the new subdir_civ1
    30042986        if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
    30052987            [m1,m2,m3]=mkdir(subdir_civ1);
    30062988            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
    30092993            end
    30102994        end
    30112995        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;
    30122998            for ifile=1:nbfield
    30132999                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);%
    30153001                    detect=exist(filename,'file')==2;
    30163002                    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)];
    30183005                        subdir_civ2=subdir_civ1;
    30193006                        break
     
    30253012                end
    30263013            end
     3014            subdir_civ1=subdir_civ1_new;
    30273015            %create the new subdir_civ1
    30283016            if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
     
    30303018                if ~isequal(m2,'')
    30313019                    msgbox_uvmat('ERROR', m2)
     3020                    cd(currentdir)
     3021                    filecell={};
     3022                    return
    30323023                end
    30333024            end
     
    30473038        if idetectmin==0,
    30483039            msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
    3049             filecell=[];
     3040            filecell={};
     3041            cd(currentdir)
    30503042            return
    30513043        end
     
    30533045        if idetectmin==0,
    30543046            msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
    3055             filecell=[];
     3047            filecell={};
    30563048            cd(currentdir)
    30573049            return
     
    30713063            if idetectmin==0,
    30723064                msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found'])
    3073                 filecell=[];
     3065                filecell={};
    30743066                cd(currentdir)
    30753067                return
     
    30783070            if idetectmin==0,
    30793071                msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
    3080                 filecell=[];
     3072                filecell={};
    30813073                cd(currentdir)
    30823074                return
     
    30923084                nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
    30933085            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
    30943092            filecell.nc.civ1(ifile,j)={filename};
    30953093        end
     
    31043102                    set(handles.RUN, 'Enable','On')
    31053103                    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={};
    31093105                    cd(currentdir)
    31103106                    return
     
    31413137            if ~isequal(m2,'')
    31423138                msgbox_uvmat('ERROR', m2)
     3139                filecell={};
     3140                cd(currentdir)
     3141                return
    31433142            end
    31443143        end
    31453144        if strcmp(compare,'stereo PIV')%check second nc series
     3145            vers=0;
     3146            subdir_civ2_new=subdir_civ2;
    31463147            for ifile=1:nbfield
    31473148                for j=1:nbslice
    31483149                    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);%
    31503151                    detect=exist(filename,'file')==2;
    31513152                    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)];
    31533155                        break
    31543156                    end
     
    31593161                end
    31603162            end
     3163            subdir_civ2=subdir_civ2_new;
    31613164            %create the new subdir_civ1
    31623165            if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
    31633166                [m1,m2,m3]=mkdir(subdir_civ2);
    31643167                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
    31673172                end
    31683173            end
     
    31713176end
    31723177cd(currentdir);%come back to the current working directory
    3173 
    31743178
    31753179%%%%%%%%%%%%%  if civ2 results are obtained or used  %%%%%%%%%%%%%
     
    31843188                if ~exist(filename,'file')
    31853189                    msgbox_uvmat('ERROR',['input file ' filename ' not found'])
    3186                     filecell=[];
     3190                    filecell={};
    31873191                    return
    31883192                end
     
    32163220                        set(handles.RUN, 'Enable','On')
    32173221                        set(handles.RUN,'BackgroundColor',[1 0 0])
    3218                         %                                set(handles.BATCH, 'Enable','On')
    3219                         %                     set(handles.BATCH,'BackgroundColor',[1 0 0])
    3220                         cd(currentdir)
    32213222                        return
    32223223                    end
     
    42334234%------------------------------------------------------------------------
    42344235% --- 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')
     4236function str=num2stra(num,nom_type)
     4237%------------------------------------------------------------------------
     4238if isempty(nom_type)
     4239    str='';
     4240elseif strcmp(nom_type(end),'a')
    42384241    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')
     4242elseif strcmp(nom_type(end),'A')
     4243    str=char(96+num);
     4244elseif isempty(nom_type(2:end))%a single index
    42414245    str='';
    42424246else
     
    50655069fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
    50665070fprintf(fid, ['XX 1' '\n' ]);
    5067 fprintf(fid, ['ShiftXY 0 0\n']);
     5071fprintf(fid, 'ShiftXY 0 0\n');
    50685072fprintf(fid, ['Grid ' par.gridflag '\n' ]);
    50695073fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']);
     
    52465250fileinput=[PathName FileName];
    52475251sizf=size(fileinput);
    5248 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
     5252if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    52495253[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    52505254ref.filebase=fullfile(Path,File);
  • trunk/src/name2display.m

    r120 r122  
    1313%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
    1414%   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')
    1921%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
    2022%   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'
    2424%subdir: name of the subdirectory for netcdf files
    2525%
     
    4444
    4545        %recognize the name form
    46 filerawascii=double(RootFile);%ascci code
    47 val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
    48 indsel=find(val);% character indices of non numerical characters
     46% filerawascii=double(RootFile);%ascci code
     47% val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
     48indsel=regexp(RootFile,'\D');% character indices of non numerical characters
    4949filelit=RootFile(indsel);% fileraw name with numbers removed
    5050nbchar=length(indsel);
     
    6969penult=double(RootFile(indcur-1));%ascii code of the penultimate character
    7070testsub=0; %default
     71% case of an indexed series in a single file
    7172if strcmpi(ext,'.avi')
    7273     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)                                                             
     77elseif  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;
    8988    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'];
    10991    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'];
    11593    end   
    116 %     indcur=indcur-1;
    11794elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
    11895    field_count=num0;
     
    149126    str2='';
    150127    str_a=num3;
    151     nom_type='_i_j';
     128    nom_type='_1_1';
    152129elseif strcmp(filelit(end),'_')
    153130    indcur=separ3-1;
     
    157134    %detect zeros before the number
    158135%     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     
    165145elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
    166146    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)
    169148          str_a=last(1);%put appendix a,b,c, ou d
    170149          str_b=last(2);%put appendix a,b,c, ou d
    171150%           indcur=indcur-3;
    172151          separ0=indsel(end-3);
    173         num0=RootFile(separ0+1:separ1-1);
    174         field_count=num0;
     152        field_count=RootFile(separ0+1:separ1-1);
    175153        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];
    178163    end
    179164%search for other names with counter
     
    191176            if count~=0   
    192177                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
    199186            end
    200187    end
  • trunk/src/name_generator.m

    r120 r122  
    11%'name_generator': creates a file name from a root name and indices.
    22%------------------------------------------------------------------------
    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]=...
    44%        name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
    55%------------------------------------------------------------------------           
     
    1010% OUTPUT:
    1111% filename: string representing the file name (including path)
    12 % idetect: =1 if the file is detected, 0 otherwise
    1312% num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected
    1413%            for free input (= to the corresponding input indices when comp_input=1)
     
    1918% 'num_j1', first labelling index j
    2019% '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'
    3632%'comp_input' (for nom_type involving index pairs (e.g. netc))
    3733%       comp_input=1: the index pair is imposed,
     
    4541% A FAIRE: si comp_inpu=0, si _i_j n'existe pas, chercher _i,
    4642function [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)
    4844sizf=size(filebase);
    4945if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
     
    7571num_i2_out=num_i2;%default output
    7672num_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 
     73test_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');
     77if ~isequal(subdir,'') && ~isequal(subdir,'?')
     78      [Path,Name]=fileparts(filebase);
     79      filename=fullfile(Path,subdir,Name);
     80else
     81    filename=filebase;%default
     82end
     83if ~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
    123148%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
     149else
    131150     %inexistant pair if num_i2=0 or num_j2=0
    132151%     if strcmp(num_i2,0)
     
    139158%     end
    140159    % 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')
    143185                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
    144                     filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) ext];
    145                 else
    146                     filename=[filebasesub 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];
    147189                end
    148190                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')
    157192                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
    158                       filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
    159                 else
    160                     filename=[filebasesub '_' 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];
    161196                end
    162197                num_j2_out=num_j1;
    163             elseif isequal(nom_type,'netc_series') || isequal(nom_type,'_i1-i2')
     198            elseif  isequal(nom_type,'i1-i2')
    164199                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
    165                      filename=[filebasesub '_' num2str(num_i1) ext];
    166                 else
    167                     filename=[filebasesub '_' 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];
    168203                end
    169204                num_j2_out=num_j1;
    170             elseif isequal(nom_type,'_i1-i2_j1-j2')
     205            elseif isequal(nom_type,'i1-i2_j1-j2')
    171206                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
    172207                    app1= [num2str(num_i1)];
     
    179214                    app2= [num2str(num_j1) '-' num2str(num_j2)];
    180215                end     
    181                 filename=[filebasesub '_' app1 '_' app2 ext];
     216                filename=[filename app1 '_' app2 ext];
    182217            end
    183218            idetect=1;
     
    185220     % case of an image pair to determine (comp_input=0)
    186221    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);
    188223    end
    189224   
     
    230265        end
    231266    end
    232 % elseif isequal(nom_type,'none')|isequal(nom_type,'')|isequal(nom_type,'*')
    233 else
    234     filebasesub=filebase;
    235     if ~isequal(subdir,'') && ~isequal(subdir,'?')
    236             [Path,Name]=fileparts(filebase);
    237             filebasesub=fullfile(Path,subdir,Name);
    238     end
    239     filename=[filebasesub ext];
    240     idetect=(exist(filename,'file')==2); 
    241267end
    242268if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end;
  • trunk/src/num2stra.m

    r19 r122  
    1212% see also: stra2num, name_generator, name2display
    1313
    14 function str=num2stra(num,nom_type,index);
     14function str=num2stra(num,nom_type,index)
    1515if ~exist('index','var')
    1616    index=2; %index 1 or 2 of the file indices
  • trunk/src/uvmat.m

    r121 r122  
    823823        set(handles.transform_fct,'Value',1); %  no transform by default
    824824    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)) ||...
    826826            (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
    827827            set(handles.pxcm,'String','var')
    828828            set(handles.pycm,'String','var')
    829829        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);
    832832            set(handles.pxcm,'String',num2str(pixcmx))
    833833            set(handles.pycm,'String',num2str(pixcmy))
     
    911911state_j='off'; %default
    912912scan_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
     913NomTypeRaw=regexprep(NomType(2:end), '-', '');
     914if numel(regexp(NomTypeRaw,'\D'))>=1
     915%     case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
    915916        state_j='on';
    916917        if isequal(nbfield,1)
    917             scan_option='j';                
     918            scan_option='j'; %scan j index by default if nbfield=1               
    918919        end
    919920end
    920921if ~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
    923926            state_j='on';
    924927            if isequal(nbfield,1)
     
    14861489        ind_mask=findstr('mask',Name);
    14871490        i=ind_mask-1;
    1488         while val(i)==0 & i>0
     1491        while val(i)==0 && i>0
    14891492            i=i-1;
    14901493        end
     
    16681671UvData=get(handles.uvmat,'UserData');
    16691672
    1670 while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
     1673while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
    16711674        errormsg=runpm(hObject,eventdata,handles,increment);
    16721675        if ~isempty(errormsg)
     
    19021905    FileType='vol';
    19031906else
    1904    form=imformats(Ext([2:end]));
     1907   form=imformats(Ext(2:end));
    19051908   if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    19061909       if isequal(NomType,'*');
     
    20592062        FieldName='image';
    20602063    else
    2061        form=imformats(Ext([2:end]));
     2064       form=imformats(Ext(2:end));
    20622065       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    20632066           if isequal(NomType,'*');
     
    21062109        FieldName_1='image';
    21072110    else
    2108        form=imformats(Ext_1([2:end]));
     2111       form=imformats(Ext_1(2:end));
    21092112       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    21102113           if isequal(NomType_1,'*');
     
    26232626        %use of mask
    26242627        if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
    2625             if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
     2628            if isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
    26262629                 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
    26272630                 AX=ObjectData.AX;
     
    26292632                 MaskX=ObjectData.MaskX;
    26302633                 MaskY=ObjectData.MaskY;
    2631                  if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
     2634                 if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
    26322635                     nxy=size(flag_mask);
    26332636                     sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
    26342637                     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 display
    2636                      y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
     2638                     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
    26372640                     %project on the positions of the scalar
    26382641                     npxy=size(ObjectData.A);
    26392642                     dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
    26402643                     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);     
    26432646                     [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
    26442647                    flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
     
    26502653                 if isfield(ObjectData,'ListVarName')
    26512654                      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')
    26532656                               ind_off=[ind_off ilist];
    26542657                           end
     
    28412844    Tabchar={''};%default
    28422845    Tabcell=[];
    2843     if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
     2846    if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute)
    28442847        for iline=1:length(Field{2}.ListGlobalAttribute)
    28452848            Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
     
    38013804index_code=get(handles.col_vec,'Value');% selected string index
    38023805col_code= list_code{index_code(1)}; % selected field
    3803 if isequal(col_code,'black') | isequal(col_code,'white')
     3806if isequal(col_code,'black') || isequal(col_code,'white')
    38043807   set(handles.slider1,'Visible','off')
    38053808   set(handles.slider2,'Visible','off')
     
    44394442Data_uvmat=get(handles.uvmat,'UserData');
    44404443evalin('base','global Data_uvmat')%make CurData global in the workspace
    4441 display(['current field :'])
     4444display('current field :')
    44424445evalin('base','Data_uvmat') %display CurData in the workspace
    44434446commandwindow; %brings the Matlab command window to the front
     
    46704673        npx=size(UvData.Field.A,2);
    46714674        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;
    46744677        [Xi,Yi]=meshgrid(xi,yi);
    46754678        if isfield(UvData,'Object')
Note: See TracChangeset for help on using the changeset viewer.