1 from run_animation_layout_support_functions
import *
7 shift_amount_per_frame=1,
10 sample_range=[0, 2*100],
14 "block_phase_" + str(velocity_index))
16 "pad_phase_" + str(velocity_index))
17 frames_per_velocity = phase_data_block.shape[1]
19 "/results/friction_phase/increment_run.yaml")[
"velocities"]
20 for i
in range(velocity_index + 1, len(velocities)):
21 phase_data_block = np.concatenate((phase_data_block,
load_friction_phase_data(run_name,
"block_phase_" + str(i))), axis=1)
25 if(
"--nopad" in sys.argv):
26 phase_shape_block = phase_data_block.shape
27 block_average = np.zeros(phase_shape_block[1])
28 number_of_blocks = int(phase_shape_block[0]/2)
29 for i
in range(0, number_of_blocks):
30 block_average += phase_data_block[2*i]
31 position_data_pad = block_average/number_of_blocks
33 position_data_pad_title =
"Block avg. position" 34 position_data_pad_y_label =
"$\\frac{\sum_1^n u_i}{n}$" 36 index_first_spring = 1
38 position_data_pad = phase_data_pad[0]
39 position_data_pad_title =
"Pad position" 40 position_data_pad_y_label =
"$x$" 42 index_first_spring = 3
44 number_of_data_points = len(position_data[0])
45 if(frames > number_of_data_points):
46 frames = number_of_data_points
53 x_label=
"Time steps shown",
67 x_label=
"Time steps shown",
68 y_label=position_data_pad_y_label)
73 common_indexes=shown_indexes,
74 pad_position=position_data_pad,
78 animation_plots = [position_plot, bar_plot, position_pad_plot, spring_plot]
80 bk_animation =
BKAnimation(animation_plots, sleep_amount=0.000, max_lim_change=0.3)
81 bk_animation.init_live_plot((231, 232, 233, 212),
83 [
"Position",
"Bar", position_data_pad_title,
"Model"],
84 show_plot=live_plotting,
85 suptitle=
"Velocity: " + str(velocities[velocity_index]))
88 plot_shape = [len(animation_plots), len(position_plot.single_line_list)]
89 only_shift_first =
False 90 only_shift_first_index = number_of_data_points - shown_indexes[1] - 1
91 def init_plot_frames():
92 bk_animation.update_subplots(update_lims=
False)
94 nonlocal velocity_index, only_shift_first
95 bk_animation.update_suptitle(
"Velocity: %(velocity)1.3f |\ 96 Frame: %(frame)i" % {
'velocity': velocities[velocity_index],
98 if(n % frames_per_velocity == 0
and n > 0):
101 if(n % only_shift_first_index == 0
and n > 0):
102 only_shift_first =
True 104 shift_amount_per_frame,
106 n_line_number=plot_shape[1],
108 only_shift_first=only_shift_first)
110 shift_amount_per_frame,
114 only_shift_first=only_shift_first)
116 bk_animation.change_y(1, 0)
117 bk_animation.change_x(3, 0, get_axis=
"y")
119 bk_animation.change_x(3, 1)
120 bk_animation.update_upper_springs(3, index_first_spring=index_first_spring)
122 bk_animation.update_subplots()
123 sleep(bk_animation.sleep_amount)
127 for i
in range(0, frames):
133 ani = animation.FuncAnimation(bk_animation.fig,
135 init_func=init_plot_frames,
138 writer = animation.writers[
'ffmpeg'](fps=20)
139 simulation_path = loader.get_simulation_path(run_name)
140 ani.save(simulation_path +
'/animation_vid_7.mp4',
def make_single_line_spring_plot(single_plot, ax_number, line_number, pad_position=[], common_indexes=[], height_of_plot=0.1, x_label="", y_label="", show_pad=False)
def make_single_line_bar_plot(single_plot, ax_number, line_number, x_label="", y_label="")
def seperate_pos_vel_data(phase_data)
def make_single_line_line_plot(y_data, common_indexes, ax_number, x_values=[], y_min=0, y_max=0, x_label="", y_label="")
def load_friction_phase_data(run_name, phase_part="")
def shift_z_indexes_of_lines_in_ax(bk_animation, shift_amount_per_frame, ax_number, n_line_number, index_type, only_shift_first=False)
def pos_pos_spr_friction(run_name, shown_indexes, shift_amount_per_frame=1, frames=800, live_plotting=True, sample_range=[0, velocity_index=40)