Ignore:
Timestamp:
Dec 11, 2017, 1:15:03 AM (6 years ago)
Author:
sommeria
Message:

opendap reading intreoduced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r1011 r1022  
    4949
    5050%% get input root name and nomenclature type
     51if isempty(regexp(FilePath,'^http://'))
    5152fullfileinput=fullfile(FilePath,fileinput);% input file name with path
     53else
     54  fullfileinput=[FilePath '/' fileinput];
     55end
    5256[FileInfo,MovieObject]=get_file_info(fullfileinput);
    5357
    5458%% check for particular file types: images, movies, civ data
    55 %if isfield(FileInfo,'FileIndexing') && strcmp(FileInfo.FileIndexing,'on')
    56     [RootPath,SubDir,RootFile,i1_input,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fullfileinput);
    57     %     if ~isempty(regexp(SubDir,'^level\d+$')) && exist([RootPath '.xml'],'file')
    58     %         NomType='level';
    59     %     end
    60     i1_series=zeros(1,1,1);
    61     i2_series=zeros(1,1,1);
    62     j1_series=zeros(1,1,1);
    63     j2_series=zeros(1,1,1);
    64     checkfileindexing=1;
    65 %else % no file indexing
    66 %     [PathDir,RootFile]=fileparts(fullfileinput);
    67 %     [RootPath,SubDir,DirExt]=fileparts(PathDir);
    68 %     SubDir=[SubDir DirExt];% include part after . in the name (considered as a file extension)
    69 %     NomType='*';
    70 %     i1_series=[];i2_series=[];j1_series=[];j2_series=[];
    71 %     i1_input=1;i2_input=[];j1_input=[];j2_input=[];
    72 %     if exist(fullfileinput,'file')~=2
    73 %         RootFile='';
    74 %         return
    75 %     end
    76 %     checkfileindexing=0;
    77 %end
    78 if ~exist(FilePath,'dir')
     59[RootPath,SubDir,RootFile,i1_input,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fullfileinput);
     60i1_series=zeros(1,1,1);
     61i2_series=zeros(1,1,1);
     62j1_series=zeros(1,1,1);
     63j2_series=zeros(1,1,1);
     64checkfileindexing=1;
     65if isempty(regexp(FilePath,'^http://')) && ~exist(FilePath,'dir')
    7966    return % don't go further if the dir path does not exist
    8067end
     
    10996                        j1_input=[];
    11097                        j2_input=[];
    111                     elseif exist([RootPath '.xml'],'file')% new convention with j indices in sub-folders level0, 1...
    112                         rj=regexp(SubDir,'^level(?<j1>\d+)$','names');
    113                         if ~isempty(rj)
    114                             j1_input=rj.j1;
    115                             NomType='level';
    116                             [RootPath,SubDir]=fileparts(RootPath);
    117                         end
    11898                    end
    11999                end
     
    134114        %Look for cases with letter indexing for the second index
    135115        r=regexp(NomType,'^(?<sep1>_?)(?<i1>\d+)(?<sep2>_?)(?<j1>[a|A])(?<j2>[b|B]?)$','names');
    136         if ~isempty(r)
     116        if ~isempty(r) %indexing image pair with letters
    137117            sep1=r.sep1;
    138118            sep2=r.sep2;
     
    175155 
    176156        detect_string=['^' RootFile sep1 i1_str i2_str sep2 j1_str j2_str FileExt '$'];%string used in regexp to detect file indices
     157%         if isempty(regexp(FilePath,'^http://'))
    177158        %find the string used to extract the relevant files with the command dir
    178         star_string=[RootFile sep1 i1_star i2_star sep2 j1_star j2_star FileExt];
    179         wd=pwd;%current working directory
    180         cd (FilePath)% move to the local dir to save time in the operation dir.
    181         dirpair=dir(star_string);% look for relevant files in the file directory
    182         cd(wd)
    183         nbpair=numel(dirpair);
     159%         star_string=[RootFile sep1 i1_star i2_star sep2 j1_star j2_star FileExt];
     160%         wd=pwd;%current working directory
     161%         cd (FilePath)% move to the local dir to save time in the operation dir.
     162%         dirpair=dir(star_string);% look for relevant files in the file directory
     163%         cd(wd)
     164%         else
     165            ListStruct=dir_uvmat(FilePath);
     166            ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
     167            ListFiles=ListCells(1,:);%list of file names
     168            rr=regexp(ListFiles,detect_string,'names');
     169%         end
     170%         nbpair=numel(dirpair);
     171        nbpair=numel(rr);
    184172        ref_i_list=zeros(1,nbpair);
    185173        ref_j_list=zeros(1,nbpair);
     
    189177        % scan the list of relevant files, extract the indices
    190178        for ifile=1:nbpair
    191             rr=regexp(dirpair(ifile).name,detect_string,'names');
    192             if ~isempty(rr)
    193                 i1=str2num(rr.i1);
    194                 i2=str2num(regexprep(rr.i2,'^-',''));
    195                 j1=stra2num(regexprep(rr.j1,'^_',''));
    196                 j2=stra2num(regexprep(rr.j2,'^-',''));
     179%             rr=regexp(dirpair(ifile).name,detect_string,'names');
     180            if ~isempty(rr{ifile})
     181                i1=str2num(rr{ifile}.i1);
     182                i2=str2num(regexprep(rr{ifile}.i2,'^-',''));
     183                j1=stra2num(regexprep(rr{ifile}.j1,'^_',''));
     184                j2=stra2num(regexprep(rr{ifile}.j2,'^-',''));
    197185                ref_i=i1;
    198186                if isempty(i2_input)
     
    263251        if ~isempty(ind_select)
    264252            [tild,ifile_min]=min(ref_ij(ind_select));
    265             [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(dirpair(ind_select(ifile_min)).name);% update the representation of indices (number of 0 before the number)
     253            [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(ListFiles{ind_select(ifile_min)});% update the representation of indices (number of 0 before the number)
    266254            NomType=regexprep(NomType,['^' NomTypePref],'');
    267255            %% update the file type if the input file does not exist (pb of 0001)
    268256            if isempty(FileInfo.FileType)
    269                 [FileInfo,MovieObject]=get_file_info(fullfile(FilePath,dirpair(ifile_min).name));
     257                [FileInfo,MovieObject]=get_file_info(fullfile(FilePath,ListFiles(ifile_min)));
    270258            end
    271259        end
Note: See TracChangeset for help on using the changeset viewer.