shamrock.utils.dump.ShamrockDumpHandleHelper#
- class shamrock.utils.dump.ShamrockDumpHandleHelper(model, dump_prefix, ext='.sham', metadata=False)#
Bases:
objectHelper class to handle Shamrock checkpoint dump files.
When
metadatais enabled at construction, a JSON companion file is written and read alongside each checkpoint to store simulation metadata.Methods
Get the name of the dump file (extension from self.ext)
Get the name of the dump file with the extension
Find the last dump number.
Load a dump file.
Load the last dump or call a function if no dump is found.
Purge old dump files.
Write a dump file.
Production run: Circular disc & pseudo-newtonian Paczynski Wiita potential
Production run: Circular disc & pseudo-newtonian Paczynski Wiita potential- get_last_dump() int | None#
Find the last dump number.
When metadata mode is enabled, validate that checkpoint dumps and JSON companion files agree on the latest checkpoint index.
- load_dump(idump) dict | None#
Load a dump file.
Parameters#
- idumpint
The dump identifier to load.
Returns#
- dict or None
If
metadatawas enabled at construction, the JSON metadata loaded from the companion file; otherwiseNone.
- load_last_dump_or(functor_no_last_dump) dict | None#
Load the last dump or call a function if no dump is found.
Parameters#
- functor_no_last_dumpcallable
Setup function invoked when no dump exists. Must not return a value.
Returns#
- dict or None
If a dump was loaded and
metadatawas enabled at construction, the JSON metadata from the companion; otherwiseNone.
- purge_old_dumps(keep_first=1, keep_last=3) None#
Purge old dump files.
When metadata mode is enabled, also purge old JSON companion files.
Parameters#
- keep_firstint, optional
Number of oldest dump files to keep (default is 1, i.e. keep the first dump).
- keep_lastint, optional
Number of newest dump files to keep (default is 3, i.e. keep the last 3 dumps).
Returns#
- None
This method does not return a value.
- write_dump(idump, metadata=None, purge_old_dumps=False, keep_first=1, keep_last=3) None#
Write a dump file.
Parameters#
- idumpint
The dump identifier to write.
- metadataobject, optional
JSON-serializable metadata stored in a
.jsoncompanion next to the checkpoint. Required whenmetadatawas enabled at construction.- purge_old_dumpsbool, optional
Whether to purge old dumps (default is False).
- keep_firstint, optional
Number of oldest dump files to keep (default is 1, i.e. keep the first dump).
- keep_lastint, optional
Number of newest dump files to keep (default is 3, i.e. keep the last 3 dumps).
Returns#
- None
This method does not return a value.