openc3-cosmos-constellation 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/microservices/BRIDGE/bridge.py +64 -27
- data/microservices/BRIDGE/constellation_space/results.py +38 -2
- data/targets/CONSTELLATION/cmd_tlm/tlm.txt +20 -16
- data/tools/constellationforecast/forecast-view.js +14 -13
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb5edbac0bd29425edc88aec0efa8f52ca7c9ba2c1fd2055f7e24be0626cc0ae
|
|
4
|
+
data.tar.gz: 14b8f6b2f44ea09a03870f890d05ee9e62c1fdb2527432b5314d03a8fe571f6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8620e33fbacc23d7512c315f38db1fb2414d5b77c6cdc78c60c0d84bf548c22ceae7782a7c8d471bc4fe3f716ddcbc0e72f636b914f6667af15442a4615b2ca2
|
|
7
|
+
data.tar.gz: '0699f4dfd88fedd63752bf819b8d11e3a7af7105c042950569826532c6df9feb6f2e0aee1250ed1011c1a6548d4c11a7540cfba594f15a1b467bbfcc8ec6782f'
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.
|
|
2
|
-
# (or ./openc3.sh cli rake build VERSION=0.
|
|
1
|
+
# Builds openc3-cosmos-constellation-<VERSION>.gem: rake build VERSION=0.9.0
|
|
2
|
+
# (or ./openc3.sh cli rake build VERSION=0.9.0 inside a COSMOS checkout).
|
|
3
3
|
PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
|
|
4
4
|
|
|
5
5
|
# The tool draws the shared Constellation Forecast view, copied in from this repo when it is here.
|
|
@@ -13,7 +13,7 @@ SHARED_RESULTS = '../../clients/python/src/constellation_space/results.py'
|
|
|
13
13
|
SHARED_LICENSE = '../../LICENSE'
|
|
14
14
|
|
|
15
15
|
task :build do
|
|
16
|
-
abort('VERSION is required: rake build VERSION=0.
|
|
16
|
+
abort('VERSION is required: rake build VERSION=0.9.0') unless ENV['VERSION']
|
|
17
17
|
FileUtils.cp(SHARED_VIEW, VIEW) if File.exist?(SHARED_VIEW)
|
|
18
18
|
abort("#{VIEW} is missing: copy bridges/shared/forecast-view.js there") unless File.exist?(VIEW)
|
|
19
19
|
if File.exist?(SHARED_RESULTS)
|
|
@@ -9,7 +9,8 @@ target's packets (targets/CONSTELLATION/cmd_tlm/tlm.txt):
|
|
|
9
9
|
NEXT_PASS the next predicted pass and its expected GB, and whether it is at risk
|
|
10
10
|
as the Platform says (AT_RISK), against the contract minimum
|
|
11
11
|
NEXT_PASS_<NAME> the same for each satellite the plugin's `satellites` variable names
|
|
12
|
-
NEXT_24H passes and expected GB over the
|
|
12
|
+
NEXT_24H passes and expected GB over the day from when the run was made, as the
|
|
13
|
+
API totals them (only once it serves totals), and how many are at risk
|
|
13
14
|
SWAP the soonest rain-fade swap to decide, as advice (add a backup pass or move to
|
|
14
15
|
it), its backup's AOS, LOS and GB, the gain, and minutes left (limits go
|
|
15
16
|
yellow, then red)
|
|
@@ -60,7 +61,7 @@ from typing import Any
|
|
|
60
61
|
|
|
61
62
|
from constellation_space import results
|
|
62
63
|
|
|
63
|
-
VERSION = "0.
|
|
64
|
+
VERSION = "0.9.0"
|
|
64
65
|
TARGET = "CONSTELLATION"
|
|
65
66
|
POLL_S = int(os.environ.get("POLL_SECONDS", "15"))
|
|
66
67
|
# COSMOS shows a packet stale 30 s after its last value: re-inject every poll so a quiet feed
|
|
@@ -134,6 +135,7 @@ TIMELINE_ON = os.environ.get("TIMELINE", "off").strip().lower() == "on"
|
|
|
134
135
|
# takes ids longer than these, so a value is cut to fit. Its OVERFLOW TRUNCATE does not do it for
|
|
135
136
|
# a string in the Python decom of 7.0 to 7.5.
|
|
136
137
|
STRING_BYTES = {
|
|
138
|
+
"SOURCE": 32,
|
|
137
139
|
"SATELLITE": 64,
|
|
138
140
|
"ANTENNA": 64,
|
|
139
141
|
"AOS": 32,
|
|
@@ -157,9 +159,14 @@ STRING_BYTES = {
|
|
|
157
159
|
|
|
158
160
|
|
|
159
161
|
def fit(values: dict[str, Any]) -> dict[str, Any]:
|
|
160
|
-
"""The values with each string cut to its item's bytes, never mid-character
|
|
162
|
+
"""The values with each string cut to its item's bytes, never mid-character, and each float
|
|
163
|
+
rounded to 3 decimals, finer than any item shows, so none reads with float noise."""
|
|
161
164
|
return {
|
|
162
|
-
k: v.encode()[: STRING_BYTES[k]].decode(errors="ignore")
|
|
165
|
+
k: v.encode()[: STRING_BYTES[k]].decode(errors="ignore")
|
|
166
|
+
if k in STRING_BYTES
|
|
167
|
+
else round(v, 3)
|
|
168
|
+
if isinstance(v, float)
|
|
169
|
+
else v
|
|
163
170
|
for k, v in values.items()
|
|
164
171
|
}
|
|
165
172
|
|
|
@@ -244,10 +251,11 @@ def documents(
|
|
|
244
251
|
blocks: list[str],
|
|
245
252
|
index: dict[str, Any],
|
|
246
253
|
now: datetime,
|
|
254
|
+
totals: dict[str, Any] | None = None,
|
|
247
255
|
) -> dict[str, dict[str, Any]]:
|
|
248
|
-
"""The run as the Constellation Forecast view reads it: workflow-<slug>.json,
|
|
249
|
-
with this workflow's entry replaced. Kept
|
|
250
|
-
(a test compares them)."""
|
|
256
|
+
"""The run as the Constellation Forecast view reads it: workflow-<slug>.json, with the run's
|
|
257
|
+
totals as the API serves them, and index.json with this workflow's entry replaced. Kept
|
|
258
|
+
identical to publish_widget() in the Yamcs bridge (a test compares them)."""
|
|
251
259
|
slug = resource.get("constellation.workflow") or "workflow"
|
|
252
260
|
entry = {
|
|
253
261
|
"workflow": slug,
|
|
@@ -261,7 +269,7 @@ def documents(
|
|
|
261
269
|
workflows = {w["workflow"]: w for w in index.get("workflows", [])}
|
|
262
270
|
workflows[slug] = entry
|
|
263
271
|
return {
|
|
264
|
-
f"workflow-{slug}.json": {**entry, "items": items},
|
|
272
|
+
f"workflow-{slug}.json": {**entry, "totals": totals, "items": items},
|
|
265
273
|
"index.json": {"workflows": sorted(workflows.values(), key=lambda w: w["workflow"])},
|
|
266
274
|
}
|
|
267
275
|
|
|
@@ -274,12 +282,15 @@ def bucket() -> tuple[Any, str]:
|
|
|
274
282
|
|
|
275
283
|
|
|
276
284
|
def publish_documents(
|
|
277
|
-
resource: dict[str, Any],
|
|
285
|
+
resource: dict[str, Any],
|
|
286
|
+
items: list[dict[str, Any]],
|
|
287
|
+
blocks: list[str],
|
|
288
|
+
totals: dict[str, Any] | None = None,
|
|
278
289
|
) -> None:
|
|
279
290
|
client, name = bucket()
|
|
280
291
|
found = client.get_object(bucket=name, key=f"{DOCS}/index.json")
|
|
281
292
|
index = json.loads(found["Body"].read()) if found else {}
|
|
282
|
-
for key, doc in documents(resource, items, blocks, index, datetime.now(UTC)).items():
|
|
293
|
+
for key, doc in documents(resource, items, blocks, index, datetime.now(UTC), totals).items():
|
|
283
294
|
body = json.dumps(doc).encode()
|
|
284
295
|
client.put_object(
|
|
285
296
|
bucket=name, key=f"{DOCS}/{key}", body=body, content_type="application/json"
|
|
@@ -347,6 +358,7 @@ NO_PASS: dict[str, Any] = {
|
|
|
347
358
|
"CONTRACT_MIN_GB": 0.0,
|
|
348
359
|
# A state item: COSMOS takes its state's name for a converted value.
|
|
349
360
|
"AT_RISK": "NO",
|
|
361
|
+
"SOURCE": "",
|
|
350
362
|
}
|
|
351
363
|
|
|
352
364
|
# The same for CAPACITY and MODCOD, with no antenna-day or no plan ahead.
|
|
@@ -359,6 +371,7 @@ NO_CAPACITY: dict[str, Any] = {
|
|
|
359
371
|
"GB_P50": 0.0,
|
|
360
372
|
"TIGHTEST_ANTENNA": "NONE",
|
|
361
373
|
"TIGHTEST_GB_P50": 0.0,
|
|
374
|
+
"PARTIAL_DAY": "NO",
|
|
362
375
|
}
|
|
363
376
|
NO_MODCOD: dict[str, Any] = {
|
|
364
377
|
"SATELLITE": "NONE",
|
|
@@ -420,6 +433,8 @@ def capacity_packet(items: list[dict[str, Any]], now: datetime) -> dict[str, Any
|
|
|
420
433
|
"GB_P50": round(sum(r["value"]["p50"] for r in rows), 3),
|
|
421
434
|
"TIGHTEST_ANTENNA": tightest["entity"]["id"],
|
|
422
435
|
"TIGHTEST_GB_P50": round(tightest["value"]["p50"], 3),
|
|
436
|
+
# The run's window covers only part of the day: its numbers are that part's.
|
|
437
|
+
"PARTIAL_DAY": "YES" if any(r["value"].get("partial_day") for r in rows) else "NO",
|
|
423
438
|
}
|
|
424
439
|
|
|
425
440
|
|
|
@@ -489,6 +504,7 @@ def pass_values(item: dict[str, Any], minimum: float | None) -> dict[str, Any]:
|
|
|
489
504
|
"MAX_ELEVATION": float(results.max_elevation(item) or 0.0),
|
|
490
505
|
"CONTRACT_MIN_GB": float(minimum or 0.0),
|
|
491
506
|
"AT_RISK": "YES" if at_risk(item, minimum) else "NO",
|
|
507
|
+
"SOURCE": str(item["entity"].get("source") or ""),
|
|
492
508
|
}
|
|
493
509
|
|
|
494
510
|
|
|
@@ -553,17 +569,20 @@ def packets(
|
|
|
553
569
|
minimum: float | None = None,
|
|
554
570
|
satellites: dict[str, str] | None = None,
|
|
555
571
|
waiting: list[dict[str, Any]] | None = None,
|
|
572
|
+
day: dict[str, Any] | None = None,
|
|
556
573
|
) -> dict[str, dict[str, Any]]:
|
|
557
574
|
"""The CONSTELLATION packets for what is forecast now, from spec items: values only, ready to
|
|
558
575
|
inject. `pending` is how many swaps the newest swap run holds for approval in Constellation,
|
|
559
576
|
`minimum` the workspace's contract minimum in GB, `satellites` those with a NEXT_PASS packet
|
|
560
|
-
of their own (Constellation id to COSMOS name),
|
|
561
|
-
GET /predictions/actions (None: no HELD packet).
|
|
577
|
+
of their own (Constellation id to COSMOS name), `waiting` the actions read from
|
|
578
|
+
GET /predictions/actions (None: no HELD packet), and `day` the pass run's totals.next_24h as
|
|
579
|
+
the API serves it: NEXT_24H's passes and GB are its satellites', which overlap nowhere, never
|
|
580
|
+
the passes summed here (None: no NEXT_24H)."""
|
|
562
581
|
upcoming = sorted(
|
|
563
582
|
(p for p in passes if datetime.fromisoformat(p["until"]) > now),
|
|
564
583
|
key=lambda p: p["target_at"],
|
|
565
584
|
)
|
|
566
|
-
|
|
585
|
+
upcoming_day = [
|
|
567
586
|
p for p in upcoming if datetime.fromisoformat(p["target_at"]) < now + timedelta(hours=24)
|
|
568
587
|
]
|
|
569
588
|
open_swaps = sorted(
|
|
@@ -571,15 +590,21 @@ def packets(
|
|
|
571
590
|
key=lambda s: s["action"]["deadline"],
|
|
572
591
|
)
|
|
573
592
|
out: dict[str, dict[str, Any]] = {
|
|
574
|
-
"NEXT_24H": {
|
|
575
|
-
"PASSES": len(day),
|
|
576
|
-
"EXPECTED_GB_P10": round(sum(results.expected_gb(p)["p10"] for p in day), 3),
|
|
577
|
-
"EXPECTED_GB_P50": round(sum(results.expected_gb(p)["p50"] for p in day), 3),
|
|
578
|
-
"AT_RISK": sum(at_risk(p, minimum) for p in day),
|
|
579
|
-
},
|
|
580
593
|
"NEXT_PASS": {**NO_PASS, "CONTRACT_MIN_GB": float(minimum or 0.0)},
|
|
581
594
|
"SWAP": {**NO_SWAP, "PENDING": pending},
|
|
582
595
|
}
|
|
596
|
+
if day is not None:
|
|
597
|
+
satellites_day = day["by_satellite"].values()
|
|
598
|
+
out = {
|
|
599
|
+
"NEXT_24H": {
|
|
600
|
+
"PASSES": sum(s["counted_passes"] for s in satellites_day),
|
|
601
|
+
# Deprecated: the API totals no p10.
|
|
602
|
+
"EXPECTED_GB_P10": 0.0,
|
|
603
|
+
"EXPECTED_GB_P50": round(sum(s["gb"] for s in satellites_day), 3),
|
|
604
|
+
"AT_RISK": sum(at_risk(p, minimum) for p in upcoming_day),
|
|
605
|
+
},
|
|
606
|
+
**out,
|
|
607
|
+
}
|
|
583
608
|
if waiting is not None:
|
|
584
609
|
out["HELD"] = held_packet(waiting, now)
|
|
585
610
|
# The next AOS, as the Forecast tool shows it: a pass already under way counts in the day only.
|
|
@@ -634,6 +659,8 @@ class Forecast:
|
|
|
634
659
|
self.held: list[str | None] = []
|
|
635
660
|
self.capacity: list[dict[str, Any]] | None = None
|
|
636
661
|
self.plans: list[dict[str, Any]] | None = None
|
|
662
|
+
# The pass run's totals.next_24h as the API serves it; None when it serves none.
|
|
663
|
+
self.day: dict[str, Any] | None = None
|
|
637
664
|
self.run: dict[str, Any] = {}
|
|
638
665
|
# Approvals already reported carried out, by decision: each run shows them again.
|
|
639
666
|
self.acted: dict[str, str] = {}
|
|
@@ -644,7 +671,12 @@ class Forecast:
|
|
|
644
671
|
self.swap_workflows: list[str] = []
|
|
645
672
|
self.waiting: list[dict[str, Any]] = []
|
|
646
673
|
|
|
647
|
-
def take(
|
|
674
|
+
def take(
|
|
675
|
+
self,
|
|
676
|
+
resource: dict[str, Any],
|
|
677
|
+
items: list[dict[str, Any]],
|
|
678
|
+
totals: dict[str, Any] | None = None,
|
|
679
|
+
) -> int:
|
|
648
680
|
answers = resource.get("constellation.template") or results.kind(items)
|
|
649
681
|
if answers == "rain-fade-swap":
|
|
650
682
|
self.swaps = swap_items(items)
|
|
@@ -658,6 +690,7 @@ class Forecast:
|
|
|
658
690
|
self.plans = modcod_plans(items)
|
|
659
691
|
elif answers == "pass-yield":
|
|
660
692
|
self.passes = priced_passes(items)
|
|
693
|
+
self.day = (totals or {}).get("next_24h")
|
|
661
694
|
self.run = {
|
|
662
695
|
"WORKFLOW": resource.get("constellation.workflow") or "",
|
|
663
696
|
"TEMPLATE": answers,
|
|
@@ -691,6 +724,7 @@ class Forecast:
|
|
|
691
724
|
self.minimum,
|
|
692
725
|
SATELLITES,
|
|
693
726
|
self.waiting if self.swap_workflows else None,
|
|
727
|
+
self.day,
|
|
694
728
|
)
|
|
695
729
|
if self.passes is None:
|
|
696
730
|
for name in [n for n in out if n == "NEXT_24H" or n.startswith("NEXT_PASS")]:
|
|
@@ -783,7 +817,8 @@ class Delivered:
|
|
|
783
817
|
self.readings: dict[str, list[list[float]]] = {}
|
|
784
818
|
# pass id -> the pass, from the forecast, until it is measured or given up.
|
|
785
819
|
self.watch: dict[str, dict[str, Any]] = {}
|
|
786
|
-
# pass id -> when its record was sent, kept 7 days so no pass is
|
|
820
|
+
# pass id -> when its record was sent or it was given up, kept 7 days so no pass is
|
|
821
|
+
# sent, or said given up, twice.
|
|
787
822
|
self.sent: dict[str, float] = {}
|
|
788
823
|
# The key Constellation refused telemetry:write for; sending waits for another.
|
|
789
824
|
self.refused = ""
|
|
@@ -898,9 +933,8 @@ class Delivered:
|
|
|
898
933
|
records.append((pid, record))
|
|
899
934
|
return records, dropped
|
|
900
935
|
|
|
901
|
-
def drop(self, pids: dict[str, str]) -> None:
|
|
902
|
-
|
|
903
|
-
self.watch.pop(pid, None)
|
|
936
|
+
def drop(self, pids: dict[str, str], now_s: float) -> None:
|
|
937
|
+
self.mark_sent(list(pids), now_s)
|
|
904
938
|
|
|
905
939
|
def mark_sent(self, pids: list[str], now_s: float) -> None:
|
|
906
940
|
for pid in pids:
|
|
@@ -931,7 +965,7 @@ def measure_delivered(delivered: Delivered, forecast: Forecast, key: str, said:
|
|
|
931
965
|
records, dropped = delivered.due(now)
|
|
932
966
|
for pid, why in dropped.items():
|
|
933
967
|
log(f"no outcome for {pid}: {why}")
|
|
934
|
-
delivered.drop(dropped)
|
|
968
|
+
delivered.drop(dropped, now.timestamp())
|
|
935
969
|
if not records or key == delivered.refused:
|
|
936
970
|
return bool(dropped)
|
|
937
971
|
try:
|
|
@@ -1243,7 +1277,10 @@ def main() -> None:
|
|
|
1243
1277
|
if bad := len(items) - len(good):
|
|
1244
1278
|
applied["malformed"] = applied.get("malformed", 0) + bad
|
|
1245
1279
|
items = good
|
|
1246
|
-
|
|
1280
|
+
totals = results.run_totals(
|
|
1281
|
+
call, resource.get("constellation.run_id"), lambda m: note(said, m)
|
|
1282
|
+
)
|
|
1283
|
+
applied["forecasts"] += forecast.take(resource, items, totals)
|
|
1247
1284
|
# Approved swaps it shows as approved advice: the platform shows them acted on.
|
|
1248
1285
|
shown = f"shown in the {TARGET} SWAP packet"
|
|
1249
1286
|
if acted := results.first_acted(
|
|
@@ -1252,7 +1289,7 @@ def main() -> None:
|
|
|
1252
1289
|
applied["acted"] = applied.get("acted", 0) + acted
|
|
1253
1290
|
widget = output_of(resource).get("widget") or {}
|
|
1254
1291
|
if widget.get("on"):
|
|
1255
|
-
publish_documents(resource, items, widget["blocks"])
|
|
1292
|
+
publish_documents(resource, items, widget["blocks"], totals)
|
|
1256
1293
|
applied["widget_updates"] = applied.get("widget_updates", 0) + 1
|
|
1257
1294
|
applied["parameters"] = forecast.publish(datetime.now(UTC))
|
|
1258
1295
|
refreshed = time.time()
|
|
@@ -169,13 +169,15 @@ def first_acted(
|
|
|
169
169
|
acted: dict[str, str],
|
|
170
170
|
outcomes: list[dict[str, str]] | None = None,
|
|
171
171
|
how: str = "",
|
|
172
|
+
unshown: Callable[[dict[str, Any]], str] = lambda item: "",
|
|
172
173
|
) -> int:
|
|
173
174
|
"""How many of these items are approved actions still open (before their deadline) carried
|
|
174
175
|
out for the first time. A bridge that enforces or shows approvals on every run, rather than
|
|
175
176
|
acting once, counts each decision (action_key) once: `acted` maps each counted to when it may
|
|
176
177
|
be forgotten (acted_until), kept in the bridge's state, and loses keys long over. Each one
|
|
177
178
|
counted goes in `outcomes` as acted (`how` says how), and an approval first seen past its
|
|
178
|
-
deadline as refused, each once
|
|
179
|
+
deadline, or one `unshown` gives a reason it is not carried out, as refused, each once
|
|
180
|
+
(outcome())."""
|
|
179
181
|
_drop_over(acted)
|
|
180
182
|
first = 0
|
|
181
183
|
for item in items:
|
|
@@ -185,6 +187,8 @@ def first_acted(
|
|
|
185
187
|
acted[key] = acted_until(item)
|
|
186
188
|
if past_deadline(item):
|
|
187
189
|
said = outcome(item, "refused", too_late(item))
|
|
190
|
+
elif why := unshown(item):
|
|
191
|
+
said = outcome(item, "refused", why)
|
|
188
192
|
else:
|
|
189
193
|
first += 1
|
|
190
194
|
said = outcome(item, "acted", how)
|
|
@@ -218,6 +222,18 @@ def minute(value: Any) -> str:
|
|
|
218
222
|
return at.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%MZ") if at else ""
|
|
219
223
|
|
|
220
224
|
|
|
225
|
+
# Where a pass comes from (its entity.source), as a person reads it; any other value as sent.
|
|
226
|
+
SOURCES = {
|
|
227
|
+
"computed": "computed from orbits",
|
|
228
|
+
"computed:continuous": "a continuous slot of one UTC day",
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def source(item: dict[str, Any]) -> str:
|
|
233
|
+
raw = str((item.get("entity") or {}).get("source") or "")
|
|
234
|
+
return SOURCES.get(raw, raw)
|
|
235
|
+
|
|
236
|
+
|
|
221
237
|
# Why a swap advises its action (the action's `reason`), as a person reads it.
|
|
222
238
|
REASONS = {
|
|
223
239
|
"adds_capacity": "it adds capacity",
|
|
@@ -492,6 +508,26 @@ def results_page(call: Callable[..., Any], consumer: str, after: str) -> dict[st
|
|
|
492
508
|
return call("GET", f"/predictions/feed?{urllib.parse.urlencode(query)}")
|
|
493
509
|
|
|
494
510
|
|
|
511
|
+
def run_totals(
|
|
512
|
+
call: Callable[..., Any], run_id: str | None, log: Callable[[str], None]
|
|
513
|
+
) -> dict[str, Any] | None:
|
|
514
|
+
"""The run's totals as the API serves them (GET /predictions?run_id=, its `totals`): every
|
|
515
|
+
count and GB a bridge shows over more than one pass comes from here, never its own sum, as
|
|
516
|
+
overlapping passes of one radio or one antenna count once only by the API's rule. None when
|
|
517
|
+
the API serves none (a run finished before it did, or a run of links) or the read fails: the
|
|
518
|
+
bridge then shows nothing for them."""
|
|
519
|
+
if not run_id:
|
|
520
|
+
return None
|
|
521
|
+
query = urllib.parse.urlencode({"run_id": run_id, "page_records": 1})
|
|
522
|
+
try:
|
|
523
|
+
body = call("GET", f"/predictions?{query}")
|
|
524
|
+
except Exception as exc:
|
|
525
|
+
log(f"could not read the totals of run {run_id} ({type(exc).__name__}: {exc}): showing none")
|
|
526
|
+
return None
|
|
527
|
+
totals = body.get("totals") if isinstance(body, dict) else None
|
|
528
|
+
return totals if isinstance(totals, dict) else None
|
|
529
|
+
|
|
530
|
+
|
|
495
531
|
def rest_of_run(call: Callable[..., Any], consumer: str, cursor: str, page: int) -> dict[str, Any]:
|
|
496
532
|
"""Page `page` of the run at `cursor`."""
|
|
497
533
|
query = {"cursor": cursor, "page": page, "page_records": PAGE_RECORDS, "consumer": consumer}
|
|
@@ -575,7 +611,7 @@ def report(
|
|
|
575
611
|
raise
|
|
576
612
|
error = _detail(getattr(exc, "body", b"") or b"").get("error")
|
|
577
613
|
why = {
|
|
578
|
-
"action_not_sent": "one was declined
|
|
614
|
+
"action_not_sent": "one was declined, so never sent",
|
|
579
615
|
"unknown_decision": "a decision on one changed after this run",
|
|
580
616
|
}.get(error, "this API does not take outcomes" if status == 422 else "it refused them")
|
|
581
617
|
log(
|
|
@@ -14,27 +14,28 @@ TELEMETRY CONSTELLATION <%= packet %> BIG_ENDIAN "Forecast: <%= what %>"
|
|
|
14
14
|
APPEND_ITEM ANTENNA 512 STRING "Antenna id"
|
|
15
15
|
APPEND_ITEM AOS 256 STRING "Predicted acquisition of signal, UTC"
|
|
16
16
|
APPEND_ITEM LOS 256 STRING "Predicted loss of signal, UTC"
|
|
17
|
-
APPEND_ITEM EXPECTED_GB_P10
|
|
17
|
+
APPEND_ITEM EXPECTED_GB_P10 64 FLOAT "Deprecated, kept only so layouts do not break. Read EXPECTED_GB_P50"
|
|
18
18
|
UNITS Gigabytes GB
|
|
19
19
|
FORMAT_STRING "%.3f"
|
|
20
|
-
APPEND_ITEM EXPECTED_GB_P50
|
|
20
|
+
APPEND_ITEM EXPECTED_GB_P50 64 FLOAT "Expected GB (p50)"
|
|
21
21
|
UNITS Gigabytes GB
|
|
22
22
|
FORMAT_STRING "%.3f"
|
|
23
|
-
APPEND_ITEM EXPECTED_GB_P90
|
|
23
|
+
APPEND_ITEM EXPECTED_GB_P90 64 FLOAT "Deprecated, kept only so layouts do not break. Read EXPECTED_GB_P50"
|
|
24
24
|
UNITS Gigabytes GB
|
|
25
25
|
FORMAT_STRING "%.3f"
|
|
26
|
-
APPEND_ITEM MAX_ELEVATION
|
|
26
|
+
APPEND_ITEM MAX_ELEVATION 64 FLOAT "Peak elevation"
|
|
27
27
|
UNITS Degrees deg
|
|
28
28
|
FORMAT_STRING "%.2f"
|
|
29
|
-
APPEND_ITEM CONTRACT_MIN_GB
|
|
29
|
+
APPEND_ITEM CONTRACT_MIN_GB 64 FLOAT "The workspace's contract minimum, 0 when none is set"
|
|
30
30
|
UNITS Gigabytes GB
|
|
31
31
|
FORMAT_STRING "%.3f"
|
|
32
32
|
APPEND_ITEM AT_RISK 8 UINT "At risk, as on the Platform: expected to deliver nothing or under the contract minimum, a value unfilled, or flagged"
|
|
33
33
|
STATE NO 0 GREEN
|
|
34
34
|
STATE YES 1 YELLOW
|
|
35
|
+
APPEND_ITEM SOURCE 256 STRING "Where the pass comes from: computed (from orbits) or computed:continuous (a geostationary slot of one UTC day)"
|
|
35
36
|
|
|
36
37
|
<%- end -%>
|
|
37
|
-
TELEMETRY CONSTELLATION NEXT_24H BIG_ENDIAN "Forecast:
|
|
38
|
+
TELEMETRY CONSTELLATION NEXT_24H BIG_ENDIAN "Forecast: the passes and GB of the day from when the pass run was made, as Constellation totals them"
|
|
38
39
|
ALLOW_SHORT
|
|
39
40
|
APPEND_ITEM PASSES 32 UINT "Predicted passes"
|
|
40
41
|
APPEND_ITEM EXPECTED_GB_P10 64 FLOAT "Deprecated, kept only so layouts do not break. Read EXPECTED_GB_P50"
|
|
@@ -52,16 +53,16 @@ TELEMETRY CONSTELLATION SWAP BIG_ENDIAN "Forecast: the soonest open rain-fade sw
|
|
|
52
53
|
APPEND_ITEM SATELLITE 512 STRING "Satellite id"
|
|
53
54
|
APPEND_ITEM ANTENNA 512 STRING "Antenna at risk"
|
|
54
55
|
APPEND_ITEM AOS 256 STRING "Predicted AOS of the pass at risk, UTC"
|
|
55
|
-
APPEND_ITEM KEEPS_GB_P10
|
|
56
|
+
APPEND_ITEM KEEPS_GB_P10 64 FLOAT "Deprecated, kept only so layouts do not break. Read EXPECTED_GB_P50"
|
|
56
57
|
UNITS Gigabytes GB
|
|
57
58
|
FORMAT_STRING "%.3f"
|
|
58
|
-
APPEND_ITEM EXPECTED_GB_P50
|
|
59
|
+
APPEND_ITEM EXPECTED_GB_P50 64 FLOAT "GB the pass is expected to carry in the rain (p50)"
|
|
59
60
|
UNITS Gigabytes GB
|
|
60
61
|
FORMAT_STRING "%.3f"
|
|
61
62
|
APPEND_ITEM BACKUP_ANTENNA 512 STRING "Antenna of the backup pass advised, or NONE"
|
|
62
63
|
APPEND_ITEM BACKUP_AOS 256 STRING "Backup pass AOS, UTC"
|
|
63
64
|
APPEND_ITEM DEADLINE 256 STRING "Decide by, UTC"
|
|
64
|
-
APPEND_ITEM MINUTES_TO_DEADLINE
|
|
65
|
+
APPEND_ITEM MINUTES_TO_DEADLINE 64 FLOAT "Minutes left to decide: yellow at 30 or less, red at 15 or less (99999 when no swap is open)"
|
|
65
66
|
UNITS Minutes min
|
|
66
67
|
FORMAT_STRING "%.1f"
|
|
67
68
|
LIMITS DEFAULT 1 ENABLED 15 30 100000 100000
|
|
@@ -70,10 +71,10 @@ TELEMETRY CONSTELLATION SWAP BIG_ENDIAN "Forecast: the soonest open rain-fade sw
|
|
|
70
71
|
APPEND_ITEM PENDING 32 UINT "Swaps held for approval in Constellation, deadline ahead"
|
|
71
72
|
APPEND_ITEM ADVICE 2048 STRING "The advice in words: add a backup pass (keep this one) or move to the backup, its gain and why"
|
|
72
73
|
APPEND_ITEM BACKUP_LOS 256 STRING "Backup pass LOS, UTC"
|
|
73
|
-
APPEND_ITEM BACKUP_GB
|
|
74
|
+
APPEND_ITEM BACKUP_GB 64 FLOAT "GB the backup pass is expected to carry (p50)"
|
|
74
75
|
UNITS Gigabytes GB
|
|
75
76
|
FORMAT_STRING "%.3f"
|
|
76
|
-
APPEND_ITEM GAIN_GB
|
|
77
|
+
APPEND_ITEM GAIN_GB 64 FLOAT "GB the advice adds over doing nothing (p50)"
|
|
77
78
|
UNITS Gigabytes GB
|
|
78
79
|
FORMAT_STRING "%.3f"
|
|
79
80
|
|
|
@@ -89,11 +90,11 @@ TELEMETRY CONSTELLATION HELD BIG_ENDIAN "The soonest rain-fade swap Constellatio
|
|
|
89
90
|
APPEND_ITEM ADVICE 2048 STRING "The advice in words: add a backup pass (keep this one) or move to the backup, its gain and why"
|
|
90
91
|
APPEND_ITEM BACKUP_ANTENNA 512 STRING "Antenna of the backup pass advised, or NONE"
|
|
91
92
|
APPEND_ITEM BACKUP_AOS 256 STRING "Backup pass AOS, UTC"
|
|
92
|
-
APPEND_ITEM GAIN_GB
|
|
93
|
+
APPEND_ITEM GAIN_GB 64 FLOAT "GB the advice adds over doing nothing (p50)"
|
|
93
94
|
UNITS Gigabytes GB
|
|
94
95
|
FORMAT_STRING "%.3f"
|
|
95
96
|
APPEND_ITEM DEADLINE 256 STRING "Decide by, UTC: it expires then and nothing is sent"
|
|
96
|
-
APPEND_ITEM MINUTES_TO_DEADLINE
|
|
97
|
+
APPEND_ITEM MINUTES_TO_DEADLINE 64 FLOAT "Minutes left to decide: yellow at 30 or less, red at 15 or less (99999 with nothing held)"
|
|
97
98
|
UNITS Minutes min
|
|
98
99
|
FORMAT_STRING "%.1f"
|
|
99
100
|
LIMITS DEFAULT 1 ENABLED 15 30 100000 100000
|
|
@@ -103,7 +104,7 @@ TELEMETRY CONSTELLATION CAPACITY BIG_ENDIAN "Forecast: one day's capacity across
|
|
|
103
104
|
APPEND_ITEM DAY 128 STRING "Day, UTC"
|
|
104
105
|
APPEND_ITEM ANTENNAS 32 UINT "Antennas forecast"
|
|
105
106
|
APPEND_ITEM PASSES 32 UINT "Predicted passes"
|
|
106
|
-
APPEND_ITEM SELLABLE_MIN
|
|
107
|
+
APPEND_ITEM SELLABLE_MIN 64 FLOAT "Sellable contact minutes"
|
|
107
108
|
UNITS Minutes min
|
|
108
109
|
FORMAT_STRING "%.1f"
|
|
109
110
|
APPEND_ITEM GB_P10 64 FLOAT "Deprecated, kept only so layouts do not break. Read GB_P50"
|
|
@@ -113,9 +114,12 @@ TELEMETRY CONSTELLATION CAPACITY BIG_ENDIAN "Forecast: one day's capacity across
|
|
|
113
114
|
UNITS Gigabytes GB
|
|
114
115
|
FORMAT_STRING "%.3f"
|
|
115
116
|
APPEND_ITEM TIGHTEST_ANTENNA 512 STRING "Antenna with the least expected GB that day"
|
|
116
|
-
APPEND_ITEM TIGHTEST_GB_P50
|
|
117
|
+
APPEND_ITEM TIGHTEST_GB_P50 64 FLOAT "Its expected GB (p50)"
|
|
117
118
|
UNITS Gigabytes GB
|
|
118
119
|
FORMAT_STRING "%.3f"
|
|
120
|
+
APPEND_ITEM PARTIAL_DAY 8 UINT "YES when the run's window covers only part of the day, so these are that part's numbers, not the day's"
|
|
121
|
+
STATE NO 0
|
|
122
|
+
STATE YES 1
|
|
119
123
|
|
|
120
124
|
TELEMETRY CONSTELLATION MODCOD BIG_ENDIAN "Forecast: the next pass's MODCOD plan"
|
|
121
125
|
ALLOW_SHORT
|
|
@@ -125,7 +129,7 @@ TELEMETRY CONSTELLATION MODCOD BIG_ENDIAN "Forecast: the next pass's MODCOD plan
|
|
|
125
129
|
APPEND_ITEM CHANGES 32 UINT "MODCOD changes over the pass, after the one at AOS"
|
|
126
130
|
APPEND_ITEM FIRST 256 STRING "MODCOD at AOS"
|
|
127
131
|
APPEND_ITEM LAST 256 STRING "MODCOD at LOS"
|
|
128
|
-
APPEND_ITEM MIN_SINR_DB
|
|
132
|
+
APPEND_ITEM MIN_SINR_DB 64 FLOAT "Lowest planned SINR (p50) at a MODCOD change"
|
|
129
133
|
UNITS Decibels dB
|
|
130
134
|
FORMAT_STRING "%.2f"
|
|
131
135
|
APPEND_ITEM PLANNED_PASSES 32 UINT "Passes ahead with a plan"
|
|
@@ -301,6 +301,8 @@ export function loss(item) {
|
|
|
301
301
|
const SHARES = ['probability', 'share'];
|
|
302
302
|
// rfi-watch items are links whose value is RFI in dB (read as its p50) with a lock-loss risk (a
|
|
303
303
|
// share), and whose action is a reroute with no deadline: never GB, never a swap.
|
|
304
|
+
// Where a pass comes from (entity.source), as constellation_space.results.SOURCES words it.
|
|
305
|
+
const SOURCES = { computed: 'computed from orbits', 'computed:continuous': 'a continuous slot of one UTC day' };
|
|
304
306
|
const pct = (v) => (typeof v === 'number' ? `${Math.round(v * 100)}%` : num(v));
|
|
305
307
|
const RFI = {
|
|
306
308
|
tiles(run, items) {
|
|
@@ -354,34 +356,32 @@ const RFI = {
|
|
|
354
356
|
};
|
|
355
357
|
|
|
356
358
|
export const VIEWS = {
|
|
359
|
+
// Every total is the run's as Constellation serves it (run.totals), never a sum of the items
|
|
360
|
+
// here: overlapping passes of one radio or antenna count once only by its rule. A run it
|
|
361
|
+
// serves no totals for shows —.
|
|
357
362
|
tiles(run, items) {
|
|
358
363
|
if (run.kind === 'rfi-watch') return RFI.tiles(run, items);
|
|
364
|
+
const all = run.totals?.overall;
|
|
359
365
|
if (run.kind === 'audit-ledger') {
|
|
360
|
-
|
|
361
|
-
const delivered = items.reduce((s, i) => s + (ledgerOf(i).delivered_gb ?? 0), 0);
|
|
362
|
-
const dead = items.filter((i) => ledgerOf(i).dead).length;
|
|
363
|
-
return `<div class="cf-tiles">${tile('passes audited', items.length)}${tile('GB delivered', big(delivered), `of ${big(possible)} possible`)}${tile('delivered', possible ? `${Math.round((delivered / possible) * 100)}%` : '—')}${tile('dead passes', dead, 'failed, missed or unlogged')}</div>`;
|
|
366
|
+
return `<div class="cf-tiles">${tile('passes audited', items.length)}${tile('GB delivered', big(all?.delivered_gb), all ? `of ${big(all.possible_gb)} possible` : '')}${tile('delivered', pct(all?.delivered_share))}${tile('dead passes', all?.dead_passes ?? '—', 'failed or missed')}</div>`;
|
|
364
367
|
}
|
|
365
368
|
if (run.kind === 'antenna-capacity') {
|
|
366
|
-
|
|
367
|
-
const minutes = items.reduce((s, i) => s + (gbOf(i)?.sellable_min ?? 0), 0);
|
|
368
|
-
return `<div class="cf-tiles">${tile('antenna-days', items.length)}${tile('sellable minutes', big(minutes))}${tile('GB expected', big(gb), 'p50, summed')}${tile('antennas', new Set(items.map((i) => i.entity.id)).size)}</div>`;
|
|
369
|
+
return `<div class="cf-tiles">${tile('antenna-days', items.length)}${tile('sellable minutes', big(all?.minutes))}${tile('GB expected', big(all?.gb), 'p50, the whole run')}${tile('antennas', new Set(items.map((i) => i.entity.id)).size)}</div>`;
|
|
369
370
|
}
|
|
370
371
|
if (run.kind === 'rain-fade-swap') {
|
|
371
372
|
const swaps = items.filter(actionable).sort((a, b) => a.action.deadline.localeCompare(b.action.deadline));
|
|
372
373
|
const approved = swaps.filter((i) => actionState(i) === 'approved').length;
|
|
373
374
|
const held = items.filter((i) => actionState(i) === 'pending').length;
|
|
374
|
-
const gain = swaps.reduce((s, i) => s + (typeof i.action.gain_gb === 'number' ? i.action.gain_gb : 0), 0);
|
|
375
375
|
const soonest = swaps.find((i) => Date.parse(i.action.deadline) > Date.now());
|
|
376
376
|
const booked = swaps.filter((i) => i.action.to).length;
|
|
377
377
|
const hint = approved || held ? `${approved} approved · ${held} awaiting approval` : `${booked} with a better backup`;
|
|
378
|
-
return `<div class="cf-tiles">${tile('swaps to decide', swaps.length - approved, hint)}${tile('GB
|
|
378
|
+
return `<div class="cf-tiles">${tile('swaps to decide', swaps.length - approved, hint)}${tile('GB recovered', big(all?.recovered_gb), 'by the swaps that count (p50)')}${tile('soonest decision', soonest ? until(soonest.action.deadline) : '—', soonest ? `decide by ${minute(soonest.action.deadline)}` : '')}${tile('workflow version', `v${run.workflow_version}`)}</div>`;
|
|
379
379
|
}
|
|
380
|
-
|
|
381
|
-
const
|
|
380
|
+
// The day from when the run was made; its satellites overlap nowhere, so they add up.
|
|
381
|
+
const day = run.totals?.next_24h && Object.values(run.totals.next_24h.by_satellite);
|
|
382
382
|
const swaps = items.filter(actionable).length;
|
|
383
383
|
const next = items.find((i) => Date.parse(i.target_at) > Date.now());
|
|
384
|
-
return `<div class="cf-tiles">${tile('passes, next 24 h', day.
|
|
384
|
+
return `<div class="cf-tiles">${tile('passes, next 24 h', day ? day.reduce((s, b) => s + b.counted_passes, 0) : '—')}${tile('GB expected', big(day?.reduce((s, b) => s + b.gb, 0)), 'next 24 h from the run')}${swaps ? tile('swaps advised', swaps, 'see Risk below') : tile('next pass', next ? `${hhmm(next.target_at)}Z` : '—', next ? `${next.entity.satellite_id} @ ${shortAntenna(next.entity.antenna_id)}` : '')}${tile('workflow version', `v${run.workflow_version}`)}</div>`;
|
|
385
385
|
},
|
|
386
386
|
|
|
387
387
|
chart(run, items) {
|
|
@@ -520,7 +520,8 @@ export const VIEWS = {
|
|
|
520
520
|
const range = g
|
|
521
521
|
? `<div class="cf-range-labels"><b>${num(g.p50)} GB expected</b></div>`
|
|
522
522
|
: '';
|
|
523
|
-
|
|
523
|
+
const source = item.entity.source ? `<p class="cf-note">Source: ${esc(SOURCES[item.entity.source] ?? item.entity.source)}</p>` : '';
|
|
524
|
+
return `<aside class="cf-ledger"><h3>${run.kind === 'rfi-watch' ? 'Why this link is flagged' : 'Why this pass is worth what it is'}</h3><div class="cf-ledger-title">${esc(linkLabel(item))}<span>${minute(item.target_at)}${item.until ? ` – ${hhmm(item.until)}Z` : ''}</span></div>${source}${range}<table class="cf-table cf-compact">${laneRows}</table>${plan}<p class="cf-note">Workflow ${esc(run.workflow)} v${esc(item.workflow_version ?? run.workflow_version)} · run ${esc(run.run_id)}</p></aside>`;
|
|
524
525
|
},
|
|
525
526
|
};
|
|
526
527
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openc3-cosmos-constellation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Constellation Space Corp
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: 'A CONSTELLATION target whose packets a bridge microservice fills from
|
|
14
14
|
the Constellation feed: the next predicted pass, the next 24 hours, the soonest
|