示例#1
0
def plot_patterns(x):
    """Plot the pattern you have chosen from the list (this choice is made with x). Possible plots: Elephant valleys, Triple squared valleys and mini-mandelbrots
    """
    if x == "mini mandelbrot":
        Z_2 = Mandelbrot_2D(500, 500, 600, -0.718, -0.714, 0.213, 0.217)
        fig = plt.figure()
        fig.suptitle("Minis mandelbrot set")
        im = plt.imshow(Z_2.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x == "Elephant valley":
        Z_5 = Mandelbrot_2D(500, 500, 600, 0.26185, 0.26196, 0.002515,
                            0.002573)
        fig = plt.figure()
        fig.suptitle("Elephant valleys")
        im = plt.imshow(Z_5.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x == "Triple squared valley":
        Z = Mandelbrot_2D(500, 500, 600, -0.069, -0.0669, 0.6478, 0.6490)
        fig = plt.figure()
        fig.suptitle("Triple squared valley")
        im = plt.imshow(Z.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x != "mini mandelbrot" and x != "Elephant valley" and x != "Triple squared valley":
        return "It seems like you did not chose one of the patterns of the list...Restart the function if you want to plot a characteristic pattern"
示例#2
0
 def animate_200(i, x):
     if i <= 50:
         Z = Mandelbrot_2D(500, 500, 50, -2 + 0.02 * i, 0.5 - 0.02 * i,
                           -1.25 + 0.02 * i, 1.25 - 0.02 * i)
         im.set_data(Z.Mandelbrotset)
     if i > 50 and i <= 130:
         Z_1 = Mandelbrot_2D(500, 500, 200, -1 + 0.0026 * (i - 50),
                             -0.5 - 0.0021 * (i - 50),
                             -0.25 + 0.0044 * (i - 50),
                             0.25 - 0.0003 * (i - 50))
         im.set_data(Z_1.Mandelbrotset)
     if i > 130:
         Z_2 = Mandelbrot_2D(500, 500, 600, -0.74 + 0.00044 * (i - 150),
                             -0.71 - 0.00008 * (i - 150),
                             0.19 + 0.00046 * (i - 150),
                             0.22 - 0.00006 * (i - 150))
         im.set_data(Z_2.Mandelbrotset)
     if x == 'yes':
         plt.savefig('temp/frame_{}.png'.format(i))
     return im,
示例#3
0
def plot_patterns(x):
    """Plot the pattern you have chosen from the list (this choice is made with x). Possible plots: Elephant valleys, Triple spiral valleys and mini-Mandelbrots. All of these plots are obtained thanks to several zooms on sparse matrix
    
    :param x: a character string from the list given
    :type x: string 

    :return: a plot of a boolean matrix
    :rtype: object
    """
    if x == "mini mandelbrot":
        Z_2 = Mandelbrot_2D(500, 500, 600, -0.718, -0.714, 0.213, 0.217)
        fig = plt.figure()
        fig.suptitle("Minis mandelbrot set")
        im = plt.imshow(Z_2.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x == "Elephant valley":
        Z_5 = Mandelbrot_2D(500, 500, 600, 0.26185, 0.26196, 0.002515,
                            0.002573)
        fig = plt.figure()
        fig.suptitle("Elephant valleys")
        im = plt.imshow(Z_5.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x == "Triple spiral valley":
        Z = Mandelbrot_2D(500, 500, 600, -0.069, -0.0669, 0.6478, 0.6490)
        fig = plt.figure()
        fig.suptitle("Triple spiral valley")
        im = plt.imshow(Z.Mandelbrotset, cmap='binary')
        plt.colorbar()
        plt.show()
        return im
    if x != "mini mandelbrot" and x != "Elephant valley" and x != "Triple spiral valley":
        return "It seems like you did not chose one of the patterns of the list...Restart the function if you want to plot a characteristic pattern"
示例#4
0
def Inside_the_set(x):
    """Animate a zoom inside the Mandelbrot set:

    :param x: a character string saying if you want to save the frames of the animation
    :type x: string 

    :return: video of more than 200 frames
    :rtype: video
    """
    fig = plt.figure()
    fig.suptitle("Inside the Mandelbrot fractal")
    Z = Mandelbrot_2D(500, 500, 50, -2, 0.5, -1.25, 1.25)
    im = plt.imshow(Z.Mandelbrotset, cmap='magma')
    if x == 'yes':
        os.mkdir('temp')

    def animate_200(i, x):
        if i <= 50:
            Z = Mandelbrot_2D(500, 500, 50, -2 + 0.02 * i, 0.5 - 0.02 * i,
                              -1.25 + 0.02 * i, 1.25 - 0.02 * i)
            im.set_data(Z.Mandelbrotset)
        if i > 50 and i <= 130:
            Z_1 = Mandelbrot_2D(500, 500, 200, -1 + 0.0026 * (i - 50),
                                -0.5 - 0.0021 * (i - 50),
                                -0.25 + 0.0044 * (i - 50),
                                0.25 - 0.0003 * (i - 50))
            im.set_data(Z_1.Mandelbrotset)
        if i > 130:
            Z_2 = Mandelbrot_2D(500, 500, 600, -0.74 + 0.00044 * (i - 150),
                                -0.71 - 0.00008 * (i - 150),
                                0.19 + 0.00046 * (i - 150),
                                0.22 - 0.00006 * (i - 150))
            im.set_data(Z_2.Mandelbrotset)
        if x == 'yes':
            plt.savefig('temp/frame_{}.png'.format(i))
        return im,

    anim = animation.FuncAnimation(fig,
                                   animate_200,
                                   frames=np.arange(0, 210, 1),
                                   fargs=(x, ),
                                   interval=1,
                                   blit=False)
    plt.show()
    return im
"""
Mandelbrot set
============================

In this setion, you can see how to plot the Mandelbrot set.
"""

import matplotlib.pyplot as plt

from logistic_module.Mandelbrot2D.Mandelbrot2D import Mandelbrot_2D
Z = Mandelbrot_2D(hauteur=500, largeur=500, max_iteration=100,
                  xmin=-2, xmax=0.5, ymin=-1.25, ymax=1.25)

fig = plt.figure()
fig.suptitle("Mandelbrot set")
im = plt.imshow(Z.Mandelbrotset, cmap='magma')
plt.colorbar()
plt.show()
from numba import jit
import matplotlib.pyplot as plt
from memory_profiler import profile

from logistic_module.Mandelbrot2D.Mandelbrot2D import Mandelbrot_2D

Z_2 = Mandelbrot_2D(500, 500, 600, -1.7, 0.2, -0.95, 0.95)
Z_3 = Mandelbrot_2D(500, 500, 600, -1.5, 0, -0.75, 0.75)
Z_4 = Mandelbrot_2D(500, 500, 600, -1.5, -0.35, -0.57, 0.57)
Z_5 = Mandelbrot_2D(500, 500, 600, -1.44, -0.72, -0.4, 0.4)
Z_6 = Mandelbrot_2D(500, 500, 600, -1.42, -0.98, -0.2, 0.2)
Z_7 = Mandelbrot_2D(500, 500, 600, -1.42, -1.23, -0.1, 0.09)
Z_8 = Mandelbrot_2D(500, 500, 600, -1.41886, -1.27142, -0.0961, 0.08658)
Z_9 = Mandelbrot_2D(500, 500, 600, -1.41, -1.3366, -0.05, 0.05)


@profile
def animate(i):
    """Animated zoom on the mandelbrot set:
    
    :param i: the number of times the function is to be used
    :type i: integer

    :return: An image with a zoom on the Mandelbrot set
    :rtype: object 
    
    """
    if i == 0:
        im = plt.imshow(Z_2.Mandelbrotset, cmap='binary')
    if i == 1:
        im = plt.imshow(Z_3.Mandelbrotset, cmap='binary')
示例#7
0
def test_Mandelbrot_time():
    start = time.time()
    print(Mandelbrot_2D(500, 500, 5, -1, 1, -1, 1))
    end = time.time()
    assert (end - start) < 120.0
示例#8
0
from logistic_module.Mandelbrot2D.Mandelbrot2DAnimation import animate
from logistic_module.Mandelbrot2D.Inside_Mandelbrotset import Inside_the_set
from logistic_module.Mandelbrot2D.Plot_pattern import plot_patterns
from logistic_module.Mandelbrot3D.Mandelbrot3D import Mand_3D
from logistic_module.Mandelbrot3D.Mandelbrot3D_anim import animation
from scipy.sparse import csr_matrix, isspmatrix
import numpy as np
import time

le = Logistic_equation(n=1)
viz = Visualization()
bif = Visualization_bifurcation()
m2 = Mandelbrot_2D(largeur=2,
                   hauteur=2,
                   max_iteration=4,
                   xmin=1,
                   xmax=2,
                   ymin=1,
                   ymax=2)
M = Mandelbrot_2D(500, 500, 5, -1, 1, -1, 1)
M_1 = Mandelbrot_2D(500, 500, 50, -1, -0.5, -0.25, 0.25)
M_2 = Mandelbrot_2D(500, 500, 50, -0.74, -0.71, 0.19, 0.22)
m3 = Mand_3D(n=200, M=200, L=1.4, dx=-0.6, dy=0.0)


def test_logistic():
    assert le.logistic(2, 1) == 0


def test_vectorization():
    assert le.vectorization(1, 2) == [(1, 0), (1, 0), (0, 0)]