def _write_raw_buffer(fid, buf, cals, fmt):
 if (buf.shape[0] != len(cals)):
  raise ValueError('buffer and calibration sizes do not match')
 if (fmt not in ['short', 'int', 'single', 'double']):
  raise ValueError('fmt must be "short", "single", or "double"')
 if np.isrealobj(buf):
  if (fmt == 'short'):
   write_function = write_dau_pack16
  elif (fmt == 'int'):
   write_function = write_int
  elif (fmt == 'single'):
   write_function = write_float
  else:
   write_function = write_double
 elif (fmt == 'single'):
  write_function = write_complex64
 elif (fmt == 'double'):
  write_function = write_complex128
 else:
  raise ValueError('only "single" and "double" supported for writing complex data')
 buf = (buf / np.ravel(cals)[:, None])
 write_function(fid, FIFF.FIFF_DATA_BUFFER, buf)

def _write_raw_buffer ( fid , buf , cals , fmt ) : if ( buf . shape [ 0 ] != len ( cals ) ) : raise ValueError ( 'buffer and calibration sizes do not match' ) if ( fmt not in [ 'short' , 'int' , 'single' , 'double' ] ) : raise ValueError ( 'fmt must be "short", "single", or "double"' ) if np . isrealobj ( buf ) : if ( fmt == 'short' ) : write_function = write_dau_pack16 elif ( fmt == 'int' ) : write_function = write_int elif ( fmt == 'single' ) : write_function = write_float else : write_function = write_double elif ( fmt == 'single' ) : write_function = write_complex64 elif ( fmt == 'double' ) : write_function = write_complex128 else : raise ValueError ( 'only "single" and "double" supported for writing complex data' ) buf = ( buf / np . ravel ( cals ) [ : , None ] ) write_function ( fid , FIFF . FIFF_DATA_BUFFER , buf )
write raw buffer .