def read_from_bpch(filename, file_position, shape, dtype, endian,<EOL>use_mmap=False):
offset = file_position + <NUM_LIT:4><EOL>if use_mmap:<EOL><INDENT>d = np.memmap(filename, dtype=dtype, mode='<STR_LIT:r>', shape=shape,<EOL>offset=offset, order='<STR_LIT:F>')<EOL><DEDENT>else:<EOL><INDENT>with FortranFile(filename, '<STR_LIT:rb>', endian) as ff:<EOL><INDENT>ff.seek(file_position)<EOL>d = np.array(ff.readline('<STR_LIT>'))<EOL>d = d.reshape(shape, order='<STR_LIT:F>')<EOL><DEDENT><DEDENT>if (d.shape != shape):<EOL><INDENT>raise IOError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(filename, shape, d.shape))<EOL><DEDENT>return d<EOL>
Read a chunk of data from a bpch output file.

    Parameters
    ----------
    filename : str
        Path to file on disk containing the  data
    file_position : int
        Position (bytes) where desired data chunk begins
    shape : tuple of ints
        Resultant (n-dimensional) shape of requested data; the chunk
        will be read sequentially from disk and then re-shaped
    dtype : dtype
        Dtype of data; for best results, pass a dtype which includes
        an endian indicator, e.g. `dtype = np.dtype('>f4')`
    endian : str
        Endianness of data; should be consistent with `dtype`
    use_mmap : bool
        Memory map the chunk of data to the file on disk, else read
        immediately

    Returns
    -------
    Array with shape `shape` and dtype `dtype` containing the requested
    chunk of data from `filename`.