[MOAB-dev] Questions about Tags and Topology

James Porter jvporter at wisc.edu
Mon Feb 13 14:46:06 CST 2012


On Fri, 2012-02-10 at 17:28 -0500, Christopher Mueller wrote:
> Hi Tim,
> 
> 
> I've had a good deal of success this week and have been able to
> represent a couple of our simpler datasets in what seems to be a
> reasonable manner.  I have also come up with a few questions. 
> 
> 
> Tags:
>       * DataTypes – from what I can see, tags do not support a few of
>         the numpy datatypes, namely: float32, int16, and int64.  Is
>         this a constraint of the PyTAPS wrapper or the underlying
>         iMesh/MOAB infrastructure?

iMesh only supports a handful of types, but as mentioned, the bytes type
lets you convert to/from the type you actually want. Here are some
sample functions to do this:

def set_packed(tag, key, value):
    tag[key] = numpy.frombuffer(numpy.asarray(value), dtype=numpy.byte)

def get_packed(tag, key, dtype):
    return numpy.frombuffer(tag[key], dtype=dtype)

# In use:
set_packed(my_tag, my_entity, numpy.int16(300))
get_packed(my_tag, my_entity, numpy.int16)

- Jim



More information about the moab-dev mailing list