Commit 86924668 authored by Zoheyr Doctor's avatar Zoheyr Doctor 🔭
Browse files

edited scripts to use Binary objects internal position calculator

parent 129ca58d
......@@ -96,8 +96,6 @@ def main():
binary = Binary(
m1 = m1,
m2 = m2,
c1 = 'k',
c2 = 'k',
alpha = 45.,
beta = 20.,
gamma = 80.,
......@@ -108,24 +106,8 @@ def main():
# evolve the binary over one orbit
n_frames = int(length*fps)
# populate positions for event
event_pos_dict = {
var: np.empty(n_frames)
for var in ['x1','y1','z1','x2','y2','z2']
}
binary.evolve(n_frames)
for i in range(n_frames):
binary.orbit()
pos1,pos2 = binary.project()
event_pos_dict['z1'][i] = pos1[0]
event_pos_dict['z2'][i] = pos2[0]
event_pos_dict['x1'][i] = pos1[1]
event_pos_dict['y1'][i] = pos1[2]
event_pos_dict['x2'][i] = pos2[1]
event_pos_dict['y2'][i] = pos2[2]
# write out evolution to dictionary
pos_dict[event] = event_pos_dict
binary_dict[event] = binary
artist_dict = {} # dictionary for matplotlib artists
......@@ -133,16 +115,19 @@ def main():
def init():
for ei,event in enumerate(events):
# create artists for both stars
# create artists for both stars
z1,x1,y1 = binary_dict[event].pos1_projected[0,:]
z2,x2,y2 = binary_dict[event].pos2_projected[0,:]
artist_dict['%s_m1'%event] = ax[ei].add_artist(
Circle((pos_dict[event]['x1'][0],pos_dict[event]['y1'][0]),
Circle((x1,y1),
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]),
Circle((x2,y2),
radius=binary_dict[event].m2/200,
edgecolor='white',
facecolor='black'
......@@ -150,7 +135,7 @@ def main():
)
# make sure star that is closer is shown on top of the other
zorder_1 = int(pos_dict[event]['z1'][0]>pos_dict[event]['z2'][0])
zorder_1 = int(z1>z2)
zorder_2 = ~zorder_1
artist_dict['%s_m1'%event].set_zorder(zorder_1)
artist_dict['%s_m2'%event].set_zorder(zorder_2)
......@@ -169,11 +154,13 @@ def main():
for ei,event in enumerate(events):
# update positions of stars
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]))
z1,x1,y1 = binary_dict[event].pos1_projected[i,:]
z2,x2,y2 = binary_dict[event].pos2_projected[i,:]
artist_dict['%s_m1'%event].set_center((x1,y1))
artist_dict['%s_m2'%event].set_center((x2,y2))
# make sure star that is closer is shown on top of the other
if pos_dict[event]['z1'][i]>pos_dict[event]['z2'][i]:
if z1>z2:
zorder_1 = 2
zorder_2 = 1
else:
......
......@@ -73,12 +73,10 @@ def main():
) for event in events
}
pos_dict = {} # dictionary for all compact object positions
binary_dict = {} # dictionary for all Binary objects
# loop over all events
for event in events:
print('evolving ',event)
event_pos_dict = {} # dictionary for positions of this event
m1 = data[event]['mass_1_source']['med']
m2 = data[event]['mass_2_source']['med']
......@@ -86,8 +84,6 @@ def main():
binary = Binary(
m1 = m1,
m2 = m2,
c1 = 'k',
c2 = 'k',
alpha = 45.,
beta = 20.,
gamma = 80.,
......@@ -97,25 +93,9 @@ def main():
# evolve the binary over one orbit
n_frames = int(length*fps)
# populate positions for event
event_pos_dict = {
var: np.empty(n_frames)
for var in ['x1','y1','z1','x2','y2','z2']
}
for i in range(n_frames):
binary.orbit()
pos1,pos2 = binary.project()
event_pos_dict['z1'][i] = pos1[0]
event_pos_dict['z2'][i] = pos2[0]
event_pos_dict['x1'][i] = pos1[1]
event_pos_dict['y1'][i] = pos1[2]
event_pos_dict['x2'][i] = pos2[1]
event_pos_dict['y2'][i] = pos2[2]
binary.evolve(n_frames)
# write out evolution to dictionary
pos_dict[event] = event_pos_dict
binary_dict[event] = binary
......@@ -125,17 +105,20 @@ def main():
artist_dict = {} # dictionary for matplotlib artists
def init():
z1,x1,y1 = binary_dict[event].pos1_projected[0,:]
z2,x2,y2 = binary_dict[event].pos2_projected[0,:]
# create artists for both stars
artist_dict['%s_m1'%event] = ax.add_artist(
Circle((pos_dict[event]['x1'][0],pos_dict[event]['y1'][0]),
Circle((x1,y1),
radius=binary_dict[event].m1/200,
edgecolor='white',
facecolor='black'
)
)
artist_dict['%s_m2'%event] = ax.add_artist(
Circle((pos_dict[event]['x2'][0],pos_dict[event]['y2'][0]),
Circle((x2,y2),
radius=binary_dict[event].m2/200,
edgecolor='white',
facecolor='black'
......@@ -143,7 +126,7 @@ def main():
)
# make sure star that is closer is shown on top of the other
zorder_1 = int(pos_dict[event]['z1'][0]>pos_dict[event]['z2'][0])
zorder_1 = int(z1>z2)
zorder_2 = ~zorder_1
artist_dict['%s_m1'%event].set_zorder(zorder_1)
artist_dict['%s_m2'%event].set_zorder(zorder_2)
......@@ -155,13 +138,15 @@ def main():
return artist_dict
def animate(i):
# update positions of stars
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]))
z1,x1,y1 = binary_dict[event].pos1_projected[i,:]
z2,x2,y2 = binary_dict[event].pos2_projected[i,:]
artist_dict['%s_m1'%event].set_center((x1,y1))
artist_dict['%s_m2'%event].set_center((x2,y2))
# make sure star that is closer is shown on top of the other
if pos_dict[event]['z1'][i]>pos_dict[event]['z2'][i]:
if z1>z2:
zorder_1 = 2
zorder_2 = 1
else:
......
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