Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 4726f970c4b56b9a0ebb9a03a0b6522e > files > 192

python-tables-doc-3.0.0-4.mga4.noarch.rpm




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Utilities &mdash; PyTables 3.0.0 documentation</title>
    
    <link rel="stylesheet" href="../_static/cloud.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.0.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/jquery.cookie.js"></script>
    <script type="text/javascript" src="../_static/toggle_sections.js"></script>
    <script type="text/javascript" src="../_static/toggle_sidebar.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="top" title="PyTables 3.0.0 documentation" href="../index.html" />
    <link rel="up" title="PyTables User’s Guide" href="index.html" />
    <link rel="next" title="PyTables File Format" href="file_format.html" />
    <link rel="prev" title="PyTables parameter files" href="parameter_files.html" /> 
  </head>
  <body>
    <div class="relbar-top">
        
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="../np-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="file_format.html" title="PyTables File Format"
             accesskey="N">next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="parameter_files.html" title="PyTables parameter files"
             accesskey="P">previous</a> &nbsp; &nbsp;</li>
    <li><a href="../index.html">PyTables 3.0.0 documentation</a> &raquo;</li>

          <li><a href="index.html" accesskey="U">PyTables User&#8217;s Guide</a> &raquo;</li> 
      </ul>
    </div>
    </div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="utilities">
<h1>Utilities<a class="headerlink" href="#utilities" title="Permalink to this headline">¶</a></h1>
<p>PyTables comes with a couple of utilities that make the life easier to the
user. One is called ptdump and lets you see the contents of a PyTables file
(or generic HDF5 file, if supported). The other one is named ptrepack that
allows to (recursively) copy sub-hierarchies of objects present in a file
into another one, changing, if desired, some of the filters applied to the
leaves during the copy process.</p>
<p>Normally, these utilities will be installed somewhere in your PATH during the
process of installation of the PyTables package, so that you can invoke them
from any place in your file system after the installation has successfully
finished.</p>
<div class="section" id="ptdump">
<h2>ptdump<a class="headerlink" href="#ptdump" title="Permalink to this headline">¶</a></h2>
<p>As has been said before, ptdump utility allows you look into the contents of
your PyTables files. It lets you see not only the data but also the metadata
(that is, the <em>structure</em> and additional information in the form of
<em>attributes</em>).</p>
<div class="section" id="usage">
<h3>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h3>
<p>For instructions on how to use it, just pass the -h flag to the command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -h
</pre></div>
</div>
<p>to see the message usage:</p>
<div class="highlight-bash"><div class="highlight"><pre>usage: ptdump <span class="o">[</span>-d<span class="o">]</span> <span class="o">[</span>-v<span class="o">]</span> <span class="o">[</span>-a<span class="o">]</span> <span class="o">[</span>-c<span class="o">]</span> <span class="o">[</span>-i<span class="o">]</span> <span class="o">[</span>-R start,stop,step<span class="o">]</span> <span class="o">[</span>-h<span class="o">]</span> file<span class="o">[</span>:nodepath<span class="o">]</span>
    -d -- Dump data information on leaves
    -v -- Dump more metainformation on nodes
    -a -- Show attributes in nodes <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
    -c -- Show info of columns in tables <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
    -i -- Show info of indexed columns <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
    -R RANGE -- Select a RANGE of rows in the form <span class="s2">&quot;start,stop,step&quot;</span>
    -h -- Print <span class="nb">help </span>on usage
</pre></div>
</div>
<p>Read on for a brief introduction to this utility.</p>
</div>
<div class="section" id="a-small-tutorial-on-ptdump">
<h3>A small tutorial on ptdump<a class="headerlink" href="#a-small-tutorial-on-ptdump" title="Permalink to this headline">¶</a></h3>
<p>Let&#8217;s suppose that we want to know only the <em>structure</em> of a file. In order
to do that, just don&#8217;t pass any flag, just the file as parameter.</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of strings&#39;</span>
</pre></div>
</div>
<p>we can see that the file contains just a leaf object called vlarray1, that is
an instance of VLArray, has 4 rows, and two filters has been used in order to
create it: shuffle and zlib (with a compression level of 1).</p>
<p>Let&#8217;s say we want more meta-information. Just add the -v (verbose) flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -v vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
  <span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
  <span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">&#39;little&#39;</span>
  <span class="nv">nrows</span> <span class="o">=</span> 3
  <span class="nv">flavor</span> <span class="o">=</span> <span class="s1">&#39;numpy&#39;</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of strings&#39;</span>
  <span class="nv">atom</span> <span class="o">=</span> StringAtom<span class="o">(</span><span class="nv">itemsize</span><span class="o">=</span>2, <span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="o">)</span>
  <span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">&#39;irrelevant&#39;</span>
  <span class="nv">nrows</span> <span class="o">=</span> 3
  <span class="nv">flavor</span> <span class="o">=</span> <span class="s1">&#39;python&#39;</span>
