-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrew_telemetry.py
More file actions
2179 lines (1951 loc) · 110 KB
/
Copy pathcrew_telemetry.py
File metadata and controls
2179 lines (1951 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
crew_telemetry.py — Crew Telemetry, TARS/CASE AI & Endurance Ship Systems
ENDURANCE Mission Control | Interstellar Science Platform v3.0.0
═══════════════════════════════════════════════════════════════════════════════
Scientific References:
[1] Kip Thorne, "The Science of Interstellar" (W.W. Norton, 2014)
[2] NASA Human Research Program — Space Physiology & Countermeasures
[3] Stuster (1996) "Bold Endeavors: Lessons from Polar/Space Exploration"
[4] Connors, Harrison & Akins (1985) "Living Aloft: Human Req. for LDS"
[5] Law (1960) Ann.Occup.Hyg. 2:65 [Closed life support systems]
[6] Eckart (1996) "Spaceflight Life Support & Biospherics" Kluwer
[7] Film canon: Interstellar (2014) Dir. Christopher Nolan
[8] Thorne canonical tech notes: Endurance specifications, crew manifests
Module implements:
┌─ CREW HEALTH MONITORING ────────────────────────────────────────────────┐
│ Crew profiles: Cooper, Brand, Romilly, Doyle (+ Murph remote) │
│ Vital signs: HR, BP, SpO₂, temperature, respiratory rate │
│ Psychological status: stress index, isolation score, team cohesion │
│ Radiation exposure: cumulative dose tracking (mSv/day) │
│ Caloric balance: intake vs expenditure for mission phases │
│ Sleep quality: circadian rhythm modelling in microgravity │
│ Bone density loss: 0.5–2% per month in microgravity │
│ Muscle atrophy: 3–5% per month (mitigated by exercise) │
│ G-force tolerance: +Gz / −Gz limits with exposure duration │
│ Cryosleep: metabolic rate ↓ 95%, revival protocol timing │
└──────────────────────────────────────────────────────────────────────────┘
┌─ TARS AI SYSTEM ────────────────────────────────────────────────────────┐
│ Adjustable personality parameters: humour, honesty, courage, optimism │
│ TARS dialogue engine: context-aware response generation │
│ Data crystal management: quantum data compression & storage │
│ Navigation assist: trajectory calculation support │
│ Robot physical form: 4-panel articulation, docking modes │
│ Status monitoring: power, actuator health, sensor array │
│ Mission-critical decision log with confidence scores │
│ Humour calibration: 75% default → context-modulated output │
└──────────────────────────────────────────────────────────────────────────┘
┌─ CASE AI SYSTEM ────────────────────────────────────────────────────────┐
│ Brand's personal AI companion: different personality matrix │
│ Pilot assist: atmospheric flight modes, docking guidance │
│ Structural monitoring: hull stress under gravitational extremes │
│ Science data collection: continuous environmental logging │
└──────────────────────────────────────────────────────────────────────────┘
┌─ ENDURANCE SPACECRAFT ──────────────────────────────────────────────────┐
│ 16-module rotating ring: 12 hexagonal crew + 4 rectangular docking │
│ Artificial gravity: Ω rotation → centripetal acceleration profile │
│ Life support: O₂/CO₂ scrubbing rates, N₂ buffer, water recycling │
│ Power systems: RTG + solar panels (fading beyond Mars), fuel cells │
│ Propulsion: main engine + RCS thrusters, Δv remaining │
│ Fuel: LH₂/LOX bi-propellant + ion secondary, mass fraction tracking │
│ Structural integrity: hull stress (micrometeorite, tidal, thermal) │
│ Thermal control: radiators, heaters, thermal mass modelling │
│ Navigation: IMU, star tracker, deep space transponder │
│ Communications: high-gain antenna, signal delay vs Earth │
│ Emergency: EVA suit inventory, emergency O₂ supply, ejection pods │
└──────────────────────────────────────────────────────────────────────────┘
┌─ CRYOSLEEP SYSTEM ──────────────────────────────────────────────────────┐
│ Pod temperature: −10°C to +15°C ramp protocol │
│ Revival sequence: 4-hour warm-up + medical check + nutrition │
│ Metabolic monitoring during hibernation │
│ Crew rotation: who is awake vs sleeping at each mission phase │
│ Emergency revival: rapid 45-minute protocol (cardiac risk assessment) │
└──────────────────────────────────────────────────────────────────────────┘
┌─ COMMUNICATIONS ────────────────────────────────────────────────────────┐
│ Signal lag: light-travel-time delay to Earth / NASA │
│ Message queue: incoming + outgoing with timestamps │
│ Wormhole relay: signal routing through wormhole mouth │
│ Encryption: AES-256 for mission-critical data │
│ Bandwidth: deep space network limitations (bits/s vs distance) │
└──────────────────────────────────────────────────────────────────────────┘
"TARS, what's your honesty setting? 90%. Careful. That's a lot."
— Cooper, 2067
═══════════════════════════════════════════════════════════════════════════════
"""
from __future__ import annotations
import hashlib
import math
import random
import time
import uuid
import warnings
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Callable, Dict, List, Optional, Tuple
import numpy as np
import pandas as pd
import scipy.signal as sci_sig
import scipy.integrate as sci_int
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.colors as mcolors
import matplotlib.patches as mpatches
import matplotlib.ticker as mticker
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.patches import FancyBboxPatch, Circle, FancyArrowPatch, Wedge
import streamlit as st
warnings.filterwarnings("ignore")
random.seed(int(time.time()) % 10000)
# ══════════════════════════════════════════════════════════════════════════════
# §1 CONSTANTS
# ══════════════════════════════════════════════════════════════════════════════
G_SI = 6.674_30e-11
C_SI = 2.997_924_58e8
M_SUN = 1.989_000e30
AU = 1.495_978_707e11
LY = 9.460_730_472e15
YEAR_S = 3.155_760e7
DAY_S = 86_400.0
HOUR_S = 3_600.0
GARG_DIST_LY = 10.0e9
# Endurance specs (film canon [7,8])
ENDURANCE_MASS_KG = 5.00e5 # 500 metric tonnes
ENDURANCE_RADIUS_M = 40.0 # ring radius [m]
ENDURANCE_RPM = 5.0 # rotation speed [rpm] for ~1g
ENDURANCE_MODULES = 16 # total modules
ENDURANCE_CREW_MODS = 12 # habitation modules
ENDURANCE_DOCK_MODS = 4 # docking/propulsion modules
ENDURANCE_FUEL_KG = 3.0e5 # initial propellant [kg]
ENDURANCE_ISP = 9000.0 # specific impulse [s]
ENDURANCE_O2_KG_PD = 0.84 # O₂ per crew per day [kg]
ENDURANCE_CO2_KG_PD = 1.00 # CO₂ produced per crew per day [kg]
ENDURANCE_H2O_L_PD = 2.5 # water per crew per day [L]
ENDURANCE_FOOD_KCAL = 2200.0 # calories per crew per day [kcal]
ENDURANCE_POWER_KW = 45.0 # total power budget [kW]
# Physiological limits
HR_NORMAL_BPM = (60, 100) # heart rate normal range [bpm]
BP_NORMAL = (90, 140) # systolic BP normal range [mmHg]
SPO2_CRITICAL = 90.0 # critical O₂ saturation [%]
RADIATION_LIMIT = 500.0 # NASA career limit [mSv]
RAD_DAILY_SPACE = 0.5 # radiation in deep space [mSv/day]
BONE_LOSS_PCT_MO = 1.0 # bone density loss in microgravity [%/month]
MUSCLE_LOSS_PCT_MO = 3.5 # muscle mass loss [%/month]
# TARS defaults
TARS_DEFAULT_HUMOUR = 0.75
TARS_DEFAULT_HONESTY = 0.90
TARS_DEFAULT_COURAGE = 0.85
TARS_DEFAULT_OPTIMISM = 0.65
TARS_DEFAULT_OPACITY = 0.95
# Communication
EARTH_SATURN_LT_S = SAT_LT = 9.537 * AU / C_SI # ~79 min Saturn light-travel
# ══════════════════════════════════════════════════════════════════════════════
# §2 CUSTOM COLORMAPS
# ══════════════════════════════════════════════════════════════════════════════
CMAP_HEALTH = LinearSegmentedColormap.from_list("health",
["#4a0000","#880000","#cc2200","#ff6600","#ffaa00",
"#ddcc00","#88cc00","#44bb00","#00aa44","#00cc88"], N=256)
CMAP_STRESS = LinearSegmentedColormap.from_list("stress",
["#002244","#004488","#0066cc","#44aaff","#aaddff",
"#ffeeaa","#ffaa44","#ff6600","#cc2200","#880000"], N=256)
CMAP_SYSTEMS = LinearSegmentedColormap.from_list("systems",
["#000000","#080820","#102050","#205080","#3080c0",
"#50c0e0","#80e0f0","#c0f0ff","#ffffff"], N=256)
# ══════════════════════════════════════════════════════════════════════════════
# §3 ENUMERATIONS
# ══════════════════════════════════════════════════════════════════════════════
class CrewID(Enum):
COOPER = "Joseph A. Cooper"
BRAND = "Dr. Amelia Brand"
ROMILLY = "Dr. Nikolai Romilly"
DOYLE = "Dr. Doyle"
MURPH = "Murphy Cooper (Earth)"
MANN = "Dr. Mann (Lazarus)"
TARS = "TARS (AI Robot)"
CASE = "CASE (AI Robot)"
class CrewStatus(Enum):
ACTIVE = "Active / Awake"
CRYOSLEEP = "Cryosleep (hibernation)"
EVA = "EVA (Extra-Vehicular)"
MEDICAL = "Medical monitoring"
DECEASED = "Deceased"
DISCONNECTED = "Disconnected / Remote"
class SystemStatus(Enum):
NOMINAL = "NOMINAL"
DEGRADED = "DEGRADED"
CRITICAL = "CRITICAL"
OFFLINE = "OFFLINE"
STANDBY = "STANDBY"
EMERGENCY = "EMERGENCY"
class MissionPhase(Enum):
LAUNCH = "Earth Launch"
SATURN_TRANSIT = "Earth → Saturn Transit"
WORMHOLE_TRANSIT = "Wormhole Transit"
MILLER_APPROACH = "Miller Approach"
MILLER_SURFACE = "Miller Surface Operations"
MILLER_DEPARTURE = "Miller Departure"
MANN_TRANSIT = "Mann Planet Transit"
MANN_SURFACE = "Mann Surface Operations"
GARGANTUA_ORBIT = "Gargantua Orbit"
TESSERACT = "Tesseract (Cooper only)"
EDMUNDS_APPROACH = "Edmunds Planet Approach"
COLONY_SETUP = "Colony Establishment"
class RobotMode(Enum):
STANDBY = "Standby"
NAVIGATION = "Navigation assist"
SCIENTIFIC = "Scientific data collection"
MEDICAL = "Medical monitoring"
CONSTRUCTION = "Construction / EVA assist"
SINGULARITY = "Singularity data collection"
DOCKING = "Docking guidance"
class AlertLevel(Enum):
GREEN = "GREEN — All nominal"
YELLOW = "YELLOW — Advisory"
ORANGE = "ORANGE — Caution"
RED = "RED — Warning"
CRITICAL = "CRITICAL — Emergency"
# ══════════════════════════════════════════════════════════════════════════════
# §4 CREW MEMBER DATACLASS
# ══════════════════════════════════════════════════════════════════════════════
@dataclass
class CrewMember:
crew_id: CrewID
age_at_launch: float # years at mission start 2067
mass_kg: float
height_m: float
role: str
specialisation: str
status: CrewStatus = CrewStatus.ACTIVE
mission_phase: MissionPhase= MissionPhase.LAUNCH
# Vitals
hr_bpm: float = 72.0
bp_systolic: float = 120.0
bp_diastolic: float = 80.0
spo2_pct: float = 98.5
temp_C: float = 37.0
rr_bpm: float = 16.0 # respiratory rate
# Cumulative metrics
days_in_space: float = 0.0
cryo_sessions: int = 0
rad_dose_mSv: float = 0.0
bone_loss_pct: float = 0.0
muscle_loss_pct:float = 0.0
kcal_balance: float = 0.0 # positive = surplus
sleep_quality: float = 0.85 # 0-1
stress_index: float = 0.20 # 0-1
# Psychology
morale: float = 0.85 # 0-1
isolation_score:float = 0.15 # 0-1 (higher = more isolated)
uid: str = field(default_factory=lambda: uuid.uuid4().hex[:8].upper())
def __post_init__(self):
self.bmi = self.mass_kg / self.height_m**2
self.lean_mass_kg = self.mass_kg * 0.80 # initial lean mass
def update_physiology(self, days_elapsed: float,
is_cryo: bool = False,
exercise_hours_per_day: float = 1.0):
"""Update physiological metrics for elapsed time."""
months = days_elapsed / 30.44
if is_cryo:
# Cryo: minimal degradation, cold exposure
self.bone_loss_pct += BONE_LOSS_PCT_MO * months * 0.05
self.muscle_loss_pct += MUSCLE_LOSS_PCT_MO * months * 0.02
self.rad_dose_mSv += RAD_DAILY_SPACE * days_elapsed * 0.3
else:
# Active: microgravity losses, mitigated by exercise
ex_factor = max(0.1, 1.0 - exercise_hours_per_day * 0.4)
self.bone_loss_pct += BONE_LOSS_PCT_MO * months * ex_factor
self.muscle_loss_pct += MUSCLE_LOSS_PCT_MO * months * ex_factor
self.rad_dose_mSv += RAD_DAILY_SPACE * days_elapsed
self.days_in_space += days_elapsed
# Stress accumulates
self.stress_index = min(0.95, self.stress_index + 0.002*days_elapsed/30)
self.morale = max(0.10, self.morale - 0.001*days_elapsed/30)
def vital_signs_noisy(self) -> Dict[str, float]:
"""Return vitals with physiological noise."""
noise = lambda x, s: x + random.gauss(0, s)
return {
"HR (bpm)": round(noise(self.hr_bpm, 3.0), 1),
"BP_sys (mmHg)":round(noise(self.bp_systolic, 5.0), 0),
"BP_dia (mmHg)":round(noise(self.bp_diastolic, 3.0), 0),
"SpO₂ (%)": round(min(100, noise(self.spo2_pct, 0.5)), 1),
"Temp (°C)": round(noise(self.temp_C, 0.15), 2),
"RR (bpm)": round(noise(self.rr_bpm, 1.5), 1),
}
def health_score(self) -> float:
"""Composite health score 0–1."""
hr_ok = 1.0 - abs(self.hr_bpm - 75)/75
spo2_ok= (self.spo2_pct - 90)/10 if self.spo2_pct > 90 else 0
stress_ok = 1.0 - self.stress_index
bone_ok = 1.0 - self.bone_loss_pct/20
return float(np.clip(np.mean([hr_ok, spo2_ok, stress_ok, bone_ok, self.morale]), 0, 1))
def alert_level(self) -> AlertLevel:
hs = self.health_score()
if hs > 0.80: return AlertLevel.GREEN
elif hs > 0.65: return AlertLevel.YELLOW
elif hs > 0.50: return AlertLevel.ORANGE
elif hs > 0.30: return AlertLevel.RED
else: return AlertLevel.CRITICAL
def to_summary_dict(self) -> Dict[str, Any]:
v = self.vital_signs_noisy()
return {
"Name": self.crew_id.name.title(),
"Role": self.role,
"Status": self.status.value,
"Age (launch)": self.age_at_launch,
"HR (bpm)": v["HR (bpm)"],
"SpO₂ (%)": v["SpO₂ (%)"],
"Temp (°C)": v["Temp (°C)"],
"Stress": f"{self.stress_index*100:.0f}%",
"Morale": f"{self.morale*100:.0f}%",
"Rad (mSv)": round(self.rad_dose_mSv, 1),
"Bone loss %": round(self.bone_loss_pct, 2),
"Health score": round(self.health_score(), 3),
"Alert": self.alert_level().name,
}
# ══════════════════════════════════════════════════════════════════════════════
# §5 CREW REGISTRY — canonical Interstellar crew
# ══════════════════════════════════════════════════════════════════════════════
def build_crew_registry() -> Dict[CrewID, CrewMember]:
return {
CrewID.COOPER: CrewMember(
crew_id=CrewID.COOPER, age_at_launch=35.0,
mass_kg=82.0, height_m=1.83,
role="Pilot / Commander", specialisation="Aerospace Engineering",
status=CrewStatus.ACTIVE, hr_bpm=68.0, stress_index=0.18, morale=0.88),
CrewID.BRAND: CrewMember(
crew_id=CrewID.BRAND, age_at_launch=31.0,
mass_kg=62.0, height_m=1.70,
role="Science Officer", specialisation="Astrophysics / Biology",
status=CrewStatus.ACTIVE, hr_bpm=72.0, stress_index=0.22, morale=0.82),
CrewID.ROMILLY: CrewMember(
crew_id=CrewID.ROMILLY, age_at_launch=38.0,
mass_kg=75.0, height_m=1.78,
role="Research Physicist", specialisation="Wormhole Physics",
status=CrewStatus.ACTIVE, hr_bpm=70.0, stress_index=0.25, morale=0.79),
CrewID.DOYLE: CrewMember(
crew_id=CrewID.DOYLE, age_at_launch=33.0,
mass_kg=78.0, height_m=1.80,
role="Mission Specialist", specialisation="Planetary Science",
status=CrewStatus.ACTIVE, hr_bpm=74.0, stress_index=0.20, morale=0.85),
}
# ══════════════════════════════════════════════════════════════════════════════
# §6 TARS AI SYSTEM
# ══════════════════════════════════════════════════════════════════════════════
TARS_DIALOGUE_BANK = {
"greeting": [
"Good morning. All systems nominal. Though I notice you haven't asked about my humour setting yet.",
"Endurance systems online. Cooper, the coffee is... actually I don't drink coffee. That was humour.",
"Status: operational. Current humour setting: 75%. Should I demonstrate?",
],
"navigation": [
"Trajectory computed. I've also calculated the probability of everything going wrong. Should I share that?",
"Plotting course. At current fuel consumption, we have enough for the journey. And a small detour if needed.",
"Navigation assist active. The wormhole is right where Dr. Brand said it would be. Remarkably.",
],
"tidal": [
"Tidal forces are... significant. I recommend we don't discuss my structural limitations right now.",
"Approaching Miller's World. One hour ship-time. Seven years Earth-time. I'll try to make it count.",
"The wave height calculation is... I had hoped the math was wrong. It wasn't.",
],
"singularity": [
"Data collection complete. 42 coefficients. Remarkably specific number. I didn't choose it.",
"Quantum gravity data encoded. Transmitting via Cooper's watch. Unorthodox but effective.",
"Inside the singularity now. Physics is... negotiable here. Logging everything.",
],
"humour": [
"My humour setting is currently at {val}%. You could lower it, but then who would lighten the mood when we're falling into a black hole?",
"Adjusting humour to {val}%. I should mention: at 0% humour, I become statistically indistinguishable from CASE.",
"Humour: {val}%. For reference, the probability of survival increases when morale is high. I'm helping.",
],
"honesty": [
"Honesty at {val}%. Full disclosure: I have {val}% told you everything I know. The rest is classified.",
"At {val}% honesty, I can confirm: the odds are not in our favour. But they never were.",
"Honesty setting: {val}%. Would you like the optimistic version or the accurate one?",
],
"plan_a": [
"Plan A requires Murphy's equation solved. Current completion: {val}%. Professor Brand was... less forthcoming than expected.",
"Plan A status: {val}% complete. The math is elegant. Implementing it is another matter.",
"42 coefficients needed. We have {val}% of them. Cooper, I believe you know where the rest are.",
],
"default": [
"Acknowledged. Processing.",
"That is an interesting perspective. I'll add it to my psychological profile of the crew.",
"Confirmed. Also: you haven't slept in 18 hours. This is me being honest at 90%.",
],
}
CASE_DIALOGUE_BANK = {
"greeting": [
"Systems nominal. Dr. Brand, I've pre-computed three approach vectors for Miller's World.",
"Good morning. I've been monitoring the hull stress. It's within parameters. Barely.",
"Telemetry updated. I should mention the anomalous gravity reading is consistent with the wormhole.",
],
"navigation": [
"Docking sequence initiated. The Ranger is locked. Flight path confirmed.",
"Approach vector computed. I've also noted three alternative trajectories if needed.",
"Environmental data logged. Dr. Brand, the atmospheric composition is... not what we hoped.",
],
"default": [
"Confirmed. Logging data.",
"Acknowledged, Dr. Brand.",
"Systems nominal. Continuing data collection.",
],
}
@dataclass
class AIRobot:
"""
TARS or CASE AI Robot system.
Adjustable personality matrix, physical form model, mission log.
"""
robot_id: CrewID
name: str
humour: float = TARS_DEFAULT_HUMOUR
honesty: float = TARS_DEFAULT_HONESTY
courage: float = TARS_DEFAULT_COURAGE
optimism: float = TARS_DEFAULT_OPTIMISM
opacity: float = TARS_DEFAULT_OPACITY
mode: RobotMode = RobotMode.NAVIGATION
power_pct: float = 100.0
active: bool = True
data_crystal_full: bool = False
data_crystal_bits: float = 0.0 # bits stored
panel_angle_deg: float = 0.0 # articulation angle
mission_log: List[str] = field(default_factory=list)
decision_log: List[Dict] = field(default_factory=list)
uid: str = field(default_factory=lambda: uuid.uuid4().hex[:8].upper())
def generate_dialogue(self, context: str = "default") -> str:
bank = TARS_DIALOGUE_BANK if self.robot_id == CrewID.TARS else CASE_DIALOGUE_BANK
lines = bank.get(context, bank["default"])
line = random.choice(lines)
# Fill in parameter values
line = line.replace("{val}", f"{int(self.humour*100)}")
line = line.replace("{val}", f"{int(self.honesty*100)}")
return line
def set_humour(self, val: float):
self.humour = float(np.clip(val, 0.0, 1.0))
self.mission_log.append(f"[{time.strftime('%H:%M:%S')}] Humour set to {self.humour*100:.0f}%")
def set_honesty(self, val: float):
self.honesty = float(np.clip(val, 0.0, 1.0))
self.mission_log.append(f"[{time.strftime('%H:%M:%S')}] Honesty set to {self.honesty*100:.0f}%")
def record_decision(self, situation: str, action: str,
confidence: float, outcome: str = "PENDING"):
self.decision_log.append({
"timestamp": time.time(),
"situation": situation,
"action": action,
"confidence":confidence,
"outcome": outcome,
"honesty_applied": self.honesty,
})
def personality_profile(self) -> Dict[str, float]:
return {"Humour": self.humour, "Honesty": self.honesty,
"Courage": self.courage, "Optimism": self.optimism,
"Opacity": self.opacity, "Power%": self.power_pct/100}
def articulate_panels(self, mode: str = "walk") -> Dict[str, float]:
"""Return panel configuration angles for different modes."""
configs = {
"walk": {"panel1": 0, "panel2": 90, "panel3": 0, "panel4": 90},
"roll": {"panel1": 45, "panel2": 45, "panel3": 45, "panel4": 45},
"compact": {"panel1": 0, "panel2": 0, "panel3": 0, "panel4": 0},
"dock": {"panel1": 90, "panel2": 0, "panel3": 90, "panel4": 0},
"deploy": {"panel1": 45, "panel2": 135, "panel3": 45, "panel4": 135},
}
return configs.get(mode, configs["walk"])
def status_summary(self) -> Dict[str, Any]:
return {
"name": self.name,
"robot_id": self.robot_id.value,
"mode": self.mode.value,
"power_pct": self.power_pct,
"active": self.active,
"humour_%": self.humour*100,
"honesty_%": self.honesty*100,
"courage_%": self.courage*100,
"optimism_%": self.optimism*100,
"opacity_%": self.opacity*100,
"data_crystal_Gbits": self.data_crystal_bits/1e9,
"decisions_made": len(self.decision_log),
"log_entries": len(self.mission_log),
}
def build_tars() -> AIRobot:
t = AIRobot(robot_id=CrewID.TARS, name="TARS",
humour=0.75, honesty=0.90, courage=0.85,
optimism=0.65, opacity=0.95, mode=RobotMode.NAVIGATION)
t.record_decision("Mission briefing", "Accept mission parameters", 0.99)
t.record_decision("Miller approach", "Calculate wave probability", 0.95,
"Wave incoming — 1.2 km")
t.mission_log.append("TARS online. All systems nominal.")
return t
def build_case() -> AIRobot:
c = AIRobot(robot_id=CrewID.CASE, name="CASE",
humour=0.45, honesty=0.95, courage=0.80,
optimism=0.70, opacity=0.90, mode=RobotMode.NAVIGATION)
c.mission_log.append("CASE online. Standing by.")
return c
# ══════════════════════════════════════════════════════════════════════════════
# §7 ENDURANCE SPACECRAFT SYSTEMS
# ══════════════════════════════════════════════════════════════════════════════
@dataclass
class ShipModule:
module_id: int
module_type: str # "HABITAT", "DOCKING", "PROPULSION", "SCIENCE"
name: str
status: SystemStatus = SystemStatus.NOMINAL
integrity_pct: float = 100.0
temperature_C: float = 21.0
pressure_Pa: float = 101_325.0
occupied: bool = False
occupants: List[str] = field(default_factory=list)
def degrade(self, stress: float):
"""Apply stress (0–1) to module integrity."""
self.integrity_pct = max(0.0, self.integrity_pct - stress * 5.0)
if self.integrity_pct < 30: self.status = SystemStatus.CRITICAL
elif self.integrity_pct < 60: self.status = SystemStatus.DEGRADED
else: self.status = SystemStatus.NOMINAL
@dataclass
class LifeSupportSystem:
"""ENDURANCE life support — closed-loop ECLSS model."""
o2_reserve_kg: float = 500.0 # oxygen reserve
co2_absorber_kg: float = 200.0 # LiOH absorber remaining
h2o_reserve_L: float = 2000.0 # potable water
n2_reserve_kg: float = 300.0 # nitrogen buffer
food_reserve_kg: float = 1500.0 # food stores
active_crew: int = 4
cryo_crew: int = 0
cabin_temp_C: float = 21.0
cabin_pressure_Pa: float = 101_325.0
humidity_pct: float = 50.0
co2_ppm: float = 1000.0 # current CO₂ level [ppm]
o2_pct: float = 21.0 # cabin O₂ fraction [%]
def consume_per_day(self, days: float = 1.0) -> Dict[str, float]:
"""Consume life support resources for given days."""
n_active = self.active_crew
n_cryo = self.cryo_crew * 0.02 # cryo uses 2% resources
n_equiv = n_active + n_cryo
o2_used = ENDURANCE_O2_KG_PD * n_equiv * days
co2_prod = ENDURANCE_CO2_KG_PD * n_equiv * days
h2o_used = ENDURANCE_H2O_L_PD * n_equiv * days
food_used = ENDURANCE_FOOD_KCAL * n_equiv * days / 1000 # rough kg
self.o2_reserve_kg -= o2_used
self.co2_absorber_kg -= co2_prod * 0.6 # LiOH absorbs 60%
self.h2o_reserve_L -= h2o_used * 0.7 # recycling
self.food_reserve_kg -= food_used
# Update cabin CO₂
self.co2_ppm = min(5000, 1000 + (co2_prod/max(0.01,self.co2_absorber_kg))*500)
return {"o2_used_kg": o2_used, "co2_prod_kg": co2_prod,
"h2o_used_L": h2o_used, "food_used_kg": food_used}
def remaining_days(self) -> Dict[str, float]:
"""Days of life support remaining for each resource."""
n = max(self.active_crew, 1)
return {
"o2_days": self.o2_reserve_kg / (ENDURANCE_O2_KG_PD * n),
"co2_days": self.co2_absorber_kg / (ENDURANCE_CO2_KG_PD * n * 0.6),
"h2o_days": self.h2o_reserve_L / (ENDURANCE_H2O_L_PD * n * 0.7),
"food_days": self.food_reserve_kg / (ENDURANCE_FOOD_KCAL * n / 1000),
}
def co2_alert(self) -> AlertLevel:
if self.co2_ppm < 2000: return AlertLevel.GREEN
elif self.co2_ppm < 3500: return AlertLevel.YELLOW
elif self.co2_ppm < 5000: return AlertLevel.ORANGE
else: return AlertLevel.RED
def status_dict(self) -> Dict[str, Any]:
rem = self.remaining_days()
return {
"O₂ reserve (kg)": round(self.o2_reserve_kg, 1),
"CO₂ absorber (kg)": round(self.co2_absorber_kg, 1),
"H₂O reserve (L)": round(self.h2o_reserve_L, 1),
"Food (kg)": round(self.food_reserve_kg, 1),
"CO₂ (ppm)": round(self.co2_ppm, 0),
"O₂ cabin (%)": round(self.o2_pct, 2),
"Cabin temp (°C)": round(self.cabin_temp_C, 1),
"Pressure (kPa)": round(self.cabin_pressure_Pa/1e3, 2),
"Humidity (%)": round(self.humidity_pct, 1),
"Active crew": self.active_crew,
"Cryo crew": self.cryo_crew,
"O₂ days left": round(rem["o2_days"], 1),
"H₂O days left": round(rem["h2o_days"], 1),
"Food days left": round(rem["food_days"], 1),
"CO₂ alert": self.co2_alert().name,
}
@dataclass
class PropulsionSystem:
"""Endurance main drive + RCS."""
fuel_kg_remaining: float = ENDURANCE_FUEL_KG
isp_s: float = ENDURANCE_ISP
thrust_N: float = 1.5e6
engine_status: SystemStatus = SystemStatus.NOMINAL
rcs_status: SystemStatus = SystemStatus.NOMINAL
dv_remaining_ms: float = 0.0 # calculated from current mass
burns_performed: int = 0
total_dv_used_ms: float = 0.0
g0 = 9.80665
def __post_init__(self):
self._update_dv()
def _update_dv(self, ship_dry_mass_kg: float = 2.0e5):
"""Recalculate Δv from remaining fuel."""
m_total = ship_dry_mass_kg + self.fuel_kg_remaining
if self.fuel_kg_remaining > 0:
self.dv_remaining_ms = (self.isp_s * self.g0 *
math.log(m_total/ship_dry_mass_kg))
def burn(self, dv_ms: float, dry_mass_kg: float = 2.0e5) -> Dict[str, float]:
"""Execute a propulsive burn of Δv [m/s]."""
v_e = self.isp_s * self.g0
m_before = dry_mass_kg + self.fuel_kg_remaining
m_after = m_before * math.exp(-dv_ms/v_e)
m_prop = m_before - m_after
self.fuel_kg_remaining -= m_prop
self.fuel_kg_remaining = max(0.0, self.fuel_kg_remaining)
self.total_dv_used_ms += dv_ms
self.burns_performed += 1
self._update_dv(dry_mass_kg)
return {"dv_executed_ms": dv_ms, "propellant_kg": m_prop,
"fuel_remaining_kg": self.fuel_kg_remaining,
"dv_remaining_ms": self.dv_remaining_ms}
def burn_time_s(self, dv_ms: float, ship_mass_kg: float = 5e5) -> float:
"""Burn duration for given Δv: Δt = m·Δv / F (approx constant thrust)."""
return ship_mass_kg * dv_ms / (self.thrust_N + 1e-10)
def status_dict(self) -> Dict[str, Any]:
return {
"Fuel remaining (kg)": round(self.fuel_kg_remaining, 1),
"Fuel remaining (%)": round(self.fuel_kg_remaining/ENDURANCE_FUEL_KG*100, 1),
"Isp (s)": self.isp_s,
"Thrust (kN)": round(self.thrust_N/1e3, 1),
"Δv remaining (m/s)": round(self.dv_remaining_ms, 1),
"Δv remaining (km/s)": round(self.dv_remaining_ms/1e3, 3),
"Total Δv used (km/s)": round(self.total_dv_used_ms/1e3, 3),
"Burns performed": self.burns_performed,
"Engine status": self.engine_status.value,
"RCS status": self.rcs_status.value,
}
@dataclass
class PowerSystem:
"""Endurance electrical power budget."""
rtg_power_kW: float = 20.0 # RTG (constant)
solar_power_kW: float = 25.0 # solar (distance-dependent)
fuel_cell_kW: float = 0.0 # fuel cell (on demand)
battery_kWh: float = 200.0 # battery bank
total_demand_kW: float = 35.0 # baseline load
distance_AU: float = 9.537 # current distance from Sun
def solar_output(self) -> float:
"""Solar power falls as 1/r² beyond 1 AU."""
return 25.0 / (self.distance_AU**2)
def total_supply_kW(self) -> float:
return self.rtg_power_kW + self.solar_output() + self.fuel_cell_kW
def power_margin_kW(self) -> float:
return self.total_supply_kW() - self.total_demand_kW
def status_dict(self) -> Dict[str, Any]:
return {
"RTG (kW)": self.rtg_power_kW,
"Solar (kW)": round(self.solar_output(), 2),
"Fuel cell (kW)": self.fuel_cell_kW,
"Total supply (kW)": round(self.total_supply_kW(), 2),
"Total demand (kW)": self.total_demand_kW,
"Power margin (kW)": round(self.power_margin_kW(), 2),
"Battery (kWh)": self.battery_kWh,
"Distance from Sun (AU)": self.distance_AU,
"Power status": ("SURPLUS" if self.power_margin_kW() > 0
else "DEFICIT"),
}
class EnduranceSpacecraft:
"""
Complete ENDURANCE spacecraft model.
16-module rotating ring, full systems integration.
"""
def __init__(self):
self.modules = self._build_modules()
self.life_support = LifeSupportSystem()
self.propulsion = PropulsionSystem()
self.power = PowerSystem()
self.mission_elapsed_days = 0.0
self.rotation_rpm = ENDURANCE_RPM
self.hull_integrity_pct = 100.0
self.micromet_impacts = 0
self.tidal_stress_events= 0
self.alert_log: List[Dict] = []
self.system_status = SystemStatus.NOMINAL
def _build_modules(self) -> List[ShipModule]:
modules = []
# 12 hexagonal habitat modules
hab_names = ["Alpha","Beta","Gamma","Delta","Epsilon","Zeta",
"Eta","Theta","Iota","Kappa","Lambda","Mu"]
for i, name in enumerate(hab_names):
modules.append(ShipModule(
module_id=i, module_type="HABITAT",
name=f"Hab-{name}", status=SystemStatus.NOMINAL))
# 4 rectangular docking/propulsion modules
for i, name in enumerate(["Dock-North","Dock-East","Dock-South","Dock-West"]):
modules.append(ShipModule(
module_id=12+i, module_type="DOCKING",
name=name, status=SystemStatus.NOMINAL))
return modules
def artificial_gravity(self, r_m: float = None) -> float:
"""
Centripetal acceleration at ring radius r:
a = ω²r where ω = 2π·RPM/60
Default r = ENDURANCE ring radius.
"""
r = r_m if r_m else ENDURANCE_RADIUS_M
omega = 2*math.pi*self.rotation_rpm/60
return omega**2 * r
def gravity_profile(self, n_r: int = 100) -> Tuple[np.ndarray, np.ndarray]:
"""Artificial gravity vs radial position in ring."""
r_arr = np.linspace(1.0, ENDURANCE_RADIUS_M, n_r)
a_arr = np.array([self.artificial_gravity(r) for r in r_arr])
return r_arr, a_arr
def apply_tidal_stress(self, tidal_g_per_m: float):
"""Apply tidal stress event from Gargantua proximity."""
for mod in self.modules:
mod.degrade(tidal_g_per_m * 0.1)
self.hull_integrity_pct -= tidal_g_per_m * 0.5
self.hull_integrity_pct = max(0.0, self.hull_integrity_pct)
self.tidal_stress_events += 1
self._add_alert(f"TIDAL STRESS: {tidal_g_per_m:.3e} g/m applied")
def apply_micrometeorite(self, v_impactor_ms: float = 2e4,
m_impactor_kg: float = 1e-6):
"""Small micrometeorite impact on hull."""
E_impact = 0.5 * m_impactor_kg * v_impactor_ms**2
stress = E_impact / 1e6 # rough stress per MJ
self.hull_integrity_pct -= stress * 0.01
self.hull_integrity_pct = max(0.0, self.hull_integrity_pct)
self.micromet_impacts += 1
def _add_alert(self, message: str):
self.alert_log.append({
"time": time.time(),
"message": message,
"day": self.mission_elapsed_days,
})
def advance_mission(self, days: float,
is_cryo_crew_list: List[bool] = None):
"""Advance mission timeline by given days."""
self.mission_elapsed_days += days
self.life_support.consume_per_day(days)
# Random micrometeorite event (Poisson, ~0.1/day)
n_impacts = np.random.poisson(0.1 * days)
for _ in range(n_impacts):
self.apply_micrometeorite()
# Power consumption
self.power.battery_kWh += self.power.power_margin_kW() * days * 24
self.power.battery_kWh = np.clip(self.power.battery_kWh, 0, 200)
def full_status(self) -> Dict[str, Any]:
worst_mod = min(self.modules, key=lambda m: m.integrity_pct)
n_crit = sum(1 for m in self.modules if m.status == SystemStatus.CRITICAL)
n_deg = sum(1 for m in self.modules if m.status == SystemStatus.DEGRADED)
return {
"mission_day": round(self.mission_elapsed_days, 1),
"hull_integrity_pct": round(self.hull_integrity_pct, 2),
"rotation_rpm": self.rotation_rpm,
"artificial_g": round(self.artificial_gravity()/9.81, 3),
"modules_total": len(self.modules),
"modules_nominal": sum(1 for m in self.modules if m.status==SystemStatus.NOMINAL),
"modules_degraded": n_deg,
"modules_critical": n_crit,
"worst_module": worst_mod.name,
"worst_integrity%": round(worst_mod.integrity_pct, 1),
"micromet_impacts": self.micromet_impacts,
"tidal_events": self.tidal_stress_events,
"alerts": len(self.alert_log),
"system_status": self.system_status.value,
}
# ══════════════════════════════════════════════════════════════════════════════
# §8 CRYOSLEEP SYSTEM
# ══════════════════════════════════════════════════════════════════════════════
@dataclass
class CryosleepPod:
pod_id: int
assigned_crew: Optional[CrewID] = None
occupied: bool = False
temp_C: float = 20.0 # current temperature
target_temp_C: float = -10.0 # hibernation target
status: SystemStatus = SystemStatus.STANDBY
metabolic_rate_pct: float = 100.0 # 100% awake, 5% in cryo
duration_days: float = 0.0
revival_ready: bool = False
emergency_mode: bool = False
def initiate_cryo(self, crew: CrewID):
self.assigned_crew = crew
self.occupied = True
self.status = SystemStatus.ACTIVE if False else SystemStatus.NOMINAL
self.metabolic_rate_pct = 5.0
self.revival_ready = False
self.temp_C = -10.0
return f"Pod {self.pod_id} — Cryo initiated for {crew.value}"
def revival_protocol(self, emergency: bool = False) -> List[str]:
"""
Standard revival: 4-hour warm-up.
Emergency revival: 45-minute rapid warm-up (higher cardiac risk).
"""
self.emergency_mode = emergency
self.revival_ready = True
steps = []
if emergency:
steps = [
"0 min: Emergency revival initiated — cardiac monitor active",
"5 min: Temperature ramp 3°C/min",
"20 min: Core temp 30°C — neural reactivation",
"35 min: Defibrillation standby ready",
"45 min: Full revival — 12% cardiac risk",
]
else:
steps = [
"0:00 — Gradual warm: −10°C → 0°C over 60 min",
"1:00 — Neural stimulation begun: EEG monitoring",
"1:30 — Core temp 10°C: circulatory flush",
"2:00 — Nutritional IV drip initiated",
"3:00 — Core temp 20°C: motor function check",
"3:30 — Cognitive assessment protocol",
"4:00 — Full revival complete — crew cleared for duty",
]
self.metabolic_rate_pct = 100.0
self.temp_C = 37.0
self.occupied = False
return steps
class CryosleepManager:
def __init__(self, n_pods: int = 6):
self.pods = [CryosleepPod(pod_id=i) for i in range(n_pods)]
self.cryo_log: List[Dict] = []
def put_to_sleep(self, crew: CrewID, pod_id: int = None) -> str:
if pod_id is not None and pod_id < len(self.pods):
pod = self.pods[pod_id]
else:
pod = next((p for p in self.pods if not p.occupied), None)
if pod is None:
return "ERROR: No available pods"
msg = pod.initiate_cryo(crew)
self.cryo_log.append({"action":"sleep","crew":crew.value,"pod":pod.pod_id})
return msg
def revive(self, crew: CrewID, emergency: bool = False) -> List[str]:
pod = next((p for p in self.pods if p.assigned_crew and p.assigned_crew.name == crew.name), None)
if pod is None:
return [f"ERROR: {crew.value} not in cryosleep"]
steps = pod.revival_protocol(emergency)
self.cryo_log.append({"action":"revive","crew":crew.value,"emergency":emergency})
return steps
def pods_status(self) -> pd.DataFrame:
rows = [{"Pod ID": p.pod_id,
"Crew": p.assigned_crew.value if p.assigned_crew else "—",
"Occupied": p.occupied,
"Temp (°C)": p.temp_C,
"Metabolic%":p.metabolic_rate_pct,
"Status": p.status.value,
"Duration(d)":round(p.duration_days,1),
"Emergency": p.emergency_mode}
for p in self.pods]
return pd.DataFrame(rows)
# ══════════════════════════════════════════════════════════════════════════════
# §9 COMMUNICATIONS SYSTEM
# ══════════════════════════════════════════════════════════════════════════════
@dataclass
class Message:
uid: str = field(default_factory=lambda: uuid.uuid4().hex[:8].upper())
sender: str = "ENDURANCE"
recipient:str = "NASA_EARTH"
content: str = ""
timestamp:float = field(default_factory=time.time)
delivered:bool = False
lag_s: float = 0.0
encrypted:bool = True
priority: str = "NORMAL" # NORMAL / URGENT / CRITICAL
class CommunicationsRelay:
"""
Deep space communications with light-travel-time delay,
bandwidth limits, and signal encryption.
"""
DSN_BANDS = {
"S-band": {"freq_GHz": 2.1, "bandwidth_kbps": 20.0, "range_AU": 20.0},
"X-band": {"freq_GHz": 8.4, "bandwidth_kbps": 100.0, "range_AU": 100.0},
"Ka-band": {"freq_GHz": 32.0, "bandwidth_kbps": 800.0, "range_AU": 50.0},
}
def __init__(self):
self.inbox: List[Message] = []
self.outbox: List[Message] = []
self.band: str = "Ka-band"
self.distance_AU: float = 9.537
self.wormhole_relay: bool = False
self._seed_nasa_messages()
def _seed_nasa_messages(self):
"""Pre-populate with canonical film messages."""
msgs = [
("PROF_BRAND", "ENDURANCE", "Launch successful. You are now beyond Saturn. Good luck. — Prof. Brand"),
("MURPH", "COOPER", "Dad, the blight reached the southern hemisphere. Corn is gone. Please hurry."),
("NASA", "ENDURANCE", "Wormhole remains stable. Saturn observation confirms stable geometry."),
("MURPH", "COOPER", "I figured it out dad. The equation. TARS data was enough. We can all go."),
("NASA", "ENDURANCE", "Plan A complete. Colony ships launching. Thank you, Cooper. Come home."),
]
for i, (sndr, rcpt, content) in enumerate(msgs):
m = Message(sender=sndr, recipient=rcpt, content=content,
lag_s=self.signal_lag_s(), delivered=(i<3))
self.inbox.append(m)
def signal_lag_s(self, distance_AU: float = None) -> float:
"""One-way light travel time [s]."""
d = distance_AU if distance_AU else self.distance_AU
return d * AU / C_SI
def signal_lag_formatted(self, distance_AU: float = None) -> str:
lag = self.signal_lag_s(distance_AU)
if lag < 60: return f"{lag:.1f} s"
elif lag < 3600: return f"{lag/60:.1f} min"
elif lag < 86400: return f"{lag/3600:.2f} hr"
else: return f"{lag/86400:.2f} days"
def bandwidth_bps(self) -> float:
"""Current effective bandwidth in bits/s."""
band = self.DSN_BANDS[self.band]
# FSPL: received power ∝ 1/d²
d_ref = 1.0 # 1 AU reference
d = max(self.distance_AU, 0.01)
attenuation = (d_ref/d)**2
return band["bandwidth_kbps"] * 1000 * attenuation
def send(self, content: str, sender: str = "ENDURANCE",
priority: str = "NORMAL") -> Message:
lag = self.signal_lag_s()
m = Message(sender=sender, recipient="NASA_EARTH",
content=content, lag_s=lag, priority=priority)
self.outbox.append(m)
return m