Ignore:
Timestamp:
Feb 23, 2026, 3:58:54 PM (8 days ago)
Author:
sommeria
Message:

several bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r1181 r1194  
    11%'find_file_series': check the content of an input file and find the corresponding file series
    22%--------------------------------------------------------------------------
    3 % function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
     3% function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
    44%
    55% OUTPUT:
     
    77% SubDir: data dir containing the input file series
    88% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    9 % i1_series(pair,ref_j+1, ref_i+1),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
    10 %  (ref_i+1 is used to deal with the image index zero sometimes used)
     9% i1_series(pair,ref_j+1, ref_i+1): set of indices i1 sorted by ref index ref_i, ref_j, and pair index in case of multiple pairs with the same ref.
     10%     (ref_i+1 is used to deal with the image index zero sometimes used)
     11% i2_series,j1_series,j2_series: same as i1_series but for the indices i2,j1,j2.
     12
    1113% NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string)
    1214% FileInfo: structure containing info on the input files (assumed identical on the whole series)
     
    2426% FilePath: path to the directory to be scanned
    2527% fileinput: name (without path) of the input file sample
    26 % checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile
    27 %           =0: do not take into account xml file existence
    2828
    2929%=======================================================================
     
    4545%=======================================================================
    4646
    47 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
     47function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
    4848%------------------------------------------------------------------------
    4949
     
    7575        end
    7676    else
    77         %% if checkxml=1, possibly include the first index in the root name, if there exists a corresponding xml file
    78         if ~exist('checkxml','var')||checkxml
    79             r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType
    80             if ~isempty(r) %if NomType begins by a number or _1
    81                 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
    82                 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
    83                     rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
    84                 else% if a separator '_' is  detected
    85                     rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
    86                 end
    87                 if ~isempty(rr)
    88                     RootFile_i=[RootFile rr.i1];% new root file
    89                     %look for an xml file correspoonding to the new root name
    90                     if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file'))
    91                         RootFile=RootFile_i;
    92                         NomTypePref=r.tiretnum;
    93                         NomType=regexprep(NomType,['^'  NomTypePref],'');
    94                         i1_input=j1_input;
    95                         i2_input=j2_input;
    96                         j1_input=[];
    97                         j2_input=[];
    98                     end
    99                 end
    100             end
    101         end
     77     
    10278       
    10379        %% analyse the list of existing files when relevant
Note: See TracChangeset for help on using the changeset viewer.