how to read snapshots in a loop
teuben opened this issue · 4 comments
Environment
Which version of REBOUND are you using and on what operating system?
- REBOUND Version: 4.0.3
- API interface: C
- Operating System (including version): Linux
Goal
I'm trying to read a SA with many snapshots in a loop and convert to another format. So the essence of the code is:
struct reb_simulationarchive *sa=reb_simulationarchive_create_from_file(infile);
for (int64_t j=0; j < sa->nblobs; j++) {
// You have to reset function pointers after creating a reb_simulation struct with a binary file.
struct reb_simulation* r = reb_simulation_create_from_simulationarchive(sa, j);
...
reb_simulation_free(r);
}
reb_simulationarchive_free(sa);
but in reb_simulation_create_from_simulationarchive
I keep getting a warning I need to reset the function pointers, which I can't do until I have r
according to reb_simulation_reset_function_pointers
. I suspect I have a wrong usage pattern, but how do I process these snapshots?
You're doing it right. You might not need to set the function pointers if you only output data and don't run it.
True, i'm only using the data. But is it possible to avoid these warnings? For large numbers of snapshots this gets a little annoying.
You can use the function reb_simulation_create_from_simulationarchive_with_messages
and then ignore the error message.