hannorein/rebound

Removing snapshots from Simulation Archive

Closed this issue · 4 comments

Hi all,

I think that, if not too difficult to implement, it could be useful to have a way to remove snapshot from within a simulation archive.

Right now, as far as I understand it, the only way to do so would be to import the archive and save it again omitting the snapshot.
For example:

sa = rebound.Simulationarchive("archive.bin")

os.remove("archive.bin")

for i, sim in enumerate(sa):
    if i == 4:
        continue
    else:
        sim.save_to_file("archive.bin")

I understand that this is more of a "quality of life" feature than anything else, but it would be very handy to have it.

Let me know if you think that it's not worth it or if there's any faster way to do this without adding a new feature.

Thank you,
Alessandro

I'm not sure this is something I have time to implement right now. So in the meantime, I would do what something like what you outline above: Read in all the snapshots and then output them again without whatever snapshot you're trying to delete. If speed is an issue, this could be done faster in C.

Thank you very much for the answer!
The problem I'm facing is that of minimizing I/O time on cluster, which I think it's something that won't be too affected by switching to C, but I'll give it a try.

Thanks again!

The fastest way would be to find the length and the offset of the snapshot in the binary file, and then remove it. If this is something you want to do, have a look at the documentation of the binary format: https://rebound.readthedocs.io/en/latest/binaryformat/

Thank you, I'll definitely have a look