I have a question about tuples. I use a program which dumps large output 3-D arrays in the .mat format. They work fine in MATLAB. They are of the newer .mat format (HDF5 based). Say I generate a 10x10x10 3D matrix of complex numbers in MATLAB and save it as trial.mat
a = rand(10,10,10) + 1i*rand(10,10,10);
save('trial.mat')
Now I try to load the variable a in Python. Here is what I do.
import numpy as np
import h5py
f = h5py.File('trial.mat','r')
a = np.array(f['a'])
print a
print np.shape(a)
Here are the last few lines of the output I get.
(0.7551184371302334, 0.15987275885464014)
(0.5261111725119932, 0.7314707154838205)
(0.8501109979307012, 0.05369411719045292)
(0.8160309248196381, 0.7143895270837854)]]]
(10L, 10L, 10L)
The data is a 3D array of tuples. How do I cast this into a 3D numpy array of complex numbers? I need it for my further analysis. The actual arrays are quite large (1.5 GB and higher). I mean (0.81, 0.71) should be usable as 0.81 + 0.71j
I use MATLAB R2010a and Python 2.7.7, part of the Anaconda 2.01 (x86-64) distribution, on Windows 7.
Maybe this is related to the following question, but I am not really sure. How to read a v7.3 mat file via h5py?
Help will be greatly appreciated.