title: Importing complex data from .mat file as a numpy array
body: <p>I have a question about <strong>tuples</strong>. 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</p>
  
  <pre><code>a = rand(10,10,10) + 1i*rand(10,10,10);
  save('trial.mat')
  </code></pre>
  
  <p>Now I try to load the variable a in Python. Here is what I do.</p>
  
  <pre><code>import numpy as np
  import h5py
  f = h5py.File('trial.mat','r')
  a = np.array(f['a'])
  print a
  print np.shape(a)
  </code></pre>
  
  <p>Here are the last few lines of the output I get.</p>
  
  <pre><code>   (0.7551184371302334, 0.15987275885464014)
     (0.5261111725119932, 0.7314707154838205)
     (0.8501109979307012, 0.05369411719045292)
     (0.8160309248196381, 0.7143895270837854)]]]
  (10L, 10L, 10L)
  </code></pre>
  
  <p>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</p>
  
  <p>I use MATLAB R2010a and Python 2.7.7, part of the Anaconda 2.01 (x86-64) distribution, on Windows 7.</p>
  
  <p>Maybe this is related to the following question, but I am not really sure.
  <a href="https://stackoverflow.com/questions/19310808/how-to-read-a-v7-3-mat-file-via-h5py">How to read a v7.3 mat file via h5py?</a></p>
  
  <p>Help will be greatly appreciated. </p>