def main(args: MyProgramArgs):
    total_frames = args.fps * args.duration

    logtime = False
    cmap: Colormap = matplotlib.cm.get_cmap("Blues")

    fig1 = plt.figure(figsize=figsize)

    l: PathCollection = plt.scatter([1], [1])

    fn = filename_from_argv()
    sa = SimulationArchive(str(fn.with_suffix(".bin")))
    ed = ExtraData.load(fn)

    plt.xlim(0, 10)
    plt.xlabel("a")
    title: Text = plt.title("0")

    if args.y_axis == "e":
        plt.ylim(-0.1, 1)  # e
        plt.ylabel("e")
    elif args.y_axis == "i":
        plt.ylim(0, 10)  # i
        plt.ylabel("i")
    elif args.y_axis == "Omega":
        plt.ylim(0, 360)  # i
        plt.ylabel("Omega")

    # plt.yscale("log")
    # plt.ylim(1e-7,1e-3)

    # plt.ylim(-0.05, 0.2)  # i
    # plt.ylabel("water_fraction")

    fig1.colorbar(ScalarMappable(norm=Normalize(vmin=-5, vmax=0), cmap=cmap),
                  label="log(water fraction)")

    plt.tight_layout()
    line_ani = animation.FuncAnimation(fig1,
                                       update_plot,
                                       total_frames,
                                       fargs=(args, sa, ed, l, title),
                                       interval=1000 / args.fps,
                                       repeat=False)
    if args.save_video:
        name = f"{args.y_axis}_{args.log_time}"
        line_ani.save(str(fn.with_suffix(f".{name}.mp4")), dpi=200)
    else:
        plt.show()
Beispiel #2
0
import matplotlib.pyplot as plt
from rebound import SimulationArchive, Particle, Simulation

from extradata import ExtraData
from utils import filename_from_argv, plot_settings, is_ci

plot_settings()

fn = filename_from_argv()
sa = SimulationArchive(str(fn.with_suffix(".bin")))
ed = ExtraData.load(fn)
print(ed.meta)

data = {}
sim: Simulation
print(f"{len(sa)} Snapshots found")
for sim in sa:
    t = sim.t
    for pn in range(1, sim.N):
        part: Particle = sim.particles[pn]
        hash = part.hash.value
        if hash not in data:
            data[hash] = ([], [])
        data[hash][0].append(t)
        data[hash][1].append(part.a)

for name, d in data.items():
    times, values = d
    print(list(map(len, [times, values])))
    if False:
        plt.scatter(times, values, label=name, s=.9)