4646
4747
4848def load_phi_debug_data (base_path : Path | None = None ) -> pd .DataFrame :
49- """Load phi_step_debug_full.csv with n_round data, or fallback to real_data_full .csv"""
49+ """Load phi_step_debug_full.csv with n_round data, or fallback to perfect_paired_results .csv"""
5050 if base_path is None :
5151 base_path = Path ("out" )
5252
@@ -56,23 +56,53 @@ def load_phi_debug_data(base_path: Path | None = None) -> pd.DataFrame:
5656 if data_path .exists ():
5757 return pd .read_csv (data_path )
5858
59- # Fallback: Use real_data_full.csv
59+ # Fallback 1 (PREFERRED): Use perfect_paired_results.csv
60+ perfect_pair_path = Path ("out/perfect_paired_results.csv" )
61+ if perfect_pair_path .exists ():
62+ print (f"\n ⚠️ Using perfect pair data: { perfect_pair_path } " )
63+ df = pd .read_csv (perfect_pair_path )
64+
65+ # Map columns to expected names
66+ df ['r_emit_m' ] = df ['r_m' ]
67+ df ['M_solar' ] = df ['M_msun' ]
68+
69+ # Calculate n_round from z_obs (n_round ≈ z * φ / (1 - z))
70+ if 'n_round' not in df .columns and 'z_obs' in df .columns :
71+ df ['n_round' ] = df ['z_obs' ] * PHI / (1 - df ['z_obs' ] + 1e-10 )
72+
73+ # Use error_seg as residual (this is actual SSZ prediction error!)
74+ if 'residual' not in df .columns and 'error_seg' in df .columns :
75+ df ['residual' ] = df ['error_seg' ]
76+ df ['abs_residual' ] = np .abs (df ['residual' ])
77+
78+ # Add synthetic columns if needed
79+ if 'source' not in df .columns :
80+ df ['source' ] = 'PerfectPair_' + df ['regime' ].str .replace (' ' , '_' )
81+ if 'case' not in df .columns :
82+ df ['case' ] = df ['regime' ]
83+ if 'f_emit_Hz' not in df .columns :
84+ df ['f_emit_Hz' ] = 4.57e14 # H-alpha line
85+ if 'f_obs_Hz' not in df .columns :
86+ # Calculate from redshift: f_obs = f_emit / (1 + z)
87+ df ['f_obs_Hz' ] = df ['f_emit_Hz' ] / (1 + df ['z_obs' ])
88+
89+ return df
90+
91+ # Fallback 2: Use real_data_full.csv
6092 fallback_path = Path ("data/real_data_full.csv" )
6193 if fallback_path .exists ():
62- print (f"\n ⚠️ Using fallback data: { fallback_path } " )
94+ print (f"\n ⚠️ Using real data fallback : { fallback_path } " )
6395 df = pd .read_csv (fallback_path )
6496
65- # Calculate n_round if not present (n_round ≈ z * φ / (1 - z))
97+ # Calculate n_round if not present
6698 if 'n_round' not in df .columns and 'z' in df .columns :
6799 df ['n_round' ] = df ['z' ] * PHI / (1 - df ['z' ] + 1e-10 )
68100
69- # Calculate residuals if not present (residual = z_obs - z_seg)
101+ # Calculate residuals if not present
70102 if 'residual' not in df .columns :
71- # Use z as proxy for observed redshift
72103 z_col = 'z' if 'z' in df .columns else 'z_obs' if 'z_obs' in df .columns else None
73104 if z_col :
74- # Simple residual: assume perfect SSZ prediction (residual ≈ 0)
75- df ['residual' ] = df [z_col ] * 0.01 # Small synthetic residual
105+ df ['residual' ] = df [z_col ] * 0.01 # Synthetic residual
76106 df ['abs_residual' ] = np .abs (df ['residual' ])
77107
78108 return df
@@ -81,7 +111,8 @@ def load_phi_debug_data(base_path: Path | None = None) -> pd.DataFrame:
81111 pytest .skip (
82112 f"No data available. Tried:\n "
83113 f" 1. { data_path } (pipeline output)\n "
84- f" 2. { fallback_path } (real data)\n "
114+ f" 2. { perfect_pair_path } (perfect pair results)\n "
115+ f" 3. { fallback_path } (real data)\n "
85116 f"\n "
86117 f"🚀 To generate pipeline data: python run_all_ssz_terminal.py"
87118 )
@@ -90,7 +121,7 @@ def load_phi_debug_data(base_path: Path | None = None) -> pd.DataFrame:
90121
91122
92123def load_enhanced_debug_data (base_path : Path | None = None ) -> pd .DataFrame :
93- """Load _enhanced_debug.csv with redshift decomposition, or fallback to real_data_full .csv"""
124+ """Load _enhanced_debug.csv with redshift decomposition, or fallback to perfect_paired_results .csv"""
94125 if base_path is None :
95126 base_path = Path ("out" )
96127
@@ -100,37 +131,58 @@ def load_enhanced_debug_data(base_path: Path | None = None) -> pd.DataFrame:
100131 if data_path .exists ():
101132 return pd .read_csv (data_path )
102133
103- # Fallback: Use real_data_full.csv
134+ # Fallback 1 (PREFERRED): Use perfect_paired_results.csv
135+ perfect_pair_path = Path ("out/perfect_paired_results.csv" )
136+ if perfect_pair_path .exists ():
137+ print (f"\n ⚠️ Using perfect pair data: { perfect_pair_path } " )
138+ df = pd .read_csv (perfect_pair_path )
139+
140+ # Map columns
141+ df ['r_emit_m' ] = df ['r_m' ]
142+
143+ # z_obs already present in perfect pair data
144+ # Add decomposition columns (synthetic approximations)
145+ if 'z_grav' not in df .columns :
146+ # Most redshift is gravitational in strong field
147+ df ['z_grav' ] = df ['z_obs' ] * 0.85
148+ if 'z_SR' not in df .columns :
149+ # Small SR contribution from velocity
150+ df ['z_SR' ] = df ['z_obs' ] * 0.15
151+ if 'z_geom_hint' not in df .columns :
152+ # Geometric hint from segment structure
153+ df ['z_geom_hint' ] = df ['z_seg' ] # Use SSZ prediction as geometric marker
154+
155+ return df
156+
157+ # Fallback 2: Use real_data_full.csv
104158 fallback_path = Path ("data/real_data_full.csv" )
105159 if fallback_path .exists ():
106- print (f"\n ⚠️ Using fallback data: { fallback_path } " )
160+ print (f"\n ⚠️ Using real data fallback : { fallback_path } " )
107161 df = pd .read_csv (fallback_path )
108162
109163 # Ensure required columns exist
110164 if 'z_obs' not in df .columns :
111- # Map 'z' to 'z_obs' if present
112165 if 'z' in df .columns :
113166 df ['z_obs' ] = df ['z' ]
114167 else :
115- df ['z_obs' ] = 0.0 # Default
168+ df ['z_obs' ] = 0.0
116169
117- # Add decomposition columns if missing (synthetic for now )
170+ # Add decomposition columns (synthetic)
118171 if 'z_grav' not in df .columns :
119- df ['z_grav' ] = df ['z_obs' ] * 0.9 # Approximate: most redshift is gravitational
172+ df ['z_grav' ] = df ['z_obs' ] * 0.9
120173 if 'z_SR' not in df .columns :
121- df ['z_SR' ] = df ['z_obs' ] * 0.1 # Approximate: small SR contribution
122- if 'z_geom_hint' not in df .columns and 'z_geom_hint' in df .columns :
123- pass # Already present
124- elif 'z_geom_hint' not in df .columns :
125- df ['z_geom_hint' ] = df ['z_obs' ] * 0.5 # Synthetic geometric hint
174+ df ['z_SR' ] = df ['z_obs' ] * 0.1
175+ if 'z_geom_hint' not in df .columns :
176+ df ['z_geom_hint' ] = df ['z_obs' ] * 0.5
126177
127178 return df
128179
129180 # No data available
130181 pytest .skip (
131182 f"No data available. Tried:\n "
132183 f" 1. { data_path } (pipeline output)\n "
133- f" 2. { fallback_path } (real data)\n "
184+ f" 2. { perfect_pair_path } (perfect pair results)\n "
185+ f" 3. { fallback_path } (real data)\n "
134186 f"\n "
135187 f"🚀 To generate pipeline data: python run_all_ssz_terminal.py"
136188 )
0 commit comments