Ignore:
Timestamp:
Jul 15, 2013, 2:50:08 PM (11 years ago)
Author:
sommeria
Message:

a few bugs corrected.
multimask introduced in series
displ_uvmat transformed into disp_uvmat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r635 r667  
    2020% RootPath: path to the directory to be scanned
    2121% fileinput: name (without path) of the input file sample
     22% checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile
     23%           =0: do not take into account xml file existence
    2224%
    2325%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    3739%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3840
    39 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
     41function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
    4042%------------------------------------------------------------------------
    4143
     
    6264    end
    6365else
    64     %% possibly include the first index in the root name, if there exists a corresponding xml file
    65     r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType
    66     if ~isempty(r) %if NomType begins by a number or _1
    67         fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
    68         if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
    69             rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
    70         else% if a separator '_' is  detected
    71             rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
    72         end
    73         if ~isempty(rr)
    74             RootFile_i=[RootFile rr.i1];% new root file
    75             %look for an xml file correspoonding to the new root name
    76             if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file'))
    77                 RootFile=RootFile_i;
    78                 NomTypePref=r.tiretnum;
    79                 NomType=regexprep(NomType,['^'  NomTypePref],'');
    80                 i1_input=j1_input;
    81                 i2_input=j2_input;
    82                 j1_input=[];
    83                 j2_input=[];
    84             end       
     66    %% if checkxml=1, possibly include the first index in the root name, if there exists a corresponding xml file
     67    if ~exist('checkxml','var')||checkxml
     68        r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType
     69        if ~isempty(r) %if NomType begins by a number or _1
     70            fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
     71            if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
     72                rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
     73            else% if a separator '_' is  detected
     74                rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
     75            end
     76            if ~isempty(rr)
     77                RootFile_i=[RootFile rr.i1];% new root file
     78                %look for an xml file correspoonding to the new root name
     79                if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file'))
     80                    RootFile=RootFile_i;
     81                    NomTypePref=r.tiretnum;
     82                    NomType=regexprep(NomType,['^'  NomTypePref],'');
     83                    i1_input=j1_input;
     84                    i2_input=j2_input;
     85                    j1_input=[];
     86                    j2_input=[];
     87                end
     88            end
    8589        end
    8690    end
Note: See TracChangeset for help on using the changeset viewer.