def read_text(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

    if "NI" in dic:     # 2D data
        data = np.empty((dic['NI'], dic['NP']), dtype='complex64')

        # loop over remaining lines, extracting data values
        for iline, line in enumerate(f):
            if line[0:3] == "END":   # END marks end of data block
                break
            ni_idx, np_idx = divmod(iline, dic['NP'])
            r_val, i_val = [float(i) for i in line.split()]
            data.real[ni_idx, np_idx] = r_val
            data.imag[ni_idx, np_idx] = i_val

    else:   # 1D data
        data = np.empty((dic['NP']), dtype='complex64')

        # loop over remaining lines, extracting data values
        for iline, line in enumerate(f):
            if line[0:3] == "END":
                break
            r_val, i_val = [float(i) for i in line.split()]
            data.real[iline] = r_val
            data.imag[iline] = i_val

    f.close()
    return dic, data


#############################
# Read xreim or xyreim data #
#############################
Make a sampler GPU mode.
dataset/ETHPy150Open jjhelmus/nmrglue/nmrglue/fileio/simpson.py/read_text--crossover with--dataset/ETHPy150Open pfnet/chainer/chainer/utils/walker_alias.py/WalkerAlias.to_gpu