# - writeNodesFromPaths (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Converter.Filter as Filter t = C.newPyTree(['Base']) C.convertPyTree2File(t, 'out.hdf') # Append a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) Filter.writeNodesFromPaths('out.hdf', 'CGNSTree/Base', a) # Append and replace a = G.cart((1, 1, 1), (1, 1, 1), (10, 10, 10)) a[0] = 'cart' Filter.writeNodesFromPaths('out.hdf', 'CGNSTree/Base', a)
# - loadSkeleton - import Converter.Filter as Filter import Converter.PyTree as C import Generator.PyTree as G # Create test case a = G.cart((0,0,0), (1,1,1), (10,10,10)) C.convertPyTree2File(a, 'file.hdf') # Create a handle on a CGNS file h = Filter.Handle('file.hdf') # Load skeleton a = h.loadSkeleton()
# - readPyTreeFromPaths (pyTree) - import Converter.PyTree as C import Converter.Filter as Filter import Converter.Internal as Internal import Generator.PyTree as G # Cree le fichier test a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base', a, b]) C.convertPyTree2File(t, 'test.hdf') t = Filter.convertFile2SkeletonTree('test.hdf', maxDepth=3) # Complete t par leur paths Filter._readPyTreeFromPaths( t, 'test.hdf', ['/Base/cart/GridCoordinates', 'Base/cart.0/GridCoordinates']) Internal.printTree(t) C.convertPyTree2File(t, 'out.hdf')
# - readNodesFromPaths (pyTree) - import Converter.PyTree as C import Converter.Filter as Filter import Converter.Internal as Internal import Generator.PyTree as G # Cree le fichier test a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base', a, b]) C.convertPyTree2File(t, 'test.hdf') # Relit les noeuds par leur paths nodes = Filter.readNodesFromPaths('test.hdf', ['CGNSTree/Base/cart/GridCoordinates']) Internal.printTree(nodes)
# - deletePaths (pyTree) - import Converter.PyTree as C import Converter.Filter as Filter t = C.newPyTree(['Base']) C.convertPyTree2File(t, 'out.hdf') # Delete paths Filter.deletePaths('out.hdf', 'CGNSTree/Base')
# - HDF read/write with links - import Generator.PyTree as G import Converter.PyTree as C import Converter.Internal as Internal import Converter.Filter as Filter a = G.cart((0,0,0),(1,1,1),(50,50,50)) C._initVars(a, 'Density=1.') t = C.newPyTree(['Base',a]) # Save file with links links=[['.','coord.hdf','/Base/cart/GridCoordinates','/Base/cart/GridCoordinates']] C.convertPyTree2File(t, 'main.hdf', links=links) # full read of main returning links LC=[] t = C.convertFile2PyTree('main.hdf', links=LC); print(LC) # Read links with skeleton LC=[] t = Filter.convertFile2SkeletonTree('main.hdf', links=LC); print(LC)
import KCore.test as test # Cree le fichier test a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cartHexa((12, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base', a, b]) C.convertPyTree2File(t, 'test.hdf') # Relit les noeuds par un filtre path = [ '/Base/cart/GridCoordinates/CoordinateX', '/Base/cartHexa/GridCoordinates/CoordinateX' ] f = {} # start/stride/count (nbre d'entrees)/block DataSpaceMMRY0 = [[0, 0, 0], [1, 1, 1], [2, 2, 2], [1, 1, 1]] DataSpaceFILE0 = [[1, 1, 1], [1, 1, 1], [2, 2, 2], [1, 1, 1]] DataSpaceGLOB0 = [[0]] f[path[0]] = DataSpaceMMRY0 + DataSpaceFILE0 + DataSpaceGLOB0 DataSpaceMMRY1 = [[0], [1], [2], [1]] DataSpaceFILE1 = [[0], [1], [2], [1]] DataSpaceGLOB1 = [[0]] f[path[1]] = DataSpaceMMRY1 + DataSpaceFILE1 + DataSpaceGLOB1 # Lit seulement les chemins fournis, retourne un dictionnaire des chemins lus a = Filter.readNodesFromFilter('test.hdf', f) test.testO(a) #print a[path[0]].ravel('k') #print a[path[1]].ravel('k')
# - readNodesFromPaths (pyTree) - import Converter.PyTree as C import Converter.Filter as Filter import Generator.PyTree as G import KCore.test as test # Cree le fichier test a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base', a, b]) C.convertPyTree2File(t, 'test.adf') # Relit les noeuds par leur paths nodes = Filter.readNodesFromPaths('test.adf', '/Base/cart/GridCoordinates') test.testT(nodes, 1)
# - writeNodesFromPaths (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Converter.Filter as Filter import KCore.test as test LOCAL = test.getLocal() t = C.newPyTree(['Base']) C.convertPyTree2File(t, LOCAL+'/out.adf') # Append a = G.cart((0,0,0), (1,1,1), (10,10,10)) Filter.writeNodesFromPaths(LOCAL+'/out.adf', 'CGNSTree/Base', a) # Append and Replace a = G.cart((1,1,1), (1,1,1), (10,10,10)); a[0] = 'cart' Filter.writeNodesFromPaths(LOCAL+'/out.adf', 'CGNSTree/Base', a) # Replace a = G.cart((1,1,1), (0.1,1,1), (10,10,10)); a[0] = 'cart' Filter.writeNodesFromPaths(LOCAL+'/out.adf', 'CGNSTree/Base/cart', a, mode=1) #test.testF('out.adf', 1) t = C.newPyTree(['Base']) C.convertPyTree2File(t, LOCAL+'/out.hdf') # Append a = G.cart((0,0,0), (1,1,1), (10,10,10))