Changeset 89 for trunk/src/name_generator.m
- Timestamp:
- May 20, 2010, 1:48:25 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/name_generator.m
r85 r89 1 1 %'name_generator': creates a file name from a root name and indices. 2 %--------------------------------------------------------------------- 2 %------------------------------------------------------------------------ 3 3 % [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=... 4 4 % name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir); 5 %--------------------------------------------------------------------- 5 %------------------------------------------------------------------------ 6 6 % This function detects the existence the constructed file name and it can 7 7 % find indices according to file existence if they are not specified 8 8 % rmq: this function is related to the reverse functions display2name and name2diplay 9 %--------------------------------------------------------------------- 9 %------------------------------------------------------------------------ 10 10 % OUTPUT: 11 11 % filename: string representing the file name (including path) … … 13 13 % num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected 14 14 % for free input (= to the corresponding input indices when comp_input=1) 15 %--------------------------------------------------------------------- 15 %------------------------------------------------------------------------ 16 16 % INPUT: 17 17 % 'filebase': the root name, … … 22 22 % nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined) 23 23 % nom_type='*': the same file [filebase ext] contains successive fields (ex avi movies) 24 % nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif' 24 25 % nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png'). 26 % nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif' 25 27 % nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif' 26 28 % nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png') … … 28 30 % nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc') 29 31 % nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc') 32 % nom_type='%3da','%3dA' with a numerical index and an index letter(e.g.'aa045b.png'), 30 33 % nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j') 31 % nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif' 32 % nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif' 33 % nom_type='raw_SMD', same as '#a' but with no extension ext='', OBSOLETE 34 % nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D') 35 % nom_type='%3dab' from pairs of '%3da' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by 'netc_2D') 34 % nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'), 35 % nom_type='%3d_ab' from pairs of '%3da' images (e.g. 'aa045bc.nc') 36 36 %'comp_input' (for nom_type involving index pairs (e.g. netc)) 37 37 % comp_input=1: the index pair is imposed, … … 48 48 sizf=size(filebase); 49 49 if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end 50 if ~exist('ext','var') 51 ext=''; 52 end 53 if ~exist('nom_type','var') 54 nom_type=''; 55 end 50 56 if ~ischar(ext),ext='';end 51 % filename=[filebase ext];%default52 57 idetect=0; 53 if ~exist('num_i1','var') || ise qual(num_i1,[])58 if ~exist('num_i1','var') || isempty(num_i1) || isnan(num_i1) 54 59 num_i1=1; %default 55 60 end 56 if ~exist('num_j1','var') || isequal(num_j1,[])61 if ~exist('num_j1','var') || isempty(num_j1) || isnan(num_j1) 57 62 num_j1=1; %default 58 63 end 59 if ~exist('num_i2','var') || isequal(num_i2,[])64 if ~exist('num_i2','var') || isempty(num_i2) || isnan(num_i2) 60 65 num_i2=num_i1; %default 61 66 end 62 if ~exist('num_j2','var') || ise qual(num_i2,[])67 if ~exist('num_j2','var') || isempty(num_j2) || isnan(num_j2) 63 68 num_j2=num_j1; %default 64 69 end … … 71 76 num_j2_out=num_j2;%default output 72 77 73 test_pairs= isequal(nom_type,'netc_old')| isequal(nom_type,'netc_2D') | isequal(nom_type,'netc_3D')| isequal(nom_type,'_i1-i2_j1-j2')| ...74 isequal(nom_type,'netc_series')| isequal(nom_type,'#_ab')| isequal(nom_type,'_i_j1-j2')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');75 test_2D= isequal(nom_type,'netc_old') |isequal(nom_type,'netc_2D')|isequal(nom_type,'#_ab') |isequal(nom_type,'_i_j1-j2');76 test_3D= isequal(nom_type,'netc_3D') |isequal(nom_type,'netc_series')| isequal(nom_type,'_i1-i2_j')| isequal(nom_type,'_i1-i2');77 if isequal(nom_type,'series_i')| isequal(nom_type,'_i');78 test_pairs=strcmp(nom_type,'netc_old')| strcmp(nom_type,'netc_2D') | strcmp(nom_type,'netc_3D')| strcmp(nom_type,'_i1-i2_j1-j2')| ... 79 strcmp(nom_type,'netc_series')| strcmp(nom_type,'#_ab')| strcmp(nom_type,'_i_j1-j2')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2'); 80 test_2D= strcmp(nom_type,'netc_old') |strcmp(nom_type,'netc_2D')|strcmp(nom_type,'#_ab') |strcmp(nom_type,'_i_j1-j2'); 81 test_3D=strcmp(nom_type,'netc_3D') |strcmp(nom_type,'netc_series')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2'); 82 if strcmp(nom_type,'series_i')| strcmp(nom_type,'_i'); 78 83 filename=[filebase '_' num2str(num_i1) ext]; 79 84 num_i2_out=num_i1; 80 85 num_j1_out=[]; 81 86 num_j2_out=[]; 82 elseif length(nom_type)==5 && isequal(nom_type(1:3),'_%0')&& isequal(nom_type(5),'d');87 elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d'); 83 88 filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext]; 84 89 num_i2_out=num_i1; 85 90 num_j2_out=num_j1; 86 elseif isequal(nom_type,'series_i_j')| isequal(nom_type,'_i_j')91 elseif strcmp(nom_type,'series_i_j')| strcmp(nom_type,'_i_j') 87 92 filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext]; 88 93 num_i2_out=num_i1; 89 94 num_j2_out=num_j1; 90 elseif isequal(nom_type,'png_old')| isequal(nom_type,'#a')| isequal(nom_type,'#A')95 elseif strcmp(nom_type,'png_old')| strcmp(nom_type,'#a')| strcmp(nom_type,'#A') 91 96 filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext]; 92 97 num_i2_out=num_i1; 93 98 num_j2_out=num_j1; 94 elseif length(nom_type)>=5 & isequal(nom_type(2:3),'%0') & isequal(nom_type(5),'d') %isequal(nom_type,'_%04dA') %camera PCO Toulouse99 elseif length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d') %strcmp(nom_type,'_%04dA') %camera PCO Toulouse 95 100 filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext]; 96 101 num_i2_out=num_i1; 97 102 num_j2_out=num_j1; 98 elseif isequal(nom_type,'raw_SMD') %suffix a, b, c without extension103 elseif strcmp(nom_type,'raw_SMD') %suffix a, b, c without extension 99 104 filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)]; 100 105 num_i2_out=num_i1; 101 106 num_j2_out=num_j1; 102 elseif isequal(nom_type,'ima_num')| isequal(nom_type,'#')107 elseif strcmp(nom_type,'ima_num')| strcmp(nom_type,'#') 103 108 filename=[filebase num2str(num_i1) ext]; 104 109 num_i2_out=num_i1; 105 110 num_j1_out=[]; 106 111 num_j2_out=[]; 107 elseif length(nom_type)>=4 & isequal(nom_type(1:2),'%0') & isequal(nom_type(end),'d')112 elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d') 108 113 filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before 109 114 num_i2_out=num_i1; … … 115 120 filebasesub=filebase; 116 121 % get the root name filebasesub for the netcdf files 117 if ~ isequal(subdir,'') && ~isequal(subdir,'?')122 if ~strcmp(subdir,'') && ~strcmp(subdir,'?') 118 123 [Path,Name]=fileparts(filebase); 119 124 filebasesub=fullfile(Path,subdir,Name); 120 125 end 121 126 %inexistant pair if num_i2=0 or num_j2=0 122 % if isequal(num_i2,0)127 % if strcmp(num_i2,0) 123 128 % filename=[filebasesub '*-*_' num2str(num_i1) ext]; 124 129 % return 125 130 % end 126 % if isequal(num_j2,0)131 % if strcmp(num_j2,0) 127 132 % filename=[filebasesub '_' num2str(num_i1) '_*-*' ext]; 128 133 % return … … 232 237 if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end; 233 238 234 %--------------------------------------------------------------- 235 % search the appropriate image pair (netcdf file) corresponding to a given 236 % image number 237 %------------------------------------------------------------------- 239 %------------------------------------------------------------------------ 240 % --- search the appropriate image pair (netcdf file) corresponding to a given image number 238 241 function [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type) 242 %------------------------------------------------------------------------ 239 243 % for nom_type=netc_2D or netc_old, it searches all the pairs corresponding 240 244 % to num_i1, and chooses the most recent file.
Note: See TracChangeset
for help on using the changeset viewer.