- Timestamp:
- Dec 11, 2017, 1:15:03 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/fileparts_uvmat.m
r977 r1022 138 138 RootFile=regexprep(RootFile,[r.num1 r.end_string '$'],''); 139 139 else % case with separator '_' 140 r=regexp(RootFile,'\D (?<num1>\d+)_(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names');140 r=regexp(RootFile,'\D*(?<num1>\d+)_(?<end_string>[a-z]|[A-Z]|[a-z][a-z]|[A-Z][A-Z])$','names'); 141 141 if ~isempty(r) 142 142 NomType=['_' get_type(r.end_string)]; -
trunk/src/find_file_series.m
r1011 r1022 49 49 50 50 %% get input root name and nomenclature type 51 if isempty(regexp(FilePath,'^http://')) 51 52 fullfileinput=fullfile(FilePath,fileinput);% input file name with path 53 else 54 fullfileinput=[FilePath '/' fileinput]; 55 end 52 56 [FileInfo,MovieObject]=get_file_info(fullfileinput); 53 57 54 58 %% 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); 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 if isempty(regexp(FilePath,'^http://')) && ~exist(FilePath,'dir') 79 66 return % don't go further if the dir path does not exist 80 67 end … … 109 96 j1_input=[]; 110 97 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 end118 98 end 119 99 end … … 134 114 %Look for cases with letter indexing for the second index 135 115 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 137 117 sep1=r.sep1; 138 118 sep2=r.sep2; … … 175 155 176 156 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://')) 177 158 %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); 184 172 ref_i_list=zeros(1,nbpair); 185 173 ref_j_list=zeros(1,nbpair); … … 189 177 % scan the list of relevant files, extract the indices 190 178 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,'^-','')); 197 185 ref_i=i1; 198 186 if isempty(i2_input) … … 263 251 if ~isempty(ind_select) 264 252 [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) 266 254 NomType=regexprep(NomType,['^' NomTypePref],''); 267 255 %% update the file type if the input file does not exist (pb of 0001) 268 256 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))); 270 258 end 271 259 end -
trunk/src/fullfile_uvmat.m
r977 r1022 93 93 94 94 %% look for NomType with pairs (separator '-' or terminasion ab or AB 95 if strcmp(NomType,'level')% organisation with a sub-folder for the files of each index i96 filename=fullfile(RootPath,SubDir,['level' num2str(j1)],[RootFile num2str(i1) FileExt]);97 else95 % if strcmp(NomType,'level')% organisation with a sub-folder for the files of each index i 96 % filename=fullfile(RootPath,SubDir,['level' num2str(j1)],[RootFile num2str(i1) FileExt]); 97 % else 98 98 if ~isempty(regexp(NomType,'^_\d')) 99 99 sep1='_'; … … 136 136 end 137 137 end 138 if isempty(regexp(RootPath,'^http://')) 138 139 filename=fullfile(RootPath,SubDir,RootFile); 140 else 141 filename=[RootPath '/' SubDir '/' RootFile]; 142 end 139 143 filename=[filename sep1 i1_str sep2 i2_str sep3 j1_str sep4 j2_str]; 140 144 filename=[regexprep(filename,'_$','') FileExt];%suppress possible '_' at the end of the string and add the extension 141 end145 % end 142 146 143 147 function test -
trunk/src/get_file_info.m
r1009 r1022 38 38 function [FileInfo,VideoObject]=get_file_info(fileinput) 39 39 VideoObject=[]; 40 if exist(fileinput,'file')==240 if ~isempty(regexp(fileinput,'^http://'))|| exist(fileinput,'file') 41 41 FileInfo.FileName=fileinput; 42 42 FileInfo.FileType='txt'; %default -
trunk/src/nc2struct.m
r1001 r1022 79 79 end 80 80 else 81 if regexp(nc,'^http://') 82 nc=netcdf.open(nc,'NC_NOWRITE'); 83 testfile=1; 84 else 81 85 errormsg=['ERROR:file ' nc ' does not exist']; 82 86 return 87 end 83 88 end 84 89 else -
trunk/src/read_field.m
r1007 r1022 54 54 ParamOut=ParamIn;%default 55 55 errormsg=''; 56 if ~exist(FileName,'file')56 if isempty(regexp(FileName,'^http://'))&& ~exist(FileName,'file') 57 57 errormsg=['input file ' FileName ' does not exist']; 58 58 return -
trunk/src/uigetfile_uvmat.m
r977 r1022 48 48 InputFileName='';%default 49 49 if ischar(InputName) 50 if exist(InputName,'dir') 51 InputDir=InputName; 52 InputFileName=''; 53 elseif exist(InputName,'file') 54 [InputDir,InputFileName,Ext]=fileparts(InputName); 55 if isempty(InputFileName)% if InputName is already the root 56 InputFileName=InputDir; 57 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems 58 % InputDir=[InputDir '\'];% append '\' for a correct action of dir 59 InputFileName=[InputFileName '\']; 50 if isempty(regexp(InputName,'^http://'))%usual files 51 if exist(InputName,'dir') 52 InputDir=InputName; 53 InputFileName=''; 54 elseif exist(InputName,'file') 55 [InputDir,InputFileName,Ext]=fileparts(InputName); 56 if isempty(InputFileName)% if InputName is already the root 57 InputFileName=InputDir; 58 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems 59 % InputDir=[InputDir '\'];% append '\' for a correct action of dir 60 InputFileName=[InputFileName '\']; 61 end 62 end 63 if isdir(InputName) 64 InputFileName=['+/' InputFileName Ext]; 60 65 end 61 66 end 62 if isdir(InputName)63 Input FileName=['+/' InputFileName Ext];67 if ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems 68 InputDir=[InputDir '\'];% append '\' for a correct action of dir 64 69 end 65 e nd66 end 67 if ismember(computer,{'PCWIN','PCWIN64'})%case of Windows systems 68 InputDir=[InputDir '\'];% append '\' for a correct action of dir 69 end 70 else 71 [InputDir,InputFileName,Ext]=fileparts(InputName); 72 end 73 end 74 70 75 hfig=findobj(allchild(0),'tag',option); 71 76 if isempty(hfig) … … 147 152 htitlebox=findobj(hfig,'tag','titlebox'); % display the current dir name 148 153 DirName=get(htitlebox,'String'); 149 if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://)150 % FullSelectName=DirName;151 % else152 154 if ~strcmp(filter_ext,'uigetdir')% a file is expected as output, not a dir 153 155 hlist=findobj(hfig,'Tag','list'); … … 163 165 SelectName=SelectName(1:ind_dot-1); 164 166 end 165 FullSelectName=fullfile(DirName,SelectName); 166 % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://) 167 168 if exist(FullSelectName,'file') 167 if isempty(regexp(DirName,'^http://'))% if the input dir is not a web site (begins by http://) 168 FullSelectName=fullfile(DirName,SelectName); 169 check_exist=exist(FullSelectName,'file'); 170 else 171 FullSelectName=[DirName '/' SelectName]; 172 check_exist=1; 173 end 174 if check_exist 169 175 switch option 170 176 case 'browser' … … 185 191 end 186 192 end 187 end188 193 set(hObject,'backgroundColor',[0 1 0])% indicate end button activation 189 194 uiresume(get(hObject,'parent')) 190 195 191 %------------------------------------------------------------------------ 196 %------------------------------------------------------------------------ 192 197 % --- launched by refreshing the display figure 193 198 function refresh_GUI(hObject,InputFileName,FilterExt) … … 209 214 DirName=get(htitlebox,'String'); 210 215 hsort_option=findobj(hfig,'tag','sort_option'); 211 if strcmp(get(hfig,'Tag'),'status_display') 216 % use with GUI series 217 if strcmp(get(hfig,'Tag'),'status_display') % use with GUI series 212 218 hseries=findobj(allchild(0),'tag','series'); 213 219 hstatus=findobj(hseries,'tag','status'); … … 218 224 end 219 225 hlist=findobj(hfig,'tag','list'); 220 testrecent=0; 226 testrecent=0; 221 227 NbOutputFile=[]; 222 228 if isfield(StatusData,'NbOutputFile') … … 226 232 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 227 233 228 % %update the waitbar234 % update the waitbar 229 235 hwaitbar=findobj(hfig,'tag','waitbar'); 230 236 if ~isempty(NbOutputFile) … … 233 239 set(hwaitbar,'Position',BarPosition) 234 240 end 235 else 241 else %use as usual browser 236 242 sort_option='name'; 237 243 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) … … 281 287 htitlebox=findobj(hfig,'tag','titlebox'); % display the new dir name 282 288 DirName=get(htitlebox,'String'); 289 CheckSubDir=~isempty(regexp(list{index},'^\+')); 283 290 SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir 284 291 ind_dot=regexp(SelectName,'\s*\.\.\.');%remove what is beyond '...' … … 289 296 FullSelectName=fileparts(DirName); 290 297 else 291 FullSelectName=fullfile(DirName,SelectName); 292 end 293 if exist(FullSelectName,'dir')% a directory has been selected 298 if isempty(regexp(DirName,'^http://'))% usual files 299 FullSelectName=fullfile(DirName,SelectName); 300 else 301 FullSelectName=[DirName '/' SelectName]; 302 end 303 end 304 if CheckSubDir%exist(FullSelectName,'dir')% a directory has been selected 294 305 set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action 295 306 drawnow … … 315 326 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option,filter_ext) 316 327 %------------------------------------------------------------------------- 317 ListStruct=dir (DirName);% get structure of the current directory328 ListStruct=dir_uvmat(DirName);% get structure of the current directory 318 329 NumFiles=0; %default 319 330 if numel(ListStruct)<1 % case of empty dir 320 % if regexp(DirName,'^http://')% if the input dir is a web site (begins by http://)321 % web(DirName)322 % else323 331 ListFiles={}; 324 332 return 325 % end326 333 end 327 334 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 328 335 ListFiles=ListCells(1,:);%list of file names 329 336 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 337 % for ilist=1:numel(check_dir) 338 % if check_dir(ilist) 330 339 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 340 % end 341 % end 331 342 if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir') 332 343 if strcmp(filter_ext,'image') -
trunk/src/uvmat.m
r1010 r1022 446 446 function MenuBrowse_Callback(hObject, eventdata, handles) 447 447 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 448 if isempty(regexp(RootPath,'^http://'))%usual files 448 449 oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 450 else %Opendap 451 oldfile=[RootPath '/' SubDir '/' RootFile FileIndices FileExt]; 452 end 449 453 if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box 450 454 oldfile=get(handles.RootPath,'UserData'); … … 452 456 fileinput=uigetfile_uvmat('pick an input file',oldfile); 453 457 hh=dir(fileinput); 454 if numel(hh)>1 fill_GUI458 if numel(hh)>1 455 459 msgbox_uvmat('ERROR','invalid input, probably a broken link'); 456 460 else … … 1800 1804 %% look for the input file existence 1801 1805 errormsg='';%default 1802 if ~exist(fileinput,'file')1806 if isempty(regexp(fileinput,'^http://')) && ~exist(fileinput,'file') 1803 1807 errormsg=['input file ' fileinput ' does not exist']; 1804 1808 msgbox_uvmat('ERROR',errormsg) … … 1841 1845 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 1842 1846 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 1847 % if isempty(regexp(fileinput,'^http://')) 1843 1848 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); 1849 % else 1850 % FileInfo.FileType='netcdf'; 1851 % [RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(fileinput); 1852 % i1_series=[0 i1 i2]; 1853 % i2_series=[]; 1854 % j1_series=[0 j1 j1]; 1855 % j2_series=[0 j1 j1]; 1856 % MovieObject=[]; 1857 % % [RootPath,RootFile]=fileparts(fileinput); 1858 % % [RootPath,SubDir]=fileparts(RootPath); 1859 % % NomType='*'; 1860 % end 1844 1861 FileType=FileInfo.FileType; 1845 1862 if strcmp(FileType,'txt') … … 1883 1900 set(handles_SubDir,'String',['/' SubDir]); 1884 1901 set(handles_RootFile,'String',['/' RootFile]); %display the separator 1885 if strcmp(NomType,'level') 1886 rootname=fullfile(RootPath,SubDir,'level'); 1887 rr=regexp(fileinput,['^' rootname '(?<j>\d+)/' RootFile '(?<i>\d+)' FileExt '$'],'names'); 1888 if ~isempty(rr) 1889 set(handles_FileIndex,'String',rr.i); 1890 end 1891 else 1902 % if strcmp(NomType,'level') 1903 % rootname=fullfile(RootPath,SubDir,'level'); 1904 % rr=regexp(fileinput,['^' rootname '(?<j>\d+)/' RootFile '(?<i>\d+)' FileExt '$'],'names'); 1905 % if ~isempty(rr) 1906 % set(handles_FileIndex,'String',rr.i); 1907 % end 1908 % else 1909 if isempty(regexp(RootPath,'^http://')) 1892 1910 rootname=fullfile(RootPath,SubDir,RootFile); 1911 else 1912 rootname=[RootPath '/' SubDir '/' RootFile]; 1913 end 1893 1914 indices=fileinput(length(rootname)+1:end); 1894 1915 indices(end-length(FileExt)+1:end)=[]; %remove extension 1895 1916 set(handles_FileIndex,'String',indices); 1896 end1917 % end 1897 1918 set(handles_NomType,'String',NomType); 1898 1919 set(handles_FileExt,'String',FileExt); … … 3187 3208 if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used 3188 3209 if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used 3189 if strcmp(get(handles.NomType,'String'),'level') 3190 jindex=str2num(get(handles.j1,'String')); 3191 filename=[fullfile(RootPath,SubDir,['level' num2str(jindex)],RootFile) FileIndex FileExt];% build the input file name (first line) 3192 else 3210 % if strcmp(get(handles.NomType,'String'),'level') 3211 % jindex=str2num(get(handles.j1,'String')); 3212 % filename=[fullfile(RootPath,SubDir,['level' num2str(jindex)],RootFile) FileIndex FileExt];% build the input file name (first line) 3213 % else 3214 if isempty(regexp(RootPath,'^http://')) 3193 3215 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 3216 else 3217 filename=[RootPath '/' SubDir '/' RootFile FileIndex FileExt];% 3194 3218 end 3195 3219 filename_1='';%default second file name … … 3247 3271 3248 3272 %% determine the main input file information for action 3249 if ~exist(FileName,'file')3273 if isempty(regexp(FileName,'^http://')) &&~exist(FileName,'file') 3250 3274 errormsg=['input file ' FileName ' does not exist']; 3251 3275 return … … 4340 4364 field= list_fields{index_fields(1)}; % selected string 4341 4365 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 4366 if isempty(regexp(RootPath,'^http://')) 4342 4367 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 4368 else 4369 FileName=[RootPath '/' SubDir '/' RootFile FileIndices FileExt]; 4370 end 4343 4371 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 4344 4372 … … 4385 4413 %read selection from get_field 4386 4414 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 4415 if isempty(regexp(RootPath,'^http://')) 4387 4416 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 4417 else 4418 FileName=[RootPath '/' SubDir '/' RootFile FileIndices FileExt]; 4419 end 4388 4420 GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field 4389 4421 FieldList={};
Note: See TracChangeset
for help on using the changeset viewer.