Ignore:
Timestamp:
Jun 6, 2012, 2:46:15 PM (13 years ago)
Author:
sommeria
Message:

functions updated in series for the new file configuration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/aver_stat.m

    r420 r442  
    4545if ischar(Param) && ~isempty(find(regexp('Param','.xml$')))
    4646    Param=xml2struct(Param);
     47    checkrun=0;
    4748else %  RUN case: parameters introduced as the input structure Param
    4849    hseries=guidata(Param.hseries);%handles of the GUI series
    4950    WaitbarPos=get(hseries.waitbar_frame,'Position');
     51    checkrun=1;
    5052end
    5153[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     
    250252    ext_out='.nc';
    251253end
    252 subdir_result='aver_stat';%subdirectory for the results
    253 pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path
    254 testexist=1;
    255 while testexist
    256     pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path
    257     if NbSlice==1% keep track of the first and lsat indices of the input files
    258         %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1));
    259         NomTypeOut='_1-2';
    260         fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]);
    261         testexist=exist(fileresult{1},'file');
    262     else % simplified indexing with i_slice for multiple slices
    263         testexist=0;
    264         for i_slice=1:NbSlice
    265             fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]);
    266             if exist(fileresult{i_slice},'file')
    267                 testexist=1;
    268                 break
    269             end
    270         end
    271     end
    272     if testexist
    273         subdir_result=[subdir_result '.0'];
    274     end
    275 end
     254subdir_result=[SubDir{1} '.stat'];%subdirectory for the results
     255pathdir=RootPath{1};% full subdirectory name, including path
     256checkdetect=1;
     257while checkdetect %create a new subdir if the netcdf files already exist
     258    checkdetect=exist(fullfile(pathdir,subdir_result));
     259    if checkdetect% if a nesult dir already exists
     260        r=regexp(subdir_result,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
     261        if isempty(r)
     262            r(1).root=[subdir_result '_'];
     263            r(1).num1='0';
     264        end
     265        subdir_result=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
     266    end
     267end
     268NomTypeOut='_1-2';
     269fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]);
     270
     271% A REPRNDRE CAS MULTI-NIVEAU:
     272%     pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path
     273%     if NbSlice==1% keep track of the first and lsat indices of the input files
     274%         %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1));
     275%         NomTypeOut='_1-2';
     276%         fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),i1_series{1}(end),[],[]);
     277%         testexist=exist(fileresult{1},'file');
     278%     else % simplified indexing with i_slice for multiple slices
     279%         testexist=0;
     280%         for i_slice=1:NbSlice
     281%             fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]);
     282%             if exist(fileresult{i_slice},'file')
     283%                 testexist=1;
     284%                 break
     285%             end
     286%         end
     287%     end
     288%     if testexist
     289%         subdir_result=[subdir_result '.0'];
     290%     end
     291% end
    276292% create result directory if needed
    277 if ~exist(pathdir,'dir')
    278     [m1,m2,m3]=mkdir(pathdir);
     293if ~exist(fullfile(RootPath{1},subdir_result),'dir')
     294    [m1,m2,m3]=mkdir(fullfile(RootPath{1},subdir_result));
    279295    if ~isequal(m2,'')
    280296        msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation
    281297    end
    282298end
    283 [xx,msg2] = fileattrib(pathdir,'+w','g'); %yield writing access (+w) to user group (g)
     299[xx,msg2] = fileattrib(fullfile(RootPath{1},subdir_result),'+w','g'); %yield writing access (+w) to user group (g)
    284300if ~strcmp(msg2,'')
    285     msgbox_uvmat('ERROR',['pb of permission for ' pathdir ': ' msg2])%error message for writting access
     301    msgbox_uvmat('ERROR',['pb of permission for ' fullfile(RootPath{1},subdir_result) ': ' msg2])%error message for writting access
    286302    return
    287303end
     
    312328 %       if isequal(stopstate,'queue') % enable STOP command
    313329         %   update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
     330         if checkrun
     331             update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield*nbfield2))
     332             stopstate=get(hseries.RUN,'BusyAction');
     333         else
     334             stopstate='queue';
     335         end
    314336            ifile=indselect(index);
    315337            % reading input file(s)
Note: See TracChangeset for help on using the changeset viewer.