Rename verify_accuracy.py to AMSS_NCKU_Verify_ASC26.py and improve visual output
This commit is contained in:
@@ -14,6 +14,20 @@ import numpy as np
|
|||||||
import sys
|
import sys
|
||||||
import os
|
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):
|
def load_bh_trajectory(filepath):
|
||||||
"""Load black hole trajectory data"""
|
"""Load black hole trajectory data"""
|
||||||
@@ -110,60 +124,67 @@ def analyze_constraint_violation(constraint_data, n_levels=9):
|
|||||||
|
|
||||||
def print_header():
|
def print_header():
|
||||||
"""Print report header"""
|
"""Print report header"""
|
||||||
print("=" * 60)
|
print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
|
||||||
print("AMSS-NCKU GW150914 Simulation Accuracy Verification Report")
|
print(Color.BOLD + " AMSS-NCKU GW150914 Simulation Accuracy Verification Report" + Color.RESET)
|
||||||
print("=" * 60)
|
print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
|
||||||
|
|
||||||
|
|
||||||
def print_rms_results(rms_abs, rms_rel, error, threshold=1.0):
|
def print_rms_results(rms_abs, rms_rel, error, threshold=1.0):
|
||||||
"""Print RMS error results"""
|
"""Print RMS error results"""
|
||||||
print("\n1. RMS Error Analysis (Black Hole Trajectory)")
|
print(f"\n{Color.BOLD}1. RMS Error Analysis (Black Hole Trajectory){Color.RESET}")
|
||||||
print("-" * 40)
|
print("-" * 45)
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
print(f" Error: {error}")
|
print(f" {Color.RED}Error: {error}{Color.RESET}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print(f" RMS absolute error: {rms_abs:.4f} M")
|
passed = rms_rel < threshold
|
||||||
|
|
||||||
|
print(f" RMS absolute error: {rms_abs:.4e} M")
|
||||||
print(f" RMS relative error: {rms_rel:.4f}%")
|
print(f" RMS relative error: {rms_rel:.4f}%")
|
||||||
print(f" Requirement: < {threshold}%")
|
print(f" Requirement: < {threshold}%")
|
||||||
|
print(f" Status: {get_status_text(passed)}")
|
||||||
passed = rms_rel < threshold
|
|
||||||
status = "PASS" if passed else "FAIL"
|
|
||||||
print(f" Status: {status}")
|
|
||||||
|
|
||||||
return passed
|
return passed
|
||||||
|
|
||||||
|
|
||||||
def print_constraint_results(results, threshold=2.0):
|
def print_constraint_results(results, threshold=2.0):
|
||||||
"""Print constraint violation results"""
|
"""Print constraint violation results"""
|
||||||
print("\n2. ADM Constraint Violation Analysis (Grid Level 0)")
|
print(f"\n{Color.BOLD}2. ADM Constraint Violation Analysis (Grid Level 0){Color.RESET}")
|
||||||
print("-" * 40)
|
print("-" * 45)
|
||||||
|
|
||||||
for name in ['Ham', 'Px', 'Py', 'Pz', 'Gx', 'Gy', 'Gz']:
|
names = ['Ham', 'Px', 'Py', 'Pz', 'Gx', 'Gy', 'Gz']
|
||||||
print(f" Max |{name}|: {results[name]:.6f}")
|
for i, name in enumerate(names):
|
||||||
|
print(f" Max |{name:3}|: {results[name]:.6f}", end=" ")
|
||||||
print(f"\n Maximum constraint violation: {results['max_violation']:.6f}")
|
if (i + 1) % 2 == 0: print()
|
||||||
print(f" Requirement: < {threshold}")
|
if len(names) % 2 != 0: print()
|
||||||
|
|
||||||
passed = results['max_violation'] < threshold
|
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
|
return passed
|
||||||
|
|
||||||
|
|
||||||
def print_summary(rms_passed, constraint_passed):
|
def print_summary(rms_passed, constraint_passed):
|
||||||
"""Print summary"""
|
"""Print summary"""
|
||||||
print("\n" + "=" * 60)
|
print("\n" + Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
|
||||||
print("Verification Summary")
|
print(Color.BOLD + "Verification Summary" + Color.RESET)
|
||||||
print("=" * 60)
|
print(Color.BLUE + Color.BOLD + "=" * 65 + Color.RESET)
|
||||||
|
|
||||||
all_passed = rms_passed and constraint_passed
|
all_passed = rms_passed and constraint_passed
|
||||||
|
|
||||||
print(f" RMS error check: {'PASS' if rms_passed else 'FAIL'}")
|
res_rms = get_status_text(rms_passed)
|
||||||
print(f" Constraint violation check: {'PASS' if constraint_passed else 'FAIL'}")
|
res_con = get_status_text(constraint_passed)
|
||||||
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
|
return all_passed
|
||||||
|
|
||||||
@@ -182,16 +203,16 @@ def main():
|
|||||||
|
|
||||||
# Check if files exist
|
# Check if files exist
|
||||||
if not os.path.exists(bh_file):
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
if not os.path.exists(constraint_file):
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
# Print header
|
# Print header
|
||||||
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
|
# Load data
|
||||||
bh_data = load_bh_trajectory(bh_file)
|
bh_data = load_bh_trajectory(bh_file)
|
||||||
Reference in New Issue
Block a user