Example #1
0
def insert_file(h5fh,where,name,title,filename):
    fnode=FileNode.newNode(h5fh,where=where,name=name,title=title)
    fnode.write(open(filename,'r').read())

    import time
    fnode.attrs.creationdate=time.asctime()
    fnode.attrs.path=os.path.abspath(filename)
    import socket
    fnode.attrs.host=socket.getfqdn()
    
    fnode.close()        
Example #2
0
# Copy this file into the clipboard and paste into 'script -c python'.

from __future__ import print_function
from tables.nodes import FileNode


import tables
h5file = tables.open_file('fnode.h5', 'w')


fnode = FileNode.new_node(h5file, where='/', name='fnode_test')


print(h5file.getAttrNode('/fnode_test', 'NODE_TYPE'))


print("This is a test text line.", file=fnode)
print("And this is another one.", file=fnode)
print(file=fnode)
fnode.write("Of course, file methods can also be used.")

fnode.seek(0)  # Go back to the beginning of file.

for line in fnode:
    print(repr(line))


fnode.close()
print(fnode.closed)

Example #3
0
# Copy this file into the clipboad and paste into 'script -c python'.

from tables.nodes import FileNode


import tables

h5file = tables.openFile("fnode.h5", "w")


fnode = FileNode.newNode(h5file, where="/", name="fnode_test")


print h5file.getAttrNode("/fnode_test", "NODE_TYPE")


print >> fnode, "This is a test text line."
print >> fnode, "And this is another one."
print >> fnode
fnode.write("Of course, file methods can also be used.")

fnode.seek(0)  # Go back to the beginning of file.

for line in fnode:
    print repr(line)


fnode.close()
print fnode.closed

Example #4
0
# Copy this file into the clipboard and paste into 'script -c python'.

from tables.nodes import FileNode

import tables
h5file = tables.openFile('fnode.h5', 'w')

fnode = FileNode.newNode(h5file, where='/', name='fnode_test')

print h5file.getAttrNode('/fnode_test', 'NODE_TYPE')

print >> fnode, "This is a test text line."
print >> fnode, "And this is another one."
print >> fnode
fnode.write("Of course, file methods can also be used.")

fnode.seek(0)  # Go back to the beginning of file.

for line in fnode:
    print repr(line)

fnode.close()
print fnode.closed

node = h5file.root.fnode_test
fnode = FileNode.openNode(node, 'a+')
print repr(fnode.readline())
print fnode.tell()
print >> fnode, "This is a new line."
print repr(fnode.readline())
Example #5
0
def get_sorted_data():
    myfields = nmag2._get_nfem_fields()
    mdata = numpy.array(myfields.m.m_Py.data)
    msites = numpy.array(myfields.m.m_Py.site)
    #get order right, double check for 2nd order
    sort_ind = msites.argsort(axis=0)
    mdatasorted = numpy.take(mdata,sort_ind)
    



os.remove('test.h5')

savefield('test.h5','test.h5')


f=tables.openFile('test.h5')
node = f.root.sim.source
fnode = FileNode.openNode(node)
for line in fnode.readlines():
    print repr(line)
fnode.close()

f=open('test.h5','r')
#print str(f)
f.close()

os.system('h5ls -r test.h5')
#os.system('ptdump -av test.h5')
#os.system('ptdump -d test.h5:/sim/source')