49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
|
|
"""Test the Zernike Trajectory extractor on an existing OP2 file."""
|
||
|
|
|
||
|
|
from optimization_engine.extractors.extract_zernike_trajectory import extract_zernike_trajectory
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
op2_file = Path(r'tests\M1_Tensor\Atomizer_M1_Best_2026-01-29 - Tensor\assy_m1_assyfem1_sim1-solution_1.op2')
|
||
|
|
|
||
|
|
print(f'Testing trajectory extractor on: {op2_file}')
|
||
|
|
print('=' * 60)
|
||
|
|
|
||
|
|
try:
|
||
|
|
result = extract_zernike_trajectory(
|
||
|
|
op2_file,
|
||
|
|
reference_angle=20.0,
|
||
|
|
focal_length=22000.0
|
||
|
|
)
|
||
|
|
|
||
|
|
print('[OK] Extractor ran successfully!')
|
||
|
|
print()
|
||
|
|
print(f'Angles detected: {result["angles_deg"]}')
|
||
|
|
print(f'Reference angle: {result["reference_angle"]} deg')
|
||
|
|
print(f'Number of angles: {result["n_angles"]}')
|
||
|
|
print()
|
||
|
|
print(f'Linear fit R2: {result["linear_fit_r2"]:.4f}')
|
||
|
|
if result["linear_fit_r2"] > 0.95:
|
||
|
|
print(' [OK] Excellent fit - physics model validated')
|
||
|
|
elif result["linear_fit_r2"] > 0.85:
|
||
|
|
print(' [~] Good fit - some nonlinearity present')
|
||
|
|
else:
|
||
|
|
print(' [!] Poor fit - significant nonlinearity')
|
||
|
|
print()
|
||
|
|
print('--- Mode-Specific RMS (nm) ---')
|
||
|
|
print(f'Total Filtered RMS: {result["total_filtered_rms_nm"]:.2f} nm')
|
||
|
|
print(f'Coma RMS: {result["coma_rms_nm"]:.2f} nm')
|
||
|
|
print(f'Astigmatism RMS: {result["astigmatism_rms_nm"]:.2f} nm')
|
||
|
|
print(f'Trefoil RMS: {result["trefoil_rms_nm"]:.2f} nm')
|
||
|
|
print(f'Spherical RMS: {result["spherical_rms_nm"]:.2f} nm')
|
||
|
|
print()
|
||
|
|
print(f'Dominant mode: {result["dominant_mode"]}')
|
||
|
|
print(f'Mode ranking: {", ".join(result["mode_ranking"][:5])}')
|
||
|
|
print()
|
||
|
|
print('[OK] All validation checks passed!')
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f'[ERROR] {e}')
|
||
|
|
import traceback
|
||
|
|
traceback.print_exc()
|
||
|
|
exit(1)
|