|
@@ 414-449 (lines=36) @@
|
| 411 |
|
plt.show();
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
@staticmethod
|
| 415 |
|
def animate_phase_matrix(sync_output_dynamic, grid_width = None, grid_height = None, animation_velocity = 75, colormap = 'jet', save_movie = None):
|
| 416 |
|
"""!
|
| 417 |
|
@brief Shows animation of phase matrix between oscillators during simulation on 2D stage.
|
| 418 |
|
@details If grid_width or grid_height are not specified than phase matrix size will by calculated automatically by square root.
|
| 419 |
|
|
| 420 |
|
@param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
|
| 421 |
|
@param[in] grid_width (uint): Width of the phase matrix.
|
| 422 |
|
@param[in] grid_height (uint): Height of the phase matrix.
|
| 423 |
|
@param[in] animation_velocity (uint): Interval between frames in milliseconds.
|
| 424 |
|
@param[in] colormap (string): Name of colormap that is used by matplotlib ('gray', 'pink', 'cool', spring', etc.).
|
| 425 |
|
@param[in] save_movie (string): If it is specified then animation will be stored to file that is specified in this parameter.
|
| 426 |
|
|
| 427 |
|
"""
|
| 428 |
|
|
| 429 |
|
figure = plt.figure();
|
| 430 |
|
|
| 431 |
|
def init_frame():
|
| 432 |
|
return frame_generation(0);
|
| 433 |
|
|
| 434 |
|
def frame_generation(index_dynamic):
|
| 435 |
|
figure.clf();
|
| 436 |
|
axis = figure.add_subplot(111);
|
| 437 |
|
|
| 438 |
|
phase_matrix = sync_output_dynamic.allocate_phase_matrix(grid_width, grid_height, index_dynamic);
|
| 439 |
|
axis.imshow(phase_matrix, cmap = plt.get_cmap(colormap), interpolation='kaiser', vmin = 0.0, vmax = 2.0 * math.pi);
|
| 440 |
|
artist = figure.gca();
|
| 441 |
|
|
| 442 |
|
return [ artist ];
|
| 443 |
|
|
| 444 |
|
phase_animation = animation.FuncAnimation(figure, frame_generation, len(sync_output_dynamic), init_func = init_frame, interval = animation_velocity , repeat_delay = 1000);
|
| 445 |
|
|
| 446 |
|
if (save_movie is not None):
|
| 447 |
|
phase_animation.save(save_movie, writer = 'ffmpeg', fps = 15, bitrate = 1500);
|
| 448 |
|
else:
|
| 449 |
|
plt.show();
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
|
@@ 380-411 (lines=32) @@
|
| 377 |
|
plt.show();
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
@staticmethod
|
| 381 |
|
def animate_correlation_matrix(sync_output_dynamic, animation_velocity = 75, colormap = 'cool', save_movie = None):
|
| 382 |
|
"""!
|
| 383 |
|
@brief Shows animation of correlation matrix between oscillators during simulation.
|
| 384 |
|
|
| 385 |
|
@param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network.
|
| 386 |
|
@param[in] animation_velocity (uint): Interval between frames in milliseconds.
|
| 387 |
|
@param[in] colormap (string): Name of colormap that is used by matplotlib ('gray', 'pink', 'cool', spring', etc.).
|
| 388 |
|
@param[in] save_movie (string): If it is specified then animation will be stored to file that is specified in this parameter.
|
| 389 |
|
|
| 390 |
|
"""
|
| 391 |
|
|
| 392 |
|
figure = plt.figure();
|
| 393 |
|
|
| 394 |
|
correlation_matrix = sync_output_dynamic.allocate_correlation_matrix(0);
|
| 395 |
|
artist = plt.imshow(correlation_matrix, cmap = plt.get_cmap(colormap), interpolation='kaiser', hold = True, vmin = 0.0, vmax = 1.0);
|
| 396 |
|
|
| 397 |
|
def init_frame():
|
| 398 |
|
return [ artist ];
|
| 399 |
|
|
| 400 |
|
def frame_generation(index_dynamic):
|
| 401 |
|
correlation_matrix = sync_output_dynamic.allocate_correlation_matrix(index_dynamic);
|
| 402 |
|
artist.set_data(correlation_matrix);
|
| 403 |
|
|
| 404 |
|
return [ artist ];
|
| 405 |
|
|
| 406 |
|
correlation_animation = animation.FuncAnimation(figure, frame_generation, len(sync_output_dynamic), init_func = init_frame, interval = animation_velocity , repeat_delay = 1000, blit = True);
|
| 407 |
|
|
| 408 |
|
if (save_movie is not None):
|
| 409 |
|
correlation_animation.save(save_movie, writer = 'ffmpeg', fps = 15, bitrate = 1500);
|
| 410 |
|
else:
|
| 411 |
|
plt.show();
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
@staticmethod
|