#!/usr/bin/env python3
"""
================================================================================
deff_sensitivity.py
Sensitivity of the trap number 𝒯 to the interaction radius d_eff.

Evaluates 𝒯_max on Ryugu for d_eff = 30, 50, 75, 100 m. Confirms the
𝒯 ~ 1/d_eff^2 scaling once the enclosed mass saturates. At the finest scale
(30 m), 𝒯 exceeds unity near Otohime, indicating a true trap for fine
material at close range.

Companion code for "The Trap Number 𝒯" (prepared for submission).

Usage:
    python deff_sensitivity.py
================================================================================
"""

import numpy as np
from code_trap_number import ASTEROIDS, compute_trap_number_map

if __name__ == '__main__':
    params = ASTEROIDS['Ryugu']
    lat_grid = np.linspace(-85, 85, 40)
    lon_grid = np.linspace(0, 357, 72)

    print("d_eff sensitivity (Ryugu, seed = 0)\n")
    print(f"{'d_eff (m)':>10}{'T_max':>10}{'regime':>20}")
    print("-" * 40)
    for d_eff in [30, 50, 75, 100]:
        Tmap, _ = compute_trap_number_map(params, lat_grid, lon_grid,
                                          d_eff=d_eff, seed=0)
        regime = 'T>1: trap forms' if Tmap.max() > 1 else 'sub-threshold'
        print(f"{d_eff:>10}{Tmap.max():>10.3f}{regime:>20}")

    # Expected output:
    # Synthetic-model output. The manuscript's headline d_eff sensitivity is from
    # the REAL catalogue (code_real_ryugu_trap_number.py); both are listed here:
    #   d_eff = 30 m:  T_max = 1.9 (real) / 1.15 (synthetic)   trap can form
    #   d_eff = 50 m:  T_max = 0.67 (real) / 0.42 (synthetic)
    #   d_eff = 75 m:  T_max = 0.31 (real) / 0.19 (synthetic)
    #   d_eff = 100 m: T_max = 0.19 (real) / 0.11 (synthetic)
