chr_w at chr_w at
Mon Oct 15 09:56:21 CEST 2001

Sorry for bugging you guys again.

Some days ago I posted a thread about reading binary data into Python. I
recieved some great hints which guided me to the SciPy module. This one seems to
do the job for me just right...
As I stated the days before, I'm not really familiar with python-coding and
therefore I might just miss something very basic here. But I can't get this
thing to work. Herb Schilling sent me some code but when I tried to copy some
statements into my file, python bails out with an error (complaining about
somthing like '... numpyio ... error'). I thought this mio has been merged
completely into the scipy mudule, no? ???

The data I try to read comes from a SGI Irix platform. The file contains
double-precision floating point values and was written by a fortran
climate-model into these binary files. The file size can vary between 1 and 120 MBytes...

Maybe it's just easier to get the data into a proper ASCII file with fortran
on the SGI and do further computing with python on my machine. Would be a
bit more difficult to organize but oh well ;-)...

My apologies for the bad code below... I copied my last attemp... Maybe
(most certainly) there is something really wrong in here. Some 'good' example
lines should help me out...

The code which I used for testing this data-access comes here:
# modul import
# standard python modules:
import string

# 3rd party modules
import Numeric

# parameter specification...
# change to interactive mode later (?)
file_gsw = 'g:/biogeo/werner/climate/gsw_aug98.dat'

def readdata ( filePath ):
    fileHandle = filePath, 'r')
    imaxes = []
    jmaxes = []
    for iBlock in range( 1000 ):
        imax = fileHandle.fread(1,'l')
        jmax = fileHandle.fread(1,'l')
    numberOfBlocks = fileHandle.fort_read(1, 'l')
    print numberOfBlocks

readdata (file_gsw)

One of the error I get is this:

Traceback (most recent call last):
  File "G:\biogeo\werner\climate\", line 33, in ?
    readdata (file_gsw)
  File "G:\biogeo\werner\climate\", line 23, in readdata
    imax = fileHandle.fread(1,'l')
  File "C:\Programm\Python21\scipy\io\", line 149, in fread
    if type(count) in [types.Tupletype, types.ListType]:
AttributeError: 'types' module has no attribute 'Tupletype'

PS: I think this SciPy-Thing is just doing the work the way I want it
(fortran data import option) - but I just don't get it. If you know about a code
sample to see this module working I'd really appreciate it :-)! Manuals on this
are really rare, too...

GMX - Die Kommunikationsplattform im Internet.

More information about the Python-list mailing list