-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_notebook.py
More file actions
93 lines (73 loc) · 3.39 KB
/
patch_notebook.py
File metadata and controls
93 lines (73 loc) · 3.39 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
import json
with open("Captains Logs/Ideas/Balance Meter Simulator.ipynb", "r") as f:
nb = json.load(f)
new_cell_source = """\
# --- DUAL-LAYER BALANCE METER MATH (THE MOON CONSTRAINT) ---
# Testing the separation of Symbolic Moment (fast movers + Moon)
# and Structural Weather (slow movers, NO Moon).
OUTER_PLANETS = {'saturn', 'uranus', 'neptune', 'pluto'}
# Note: Jupiter sits on the boundary. We'll group it with Outer/Structural for this simulation as is standard, but the actual wovenReportCore splits top 4 outer vs top 6 inner.
INNER_PLANETS = {'sun', 'moon', 'mercury', 'venus', 'mars'}
def bm_magnitude_tanh(raw_magnitudes):
'''Standard Non-Linear Dominance Function for Magnitude.'''
mags = sorted([m for m in raw_magnitudes if m > 0], reverse=True)
if not mags:
return 0.0
peak = mags[0]
rest_sum = sum(mags[1:])
raw_score = peak + (0.25 * rest_sum)
return round(5.0 * math.tanh(0.4 * raw_score), 2)
def calculate_dual_layer_metrics(aspects):
# Differentiate the raw aspects based on timescale
weather_xs = [] # Structural Weather (Slow + Outer)
moment_xs = [] # Symbolic Moment (Fast + Inner + The Moon Constraint)
for asp in aspects:
x, _ = bm_raw_driver(asp)
if x <= 0: continue
t_planet = asp.get('transiting_planet', '').lower()
# THE MOON CONSTRAINT:
# Moon drives Symbolic Moment exclusively, acting as a somatic sensor.
# It is filtered OUT of Structural Weather.
if t_planet == 'moon':
moment_xs.append(x)
elif t_planet in INNER_PLANETS:
# Inner planets drive day-level moment
moment_xs.append(x)
else:
# Outer planets (and Jupiter, nodes, etc) drive chapter-level structural weather
weather_xs.append(x)
# Calculate magnitudes using the same deterministic tanh dominance function,
# but partitioned into their specific timescales.
structural_weather_score = bm_magnitude_tanh(weather_xs)
symbolic_moment_score = bm_magnitude_tanh(moment_xs)
# Combined legacy magnitude for compatibility verification
all_xs = weather_xs + moment_xs
combined_score = bm_magnitude_tanh(all_xs)
return structural_weather_score, symbolic_moment_score, combined_score
print("=" * 100)
print("DUAL-LAYER BALANCE UX — SIMULATION")
print("=" * 100)
print(f"{'Name':<12} {'Window':<20} {'Legacy Mag':>11} | {'Struct Weather':>15} {'Symb Moment':>14}")
print("-" * 100)
# Simulate what these metrics look like on the sample rows
for r in rows:
aspects = r.get('raw_events_json', [])
structural, moment, combined = calculate_dual_layer_metrics(aspects)
# Display
print(f"{r['name']:<12} {r['window_label']:<20} {combined:>11.2f} | {structural:>15.2f} {moment:>14.2f}")
print("\n" + "-" * 100)
print("Struct Weather = Outer/Slow planets. Provides contextual chapter load.")
print("Symb Moment = Inner/Fast planets + Moon constraint. Provides immediate somatic texture.")
print("Legacy Mag = Combined pool (for backwards compatibility).")
"""
new_cell = {
"cell_type": "code",
"execution_count": None,
"metadata": {},
"outputs": [],
"source": new_cell_source.splitlines(True)
}
nb['cells'].append(new_cell)
with open("Captains Logs/Ideas/Balance Meter Simulator.ipynb", "w") as f:
json.dump(nb, f, indent=1)
print("Notebook patched successfully.")