Thanks
gb
Yes. I have a module which will load MATLAB files. It's not entirely
complete but handles most MATLAB files (the most obvious omission is
sparse matrices).
It requires NumPy as the MATLAB matrices are loaded as Numeric arrays.
For MATLAB 5 files, cells are loaded as lists and structures as
dictionaries.
If the entire contents of the .mat file are loaded then they are returned
in a dictionary rather than being inserted into the current workspace as
MATLAB does.
e.g.
>>> import Numeric
>>> import matfile
>>> a=matfile.load('tau0_GUP_202_12.8.mat')
To list the matrices loaded:
>>> a.keys()
['Nkill', 'c_addr1', 's_addr1', 'datalen', 'c_addr2', 's_addr2', 'ngup',
'b_addr1', 'b_addr2', 'Sysconst']
or you can load specific matrices which will be returned in a list in the
order requested, e.g. to load the datalen and ngup matrices :
>>> b=matfile.load('tau0_GUP_202_12.8.mat','datalen','ngup')
>>> b
[array([ 31632.]), array([ 26278.])]
>>> a['datalen']
array([ 31632.])
>>> a['ngup']
array([ 26278.])
>>> b[0][0]
31632.0
>>> a['datalen'][0]
31632.0
If you would like more info e-mail me and I can send details.
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : n...@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
You can get the tarball from ftp://ion.le.ac.uk/matfile/matfile.tar.gz.
To build the module extract the tarball - it will create a directory called
matfile containing the source. Edit the Makefile and change the location
of the Python and Numerc header files and libraries for your system, the
macros which need changing are PYTHON_INLUCDE and PYTHON_LIBDIR and
PYTHON_LIBS.
Type "make" and it should build the matfile library first and then the
matfilemodule.so.
Oh, BTW, I should say that this is set up for Linux. No-one has mentioned
environment. For other *NIX systems it will be necessary to change some
of the compiler/linker options for building and naming shared objects.
I don't have a clue what would be necessary for a Windows environment.
I would like to see your implentation. I just finished writing a MAT file
reader and writer for inclusion in SciPy. (I should have checked the
newsgroups first...) My version only handles Level 4 MAT files.
-Travis