def mandelbrot_ex1():

    xB = (-0.748770, -0.748720)
    yB = ( 0.065053,  0.065103)

    start_time = time.time()

    man = mandelbrot(xB, yB, power, args=2, width=5, height=5, maxiter=5000, dpi=300)
    image(man, cmap=plt.cm.gist_yarg, filename='mandelbrot_ex1', gamma=0.3)

    print('calculation took %s seconds ' % np.round((time.time() - start_time), 3))
def mandelbrot_ex2():

    xB = (-1.70, 0.75)
    yB = (-1.25, 1.25)

    start_time = time.time()

    man = mandelbrot(xB, yB, power, args=2, width=5, height=5, maxiter=100, dpi=300)
    image(man, cmap=plt.cm.hot, filename='mandelbrot_ex1', gamma=0.3)

    print('calculation took %s seconds ' % np.round((time.time() - start_time), 3))
def mandelbrot_ex3():

    xB = ( 0.3602404434376143632361252444495 - 0.00000000000007,  0.3602404434376143632361252444495 + 0.00000000000023)
    yB = (-0.6413130610648031748603750151793 - 0.00000000000008, -0.6413130610648031748603750151793 + 0.00000000000012)

    start_time = time.time()
    mymap = stack_cmaps(plt.cm.terrain, 5)

    man = mandelbrot(xB, yB, power, args=2, width=5, height=5, maxiter=5000, dpi=300)
    image(man, cmap=mymap, filename='mandelbrot_ex1', gamma=0.8)

    print('calculation took %s seconds ' % np.round((time.time() - start_time), 3))
Exemple #4
0
def compute_cvals(Ncvals, xbound, ybound, update_func, args=2, width=5, height=5, dpi=100, importance_weight=0.75):

    xmin,xmax = [float(xbound[0]),float(xbound[1])]
    ymin,ymax = [float(ybound[0]),float(ybound[1])]

    nx = width*dpi
    ny = height*dpi

    xvals  = np.array([xmin + i*(xmax-xmin)/(nx) for i in range(nx)], dtype=np.float32)
    yvals  = np.array([ymin + i*(ymax-ymin)/(ny) for i in range(ny)], dtype=np.float32)
    xboxs = [(xvals[i],xvals[i+1]) for i in range(len(xvals)-1)]
    yboxs = [(yvals[i],yvals[i+1]) for i in range(len(yvals)-1)]
    xboxs = xboxs + [(xboxs[-1][1], xmax)]
    yboxs = yboxs + [(yboxs[-1][1], ymax)]

    NR = int(round(Ncvals * (1-importance_weight)))
    cvals = []

    for k in range(NR):

        c = xmin+(random()*(xmax-xmin)) + 1j*(ymin+(random()*(ymax-ymin)))
        cvals.append(c)

    if importance_weight > 0.0:

        NI = int(round(Ncvals * importance_weight))
        energy_grid = mandelbrot(xbound, ybound, update_func, args=args, width=width, height=height, dpi=dpi, maxiter=1000, horizon=2.5, log_smooth=False)[0]
        energy_grid = (energy_grid/energy_grid.sum()) * NI

        for i in range(nx):
            for j in range(ny):
    
                N = int(round(energy_grid[i,j]))
        
                xlo,xhi = xboxs[i]
                ylo,yhi = yboxs[j]
                cs = xlo+(random(N)*(xhi-xlo)) + 1j*(ylo+(random(N)*(yhi-ylo)))
        
                cvals.extend(list(cs))

    return np.array(cvals)