def read_binary(filename, nx, ny, nz, dtype_str, headersize):

    # open the file
    with open(filename, "rb") as opened_file:
        # read the file header
        header = opened_file.read(headersize)

        # read the entire file in as 1D list
        data = np.fromfile(file=opened_file, dtype=np.dtype(dtype_str),
                           count=-1)

    # reshape the array to 3D
    if nz is not 1:
        data.resize(nx, ny, nz)
    # unless the 3rd dimension is 1, in which case reshape the array to 2D
    elif ny is not 1:
        data.resize(nx, ny)
    # unless the 2nd dimension is also 1, in which case leave the array as 1D

    # return the array and the header
    return data, header

# set an attribute for the dsize params that are valid options
Take an IP string/int and return an object of the correct type.
dataset/ETHPy150Open scikit-beam/scikit-beam/skbeam/io/binary.py/read_binary--crossover with--dataset/ETHPy150Open anandology/pyjamas/pyjs/src/pyjs/lib/ipaddr.py/IPAddress