#NEWLINE# def read_binary( filename , nx , ny , nz , dtype_str , headersize ) : #NEWLINE# #INDENT# '\n    docstring, woo!\n\n    Parameters\n    ----------\n    filename : String\n        The name of the file to open\n    nx : integer\n        The number of data elements in the x-direction\n    ny : integer\n        The number of data elements in the y-direction\n    nz : integer\n        The number of data elements in the z-direction\n    dtype_str : str\n        A valid argument for np.dtype(some_str). See read_binary.dsize\n        attribute\n    headersize : integer\n        The size of the file header in bytes\n\n    Returns\n    -------\n    data : ndarray\n            data.shape = (x, y, z) if z > 1\n            data.shape = (x, y) if z == 1\n            data.shape = (x,) if y == 1 && z == 1\n    header : String\n            header = file.read(headersize)\n    ' #NEWLINE# with open ( filename , 'rb' ) as opened_file : #NEWLINE# #INDENT# header = opened_file . read ( headersize ) #NEWLINE# data = np . fromfile ( file = opened_file , dtype = np . dtype ( dtype_str ) , count = ( - 1 ) ) #NEWLINE# #UNINDENT# if ( nz is not 1 ) : #NEWLINE# #INDENT# data . resize ( nx , ny , nz ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ny is not 1 ) : #NEWLINE# #INDENT# data . resize ( nx , ny ) #NEWLINE# #UNINDENT# #UNINDENT# return ( data , header )