ADCS.helpers.animations.godot.writer module¶
- class ADCS.helpers.animations.godot.writer.VizLogWriter(path, channels, epoch_jd_tt, epoch_iso_utc=None, scene=None, metadata=None, overwrite=False, flush_every=256)[source]¶
Bases:
objectWrite an
adcs-vizlogdirectory (format version 1).Layout:
<path>/manifest.json metadata, channel table, runs <path>/scene.json static spacecraft / scene description <path>/assets/models/ model LOD files referenced by the scene <path>/runs/<id>/<channel>.f64 little-endian float64, shape (n_rows, width) <path>/runs/<id>/rows.json {"n_rows": N, "complete": bool}
Every run contains every declared channel; missing values are written as NaN. Rows can be written in bulk (
write_run()) or appended as they are produced (append()), in which caserows.jsonis rewritten atomically at each flush so that a reader of an interrupted log sees only whole rows.- Parameters:
path (str | Path) – Output directory. Created if missing.
channels (Iterable[Channel]) – Channels every run will contain. Must include all
REQUIRED_CHANNELS.epoch_jd_tt (float) – Julian date (TT) that
t_s = 0refers to.epoch_iso_utc (str | None) – Same instant as an ISO-8601 UTC string, for humans.
scene (Dict[str, Any] | None) – Static scene description written to
scene.json.metadata (Dict[str, Any] | None) – Extra manifest entries (
generator,ephemeris,eop, …).overwrite (bool) – Replace an existing vizlog at
path.flush_every (int) – Rows buffered per run before
append()flushes.
- append(run_id, **row)[source]¶
Append one row to a run started with
begin_run().- Parameters:
run_id (int | str) – Run identifier.
row (Any) – One value per channel name; omitted channels are NaN.
- Return type:
None
- begin_run(run_id, dt_s=None, **info)[source]¶
Start a run that rows will be appended to.
- Parameters:
run_id (int | str) – Run identifier (
[A-Za-z0-9_-], at most 64 characters).dt_s (float | None) – Nominal sample spacing [s], informational.
info (Any) – Extra per-run manifest entries (e.g.
seed).
- Returns:
The run id as a string.
- Return type:
str
- end_run(run_id)[source]¶
Flush a run and mark it complete.
- Parameters:
run_id (int | str)
- Return type:
None
- flush(run_id=None)[source]¶
Write buffered rows of one run (or all runs) to disk.
- Parameters:
run_id (int | str | None)
- Return type:
None
- write_run(run_id, columns, dt_s=None, **info)[source]¶
Write a complete run from whole columns.
- Parameters:
run_id (int | str) – Run identifier.
columns (Dict[str, ndarray]) –
{channel: array}with shape(n_rows, width)(or(n_rows,)for width 1). Omitted channels are NaN.dt_s (float | None) – Nominal sample spacing [s], informational.
info (Any) – Extra per-run manifest entries.
- Return type:
None
- ADCS.helpers.animations.godot.writer.make_manifest(channels, epoch_jd_tt, epoch_iso_utc=None, metadata=None)[source]¶
Build the
manifest.jsoncontent, without runs.Shared by
VizLogWriterand the live stream, so a streamed session describes itself exactly as a file would.- Parameters:
channels (Iterable[Channel]) – Channels every run contains.
epoch_jd_tt (float) – Julian date (TT) that
t_s = 0refers to.epoch_iso_utc (str | None) – Same instant as ISO-8601 UTC, for humans.
metadata (Dict[str, Any] | None) – Extra manifest entries.
- Returns:
Manifest dictionary with an empty
runslist.- Return type:
Dict[str, Any]