Beispiel #1
0
dirname = './c={},i={},r={}'.format(colors, inputs, rule)
try:
    os.mkdir(dirname)
except Exception as e:
    print(e)
    pass

os.chdir(dirname)

#keys = list(sorted(cfg.keys())) # enforce an ordering

with open('recurrence.txt', 'w') as f:
    f.write(str(cur)+'\n')
    f.write('\n\n\n\n\n\n')
    for key in sorted(cfg.keys()):
        f.write(str(m.deserializeMatrix(key))+'\n\n')
        f.write(str(cfg[key])+'\n')
        f.write('\n\n\n\n')


#import sys
#sys.exit()
        

def saveFFT(cur, num_cells):
    ft = np.fft.fft2(cur)
    #global aaa
    #aaa = -1
    #def ppp(x):
    #    global aaa
    #    aaa += 1
Beispiel #2
0
mpl.rcParams['font.family'] = 'monospace'

with PdfPages('(rule={}, colors={}, inputs={}) with {} to {} cells.pdf'.format(rule, colors, inputs, num_cells_start, num_cells_end)) as pdf:
#for potato in range(1):

    #fig = plt.figure()
    fig, ax = plt.subplots()
    ax.xaxis.set_visible(False)
    ax.yaxis.set_visible(False)
    plt.title('Fractal Replacement Rule')
    keys = list(sorted(cfg.keys())) # enforce an ordering
    table = plt.table(
        cellText=[
            [str(cfg[key])] for key in keys
        ],
        rowLabels=[str(m.deserializeMatrix(key)) for key in keys],
        #rowColours=colors,
        #colLabels=['val'],
        cellLoc='left',
        loc='center'
    )
    maxlen = max(len(key) for key in keys)
    for cell in table.properties()['child_artists']:
        cell.set_height(maxlen/10)
    #pdf.savefig()
    plt.close()
    
    for num_cells in range(num_cells_start, num_cells_end+1):
        print('num_cells:', num_cells)
        eigvals, eigvecs = eigs = np.linalg.eig(cur)
        eigvals = np.array(list(filter(lambda x: x.real < 0.99, eigvals)))  # get rid of trivial 1+0j eigval