problem loading matlab data with ompc and python

N

no1

Hi, we're investigating transitioning our company from matlab to python. Wefound OMPC as a MATLAB m-file-to Python translator, but we're encounteringa problem using the translated code to import MATLAB data structures into Python. For example, when we save data within MATLAB this way:

x.a = 5;
x.b = 6;
save -v6 test x

this saves data in test.mat, with MATLAB version 6 compatibility (OMPC saysit's not compatible with the latest versions of MATLAB). The code to read in data in MATLAB is just

load test

and when we run it through OMPC we get

load(mstring('test.mat'))

but when we run it we get the error message

File "ompclib\ompclib_numpy.py", line 1496, in load
KeyError: "[('a', '|O4'), ('b', '|O4')]"

Reading in simpler data (up to arrays) does not have this problem.

To get other people in the company to transition, we were hoping that the translation process could be done in one step or on the fly. We could read in MATLAB data using I/O functions imported from scipy, but then the transition isn't seamless any more.

Is there a simple fix to using OMPC? Or a similar alternative that would work better?

Thanks
 
T

Tim Williams

Hi, we're investigating transitioning our company from matlab to python. We found OMPC as a MATLAB m-file-to Python translator, but we're encountering a problem using the translated code to import MATLAB data structures into Python. For example, when we save data within MATLAB this way:

x.a = 5;
x.b = 6;
save -v6 test x

this saves data in test.mat, with MATLAB version 6 compatibility (OMPC says it's not compatible with the latest versions of MATLAB). The code to read in data in MATLAB is just

load test

and when we run it through OMPC we get

load(mstring('test.mat'))

but when we run it we get the error message

File "ompclib\ompclib_numpy.py", line 1496, in load
KeyError: "[('a', '|O4'), ('b', '|O4')]"

Reading in simpler data (up to arrays) does not have this problem.

To get other people in the company to transition, we were hoping that thetranslation process could be done in one step or on the fly. We could readin MATLAB data using I/O functions imported from scipy, but then the transition isn't seamless any more.

Is there a simple fix to using OMPC? Or a similar alternative that would work better?

Thanks

Have you tried using loadmat from the scipy.io module?

http://docs.scipy.org/doc/scipy/reference/io.html
 
N

no1

Hi, we're investigating transitioning our company from matlab to python.. We found OMPC as a MATLAB m-file-to Python translator, but we're encountering a problem using the translated code to import MATLAB data structures into Python. For example, when we save data within MATLAB this way:

x.a = 5;
x.b = 6;
save -v6 test x

this saves data in test.mat, with MATLAB version 6 compatibility (OMPC says it's not compatible with the latest versions of MATLAB). The code to read in data in MATLAB is just

load test

and when we run it through OMPC we get

load(mstring('test.mat'))

but when we run it we get the error message

File "ompclib\ompclib_numpy.py", line 1496, in load
KeyError: "[('a', '|O4'), ('b', '|O4')]"

Reading in simpler data (up to arrays) does not have this problem.

To get other people in the company to transition, we were hoping that the translation process could be done in one step or on the fly. We could read in MATLAB data using I/O functions imported from scipy, but then the transition isn't seamless any more.

Is there a simple fix to using OMPC? Or a similar alternative that would work better?

Thanks

Have you tried using loadmat from the scipy.io module?

http://docs.scipy.org/doc/scipy/reference/io.html

Yes (I mentioned the scipi I/O module near the end of my original post) butwe were hoping not to have to require the users to learn any Python to start. The simpler the process, the less resistance to using the "new" Python methodology; we were hoping the use of a single "black box" like translator(OMPC) would be enough. We'd really like to avoid any additional steps forthe user, like rewriting code, otherwise the users are going to resist thetransition.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top