def parse_STATS_header(header):
  """
  Extract the header from a binary STATS data file.

  This extracts the STATS binary file header information
  into variables with meaningful names.  It also converts year
  and day_of_year to seconds at midnight since the epoch used by
  UNIX systems.

  @param header : string of binary data

  @return: tuple
    (spcid, vsrid, chanid, bps, srate, errflg, year, doy, sec, freq,
    orate,nsubchan)
  """
  (spcid,             #  1) station id - 10, 40, 60, 21
   vsrid,             #  2) vsr1a, vsr1b ...
   chanid,            #  3) subchannel id 0,1,2,3
   bps,               #  4) number of bits per sample - 1, 2, 4, 8, or 16
   srate,             #  5) number of samples per second in samples per second
   errflg,            #  6) hardware error flag, dma error or num_samples
                      #     error, 0 ==> no errors
   year,              #  7) time tag - year
   doy,               #  8) time tag - day of year

   sec,               #  9) time tag - second of day

   freq,              # 10) frequency in Hz

   orate,             # 11) number of statistics samples per second

   nsubchan           # 12) number of output sub chans
   ) = header
  return spcid, vsrid, chanid, bps, srate, errflg, year, doy, sec, freq, \
         orate,nsubchan