source: trunk/src/uvmat_doc/FUNCTIONS_DOC/name2display.html @ 37

Last change on this file since 37 was 37, checked in by sommeria, 14 years ago

create_grid.fig ,
uvmat_doc and all the included files added

File size: 19.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2                "http://www.w3.org/TR/REC-html40/loose.dtd">
3<html>
4<head>
5  <title>Description of name2display</title>
6  <meta name="keywords" content="name2display">
7  <meta name="description" content="'name2display': extracts the root name and field numbers from an input filename">
8  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
10  <meta name="robots" content="index, follow">
11  <link type="text/css" rel="stylesheet" href="../m2html.css">
12</head>
13<body>
14<a name="_top"></a>
15<div><a href="../index.html">Home</a> &gt;  <a href="index.html">.</a> &gt; name2display.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for .&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
19
20<h1>name2display
21</h1>
22
23<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
24<div class="box"><strong>'name2display': extracts the root name and field numbers from an input filename</strong></div>
25
26<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
27<div class="box"><strong>function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) </strong></div>
28
29<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
30<div class="fragment"><pre class="comment">'name2display': extracts the root name and field numbers from an input filename
31--------------------------------------------------------------------
32[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
33
34OUTPUT:
35filebasesub: filename without appendix
36field_count: string for the first number i
37str2: string for the second number i (only for .nc files)
38str_a: string for the first number j
39str_b:string for the second number j (only for .nc files)
40ext: file extension
41nom_type: char chain characterizing the file nomenclature: with values
42   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
43   nom_type='*':constant name for a file representing a series (e.g. avi movie)
44   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
45   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
46   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
47   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
48   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
49   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
50   nom_type='#a','#A&quot;, with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
51   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
52   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
53subdir: name of the subdirectory for netcdf files
54
55INPUT:
56fileinput: complete name of the file, including path</pre></div>
57
58<!-- crossreference -->
59<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
60This function calls:
61<ul style="list-style-image:url(../matlabicon.gif)">
62</ul>
63This function is called by:
64<ul style="list-style-image:url(../matlabicon.gif)">
65<li><a href="civ.html" class="code" title="function varargout = civ(varargin)">civ</a>  'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)</li><li><a href="civ_3D.html" class="code" title="function varargout = civ_3D(varargin)">civ_3D</a>        'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume</li><li><a href="geometry_calib.html" class="code" title="function varargout = geometry_calib(varargin)">geometry_calib</a>     'geometry_calib': performs geometric calibration from a set of reference points</li><li><a href="name_generator.html" class="code" title="function [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);">name_generator</a>   'name_generator': creates a file name from a root name and indices.</li><li><a href="probe_calib.html" class="code" title="function varargout = probe_calib(varargin)">probe_calib</a>  'probe_calib': performs geometric calibration from a set of reference points</li><li><a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>     'read_xls': function for reading and displaying Excel files</li><li><a href="series.html" class="code" title="function varargout = series(varargin)">series</a> 'series': master function associated to the GUI series.m for analysis field series</li><li><a href="set_grid.html" class="code" title="function varargout = set_grid(varargin)">set_grid</a>    'set_grid':produce grid for PIV with one or two images (stereo case)</li><li><a href="uvmat.html" class="code" title="function varargout = uvmat(varargin)">uvmat</a>   'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization</li></ul>
66<!-- crossreference -->
67
68
69<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
70<div class="fragment"><pre>0001 <span class="comment">%'name2display': extracts the root name and field numbers from an input filename</span>
710002 <span class="comment">%--------------------------------------------------------------------</span>
720003 <span class="comment">%[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)</span>
730004 <span class="comment">%</span>
740005 <span class="comment">%OUTPUT:</span>
750006 <span class="comment">%filebasesub: filename without appendix</span>
760007 <span class="comment">%field_count: string for the first number i</span>
770008 <span class="comment">%str2: string for the second number i (only for .nc files)</span>
780009 <span class="comment">%str_a: string for the first number j</span>
790010 <span class="comment">%str_b:string for the second number j (only for .nc files)</span>
800011 <span class="comment">%ext: file extension</span>
810012 <span class="comment">%nom_type: char chain characterizing the file nomenclature: with values</span>
820013 <span class="comment">%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)</span>
830014 <span class="comment">%   nom_type='*':constant name for a file representing a series (e.g. avi movie)</span>
840015 <span class="comment">%   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').</span>
850016 <span class="comment">%   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'</span>
860017 <span class="comment">%   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')</span>
870018 <span class="comment">%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')</span>
880019 <span class="comment">%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')</span>
890020 <span class="comment">%   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')</span>
900021 <span class="comment">%   nom_type='#a','#A&quot;, with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)</span>
910022 <span class="comment">%   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE</span>
920023 <span class="comment">%   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')</span>
930024 <span class="comment">%subdir: name of the subdirectory for netcdf files</span>
940025 <span class="comment">%</span>
950026 <span class="comment">%INPUT:</span>
960027 <span class="comment">%fileinput: complete name of the file, including path</span>
970028
980029 <a name="_sub0" href="#_subfunctions" class="code">function [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)</a>
990030 <span class="comment">% siz=length(fileinput);</span>
1000031 <span class="comment">% indcur=siz;</span>
1010032 <span class="comment">% default values:</span>
1020033 <span class="comment">% test_=0;</span>
1030034 field_count=<span class="string">''</span>;<span class="comment">%character string</span>
1040035 str2=<span class="string">''</span>;
1050036 str_a=<span class="string">''</span>;
1060037 str_b=<span class="string">''</span>;
1070038 <span class="comment">% ext='';</span>
1080039 nom_type=<span class="string">''</span>;
1090040 subdir=<span class="string">''</span>;
1100041         <span class="comment">%select file extension</span>
1110042 [RootPath,RootFile,ext]=fileparts(fileinput);
1120043 indcur=length(RootFile);<span class="comment">% nbre of characters in fileraw</span>
1130044
1140045         <span class="comment">%recognize the name form</span>
1150046 filerawascii=double(RootFile);<span class="comment">%ascci code</span>
1160047 val=(48&gt;filerawascii)|(filerawascii&gt;57); <span class="comment">% test for the non-numerical characters</span>
1170048 indsel=find(val);<span class="comment">% character indices of non numerical characters</span>
1180049 filelit=RootFile(indsel);<span class="comment">% fileraw name with numbers removed</span>
1190050 nbchar=length(indsel);
1200051 <span class="keyword">if</span> nbchar&lt;4<span class="comment">% put '*' before the name (remove at the end)</span>
1210052    prefilelit(1:4-nbchar)=<span class="string">'*'</span>;<span class="comment">%insert 3_nbchar '*' in the file name</span>
1220053    filelit=[prefilelit filelit];
1230054    indsel=[1:4-nbchar indsel+4-nbchar];
1240055    RootFile=[prefilelit RootFile];
1250056    indcur=indcur+4-nbchar;
1260057 <span class="keyword">end</span>
1270058 separ3=indsel(end);<span class="comment">% index of last non numerical character in fileraw</span>
1280059 separ2=indsel(end-1);<span class="comment">% index of previous non numerical character</span>
1290060 separ1=indsel(end-2);
1300061 separ0=indsel(end-3);
1310062 num1=<span class="string">''</span>;num2=<span class="string">''</span>;num3=<span class="string">''</span>;
1320063 <span class="keyword">if</span> separ1&gt;=separ0+1,num0=RootFile(separ0+1:separ1-1);<span class="keyword">end</span>
1330064 <span class="keyword">if</span> separ2&gt;=separ1+1,num1=RootFile(separ1+1:separ2-1);<span class="keyword">end</span>
1340065 <span class="keyword">if</span> separ3&gt;=separ2+1,num2=RootFile(separ2+1:separ3-1);<span class="keyword">end</span>
1350066 <span class="keyword">if</span> indcur&gt;=separ3+1,num3=RootFile(separ3+1:indcur);<span class="keyword">end</span>
1360067 last_str=RootFile(indcur);<span class="comment">%last character in fileraw</span>
1370068 last=double(last_str);<span class="comment">%corresponding ascii code</span>
1380069 penult=double(RootFile(indcur-1));<span class="comment">%ascii code of the penultimate character</span>
1390070 testsub=0; <span class="comment">%default</span>
1400071 <span class="keyword">if</span> strcmpi(ext,<span class="string">'.avi'</span>)
1410072      nom_type=<span class="string">'*'</span>;
1420073       <span class="comment">%case of old image nomenclature</span>
1430074 <span class="keyword">elseif</span> (strcmp(ext,<span class="string">'.png'</span>) || strcmp(ext,<span class="string">''</span>)) &amp;&amp;  penult &gt;= 48 &amp;&amp; penult &lt;= 57 &amp;&amp; (last &lt; 48 || last &gt; 57)
1440075     <span class="comment">% if the penultimate character is a number and the last a letter</span>
1450076     <span class="comment">% search the appendix a,b,c,</span>
1460077     str_a=last_str; <span class="comment">%put appendix a,b,c....</span>
1470078     indcur=indcur-1;
1480079     <span class="keyword">if</span> strcmp(ext,<span class="string">'.png'</span>), nom_type=<span class="string">'#a'</span>; <span class="keyword">end</span>
1490080     <span class="keyword">if</span> strcmp(ext,<span class="string">''</span>), nom_type=<span class="string">'raw_SMD'</span>; <span class="keyword">end</span>     
1500081     num=1;count=0; <span class="comment">% extract the numerical appendix</span>
1510082     <span class="keyword">while</span> num==1;
1520083         filascii=double(RootFile(indcur));
1530084         <span class="keyword">if</span> (48&gt;filascii)||(filascii&gt;57); <span class="comment">% select the non-numerical characters</span>
1540085             num=0;
1550086         <span class="keyword">else</span>
1560087             indcur=indcur-1; count=count+1;
1570088         <span class="keyword">end</span>
1580089     <span class="keyword">end</span>
1590090     <span class="keyword">if</span> count~=0             
1600091             field_count=RootFile(indcur+1:indcur+count);<span class="comment">% set the selected field number</span>
1610092     <span class="keyword">end</span>
1620093 <span class="keyword">elseif</span>  penult &gt;= 48 &amp;&amp; penult &lt;= 57  &amp;&amp; (last &lt;= 66 &amp;&amp; last &gt;= 65)<span class="comment">% PCO camera Toulouse, end with A or B (NEW)</span>
1630094     <span class="comment">% if the penultimate character is a number and the last a letter</span>
1640095     <span class="comment">% search the appendix a,b,c,</span>
1650096     str_a=last_str; <span class="comment">%put appendix a,b,c....</span>
1660097     indcur=indcur-1;
1670098     nom_type=<span class="string">'#A'</span>;   
1680099     num=1;count=0; <span class="comment">% extract the numerical appendix</span>
1690100     <span class="keyword">while</span> num==1;
1700101         filascii=double(RootFile(indcur));
1710102         <span class="keyword">if</span> (48&gt;filascii)||(filascii&gt;57); <span class="comment">% select the non-numerical characters</span>
1720103             num=0;
1730104         <span class="keyword">else</span>
1740105             indcur=indcur-1; count=count+1;
1750106         <span class="keyword">end</span>
1760107     <span class="keyword">end</span>
1770108     <span class="keyword">if</span> count~=0             
1780109             field_count=RootFile(indcur+1:indcur+count);<span class="comment">% set the selected field number</span>
1790110     <span class="keyword">end</span>   
1800111     indcur=indcur-1;
1810112 <span class="keyword">elseif</span> strcmp(filelit(end-2:end),<span class="string">'-_-_'</span>)<span class="comment">%new  nomenclature appendix num1-num2_num_a-num_b</span>
1820113     field_count=num0;
1830114     str2=num1;
1840115     str_a=num2;
1850116     str_b=num3;
1860117     nom_type=<span class="string">'_i1-i2_j1-j2'</span>;
1870118     testsub=1;
1880119     indcur=separ0-1;
1890120 <span class="keyword">elseif</span> strcmp(filelit(end-2:end),<span class="string">'_-_'</span>)<span class="comment">%new  nomenclature appendix num1-num2_num_a</span>
1900121     field_count=num1;
1910122     str2=num2;
1920123     str_a=num3;
1930124     nom_type=<span class="string">'_i1-i2_j'</span>;
1940125     testsub=1;
1950126     indcur=separ1-1;
1960127 <span class="keyword">elseif</span> strcmp(filelit(end-2:end),<span class="string">'__-'</span>)<span class="comment">%new  nomenclature appendix num1_num2-num2</span>
1970128     indcur=separ1-1;
1980129     field_count=num1;
1990130     str_a=num2;
2000131     str_b=num3;
2010132     nom_type=<span class="string">'_i_j1-j2'</span>;
2020133     testsub=1;
2030134 <span class="keyword">elseif</span> strcmp(filelit(end-1:end),<span class="string">'_-'</span>)
2040135     indcur=separ2-1;
2050136     field_count=num2;
2060137     str2=num3;
2070138     str_a=<span class="string">''</span>;
2080139     nom_type=<span class="string">'_i1-i2'</span>;
2090140     testsub=1;
2100141 <span class="keyword">elseif</span> strcmp(filelit(end-1:end),<span class="string">'__'</span>)
2110142     indcur=separ2-1;
2120143     field_count=num2;
2130144     str2=<span class="string">''</span>;
2140145     str_a=num3;
2150146     nom_type=<span class="string">'_i_j'</span>;
2160147 <span class="keyword">elseif</span> strcmp(filelit(end),<span class="string">'_'</span>)
2170148     indcur=separ3-1;
2180149 <span class="comment">%     field_count=num3;</span>
2190150     str2=<span class="string">''</span>;
2200151     str_a=<span class="string">''</span>;
2210152     <span class="comment">%detect zeros before the number</span>
2220153 <span class="comment">%     count=0; % extract the numerical appendix</span>
2230154     <span class="keyword">if</span> strcmp(<span class="string">'0'</span>,RootFile(separ3+1)); <span class="comment">% select the non-numerical characters</span>
2240155         nom_type=[<span class="string">'_%0'</span> num2str(length(RootFile(separ3+1:end))) <span class="string">'d'</span>];
2250156     <span class="keyword">else</span>
2260157         nom_type=<span class="string">'_i'</span>;
2270158     <span class="keyword">end</span> 
2280159     field_count=RootFile(separ3+1:end);<span class="comment">% set the selected field number'%03d'</span>
2290160 <span class="keyword">elseif</span> RootFile(indcur-2)==<span class="string">'_'</span><span class="comment">% search appendix a,b,c,d</span>
2300161     last=RootFile(indcur-1:indcur);
2310162     <span class="keyword">if</span> isequal(length(last),2) &amp;&amp; double(last(1)) &gt;= 97 &amp;&amp; double(last(1)) &lt;= 122 <span class="keyword">...</span><span class="comment">% = 1 for letters</span>
2320163             &amp;&amp; double(last(2)) &gt;= 97 &amp;&amp; double(last(2)) &lt;= 122
2330164           str_a=last(1);<span class="comment">%put appendix a,b,c, ou d</span>
2340165           str_b=last(2);<span class="comment">%put appendix a,b,c, ou d</span>
2350166 <span class="comment">%           indcur=indcur-3;</span>
2360167           separ0=indsel(end-3);
2370168         num0=RootFile(separ0+1:separ1-1);
2380169         field_count=num0;
2390170         indcur=separ0;
2400171         nom_type=<span class="string">'#_ab'</span>;
2410172         testsub=1;
2420173     <span class="keyword">end</span>
2430174 <span class="comment">%search for other names with counter</span>
2440175 <span class="keyword">else</span>
2450176     <span class="keyword">if</span> length(ext)&gt;1     
2460177             num=1;count=0; <span class="comment">% extract the numerical appendix</span>
2470178             <span class="keyword">while</span> num==1;
2480179                 filascii=double(RootFile(indcur));
2490180                 <span class="keyword">if</span> (48&gt;filascii)||(filascii&gt;57); <span class="comment">% select the non-numerical characters</span>
2500181                     num=0;
2510182                 <span class="keyword">else</span>
2520183                     indcur=indcur-1; count=count+1;
2530184                 <span class="keyword">end</span>
2540185             <span class="keyword">end</span>
2550186             <span class="keyword">if</span> count~=0   
2560187                 field_count=RootFile(indcur+1:indcur+count);<span class="comment">% set the selected field number'%03d'</span>
2570188                 <span class="keyword">if</span> isequal(field_count(1),<span class="string">'0'</span>)
2580189                     nbfigures=length(field_count);
2590190                     nom_type=[<span class="string">'%0'</span> num2str(nbfigures) <span class="string">'d'</span>];
2600191                 <span class="keyword">else</span>
2610192                     nom_type=<span class="string">'#'</span>;
2620193                 <span class="keyword">end</span>
2630194             <span class="keyword">end</span>
2640195     <span class="keyword">end</span>
2650196 <span class="keyword">end</span>
2660197             <span class="comment">%select the root name in the file_input window</span>
2670198 RootFile=RootFile(1:indcur);
2680199 <span class="keyword">if</span> nbchar&lt;4<span class="comment">% put '*' before the name (remove at the end)</span>
2690200    RootFile(1:4-nbchar)=[];
2700201 <span class="keyword">end</span>
2710202 <span class="keyword">if</span> testsub
2720203     [RootPath,subdir,extdir]=fileparts(RootPath);
2730204     subdir=[subdir extdir];
2740205 <span class="keyword">end</span></pre></div>
275<hr><address>Generated on Fri 13-Nov-2009 11:17:03 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
276</body>
277</html>
Note: See TracBrowser for help on using the repository browser.