From c6945bb0950eb26e57c4eb13cc05ae81ef325e02 Mon Sep 17 00:00:00 2001 From: CGH0S7 Date: Sat, 17 Jan 2026 14:54:33 +0800 Subject: [PATCH] Rename verify_accuracy.py to AMSS_NCKU_Verify_ASC26.py and improve visual output --- ...y_accuracy.py => AMSS_NCKU_Verify_ASC26.py | 81 ++++++++++++------- 1 file changed, 51 insertions(+), 30 deletions(-) rename verify_accuracy.py => AMSS_NCKU_Verify_ASC26.py (65%) diff --git a/verify_accuracy.py b/AMSS_NCKU_Verify_ASC26.py similarity index 65% rename from verify_accuracy.py rename to AMSS_NCKU_Verify_ASC26.py index 2b99f2b..27939c5 100644 --- a/verify_accuracy.py +++ b/AMSS_NCKU_Verify_ASC26.py @@ -14,6 +14,20 @@ import numpy as np import sys import os +# ANSI Color Codes +class Color: + GREEN = '\033[92m' + RED = '\033[91m' + YELLOW = '\033[93m' + BLUE = '\033[94m' + BOLD = '\033[1m' + RESET = '\033[0m' + +def get_status_text(passed): + if passed: + return f"{Color.GREEN}{Color.BOLD}PASS{Color.RESET}" + else: + return f"{Color.RED}{Color.BOLD}FAIL{Color.RESET}" def load_bh_trajectory(filepath): """Load black hole trajectory data""" @@ -110,60 +124,67 @@ def analyze_constraint_violation(constraint_data, n_levels=9): def print_header(): """Print report header""" - print("=" * 60) - print("AMSS-NCKU GW150914 Simulation Accuracy Verification Report") - print("=" * 60) + print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET) + print(Color.BOLD + " AMSS-NCKU GW150914 Simulation Accuracy Verification Report" + Color.RESET) + print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET) def print_rms_results(rms_abs, rms_rel, error, threshold=1.0): """Print RMS error results""" - print("\n1. RMS Error Analysis (Black Hole Trajectory)") - print("-" * 40) + print(f"\n{Color.BOLD}1. RMS Error Analysis (Black Hole Trajectory){Color.RESET}") + print("-" * 45) if error: - print(f" Error: {error}") + print(f" {Color.RED}Error: {error}{Color.RESET}") return False - print(f" RMS absolute error: {rms_abs:.4f} M") - print(f" RMS relative error: {rms_rel:.4f}%") - print(f" Requirement: < {threshold}%") - passed = rms_rel < threshold - status = "PASS" if passed else "FAIL" - print(f" Status: {status}") + + print(f" RMS absolute error: {rms_abs:.4e} M") + print(f" RMS relative error: {rms_rel:.4f}%") + print(f" Requirement: < {threshold}%") + print(f" Status: {get_status_text(passed)}") return passed def print_constraint_results(results, threshold=2.0): """Print constraint violation results""" - print("\n2. ADM Constraint Violation Analysis (Grid Level 0)") - print("-" * 40) + print(f"\n{Color.BOLD}2. ADM Constraint Violation Analysis (Grid Level 0){Color.RESET}") + print("-" * 45) - for name in ['Ham', 'Px', 'Py', 'Pz', 'Gx', 'Gy', 'Gz']: - print(f" Max |{name}|: {results[name]:.6f}") - - print(f"\n Maximum constraint violation: {results['max_violation']:.6f}") - print(f" Requirement: < {threshold}") + names = ['Ham', 'Px', 'Py', 'Pz', 'Gx', 'Gy', 'Gz'] + for i, name in enumerate(names): + print(f" Max |{name:3}|: {results[name]:.6f}", end=" ") + if (i + 1) % 2 == 0: print() + if len(names) % 2 != 0: print() passed = results['max_violation'] < threshold - status = "PASS" if passed else "FAIL" - print(f" Status: {status}") + + print(f"\n Maximum violation: {results['max_violation']:.6f}") + print(f" Requirement: < {threshold}") + print(f" Status: {get_status_text(passed)}") return passed def print_summary(rms_passed, constraint_passed): """Print summary""" - print("\n" + "=" * 60) - print("Verification Summary") - print("=" * 60) + print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET) + print(Color.BOLD + "Verification Summary" + Color.RESET) + print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET) all_passed = rms_passed and constraint_passed + + res_rms = get_status_text(rms_passed) + res_con = get_status_text(constraint_passed) - print(f" RMS error check: {'PASS' if rms_passed else 'FAIL'}") - print(f" Constraint violation check: {'PASS' if constraint_passed else 'FAIL'}") - print(f"\n Overall result: {'All checks passed' if all_passed else 'Some checks failed'}") + print(f" [1] RMS trajectory check: {res_rms}") + print(f" [2] ADM constraint check: {res_con}") + + final_status = f"{Color.GREEN}{Color.BOLD}ALL CHECKS PASSED{Color.RESET}" if all_passed else f"{Color.RED}{Color.BOLD}SOME CHECKS FAILED{Color.RESET}" + print(f"\n Overall result: {final_status}") + print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET + "\n") return all_passed @@ -182,16 +203,16 @@ def main(): # Check if files exist if not os.path.exists(bh_file): - print(f"Error: Black hole trajectory file not found: {bh_file}") + print(f"{Color.RED}{Color.BOLD}Error:{Color.RESET} Black hole trajectory file not found: {bh_file}") sys.exit(1) if not os.path.exists(constraint_file): - print(f"Error: Constraint data file not found: {constraint_file}") + print(f"{Color.RED}{Color.BOLD}Error:{Color.RESET} Constraint data file not found: {constraint_file}") sys.exit(1) # Print header print_header() - print(f"\nData directory: {output_dir}") + print(f"\n{Color.BOLD}Target Directory:{Color.RESET} {Color.BLUE}{output_dir}{Color.RESET}") # Load data bh_data = load_bh_trajectory(bh_file)