Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2021
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.57 KB | None | 0 0
  1.  
  2. def init():
  3.     line[0].set_data([], [])
  4.     line[1].set_data([], [])
  5.     line[2].set_data([], [])
  6.     line[3].set_data([], [])
  7.     return line[0], line[1], line[2], line[3]
  8.  
  9.  
  10. # %%
  11. def animate(i, pplotted):
  12.     Pot = GenPwr[pplotted: pplotted + i]
  13.     t_pot = Time[pplotted:pplotted + i]
  14.     RotSp = RotSpeed[pplotted:pplotted + i]
  15.     RotTh = RotThrust[pplotted:pplotted + i]
  16.     WindV = WindVel[pplotted:pplotted + i]
  17.  
  18.     # ___________GENPWR___________#
  19.     ax1.text(max(Time) / 10, 1500, "GenPwr (kW)=" + str(GenPwr[pplotted + i]), fontsize=8)
  20.     ax1.set_xlabel("Time (s)").set_size(tittle_axes_size)
  21.     ax1.grid(True, axis="y")
  22.  
  23.     # ___________ROTSPEED___________#
  24.     ax2.text(
  25.         max(Time) / 10,
  26.         max(RotSpeed) / 13,
  27.         "RotSpeed (rpm)=" + str(RotSpeed[pplotted + i]),
  28.         fontsize=8,
  29.     )
  30.     ax2.set_xlabel("Time (s)").set_size(tittle_axes_size)
  31.     ax2.grid(True, axis="y")
  32.  
  33.     # ___________ROTTHRUST___________#
  34.     ax3.text(
  35.         max(Time) / 10,
  36.         max(RotThrust) / 10,
  37.         "RotThrust (kW)=" + str(RotThrust[pplotted + i]),
  38.         fontsize=8,
  39.     )
  40.     ax3.set_xlabel("Time (s)").set_size(tittle_axes_size)
  41.     ax3.grid(True, axis="y")
  42.  
  43.     # ___________WINDVEL___________#
  44.     ax4.text(
  45.         max(Time) / 10, 1, "WindVel (m/s)=" + str(round(WindVel[pplotted + i], 2)), fontsize=8
  46.     )
  47.     ax4.set_xlabel("Time (s)").set_size(tittle_axes_size)
  48.     ax4.grid(True, axis="y")
  49.  
  50.     line[0].set_data(t_pot, Pot)
  51.     line[1].set_data(t_pot, RotSp)
  52.     line[2].set_data(t_pot, RotTh)
  53.     line[3].set_data(t_pot, WindV)
  54.  
  55.     return line[0], line[1], line[2], line[3]
  56.  
  57. fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True)
  58. plt.tight_layout()
  59. camera = Camera(fig)
  60.  
  61. line1, = ax1.plot([], [], lw=1, animated=True)
  62. line2, = ax2.plot([], [], lw=1, color="r", animated=True)
  63. line3, = ax3.plot([], [], lw=1, color="c", animated=True)
  64. line4, = ax4.plot([], [], lw=1, color="m", animated=True)
  65. line = [line1, line2, line3, line4]
  66.  
  67. Pot = []
  68. RotSp = []
  69. RotTh = []
  70. WindV = []
  71. t_pot = []
  72.  
  73. dataPointsNumber = len(Time)
  74. shards = int(dataPointsNumber / 400)
  75.  
  76. for shardN in range(1, shards + 1):
  77.     pplotted = (400 * (shardN - 1))
  78.  
  79.     anim = animation.FuncAnimation(
  80.         fig,
  81.         animate,
  82.         frames=400,
  83.         init_func=init,
  84.         interval=10,
  85.         blit=True,
  86.         fargs=[pplotted],
  87.         cache_frame_data=False,
  88.     )
  89.     plt.show()
  90.  
  91.     writer = animation.writers["ffmpeg"](fps=240)
  92.     anim.save("animation_shard_%s.mp4" %shardN, writer=writer, dpi=200)
  93.     plt.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement