'Write some data to a csv file.  Only use for debugging!'

def write2file(self, file_name, data):

    import csv
    data_file = csv.writer(open(file_name, 'w'))
    data = np.column_stack(data)
    nobs = max(np.shape(data))
    K = min(np.shape(data))
    data = np.reshape(data, (nobs, K))
    for i in range(nobs):
        data_file.writerow(list(data[i, :]))
