Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def init():
- line[0].set_data([], [])
- line[1].set_data([], [])
- line[2].set_data([], [])
- line[3].set_data([], [])
- return line[0], line[1], line[2], line[3]
- # %%
- def animate(i, pplotted):
- Pot = GenPwr[pplotted: pplotted + i]
- t_pot = Time[pplotted:pplotted + i]
- RotSp = RotSpeed[pplotted:pplotted + i]
- RotTh = RotThrust[pplotted:pplotted + i]
- WindV = WindVel[pplotted:pplotted + i]
- # ___________GENPWR___________#
- ax1.text(max(Time) / 10, 1500, "GenPwr (kW)=" + str(GenPwr[pplotted + i]), fontsize=8)
- ax1.set_xlabel("Time (s)").set_size(tittle_axes_size)
- ax1.grid(True, axis="y")
- # ___________ROTSPEED___________#
- ax2.text(
- max(Time) / 10,
- max(RotSpeed) / 13,
- "RotSpeed (rpm)=" + str(RotSpeed[pplotted + i]),
- fontsize=8,
- )
- ax2.set_xlabel("Time (s)").set_size(tittle_axes_size)
- ax2.grid(True, axis="y")
- # ___________ROTTHRUST___________#
- ax3.text(
- max(Time) / 10,
- max(RotThrust) / 10,
- "RotThrust (kW)=" + str(RotThrust[pplotted + i]),
- fontsize=8,
- )
- ax3.set_xlabel("Time (s)").set_size(tittle_axes_size)
- ax3.grid(True, axis="y")
- # ___________WINDVEL___________#
- ax4.text(
- max(Time) / 10, 1, "WindVel (m/s)=" + str(round(WindVel[pplotted + i], 2)), fontsize=8
- )
- ax4.set_xlabel("Time (s)").set_size(tittle_axes_size)
- ax4.grid(True, axis="y")
- line[0].set_data(t_pot, Pot)
- line[1].set_data(t_pot, RotSp)
- line[2].set_data(t_pot, RotTh)
- line[3].set_data(t_pot, WindV)
- return line[0], line[1], line[2], line[3]
- fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True)
- plt.tight_layout()
- camera = Camera(fig)
- line1, = ax1.plot([], [], lw=1, animated=True)
- line2, = ax2.plot([], [], lw=1, color="r", animated=True)
- line3, = ax3.plot([], [], lw=1, color="c", animated=True)
- line4, = ax4.plot([], [], lw=1, color="m", animated=True)
- line = [line1, line2, line3, line4]
- Pot = []
- RotSp = []
- RotTh = []
- WindV = []
- t_pot = []
- dataPointsNumber = len(Time)
- shards = int(dataPointsNumber / 400)
- for shardN in range(1, shards + 1):
- pplotted = (400 * (shardN - 1))
- anim = animation.FuncAnimation(
- fig,
- animate,
- frames=400,
- init_func=init,
- interval=10,
- blit=True,
- fargs=[pplotted],
- cache_frame_data=False,
- )
- plt.show()
- writer = animation.writers["ffmpeg"](fps=240)
- anim.save("animation_shard_%s.mp4" %shardN, writer=writer, dpi=200)
- plt.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement