1
0
Fork 0
mirror of https://github.com/Findus23/rebound-collisions.git synced 2024-09-19 15:53:48 +02:00
rebound-collisions/analyze.py

40 lines
1 KiB
Python
Raw Normal View History

2020-03-31 15:39:59 +02:00
import matplotlib.pyplot as plt
from rebound import SimulationArchive, Particle, Simulation
2020-03-31 15:39:59 +02:00
from extradata import ExtraData
2021-05-03 16:42:34 +02:00
from utils import filename_from_argv, plot_settings, is_ci
plot_settings()
2020-03-31 15:39:59 +02:00
fn = filename_from_argv()
sa = SimulationArchive(str(fn.with_suffix(".bin")))
2021-02-04 17:29:01 +01:00
ed = ExtraData.load(fn)
2020-04-02 12:54:11 +02:00
print(ed.meta)
2020-03-31 15:39:59 +02:00
data = {}
sim: Simulation
2021-01-04 14:48:48 +01:00
print(f"{len(sa)} Snapshots found")
for sim in sa:
t = sim.t
2020-03-31 15:39:59 +02:00
for pn in range(1, sim.N):
part: Particle = sim.particles[pn]
hash = part.hash.value
if hash not in data:
data[hash] = ([], [])
2020-04-02 12:54:11 +02:00
data[hash][0].append(t)
data[hash][1].append(part.a)
2020-03-31 15:39:59 +02:00
for name, d in data.items():
times, values = d
print(list(map(len, [times, values])))
2020-04-02 12:54:11 +02:00
if False:
2020-03-31 15:39:59 +02:00
plt.scatter(times, values, label=name, s=.9)
else:
plt.plot(times, values, label=name, linewidth=0.6)
2020-03-31 15:39:59 +02:00
# plt.legend()
# OrbitPlot(sim, slices=1)
plt.tight_layout()
2021-05-03 16:31:30 +02:00
if not is_ci():
plt.savefig("/home/lukas/tmp/time.pdf", transparent=True)
2020-03-31 15:39:59 +02:00
plt.show()