</pre></div>
</div>
<p>so we can see more info about the atoms that are the components of the
vlarray1 dataset, i.e. they are scalars of type Int32 and with NumPy
<em>flavor</em>.</p>
<p>If we want information about the attributes on the nodes, we must add the -a
flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -va vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
  /._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 4 attributes:
   <span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">&#39;GROUP&#39;</span>,
    PYTABLES_FORMAT_VERSION :<span class="o">=</span> <span class="s1">&#39;2.0&#39;</span>,
    TITLE :<span class="o">=</span> <span class="s1">&#39;&#39;</span>,
    VERSION :<span class="o">=</span> <span class="s1">&#39;1.0&#39;</span><span class="o">]</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
  <span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
  <span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">&#39;little&#39;</span>
  <span class="nv">nrows</span> <span class="o">=</span> 3
  <span class="nv">flavor</span> <span class="o">=</span> <span class="s1">&#39;numpy&#39;</span>
  /vlarray1._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 3 attributes:
   <span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">&#39;VLARRAY&#39;</span>,
    TITLE :<span class="o">=</span> <span class="s1">&#39;ragged array of ints&#39;</span>,
    VERSION :<span class="o">=</span> <span class="s1">&#39;1.3&#39;</span><span class="o">]</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of strings&#39;</span>
  <span class="nv">atom</span> <span class="o">=</span> StringAtom<span class="o">(</span><span class="nv">itemsize</span><span class="o">=</span>2, <span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="o">)</span>
  <span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">&#39;irrelevant&#39;</span>
  <span class="nv">nrows</span> <span class="o">=</span> 3
  <span class="nv">flavor</span> <span class="o">=</span> <span class="s1">&#39;python&#39;</span>
  /vlarray2._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 4 attributes:
   <span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">&#39;VLARRAY&#39;</span>,
    FLAVOR :<span class="o">=</span> <span class="s1">&#39;python&#39;</span>,
    TITLE :<span class="o">=</span> <span class="s1">&#39;ragged array of strings&#39;</span>,
    VERSION :<span class="o">=</span> <span class="s1">&#39;1.3&#39;</span><span class="o">]</span>
</pre></div>
</div>
<p>Let&#8217;s have a look at the real data:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -d vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
  Data dump:
<span class="o">[</span>0<span class="o">]</span> <span class="o">[</span>5 6<span class="o">]</span>
<span class="o">[</span>1<span class="o">]</span> <span class="o">[</span>5 6 7<span class="o">]</span>
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of strings&#39;</span>
  Data dump:
