[SciPy-user] problem with using scipy.io.mio on Windows

Travis Oliphant oliphant at ee.byu.edu
Wed Jan 16 11:00:05 CST 2002


On Wed, 16 Jan 2002, Herb Schilling wrote:

> Hello,
>
>   I am using scipy.io.mio to read in binary PLOT3D files. Everything
> works fine when I run my code on an SGI but when I run it under
> Windows 98 I have problems.  ( I am using  Windows native, not-cygwin
> Python 2.1 ).
>
>
>
> Here is the basic code I am using
>
> import scipy.io.mio


Note, fopen is defined right under scipy.io (you shouldn't have to import
mio).

so after an

import scipy.io

scipy.io.fopen  should work

>
> # open the file
> fileHandle = scipy.io.mio.fopen( filePath, 'r' , format = 'b' )
>
> # read in the total number of blocks in this file
> numberOfBlocks = fileHandle.fread( 1 , 'l' )
>
> # Read in the size of each block
> imaxes = []
> jmaxes = []
> for iBlock in range( numberOfBlocks ) :
>    imax = fileHandle.fread( 1 , 'l' )
>    jmax = fileHandle.fread( 1 , 'l' )
>    imaxes.append( imax )
>    jmaxes.append( jmax )
>
> # Read in the X,Y coordinates of the points in the grids
> for iBlock in range( numberOfBlocks ) :
>    imax = imaxes[ iBlock ]
>    jmax = jmaxes[ iBlock ]
>
> # Note that we do want the transposed form
>    xGrid = fileHandle.fread(  ( jmax, imax ) , 'f' , 'f' )
>    yGrid = fileHandle.fread(  ( jmax, imax ) , 'f' , 'f' )
>
>
> numpyio: Warning: 30060 bytes requested, 12 bytes read.
> numpyio: Warning: 30060 bytes requested, 0 bytes read.
> numpyio: Warning: 11084 bytes requested, 0 bytes read.
> numpyio: Warning: 11084 bytes requested, 0 bytes read.
> numpyio: Warning: 36816 bytes requested, 0 bytes read.
> numpyio: Warning: 36816 bytes requested, 0 bytes read.
> numpyio: Warning: 34160 bytes requested, 0 bytes read.
> numpyio: Warning: 34160 bytes requested, 0 bytes read.
> numpyio: Warning: 34160 bytes requested, 0 bytes read.
> numpyio: Warning: 34160 bytes requested, 0 bytes read.
>

For some reason the C-code is not reading as many bytes as was requested.
This warning just alerts you to that fact.

One problem I've seen is byte order issues.  What is the byte-order on an
SGI?   It looks like you are opening the file with "big-endian" so that
shouldn't be it.  Can you send me an example file that I could try to read
on Linux?

One test you could do is to run fileHandle.tell() to see where the
file-pointer is after each read.  This should tell you how you are
progressing through the file.

Sorry I can't help further.

-Travis





More information about the SciPy-user mailing list