3def genere_notebook(pts, graphs=(
True,
True,
True,
True,
True)):
5 fonction qui génère et retourne un Notebook Jupyter
7 * pts : tuple [str] (t, x, y)
8 * graphs : tuple [True/
False] (chronogramme, vitesse, vecteurs variation de vitesse, accélération, énergies)
10 nb = nbf.v4.new_notebook()
14%config InlineBackend.figure_format = 'svg'"""
19import matplotlib.pyplot as plt
20# Paramètres matplotlib
21plt.rcParams["figure.figsize"] = (9, 6)
22plt.style.use('seaborn-whitegrid')
27# Coordonnées de Pymecavideo
30y = {2}""".format(pts[0], pts[1], pts[2])
32 chrono0 =
"""### Chronogramme des positions"""
35plt.plot(x, y, style, markersize = markersize)
36plt.ylabel('Hauteur (m)')
37plt.xlabel('Distance (m)')
38plt.title("Chronogramme des positions")
39plt.gca().set_aspect('equal', adjustable='datalim')
42 vitesse0 =
"""### Vecteurs vitesse"""
45Δx = np.array([x[i+1]-x[i-1] for i in range(1, len(x)-1)])
46Δy = np.array([y[i+1]-y[i-1] for i in range(1, len(y)-1)])
47Δt = np.array([t[i+1]-t[i-1] for i in range(1, len(t)-1)])
50plt.plot(x, y, style, markersize = markersize)
51plt.ylabel('Hauteur (m)')
52plt.title("Vecteurs vitesse")
53plt.xlabel('Distance (m)')
55plt.quiver(x[1:-1], y[1:-1], vx, vy, scale_units = 'xy', angles = 'xy', width = 0.003)
56plt.gca().set_aspect('equal', adjustable='datalim')
59 variation0 =
"""### Vecteurs variation de vitesse"""
62Δvx = np.array([vx[i+1]-vx[i-1] for i in range(1, len(vx)-1)])
63Δvy = np.array([vy[i+1]-vy[i-1] for i in range(1, len(vy)-1)])
64plt.plot(x, y, style, markersize = markersize)
65plt.ylabel('Hauteur (m)')
66plt.xlabel('Distance (m)')
67plt.title("Vecteurs variation de vitesse")
69plt.quiver(x[2:-2], y[2:-2], Δvx, Δvy, scale_units = 'xy', angles = 'xy', width = 0.003)
70plt.gca().set_aspect('equal', adjustable='datalim')
73 acceleration0 =
"""### Vecteurs accélération"""
76Δt_ = np.array([t[i+1]-t[i-1] for i in range(2, len(t)-2)])
77Δvx = np.array([vx[i+1]-vx[i-1] for i in range(1, len(vx)-1)])
78Δvy = np.array([vy[i+1]-vy[i-1] for i in range(1, len(vy)-1)])
81plt.plot(x, y, style, markersize = markersize)
82plt.ylabel('Hauteur (m)')
83plt.xlabel('Distance (m)')
84plt.title("Vecteurs accélération")
86plt.quiver(x[2:-2], y[2:-2], ax, ay, scale_units = 'xy', angles = 'xy', width = 0.003)
87plt.gca().set_aspect('equal', adjustable='datalim')
90 energie0 =
"""### Energies"""
94m = 1.00 # Masse du système (kg)
95g = 9.81 # Intensité de la pesanteur (N/kg)"""
99Δx = np.array([x[i+1]-x[i-1] for i in range(1, len(x)-1)])
100Δy = np.array([y[i+1]-y[i-1] for i in range(1, len(y)-1)])
101Δt = np.array([t[i+1]-t[i-1] for i in range(1, len(t)-1)])
104v = np.sqrt(vx**2+vy**2)
108plt.plot(t_, Ec, label = 'Ec')
109plt.plot(t_, Ep, label = 'Ep')
110plt.plot(t_, Em, label = 'Em')
111plt.xlabel('Temps (s)')
112plt.ylabel('Energies (J)')
117 kernelspec = {
"display_name" :
"Python 3",
"language" :
"python",
"name" :
"python3"}
118 language_info = {
"codemirror_mode": {
"name":
"ipython",
"version": 3}}
119 nb[
'metadata'][
'kernelspec'] = kernelspec
120 nb[
'metadata'][
'language_info'] = language_info
121 nb[
'metadata'][
'file_extension'] =
".py"
122 nb[
'metadata'][
'mimetype'] =
"text/x-python"
123 nb[
'metadata'][
'name'] =
"python"
124 nb[
'metadata'][
'nbconvert_exporter'] =
"python"
125 nb[
'metadata'][
'pygments_lexer'] =
"ipython3"
126 nb[
'metadata'][
'version'] =
"3.9.2"
128 nb[
'cells'] = [nbf.v4.new_code_cell(entete1),
129 nbf.v4.new_code_cell(entete2),
130 nbf.v4.new_code_cell(coord)]
132 nb[
'cells'] += [nbf.v4.new_markdown_cell(chrono0),
133 nbf.v4.new_code_cell(chrono1)]
135 nb[
'cells'] += [nbf.v4.new_markdown_cell(vitesse0),
136 nbf.v4.new_code_cell(vitesse1)]
138 nb[
'cells'] += [nbf.v4.new_markdown_cell(variation0),
139 nbf.v4.new_code_cell(variation1)]
141 nb[
'cells'] += [ nbf.v4.new_markdown_cell(acceleration0),
142 nbf.v4.new_code_cell(acceleration1)]
144 nb[
'cells'] += [ nbf.v4.new_markdown_cell(energie0),
145 nbf.v4.new_code_cell(energie1),
146 nbf.v4.new_code_cell(energie2)]