Adds null test to artifact.
This commit is contained in:
@@ -133,13 +133,42 @@ def main():
|
||||
print(f" Measured: {freq_acc['measured_freq_hz']:.2f} Hz")
|
||||
print(f" Error: {freq_acc['error_hz']:+.2f} Hz ({freq_acc['error_percent']:+.3f}%)")
|
||||
|
||||
nt = result.get('null_test')
|
||||
if nt and nt.get('enabled'):
|
||||
print("\n🔬 NULL TEST (Ch2 DUT vs Ch1 Loopback reference):")
|
||||
print(f" Alignment lag: {nt['lag_ms']:.2f} ms ({nt['lag_samples']} samples)")
|
||||
print(f" Gain factor: {nt['gain_factor']:.4f}")
|
||||
print(f" Residual RMS: {nt['residual_rms']:.2e}")
|
||||
print(f" Residual peak: {nt['residual_peak']:.4f}")
|
||||
print(f" Glitches found: {nt['total_count']}")
|
||||
if nt['by_type']:
|
||||
print(" By type:")
|
||||
for artifact_type, count in nt['by_type'].items():
|
||||
print(f" - {artifact_type}: {count}")
|
||||
if nt['artifacts']:
|
||||
print(" Glitch timestamps:")
|
||||
for a in nt['artifacts'][:20]:
|
||||
if a['type'] == 'null_test_glitch':
|
||||
print(f" {a['time_sec']:.3f}s dur={a['duration_ms']:.1f}ms "
|
||||
f"dev={a['deviation_factor']:.1f}×baseline")
|
||||
elif a['type'] == 'sample_slip':
|
||||
baseline = a.get('lag_baseline', a.get('lag_before', '?'))
|
||||
at = a.get('lag_at_marker', a.get('lag_after', '?'))
|
||||
print(f" {a['time_sec']:.3f}s sample_slip "
|
||||
f"Δ={a['lag_change_samples']:+d} samples "
|
||||
f"(baseline={baseline}, at_marker={at})")
|
||||
if len(nt['artifacts']) > 20:
|
||||
print(f" ... and {len(nt['artifacts']) - 20} more (see YAML)")
|
||||
|
||||
ch1_count = result['channel_1_loopback']['total_artifacts']
|
||||
ch2_count = result['channel_2_dut']['total_artifacts']
|
||||
|
||||
if ch2_count > ch1_count:
|
||||
if nt and nt.get('enabled') and nt['total_count'] > 0:
|
||||
print(f"\n⚠️ NULL TEST: {nt['total_count']} glitch(es) detected in DUT path residual")
|
||||
elif ch2_count > ch1_count:
|
||||
delta = ch2_count - ch1_count
|
||||
print(f"\n⚠️ DEGRADATION DETECTED: {delta} more artifacts in radio path vs loopback")
|
||||
elif ch1_count == ch2_count == 0:
|
||||
elif ch1_count == ch2_count == 0 and (not nt or nt['total_count'] == 0):
|
||||
print("\n✅ EXCELLENT: No artifacts detected in either path!")
|
||||
else:
|
||||
print(f"\nℹ️ Loopback baseline: {ch1_count} artifacts")
|
||||
|
||||
Reference in New Issue
Block a user