Ignore:
Timestamp:
May 20, 2010, 1:48:25 AM (14 years ago)
Author:
sommeria
Message:

many bug corrections and cleaning. Activation of the BW option in uvmat. Improvement of the interaction of get_field with uvmat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/name_generator.m

    r85 r89  
    11%'name_generator': creates a file name from a root name and indices.
    2 %---------------------------------------------------------------------
     2%------------------------------------------------------------------------
    33% [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
    44%        name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
    5 %---------------------------------------------------------------------           
     5%------------------------------------------------------------------------           
    66% This function detects the existence the constructed file name and it can
    77% find indices according to file existence if they are not specified
    88% rmq: this function is related to the reverse functions display2name and name2diplay
    9 %---------------------------------------------------------------------
     9%------------------------------------------------------------------------
    1010% OUTPUT:
    1111% filename: string representing the file name (including path)
     
    1313% num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected
    1414%            for free input (= to the corresponding input indices when comp_input=1)
    15 %---------------------------------------------------------------------
     15%------------------------------------------------------------------------
    1616% INPUT:
    1717% 'filebase': the root name,
     
    2222%       nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
    2323%       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'
    2425%       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'
    2527%       nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
    2628%       nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
     
    2830%       nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
    2931%       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'),
    3033%       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')
    3636%'comp_input' (for nom_type involving index pairs (e.g. netc))
    3737%       comp_input=1: the index pair is imposed,
     
    4848sizf=size(filebase);
    4949if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
     50if ~exist('ext','var')
     51    ext='';
     52end
     53if ~exist('nom_type','var')
     54    nom_type='';
     55end
    5056if ~ischar(ext),ext='';end
    51 % filename=[filebase ext];%default
    5257idetect=0;
    53 if ~exist('num_i1','var') || isequal(num_i1,[])
     58if ~exist('num_i1','var') || isempty(num_i1) || isnan(num_i1)
    5459    num_i1=1; %default
    5560end
    56 if ~exist('num_j1','var') || isequal(num_j1,[])
     61if ~exist('num_j1','var') ||  isempty(num_j1) || isnan(num_j1)
    5762    num_j1=1; %default
    5863end
    59 if ~exist('num_i2','var') || isequal(num_i2,[])
     64if ~exist('num_i2','var') ||  isempty(num_i2) || isnan(num_i2)
    6065    num_i2=num_i1; %default
    6166end
    62 if ~exist('num_j2','var') || isequal(num_i2,[])
     67if ~exist('num_j2','var') || isempty(num_j2) || isnan(num_j2)
    6368    num_j2=num_j1; %default
    6469end
     
    7176num_j2_out=num_j2;%default output
    7277
    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');
     78test_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');
     80test_2D= strcmp(nom_type,'netc_old') |strcmp(nom_type,'netc_2D')|strcmp(nom_type,'#_ab') |strcmp(nom_type,'_i_j1-j2');
     81test_3D=strcmp(nom_type,'netc_3D') |strcmp(nom_type,'netc_series')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2');
     82if strcmp(nom_type,'series_i')| strcmp(nom_type,'_i');
    7883        filename=[filebase '_' num2str(num_i1) ext];
    7984        num_i2_out=num_i1;
    8085        num_j1_out=[];
    8186        num_j2_out=[];
    82 elseif length(nom_type)==5 && isequal(nom_type(1:3),'_%0')&& isequal(nom_type(5),'d');
     87elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d');
    8388        filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext];
    8489        num_i2_out=num_i1;
    8590        num_j2_out=num_j1;
    86 elseif isequal(nom_type,'series_i_j')| isequal(nom_type,'_i_j')
     91elseif strcmp(nom_type,'series_i_j')| strcmp(nom_type,'_i_j')
    8792        filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext];
    8893        num_i2_out=num_i1;
    8994        num_j2_out=num_j1;
    90 elseif isequal(nom_type,'png_old')| isequal(nom_type,'#a')| isequal(nom_type,'#A')
     95elseif strcmp(nom_type,'png_old')| strcmp(nom_type,'#a')| strcmp(nom_type,'#A')
    9196        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext];
    9297        num_i2_out=num_i1;
    9398        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 Toulouse
     99elseif  length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d')  %strcmp(nom_type,'_%04dA') %camera PCO Toulouse
    95100        filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext];
    96101        num_i2_out=num_i1;
    97102        num_j2_out=num_j1;   
    98 elseif isequal(nom_type,'raw_SMD') %suffix a, b, c without extension
     103elseif strcmp(nom_type,'raw_SMD') %suffix a, b, c without extension
    99104        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)];
    100105        num_i2_out=num_i1;
    101106        num_j2_out=num_j1;
    102 elseif isequal(nom_type,'ima_num')| isequal(nom_type,'#')
     107elseif strcmp(nom_type,'ima_num')| strcmp(nom_type,'#')
    103108        filename=[filebase num2str(num_i1) ext];
    104109        num_i2_out=num_i1;
    105110        num_j1_out=[];
    106111        num_j2_out=[];
    107 elseif length(nom_type)>=4 & isequal(nom_type(1:2),'%0') & isequal(nom_type(end),'d')
     112elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d')
    108113        filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before
    109114        num_i2_out=num_i1;
     
    115120    filebasesub=filebase;
    116121    % get the root name filebasesub for the netcdf files
    117     if  ~isequal(subdir,'') && ~isequal(subdir,'?')
     122    if  ~strcmp(subdir,'') && ~strcmp(subdir,'?')
    118123            [Path,Name]=fileparts(filebase);
    119124            filebasesub=fullfile(Path,subdir,Name);
    120125    end
    121126     %inexistant pair if num_i2=0 or num_j2=0
    122 %     if isequal(num_i2,0)
     127%     if strcmp(num_i2,0)
    123128%         filename=[filebasesub '*-*_' num2str(num_i1) ext];
    124129%         return
    125130%     end
    126 %     if isequal(num_j2,0)
     131%     if strcmp(num_j2,0)
    127132%         filename=[filebasesub '_' num2str(num_i1) '_*-*' ext];
    128133%         return
     
    232237if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end;
    233238
    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
    238241function [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type)
     242%------------------------------------------------------------------------
    239243% for nom_type=netc_2D or netc_old, it searches all the pairs corresponding
    240244% to num_i1, and chooses the most recent file.
Note: See TracChangeset for help on using the changeset viewer.