On Thursday 10 August 2006 16:57, Travis Oliphant wrote: > Sebastian Haase wrote: > > Hi, > > trying to convert my memmap - records - numarray code for reading a > > image file format (Mrc). > > There are 10 fields of strings (each 80 chars long) in the header: > > in numarray I used the format string '10a80' > > This results in a single <None> value in numpy. > > Same after changing it to '10S80'. > > > > Am I doing something wrong !? > > Not that I can see. But, it's possible that there is a > misunderstanding of what '10a80' represents. > > What is giving you the <None> value? > > For example, I can create a file with 10, 80-character strings and open it > using memmap and a data-type of > > dt = numpy.dtype('10a80') > > and it seems to work fine. > > -Travis
This is what I get: It claims that the 'title' field (the last one) is 10 times 'S80' but trying to read that array from the first (and only) record (a.Mrc._hdrArray.title[0]) I just get None... >>> a=Mrc.bindFile('Heather2/GFPtublive-Vecta43') TODO: byteorder >>> repr(a.Mrc._hdrArray.dtype) 'dtype([('Num', '<i4', 3), ('PixelType', '<i4'), ('mst', '<i4', 3), ('m', '<i4', 3), ('d', '<f4', 3), ('angle', '<f4', 3), ('axis', '<i4', 3), ('mmm1', '<f4', 3), ('type', '<i2'), ('nspg', '<i2'), ('next', '<i4'), ('dvid', '<i2'), ('blank', '|i1', 30), ('NumIntegers', '<i2'), ('NumFloats', '<i2'), ('sub', '<i2'), ('zfac', '<i2'), ('mm2', '<f4', 2), ('mm3', '<f4', 2), ('mm4', '<f4', 2), ('ImageType', '<i2'), ('LensNum', '<i2'), ('n1', '<i2'), ('n2', '<i2'), ('v1', '<i2'), ('v2', '<i2'), ('mm5', '<f4', 2), ('NumTimes', '<i2'), ('ImgSequence', '<i2'), ('tilt', '<f4', 3), ('NumWaves', '<i2'), ('wave', '<i2', 5), ('zxy0', '<f4', 3), ('NumTitles', '<i4'), ('title', '| S80', 10)])' >>> a.Mrc._hdrArray.NumTitles [3] >>> a.Mrc._hdrArray.NumTitles[0] 3 >>> type(a.Mrc._hdrArray.title[0]) <type 'NoneType'> >>> type(a.Mrc._hdrArray.title[1]) Traceback (most recent call last): File "<input>", line 1, in ? File "/home/haase/qqq/lib/python/numpy/core/defchararray.py", line 45, in __getitem__ val = ndarray.__getitem__(self, obj) IndexError: index out of bounds I get the same on byteswapped data and non-byteswapped data. -Sebastian ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion