title: How to use function like matlab 'fread' in python?
body: <p>This is a <a href="https://drive.google.com/open?id=0BzCLPN5o3ziHYTZOZFNzM1hLdjQ" rel="nofollow noreferrer">.dat file.</a></p>
  
  <p>In Matlab, I can use this code to read.</p>
  
  <pre><code>lonlatfile='NOM_ITG_2288_2288(0E0N)_LE.dat';
  f=fopen(lonlatfile,'r');
  lat_fy=fread(f,[2288*2288,1],'float32');
  lon_fy=fread(f,[2288*2288,1],'float32')+86.5;
  lon=reshape(lon_fy,2288,2288);
  lat=reshape(lat_fy,2288,2288);
  </code></pre>
  
  <p>Here are some results of Matlab:
  <a href="https://i.stack.imgur.com/0PpIU.png" rel="nofollow noreferrer">matalab</a></p>
  
  <p>How to do in python to get the same result?</p>
  
  <p>PS: My code is this:</p>
  
  <pre><code>def fromfileskip(fid,shape,counts,skip,dtype):
  """
  fid    : file object,    Should be open binary file.
  shape  : tuple of ints,  This is the desired shape of each data block.
         For a 2d array with xdim,ydim = 3000,2000 and xdim = fastest 
         dimension, then shape = (2000,3000).
  counts : int, Number of times to read a data block.
  skip   : int, Number of bytes to skip between reads.
  dtype  : np.dtype object, Type of each binary element.
  """
      data = np.zeros((counts,)  + shape)
      for c in range(counts):
          block = np.fromfile(fid,dtype=np.float32,count=np.product(shape))
          data[c] = block.reshape(shape)
          fid.seek( fid.tell() + skip)
      return data
  
  fid = open(r'NOM_ITG_2288_2288(0E0N)_LE.dat','rb')
  data = fromfileskip(fid,(2288,2288),1,0,np.float32)
  loncenter = 86.5 #Footpoint of FY2E
  latcenter = 0
  lon2e = data+loncenter
  lat2e = data+latcenter
  Lon = lon2e.reshape(2288,2288)
  Lat = lat2e.reshape(2288,2288)
  </code></pre>
  
  <p>But, the result is different from that of Matlab.</p>