[SciPy-user] mat file problem in linux

Ryan Krauss ryanlists at gmail.com
Fri Oct 14 12:43:24 EDT 2005


I have a *.mat file created by Matlab in Windows.  Scipy in windows
can open this file without a problem.  I am now trying to run the same
code in linux and I get this error:

/home/ryan/datafit/bodetest.py
     12 #load matlab data
     13 #bob=scipy.io.read_array('iobodetest.txt')
---> 14 modeldict=scipy.io.loadmat('tmm_mat_model_params.mat')
     15 bodedict=scipy.io.loadmat('bodetest.mat')
     16 freq=bodedict['freq']

/usr/lib/python2.3/site-packages/scipy/io/mio.py in loadmat(name,
dict, appendmat, basename)
    690     if not (0 in test_vals):       # MATLAB version 5 format
    691         fid.rewind()
--> 692         thisdict = _loadv5(fid,basename)
    693         if dict is not None:
    694             dict.update(thisdict)

/usr/lib/python2.3/site-packages/scipy/io/mio.py in _loadv5(fid, basename)
    634             dict[varname] = el
    635         except EOFError:
--> 636             break
    637     return dict
    638

/usr/lib/python2.3/site-packages/scipy/io/mio.py in _get_element(fid)
    617
    618     # handle miMatrix type
--> 619     el, name = _parse_mimatrix(fid,numbytes)
    620     return el, name
    621

/usr/lib/python2.3/site-packages/scipy/io/mio.py in _parse_mimatrix(fid, bytes)
    499     dclass, cmplx, nzmax =_parse_array_flags(fid)
    500     dims = _get_element(fid)[0]
--> 501     name = ''.join(asarray(_get_element(fid)[0]).astype('c'))
    502     if dclass in mxArrays:
    503         result, unused =_get_element(fid)

TypeError: sequence item 0: expected string, array (scipy) found
WARNING: Failure executing file: <bodetest.py>

In [4]: scipy.__version__
Out[4]: '0.3.2'

The version is the same.  I actually have scipy installed on 3
different linux distros (the 3rd one isn't really working right now). 
The other 2 give this same error.  The *.mat file is small, so I am
attaching it.  This particular linux is on fedora core 3 and I
compiled everything from source and did the python setup.py install
from the 0.3.2 tarball.  This FC3 install in running python 2.3.  The
Windows version that can open the *.mat file is also python 2.3 with
the binaries from the scipy website.  The other linux distro with the
same problem is a Ubuntu Hoary 5.04 with scipy from apt-get following
John Hunter's previous post to this list.  (The one that isn't really
working is running Breezy 5.10.  It gets stuck in a different spot.  I
will look into that.)

So, is there something wrong with this mat file or do I need to do
something different to make them cross-platform?  I guess I thought
matlab took care of that part.

Thanks,

Ryan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tmm_mat_model_params.mat
Type: application/octet-stream
Size: 600 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20051014/08834298/attachment.obj>


More information about the SciPy-User mailing list