Changeset 122 for trunk/src/civ.m


Ignore:
Timestamp:
Nov 14, 2010, 9:58:15 PM (13 years ago)
Author:
sommeria
Message:
 
File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.