Commit 8f016c3d authored by Zoheyr Doctor's avatar Zoheyr Doctor 🔭
Browse files

fixed animation script and updated mp4

parent 92d3efff
......@@ -37,13 +37,18 @@ def main():
ax = ax.flatten()
for axi in ax: axi.set_axis_off()
# set frame rate and movie length
fps = 30. # frames per second
length = 10. # seconds
pos_dict = {}
binary_dict = {}
# loop over all events
for event in events:
print('evolving ',event)
event_pos_dict = {}
omega = 100.*(data[event]['mass_1_source']['med'] + data[event]['mass_2_source']['med'])**(-3./2)
# create a Binary instance for the event
binary = Binary(
m1 = data[event]['mass_1_source']['med'],
......@@ -52,11 +57,13 @@ def main():
c2 = 'k',
alpha = 45.,
beta = 20.,
gamma = 80.
gamma = 80.,
omega = omega,
frame_rate = fps
)
print('omega',binary.omega)
# evolve the binary over one orbit
n_frames = 30
n_frames = int(length*fps)
event_pos_dict = {
var: np.empty(n_frames)
......@@ -77,14 +84,13 @@ def main():
pos_dict[event] = event_pos_dict
binary_dict[event] = binary
print(event_pos_dict['z1'],event_pos_dict['z2'])
artist_dict = {}
def init():
for ei,event in enumerate(events):
artist_dict['%s_m1'%event] = ax[ei].add_artist(Circle((event_pos_dict['x1'][0],event_pos_dict['y1'][0]),radius=binary_dict[event].m1/200,edgecolor='white',facecolor='black'))
artist_dict['%s_m2'%event] = ax[ei].add_artist(Circle((event_pos_dict['x2'][0],event_pos_dict['y2'][0]),radius=binary_dict[event].m2/200,edgecolor='white',facecolor='black'))
zorder_1 = int(event_pos_dict['z1'][0]>event_pos_dict['z2'][0])
artist_dict['%s_m1'%event] = ax[ei].add_artist(Circle((pos_dict[event]['x1'][0],pos_dict[event]['y1'][0]),radius=binary_dict[event].m1/200,edgecolor='white',facecolor='black'))
artist_dict['%s_m2'%event] = ax[ei].add_artist(Circle((pos_dict[event]['x2'][0],pos_dict[event]['y2'][0]),radius=binary_dict[event].m2/200,edgecolor='white',facecolor='black'))
zorder_1 = int(pos_dict[event]['z1'][0]>pos_dict[event]['z2'][0])
zorder_2 = ~zorder_1
artist_dict['%s_m1'%event].set_zorder(zorder_1)
artist_dict['%s_m2'%event].set_zorder(zorder_2)
......@@ -96,9 +102,9 @@ def main():
def animate(i):
for ei,event in enumerate(events):
artist_dict['%s_m1'%event].set_center((event_pos_dict['x1'][i],event_pos_dict['y1'][i]))
artist_dict['%s_m2'%event].set_center((event_pos_dict['x2'][i],event_pos_dict['y2'][i]))
if event_pos_dict['z1'][i]>event_pos_dict['z2'][i]:
artist_dict['%s_m1'%event].set_center((pos_dict[event]['x1'][i],pos_dict[event]['y1'][i]))
artist_dict['%s_m2'%event].set_center((pos_dict[event]['x2'][i],pos_dict[event]['y2'][i]))
if pos_dict[event]['z1'][i]>pos_dict[event]['z2'][i]:
zorder_1 = 2
zorder_2 = 1
else:
......@@ -110,8 +116,8 @@ def main():
return artist_dict
anim = animation.FuncAnimation(fig,animate,init_func=init,frames=n_frames)
anim.save('orbit.gif',fps=30,dpi=300,writer='imagemagick',extra_args=['-vcodec', 'libx264'])
#anim.save('orbit.gif',fps=fps,writer='imagemagick',extra_args=['-vcodec', 'libx264'])
anim.save('orbit.mp4',fps=fps,extra_args=['-vcodec', 'libx264'])
if __name__ == '__main__':
main()
......@@ -68,8 +68,8 @@ class Binary:
return self._phase1
@phase1.setter
def phase1(self,gamma_rad):
self._phase1 = gamma_rad % 2*np.pi
def phase1(self,phase_rad):
self._phase1 = phase_rad % 2*np.pi
@property
def phase2(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment