1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
TITLE="PyTables User's Guide"
11
HREF="index.html"><LINK
14
HREF="a6829.html"><LINK
17
HREF="a6829.html"><LINK
20
HREF="x6938.html"></HEAD
31
SUMMARY="Header navigation table"
43
> User's Guide: Hierarchical datasets in Python - Release 1.3.2</TH
59
>Appendix C. Utilities</TD
86
>This utility is a very powerful one and lets you copy any
87
leaf, group or complete subtree into another file. During
88
the copy process you are allowed to change the filter
89
properties if you want so. Also, in the case of duplicated
90
pathnames, you can decide if you want to overwrite already
91
existing nodes on the destination file. Generally
93
CLASS="computeroutput"
95
> can be useful in may
96
situations, like replicating a subtree in another file,
97
change the filters in objects and see how affect this to
98
the compression degree or I/O performance, consolidating
99
specific data in repositories or even <SPAN
107
CLASS="computeroutput"
109
> files and create true
111
CLASS="computeroutput"
120
NAME="subsectionC.2.1"
124
>For instructions on how to use it, just pass the
126
CLASS="computeroutput"
128
> flag to the command:
136
to see the message usage:
140
> usage: ptrepack [-h] [-v] [-o] [-R start,stop,step] [--non-recursive]
141
[--dest-title=title] [--dont-copyuser-attrs] [--overwrite-nodes]
142
[--complevel=(0-9)] [--complib=lib] [--shuffle=(0|1)]
143
[--fletcher32=(0|1)] [--keep-source-filters]
144
sourcefile:sourcegroup destfile:destgroup
145
-h -- Print usage message.
146
-v -- Show more information.
147
-o -- Overwite destination file.
148
-R RANGE -- Select a RANGE of rows (in the form "start,stop,step")
149
during the copy of *all* the leaves.
150
--non-recursive -- Do not do a recursive copy. Default is to do it.
151
--dest-title=title -- Title for the new file (if not specified,
152
the source is copied).
153
--dont-copy-userattrs -- Do not copy the user attrs (default is to do it)
154
--overwrite-nodes -- Overwrite destination nodes if they exist. Default is
155
to not overwrite them.
156
--complevel=(0-9) -- Set a compression level (0 for no compression, which
158
--complib=lib -- Set the compression library to be used during the copy.
159
lib can be set to "zlib", "lzo", "ucl" or "bzip2". Defaults to "zlib".
160
--shuffle=(0|1) -- Activate or not the shuffling filter (default is active
162
--fletcher32=(0|1) -- Whether to activate or not the fletcher32 filter (not
164
--keep-source-filters -- Use the original filters in source files. The
165
default is not doing that if any of --complevel, --complib, --shuffle
166
or --fletcher32 option is specified.
176
NAME="subsectionC.2.2"
177
>C.2.2. A small tutorial on <SPAN
183
>Imagine that we have ended the tutorial 1 (see the
185
CLASS="computeroutput"
186
>examples/tutorial1-1.py</SAMP
188
want to copy our reduced data (i.e. those datasets that
190
CLASS="computeroutput"
193
file. First, let's remember the content of the
195
CLASS="computeroutput"
196
>examples/tutorial1.h5</SAMP
201
> $ ptdump tutorial1.h5
202
Filename: 'tutorial1.h5' Title: 'Test file' , Last modif.: 'Fri Feb 6
203
19:33:28 2004' , rootUEP='/', filters=Filters(), Format version: 1.2
204
/ (Group) 'Test file'
205
/columns (Group) 'Pressure and Name'
206
/columns/name (Array(3,)) 'Name column selection'
207
/columns/pressure (Array(3,)) 'Pressure column selection'
208
/detector (Group) 'Detector information'
209
/detector/readout (Table(10L,)) 'Readout example'
214
CLASS="computeroutput"
217
non-existing file. That's easy:
221
> $ ptrepack tutorial1.h5:/columns reduced.h5
224
That's all. Let's see the contents of the newly created
226
CLASS="computeroutput"
232
> $ ptdump reduced.h5
233
Filename: 'reduced.h5' Title: '' , Last modif.: 'Fri Feb 20 15:26:47 2004' ,
234
rootUEP='/', filters=Filters(), Format version: 1.2
236
/name (Array(3,)) 'Name column selection'
237
/pressure (Array(3,)) 'Pressure column selection'
240
so, you have copied the children of
242
CLASS="computeroutput"
244
> group into the <SPAN
252
CLASS="computeroutput"
257
>Now, you suddenly realized that what you intended to do
258
was to copy all the hierarchy, the group
260
CLASS="computeroutput"
262
> itself included. You can do that
263
by just specifying the destination group:
267
> $ ptrepack tutorial1.h5:/columns reduced.h5:/columns
269
Filename: 'reduced.h5' Title: '' , Last modif.: 'Fri Feb 20 15:39:15 2004' ,
270
rootUEP='/', filters=Filters(), Format version: 1.2
272
/name (Array(3,)) 'Name column selection'
273
/pressure (Array(3,)) 'Pressure column selection'
275
/columns/name (Array(3,)) 'Name column selection'
276
/columns/pressure (Array(3,)) 'Pressure column selection'
279
OK. Much better. But you want to get rid of the existing
280
nodes on the new file. You can achieve this by adding
285
> $ ptrepack -o tutorial1.h5:/columns reduced.h5:/columns
287
Filename: 'reduced.h5' Title: '' , Last modif.: 'Fri Feb 20 15:41:57 2004' ,
288
rootUEP='/', filters=Filters(), Format version: 1.2
291
/columns/name (Array(3,)) 'Name column selection'
292
/columns/pressure (Array(3,)) 'Pressure column selection'
295
where you can see how the old contents of the
297
CLASS="computeroutput"
299
> file has been overwritten.
302
>You can copy just one single node in the repacking
303
operation and change its name in destination:
307
> $ ptrepack tutorial1.h5:/detector/readout reduced.h5:/rawdata
309
Filename: 'reduced.h5' Title: '' , Last modif.: 'Fri Feb 20 15:52:22 2004',
310
rootUEP='/', filters=Filters(), Format version: 1.2
312
/rawdata (Table(10L,)) 'Readout example'
314
/columns/name (Array(3,)) 'Name column selection'
315
/columns/pressure (Array(3,)) 'Pressure column selection'
319
CLASS="computeroutput"
320
>/detector/readout</SAMP
323
CLASS="computeroutput"
328
>We can change the filter properties as well:
331
> $ ptrepack --complevel=1 tutorial1.h5:/detector/readout reduced.h5:/rawdata
332
Problems doing the copy from 'tutorial1.h5:/detector/readout' to
333
'reduced.h5:/rawdata'
334
The error was --> exceptions.ValueError: The destination
335
(/rawdata (Table(10L,)) 'Readout example') already exists.
336
Assert the overwrite parameter if you really want to overwrite it.
337
The destination file looks like:
338
Filename: 'reduced.h5' Title: ''; Last modif.: 'Fri Feb 20 15:52:22 2004';
339
rootUEP='/'; filters=Filters(), Format version: 1.2
341
/rawdata (Table(10L,)) 'Readout example'
343
/columns/name (Array(3,)) 'Name column selection'
344
/columns/pressure (Array(3,)) 'Pressure column selection'
346
Traceback (most recent call last):
347
File "../utils/ptrepack", line 358, in ?
348
start=start, stop=stop, step=step)
349
File "../utils/ptrepack", line 111, in copyLeaf
350
raise RuntimeError, "Please, check that the node names are not
351
duplicated in destination, and if so, add the --overwrite-nodes flag
353
RuntimeError: Please, check that the node names are not duplicated in
354
destination, and if so, add the --overwrite-nodes flag if desired.
357
ooops!. We ran into problems: we forgot that
359
CLASS="computeroutput"
361
> pathname already existed
362
in destination file. Let's add the
364
CLASS="computeroutput"
365
>--overwrite-nodes</SAMP
370
> $ ptrepack --overwrite-nodes --complevel=1 tutorial1.h5:/detector/readout
373
Filename: 'reduced.h5' Title: ''; Last modif.: 'Fri Feb 20 16:02:20 2004';
374
rootUEP='/'; filters=Filters(), Format version: 1.2
376
/rawdata (Table(10L,), shuffle, zlib(1)) 'Readout example'
378
/columns/name (Array(3,)) 'Name column selection'
379
/columns/pressure (Array(3,)) 'Pressure column selection'
382
you can check how the filter properties has been changed
384
CLASS="computeroutput"
386
> table. Check as the other
390
>Finally, let's copy a <SPAN
398
CLASS="computeroutput"
400
> table in origin to destination,
401
under a new group called <SAMP
402
CLASS="computeroutput"
405
the name, for example, <SAMP
406
CLASS="computeroutput"
411
> $ ptrepack -R1,8,3 tutorial1.h5:/detector/readout reduced.h5:/slices/aslice
413
Filename: 'reduced.h5' Title: ''; Last modif.: 'Fri Feb 20 16:17:13 2004';
414
rootUEP='/'; filters=Filters(); Format version: 1.2
416
/rawdata (Table(10L,), shuffle, zlib(1)) 'Readout example'
418
/columns/name (Array(3,)) 'Name column selection'
419
/columns/pressure (Array(3,)) 'Pressure column selection'
421
/slices/aslice (Table(3L,)) 'Readout example'
424
note how only 3 rows of the original
426
CLASS="computeroutput"
428
> table has been copied to the new
430
CLASS="computeroutput"
432
> destination. Note as well how the
433
previously inexistent <SAMP
434
CLASS="computeroutput"
437
created in the same operation.
446
SUMMARY="Footer navigation table"
b'\\ No newline at end of file'