<span class="o">[</span>0<span class="o">]</span> <span class="o">[</span><span class="s1">&#39;5&#39;</span>, <span class="s1">&#39;66&#39;</span><span class="o">]</span>
<span class="o">[</span>1<span class="o">]</span> <span class="o">[</span><span class="s1">&#39;5&#39;</span>, <span class="s1">&#39;6&#39;</span>, <span class="s1">&#39;77&#39;</span><span class="o">]</span>
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span><span class="s1">&#39;5&#39;</span>, <span class="s1">&#39;6&#39;</span>, <span class="s1">&#39;9&#39;</span>, <span class="s1">&#39;88&#39;</span><span class="o">]</span>
</pre></div>
</div>
<p>We see here a data dump of the 4 rows in vlarray1 object, in the form of a
list. Because the object is a VLA, we see a different number of integers on
each row.</p>
<p>Say that we are interested only on a specific <em>row range</em> of the /vlarray1
object:</p>
<div class="highlight-bash"><div class="highlight"><pre>ptdump -R2,3 -d vlarray1.h5:/vlarray1
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
  Data dump:
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
</pre></div>
</div>
<p>Here, we have specified the range of rows between 2 and 4 (the upper limit
excluded, as usual in Python). See how we have selected only the /vlarray1
object for doing the dump (vlarray1.h5:/vlarray1).</p>
<p>Finally, you can mix several information at once:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -R2,3 -vad vlarray1.h5:/vlarray1
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;ragged array of ints&#39;</span>
  <span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
  <span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">&#39;little&#39;</span>
  <span class="nv">nrows</span> <span class="o">=</span> 3
  <span class="nv">flavor</span> <span class="o">=</span> <span class="s1">&#39;numpy&#39;</span>
  /vlarray1._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 3 attributes:
   <span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">&#39;VLARRAY&#39;</span>,
    TITLE :<span class="o">=</span> <span class="s1">&#39;ragged array of ints&#39;</span>,
    VERSION :<span class="o">=</span> <span class="s1">&#39;1.3&#39;</span><span class="o">]</span>
  Data dump:
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="ptrepack">
<span id="ptrepackdescr"></span><h2>ptrepack<a class="headerlink" href="#ptrepack" title="Permalink to this headline">¶</a></h2>
<p>This utility is a very powerful one and lets you copy any leaf, group or
complete subtree into another file. During the copy process you are allowed
to change the filter properties if you want so. Also, in the case of
duplicated pathnames, you can decide if you want to overwrite already
existing nodes on the destination file. Generally speaking, ptrepack can be
useful in may situations, like replicating a subtree in another file, change
the filters in objects and see how affect this to the compression degree or
I/O performance, consolidating specific data in repositories or even
<em>importing</em> generic HDF5 files and create true PyTables counterparts.</p>
<div class="section" id="id1">
<h3>Usage<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>For instructions on how to use it, just pass the -h flag to the command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -h
</pre></div>
</div>
<p>to see the message usage:</p>
<div class="highlight-bash"><div class="highlight"><pre>usage: ptrepack <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>-v<span class="o">]</span> <span class="o">[</span>-o<span class="o">]</span> <span class="o">[</span>-R start,stop,step<span class="o">]</span> <span class="o">[</span>--non-recursive<span class="o">]</span> <span class="o">[</span>--dest-title<span class="o">=</span>title<span class="o">]</span> <span class="o">[</span>--dont-create-sysattrs<span class="o">]</span> <span class="o">[</span>--dont-copy-userattrs<span class="o">]</span> <span class="o">[</span>--overwrite-nodes<span class="o">]</span> <span class="o">[</span>--complevel<span class="o">=(</span>0-9<span class="o">)]</span> <span class="o">[</span>--complib<span class="o">=</span>lib<span class="o">]</span> <span class="o">[</span>--shuffle<span class="o">=(</span>0|1<span class="o">)]</span> <span class="o">[</span>--fletcher32<span class="o">=(</span>0|1<span class="o">)]</span> <span class="o">[</span>--keep-source-filters<span class="o">]</span> <span class="o">[</span>--chunkshape<span class="o">=</span>value<span class="o">]</span> <span class="o">[</span>--upgrade-flavors<span class="o">]</span> <span class="o">[</span>--dont-regenerate-old-indexes<span class="o">]</span> <span class="o">[</span>--sortby<span class="o">=</span>column<span class="o">]</span> <span class="o">[</span>--checkCSI<span class="o">]</span> <span class="o">[</span>--propindexes<span class="o">]</span> sourcefile:sourcegroup destfile:destgroup
    -h -- Print usage message.
    -v -- Show more information.
    -o -- Overwrite destination file.
    -R RANGE -- Select a RANGE of rows <span class="o">(</span>in the form <span class="s2">&quot;start,stop,step&quot;</span><span class="o">)</span>
        during the copy of <span class="se">\*</span>all* the leaves.  Default values are
        <span class="s2">&quot;None,None,1&quot;</span>, which means a copy of all the rows.
    --non-recursive -- Do not <span class="k">do </span>a recursive copy. Default is to <span class="k">do </span>it.
    --dest-title<span class="o">=</span>title -- Title <span class="k">for </span>the new file <span class="o">(</span><span class="k">if </span>not specified,
        the <span class="nb">source </span>is copied<span class="o">)</span>.
    --dont-create-sysattrs -- Do not create sys attrs <span class="o">(</span>default is to <span class="k">do </span>it<span class="o">)</span>.
    --dont-copy-userattrs -- Do not copy the user attrs <span class="o">(</span>default is to <span class="k">do </span>it<span class="o">)</span>.
    --overwrite-nodes -- Overwrite destination nodes <span class="k">if </span>they exist. Default is
        to not overwrite them.
    --complevel<span class="o">=(</span>0-9<span class="o">)</span> -- Set a compression level <span class="o">(</span>0 <span class="k">for </span>no compression, which
        is the default<span class="o">)</span>.
    --complib<span class="o">=</span>lib -- Set the compression library to be used during the copy.
        lib can be <span class="nb">set </span>to <span class="s2">&quot;zlib&quot;</span>, <span class="s2">&quot;lzo&quot;</span>, <span class="s2">&quot;bzip2&quot;</span> or <span class="s2">&quot;blosc&quot;</span>.  Defaults to
        <span class="s2">&quot;zlib&quot;</span>.
    --shuffle<span class="o">=(</span>0|1<span class="o">)</span> -- Activate or not the shuffling filter <span class="o">(</span>default is active
        <span class="k">if </span>complevel&gt;0<span class="o">)</span>.
    --fletcher32<span class="o">=(</span>0|1<span class="o">)</span> -- Whether to activate or not the fletcher32 filter
        <span class="o">(</span>not active by default<span class="o">)</span>.
    --keep-source-filters -- Use the original filters in <span class="nb">source </span>files. The
        default is not doing that <span class="k">if </span>any of --complevel, --complib, --shuffle
        or --fletcher32 option is specified.
    --chunkshape<span class="o">=(</span><span class="s2">&quot;keep&quot;</span><span class="se">\|</span><span class="s2">&quot;auto&quot;</span><span class="se">\|</span>int|tuple<span class="o">)</span> -- Set a chunkshape.  A value
        of <span class="s2">&quot;auto&quot;</span> computes a sensible value <span class="k">for </span>the chunkshape of the
        leaves copied.  The default is to <span class="s2">&quot;keep&quot;</span> the original value.
    --upgrade-flavors -- When repacking PyTables 1.x files, the flavor of
        leaves will be unset. With this, such a leaves will be serialized
        as objects with the internal flavor <span class="o">(</span><span class="s1">&#39;numpy&#39;</span> <span class="k">for </span>2.x series<span class="o">)</span>.
    --dont-regenerate-old-indexes -- Disable regenerating old indexes. The
        default is to regenerate old indexes as they are found.
    --sortby<span class="o">=</span>column -- Do a table copy sorted by the index in <span class="s2">&quot;column&quot;</span>.
        For reversing the order, use a negative value in the <span class="s2">&quot;step&quot;</span> part of
        <span class="s2">&quot;RANGE&quot;</span> <span class="o">(</span>see <span class="s2">&quot;-R&quot;</span> flag<span class="o">)</span>.  Only applies to table objects.
    --checkCSI -- Force the check <span class="k">for </span>a CSI index <span class="k">for </span>the --sortby column.
    --propindexes -- Propagate the indexes existing in original tables.  The
        default is to not propagate them.  Only applies to table objects.
</pre></div>
</div>
<p>Read on for a brief introduction to this utility.</p>
</div>
<div class="section" id="a-small-tutorial-on-ptrepack">
<h3>A small tutorial on ptrepack<a class="headerlink" href="#a-small-tutorial-on-ptrepack" title="Permalink to this headline">¶</a></h3>
<p>Imagine that we have ended the tutorial 1 (see the output of
examples/tutorial1-1.py), and we want to copy our reduced data (i.e. those
datasets that hangs from the /column group) to another file. First, let&#8217;s
remember the content of the examples/tutorial1.h5:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump tutorial1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;Test file&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;Pressure and Name&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
/detector <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;Detector information&#39;</span>
/detector/readout <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
</pre></div>
</div>
<p>Now, copy the /columns to other non-existing file. That&#8217;s easy:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/columns reduced.h5
</pre></div>
</div>
<p>That&#8217;s all. Let&#8217;s see the contents of the newly created reduced.h5 file:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
</pre></div>
</div>
<p>so, you have copied the children of /columns group into the <em>root</em> of the
reduced.h5 file.</p>
<p>Now, you suddenly realized that what you intended to do was to copy all the
hierarchy, the group /columns itself included. You can do that by just
specifying the destination group:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/columns reduced.h5:/columns
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
</pre></div>
</div>
<p>OK. Much better. But you want to get rid of the existing nodes on the new
file. You can achieve this by adding the -o flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -o tutorial1.h5:/columns reduced.h5:/columns
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
</pre></div>
</div>
<p>where you can see how the old contents of the reduced.h5 file has been
overwritten.</p>
<p>You can copy just one single node in the repacking operation and change its
name in destination:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/detector/readout reduced.h5:/rawdata
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
</pre></div>
</div>
<p>where the /detector/readout has been copied to /rawdata in destination.</p>
<p>We can change the filter properties as well:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack --complevel<span class="o">=</span>1 tutorial1.h5:/detector/readout reduced.h5:/rawdata
Problems doing the copy from <span class="s1">&#39;tutorial1.h5:/detector/readout&#39;</span> to <span class="s1">&#39;reduced.h5:/rawdata&#39;</span>
The error was --&gt; tables.exceptions.NodeError: destination group <span class="se">\`</span><span class="sb">`</span>/<span class="se">\`</span><span class="sb">`</span> already has a node named <span class="se">\`</span><span class="sb">`</span>rawdata<span class="sb">``</span>; you may want to use the <span class="se">\`</span><span class="sb">`</span>overwrite<span class="sb">``</span> argument
The destination file looks like:
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
  File <span class="s2">&quot;utils/ptrepack&quot;</span>, line 3, in ?
    main<span class="o">()</span>
  File <span class="s2">&quot;.../tables/scripts/ptrepack.py&quot;</span>, line 349, in main
    <span class="nv">stats</span> <span class="o">=</span> stats, <span class="nv">start</span> <span class="o">=</span> start, <span class="nv">stop</span> <span class="o">=</span> stop, <span class="nv">step</span> <span class="o">=</span> step<span class="o">)</span>
  File <span class="s2">&quot;.../tables/scripts/ptrepack.py&quot;</span>, line 107, in copy_leaf
    raise RuntimeError, <span class="s2">&quot;Please check that the node names are not</span>
<span class="s2">    duplicated in destination, and if so, add the --overwrite-nodes flag</span>
<span class="s2">    if desired.&quot;</span>
RuntimeError: Please check that the node names are not duplicated in
destination, and <span class="k">if </span>so, add the --overwrite-nodes flag <span class="k">if </span>desired.
</pre></div>
</div>
<p>Ooops! We ran into problems: we forgot that the /rawdata pathname already
existed in destination file. Let&#8217;s add the &#8211;overwrite-nodes, as the verbose
error suggested:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack --overwrite-nodes --complevel<span class="o">=</span>1 tutorial1.h5:/detector/readout
reduced.h5:/rawdata
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
</pre></div>
</div>
<p>you can check how the filter properties has been changed for the /rawdata
table. Check as the other nodes still exists.</p>
<p>Finally, let&#8217;s copy a <em>slice</em> of the readout table in origin to destination,
under a new group called /slices and with the name, for example, aslice:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -R1,8,3 tutorial1.h5:/detector/readout reduced.h5:/slices/aslice
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Name column selection&#39;</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Pressure column selection&#39;</span>
/slices <span class="o">(</span>Group<span class="o">)</span> <span class="s1">&#39;&#39;</span>
/slices/aslice <span class="o">(</span>Table<span class="o">(</span>3,<span class="o">))</span> <span class="s1">&#39;Readout example&#39;</span>
</pre></div>
</div>
<p>note how only 3 rows of the original readout table has been copied to the new
aslice destination. Note as well how the previously nonexistent slices group
has been created in the same operation.</p>
</div>
</div>
<div class="section" id="pt2to3">
<h2>pt2to3<a class="headerlink" href="#pt2to3" title="Permalink to this headline">¶</a></h2>
<p>The PyTables 3.x series now follows <a class="reference external" href="http://www.python.org/dev/peps/pep-0008/">PEP 8</a> coding standard.  This makes
using PyTables more idiomatic with surrounding Python code that also adheres
to this standard.  The primary way that the 2.x series was <em>not</em> PEP 8
compliant was with respect to variable naming conventions.  Approximately 450
API variables were identified and updated for PyTables 3.x.</p>
<p>To ease migration, PyTables ships with a new <tt class="docutils literal"><span class="pre">pt2to3</span></tt> command line tool.
This tool will run over a file and replace any instances of the old variable
names with the 3.x version of the name.  This tool covers the overwhelming
majority of cases was used to transition the PyTables code base itself!  However,
it may also accidentally also pick up variable names in 3rd party codes that
have <em>exactly</em> the same name as a PyTables&#8217; variable.  This is because <tt class="docutils literal"><span class="pre">pt2to3</span></tt>
was implemented using regular expressions rather than a fancier AST-based
method. By using regexes, <tt class="docutils literal"><span class="pre">pt2to3</span></tt> works on Python and Cython code.</p>
<p><tt class="docutils literal"><span class="pre">pt2to3</span></tt> <strong>help:</strong></p>
<div class="highlight-bash"><div class="highlight"><pre>usage: pt2to3 <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>-r<span class="o">]</span> <span class="o">[</span>-p<span class="o">]</span> <span class="o">[</span>-o OUTPUT<span class="o">]</span> <span class="o">[</span>-i<span class="o">]</span> filename

