@@ -53,6 +53,9 @@ def build_from_config(config: dict | None):
5353 # 交給庫函式做理論值
5454 out = flux_ratio_FRW (R , {"flux" : {"sigma" : sigma , "c" : c }})
5555 # out 期望含有:out["R"], out["R_DBI_CM"]
56+ R = np .asarray (out ["R" ], dtype = float )
57+ Q = np .asarray (out ["R_DBI_CM" ], dtype = float )
58+ eps = np .finfo (float ).eps
5659
5760 # --- CSV ---
5861 csv_path = os .path .join (DATA_DIR , CSV_NAME )
@@ -65,11 +68,34 @@ def build_from_config(config: dict | None):
6568 # --- PDF ---
6669 pdf_path = os .path .join (PDF_DIR , PDF_NAME )
6770 plt .figure (figsize = (4.8 , 3.2 ), dpi = 180 )
68- plt .plot (out ["R" ], out ["R_DBI_CM" ], lw = 1.6 , label = r"$\mathcal{R}_{X/Y}(R)$" )
71+ #plt.plot(out["R"], out["R_DBI_CM"], lw=1.6, label=r"$\mathcal{R}_{X/Y}(R)$")
72+ plt .plot (R , Q , lw = 1.6 , label = r"$\mathcal{R}_{X/Y}(R)$" )
6973 plt .axhline (1.0 , ls = "--" , lw = 1.0 , label = "unity" )
7074 plt .xlabel (r"$R$" )
7175 plt .ylabel (r"$\mathcal{R}_{X/Y}$" )
7276 plt .title (r"Boundary flux ratio $\to 1$ with $R^{-\sigma}$ tail" )
77+ #plt.legend(frameon=False)
78+ # ---- 擬合 R^{-sigma} 的收斂率 ----
79+ try :
80+ fit_Rmin = float (_cfg_get (config , ["flux" , "fit" , "Rmin" ], R .min () + 0.5 * (R .max ()- R .min ())))
81+ mask = (R >= fit_Rmin ) & (np .abs (Q - 1.0 ) > 1e-14 )
82+ if np .any (mask ):
83+ X = np .log (R [mask ])
84+ Y = np .log (np .abs (Q [mask ] - 1.0 ) + eps )
85+ m , b = np .polyfit (X , Y , 1 ) # Y ≈ m X + b
86+ sigma_hat = - m
87+ A_hat = np .exp (b )
88+ # 以尾端平均號誌的符號還原 ±
89+ sgn = np .sign (np .mean (Q [mask ] - 1.0 ))
90+ Qfit = 1.0 + sgn * A_hat * (R ** (- sigma_hat ))
91+ plt .plot (R , Qfit , ls = ":" , lw = 1.2 , label = rf"fit: $1+A R^{{-\hat\sigma}}$, $\hat\sigma$≈{ sigma_hat :.2f} " )
92+ plt .text (
93+ 0.02 , 0.05 , rf"fit window: $R\ge { fit_Rmin :g} $" ,
94+ transform = plt .gca ().transAxes , fontsize = 8
95+ )
96+ except Exception :
97+ pass
98+
7399 plt .legend (frameon = False )
74100 plt .tight_layout ()
75101 plt .savefig (pdf_path )
0 commit comments