def read_binary(filename):
    f = open(filename, 'r')  # open the file

    dic = {}                # initalize dictionary of parameters

    # parse the header of the file, storing parameters in dictionary, stop
    # when we hit the data line
    for line in f:
        line = line.strip('\n')
        if line == "SIMP":
            continue
        elif line == "DATA":
            break
        elif "=" in line:
            key, value = line.split("=")
            dic[key] = value
        else:
            warn("Warning, skipping line: %s" % (line))

    # convert float and int keys
    for key in ['SW1', 'SW']:    # convert keys to floats
        if key in dic:
            dic[key] = float(dic[key])
    for key in ['NP', 'NI']:    # convert keys to ints
        if key in dic:
            dic[key] = int(dic[key])

    # DEBUGGING
    # return dic, f

    # extract characters from data block
    chardata = "".join([line.strip('\n') for line in f])
    chardata = chardata[:-3]    # remove END
    f.close()

    # convert every 4 character to 3 'bytes'
    nquads, mod = divmod(len(chardata), 4)
    assert mod == 0     # character should be in blocks of 4
    bytes = []
    for i in range(nquads):
        bytes += chars2bytes(chardata[i * 4:(i + 1) * 4])

    # DEBUGGING
    # return dic, bytes
    # convert every 4 'bytes' to a float, then complex data
    num_points, _num_pad = divmod(len(bytes), 4)
    data = np.empty((num_points, ), dtype='float32')

    for i in range(num_points):
        data[i] = bytes2float(bytes[i * 4: (i + 1) * 4])
    data = data.view('complex64')

    # reorder data according to dimensionality and domain
    if 'NI' in dic:  # 2D data
        return dic, data.reshape(dic["NI"], dic["NP"])

    else:   # 1D data
        return dic, data
Read a binary SIMPSON file. See :py:func:`read`.
dataset/ETHPy150Open jjhelmus/nmrglue/nmrglue/fileio/simpson.py/read_binary