PyTables 2.x -&gt; 3.x API transition tool This tool displays to standard out, so
it is common to pipe this to another file: <span class="nv">$ </span>pt2to3 oldfile.py &gt; newfile.py

positional arguments:
  filename              path to input file.

optional arguments:
  -h, --help            show this <span class="nb">help </span>message and <span class="nb">exit</span>
  -r, --reverse         reverts changes, going from 3.x -&gt; 2.x.
  -p, --no-ignore-previous
                        ignores previous_api<span class="o">()</span> calls.
  -o OUTPUT             output file to write to.
  -i, --inplace         overwrites the file in-place.
</pre></div>
</div>
<p>Note that <tt class="docutils literal"><span class="pre">pt2to3</span></tt> only works on a single file, not a a directory.  However,
a simple BASH script may be written to run <tt class="docutils literal"><span class="pre">pt2to3</span></tt> over an entire directory
and all sub-directories:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c">#!/bin/bash</span>
<span class="k">for </span>f in <span class="k">$(</span>find .<span class="k">)</span>
<span class="k">do</span>
<span class="k">    </span><span class="nb">echo</span> <span class="nv">$f</span>
    pt2to3 <span class="nv">$f</span> &gt; temp.txt
    mv temp.txt <span class="nv">$f</span>
<span class="k">done</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><strong class="program">pt2to3</strong> uses the <tt class="xref py py-mod docutils literal"><span class="pre">argparse</span></tt> module that is part of the
Python standard library since Python 2.7.
Users of Python 2.6 should install <tt class="xref py py-mod docutils literal"><span class="pre">argparse</span></tt> separately
(e.g. via <strong class="program">pip</strong>).</p>
</div>
<p>The old APIs and variable names will continue to be supported for the short term,
where possible.  (The major backwards incompatible changes come from the renaming
of some function and method arguments and keyword arguments.)  Using the 2.x APIs
in the 3.x series, however, will issue warnings.  The following is the release
plan for the warning types:</p>
<ul class="simple">
<li>3.0 - PendingDeprecationWarning</li>
<li>3.1 - DeprecationWarning</li>
<li>&gt;=3.2 - Remove warnings, previous_api(), and _past.py; keep pt2to3,</li>
</ul>
<p>The current plan is to maintain the old APIs for at least 2 years, though this
is subject to change.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
        <p class="logo"><a href="../index.html">
          <img class="logo" src="../_static/logo-pytables-small.png" alt="Logo"/>
        </a></p>
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Utilities</a><ul>
<li><a class="reference internal" href="#ptdump">ptdump</a><ul>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#a-small-tutorial-on-ptdump">A small tutorial on ptdump</a></li>
</ul>
</li>
<li><a class="reference internal" href="#ptrepack">ptrepack</a><ul>
<li><a class="reference internal" href="#id1">Usage</a></li>
<li><a class="reference internal" href="#a-small-tutorial-on-ptrepack">A small tutorial on ptrepack</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pt2to3">pt2to3</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="parameter_files.html"
                        title="previous chapter">PyTables parameter files</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="file_format.html"
                        title="next chapter">PyTables File Format</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/usersguide/utilities.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="relbar-bottom">
        
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="../np-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="file_format.html" title="PyTables File Format"
             >next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="parameter_files.html" title="PyTables parameter files"
             >previous</a> &nbsp; &nbsp;</li>
    <li><a href="../index.html">PyTables 3.0.0 documentation</a> &raquo;</li>

          <li><a href="index.html" >PyTables User&#8217;s Guide</a> &raquo;</li> 
      </ul>
    </div>
    </div>

    <div class="footer">
        &copy; Copyright 2011-2013, PyTables maintainers.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
    <!-- cloud_sptheme 1.3 -->
  </body>
</html>