title: Reading data from a 16-bit unsigned big endian raw image file in python
body: <p>I have some images I want to analyze using a python script.
  They are stored as raw binary data files. They are in the following format. 16-bit unsigned, big endian,   592x600 pixels with a 520 byte header.</p>
  
  <p>When I look at the .dat file in my OS (OS X yosemite) I see that the file is 710,920 bytes</p>
  
  <p>This makes sense as (592 x 600 pixels) * (2 bytes per pixel) = 710,400 bytes. Thus the remainder is the 520 byte header.</p>
  
  <p>I want to write a quick python script to generate an array of the pixel values. i.e. I want to ditch the header of the file and store the rest of the data as an array so that I can use something like PIL to then quickly convert into an image and output a jpg or png.</p>
  
  <p>Just doing something really quick quick:</p>
  
  <pre><code>myfile = open('test.dat', 'rb') 
  
  data = myfile.read()
  
  len(data)
  
  trimdata = data[520:]
  
  len(trimdata)
  </code></pre>
  
  <p>This gives me the raw data without the header.</p>
  
  <p>From here I am unsure about the easiest way to parse the data into  a 592x600 array that I can then use with PIL to export a quick greayscale image.</p>
  
  <p>here is a link to the file incase that helps out:
  <a href="https://www.dropbox.com/s/ebm65sorcyh976l/test.dat?dl=0" rel="nofollow">test.dat</a></p>
  
  <p>Edit: Thanks for all the help - It appears the data was Little Endian not Big Endian after all. Cheers.</p>