0

I am having a hard time understanding how to access the data in a carray. http://carray.pytables.org/docs/manual/index.html

I have a carray that I can view in a group structure using vitables - but how to open it and retrieve the data it beyond me.

The data are a point cloud that is 3 levels down that I want to make a scatter plot of and extract as a .obj file.. I then have to loop through (many) clouds and do the same thing..

Is there anyone that can give me a simple example of how to do this?

This was my attempt:

import carray as ca 

fileName = 'hdf5_example_db.h5'
a = ca.open(rootdir=fileName)
print a
ashley
  • 1,535
  • 1
  • 14
  • 19

1 Answers1

0

I managed to solve my issue.. I wasn't treating the carray differently to the rest of the hierarchy. I needed to first load the entire db, then refer to the data I needed. I ended up not having to use carray, and just stuck to h5py:


    from __future__ import print_function
    import h5py 
    import numpy as np

    # read the hdf5 format file
    fileName = 'hdf5_example_db.h5'
    f = h5py.File(fileName, 'r')

    # full path of carry type data (which is in ply format)
    dataspace = '/objects/object_000/object_model'

    # view the data
    print(f[dataspace])

    # print to ply file  
    with open('object_000.ply', 'w') as fo:
        for line in f[dataspace]: 
            fo.write(line+'\n')

ashley
  • 1,535
  • 1
  • 14
  • 19