'Write header for given data options
Parameters
name : str
name of variable
shape : sequence
Shape of array as it will be read in matlab
P : int, optional
code for mat4 data type, one of ``miDOUBLE, miSINGLE, miINT32,
miINT16, miUINT16, miUINT8``
T : int, optional
code for mat4 matrix class, one of ``mxFULL_CLASS, mxCHAR_CLASS,
mxSPARSE_CLASS``
imagf : int, optional
flag indicating complex'

def write_header(self, name, shape, P=miDOUBLE, T=mxFULL_CLASS, imagf=0):

    header = np.empty((), mdtypes_template['header'])
    M = (not SYS_LITTLE_ENDIAN)
    O = 0
    header['mopt'] = ((((M * 1000) + (O * 100)) + (P * 10)) + T)
    header['mrows'] = shape[0]
    header['ncols'] = shape[1]
    header['imagf'] = imagf
    header['namlen'] = (len(name) + 1)
    self.write_bytes(header)
    self.write_string(asbytes((name + '\x00')))
