From: Dominik Szczerba <domi@vi...>  20070621 12:26:43

Hi, Is there an easy way to merge hdf5 datasets in pytables? I cannot google it out anywhere. I have unstructured submeshes coming from domain decomposition and I want to stich them back together. They share some nodes on the subdomain boundaries so I want to stitch them in a clever way (like AppendDatasets and CleanToGrid in Paraview). Any options available? thanks for any hints, Dominik  Dominik Szczerba, Ph.D. Computer Vision Lab CH8092 Zurich http://www.vision.ee.ethz.ch/~domi 
From: Francesc Altet <faltet@ca...>  20070621 15:40:04

Hi Dominik, El dj 21 de 06 del 2007 a les 14:26 +0200, en/na Dominik Szczerba va escriure: > Hi, > Is there an easy way to merge hdf5 datasets in pytables? What kind of datasets? The most easy way for merging Table objects is Table.whereAppend() method. See: http://www.pytables.org/docs/manual/ch04.html#Table_methods for more info. For Array objects, you can always iterate over one array and append it row to row to the other. Look at this example: In [1]:import numpy In [2]:import tables In [3]:f=tables.openFile('/tmp/test.h5', 'w') In [4]:e1=f.createEArray(f.root, 'array1', tables.Float64Atom(), shape=(0,300)) In [5]:e2=f.createEArray(f.root, 'array2', tables.Float64Atom(), shape=(0,300)) In [6]:e1.append(numpy.empty(shape=(200,300)))In [7]:e2.append(numpy.empty(shape=(200,300))) In [8]:for row in e1: ...: e2.append(row[numpy.newaxis,:]) # append e1 rows to e2 ...: In [9]:e2 Out[9]: /array2 (EArray(400L, 300)) '' atom := Float64Atom(shape=(), dflt=0.0) maindim := 0 flavor := 'numpy' byteorder := 'little' Of course, you can always add complexity to the "for row in e1:" loop in order to conveniently filter the desired subset of rows. > I cannot google it out anywhere. > I have unstructured submeshes coming from domain decomposition and I > want to stich them back together. They share some nodes on the > subdomain boundaries so I want to stitch them in a clever way (like > AppendDatasets and CleanToGrid in Paraview). Any options available? I have no experience with Paraview. If the solution above doesn't work for you, ask again please.  Francesc Altet  Be careful about using the following code  Carabos Coop. V.  I've only proven that it works, http://www.carabos.com  I haven't tested it.  Donald Knuth 
From: Dominik Szczerba <domi@vi...>  20070621 16:49:37

Hi Francesc, Thanks a lot for your answer. I meant unstructured meshes. I can nowhere find any examples on this case with HDF5 in general and PyTables in particular (only some obscure info on some HDF5 Mesh API that is 4 years old since last modification). My case is: one big unstructured mesh is split into submeshes, some calculations are performed on each submesh resulting in some solutions (scalars or vectors) per node and/or per element. Such meshes have to be merged back at the end in a smart way such that the duplicate nodes (that will be there on subdomains boundaries) are corrected for. Therefore, I would split my question into 2 subquestions:  where can I get started with HDF5/PyTables and unstructured meshes, handling scalars and vectors per node and element,  can I merge/append such meshes while avoiding duplicate nodes and ensuring consistent numbering of elements. Thanks a lot for any hints,  Dominik Francesc Altet wrote: > Hi Dominik, > > El dj 21 de 06 del 2007 a les 14:26 +0200, en/na Dominik Szczerba va > escriure: >> Hi, >> Is there an easy way to merge hdf5 datasets in pytables? > > What kind of datasets? The most easy way for merging Table objects is > Table.whereAppend() method. See: > > http://www.pytables.org/docs/manual/ch04.html#Table_methods > > for more info. > > For Array objects, you can always iterate over one array and append it > row to row to the other. Look at this example: > > In [1]:import numpy > In [2]:import tables > In [3]:f=tables.openFile('/tmp/test.h5', 'w') > In [4]:e1=f.createEArray(f.root, 'array1', tables.Float64Atom(), > shape=(0,300)) > In [5]:e2=f.createEArray(f.root, 'array2', tables.Float64Atom(), > shape=(0,300)) > In [6]:e1.append(numpy.empty(shape=(200,300)))In > [7]:e2.append(numpy.empty(shape=(200,300))) > In [8]:for row in e1: > ...: e2.append(row[numpy.newaxis,:]) # append e1 rows to e2 > ...: > In [9]:e2 > Out[9]: > /array2 (EArray(400L, 300)) '' > atom := Float64Atom(shape=(), dflt=0.0) > maindim := 0 > flavor := 'numpy' > byteorder := 'little' > > Of course, you can always add complexity to the "for row in e1:" loop in > order to conveniently filter the desired subset of rows. > >> I cannot google it out anywhere. >> I have unstructured submeshes coming from domain decomposition and I >> want to stich them back together. They share some nodes on the >> subdomain boundaries so I want to stitch them in a clever way (like >> AppendDatasets and CleanToGrid in Paraview). Any options available? > > I have no experience with Paraview. If the solution above doesn't work > for you, ask again please. >  Dominik Szczerba, Ph.D. Computer Vision Lab CH8092 Zurich http://www.vision.ee.ethz.ch/~domi 
From: Francesc Altet <faltet@ca...>  20070622 08:50:06

A Dijous 21 Juny 2007 18:49, Dominik Szczerba escrigu=E9: > Hi Francesc, > Thanks a lot for your answer. > I meant unstructured meshes. > I can nowhere find any examples on this case with HDF5 in general and > PyTables in particular (only some obscure info on some HDF5 Mesh API > that is 4 years old since last modification). My case is: one big > unstructured mesh is split into submeshes, some calculations are > performed on each submesh resulting in some solutions (scalars or > vectors) per node and/or per element. Such meshes have to be merged back > at the end in a smart way such that the duplicate nodes (that will be > there on subdomains boundaries) are corrected for. Therefore, I would > split my question into 2 subquestions: > >  where can I get started with HDF5/PyTables and unstructured meshes, > handling scalars and vectors per node and element, > >  can I merge/append such meshes while avoiding duplicate nodes and > ensuring consistent numbering of elements. I'm sorry, but I'm afraid that there is not provision at all in PyTables fo= r=20 dealing with unstructured meshes as such. What PyTables does provide is a= =20 set of basic containers for data, as you can see in: http://www.pytables.org/moin/FAQ#head50aaafafdb19bf721d6765227e4edda0b324c= 226 So, users should add a layer on top of them for their own needs. =2D=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "" 