Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
FaroutYLq committed Apr 5, 2024
1 parent d189842 commit dee118a
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions saltax/match/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,36 +693,35 @@ def show_area_bias(salt, simu, title, fraction=False,
bias_2sig_u = []
bias_2sig_l = []

for i in range(n_bins-1):
mask0_i = (simu[coord]>=bins[i])&(simu[coord]<bins[i+1])
bias_i = bias[mask0_i]
bias_med.append(np.median(bias_i))
bias_1sig_l.append(np.percentile(bias_i, 16.5))
bias_1sig_u.append(np.percentile(bias_i, 83.5))
bias_2sig_l.append(np.percentile(bias_i, 2.5))
bias_2sig_u.append(np.percentile(bias_i, 97.5))
if not fraction:
for i in range(n_bins-1):
mask0_i = (simu[coord]>=bins[i])&(simu[coord]<bins[i+1])
bias_i = bias[mask0_i]
bias_med.append(np.median(bias_i))
bias_1sig_l.append(np.percentile(bias_i, 16.5))
bias_1sig_u.append(np.percentile(bias_i, 83.5))
bias_2sig_l.append(np.percentile(bias_i, 2.5))
bias_2sig_u.append(np.percentile(bias_i, 97.5))
else:
for i in range(n_bins-1):
mask0_i = (simu[coord]>=bins[i])&(simu[coord]<bins[i+1])
bias_i = bias[mask0_i]
bias_med.append(np.median(bias_i)/np.median(simu[coord][mask0_i])*100)
bias_1sig_l.append(np.percentile(bias_i, 16.5)/np.percentile(simu[coord][mask0_i], 16.5)*100)
bias_1sig_u.append(np.percentile(bias_i, 83.5)/np.percentile(simu[coord][mask0_i], 83.5)*100)
bias_2sig_l.append(np.percentile(bias_i, 2.5)/np.percentile(simu[coord][mask0_i], 2.5)*100)
bias_2sig_u.append(np.percentile(bias_i, 97.5)/np.percentile(simu[coord][mask0_i], 97.5)*100)

plt.figure(dpi=150)
plt.scatter(simu[coord], bias, s=0.5, alpha=0.2, color='k')
plt.plot(bins_mid, bias_med, color='tab:blue', label='Median')
plt.plot(bins_mid, bias_1sig_l, color='tab:blue', linestyle='dashed', label='1Sig')
plt.plot(bins_mid, bias_1sig_u, color='tab:blue', linestyle='dashed')
plt.plot(bins_mid, bias_2sig_l, color='tab:blue', linestyle='dashed', alpha=0.5, label='2Sig')
plt.plot(bins_mid, bias_2sig_u, color='tab:blue', linestyle='dashed', alpha=0.5)
if not fraction:
plt.scatter(simu[coord], bias, s=0.5, alpha=0.2, color='k')
plt.plot(bins_mid, bias_med, color='tab:blue', label='Median')
plt.plot(bins_mid, bias_1sig_l, color='tab:blue', linestyle='dashed', label='1Sig')
plt.plot(bins_mid, bias_1sig_u, color='tab:blue', linestyle='dashed')
plt.plot(bins_mid, bias_2sig_l, color='tab:blue', linestyle='dashed', alpha=0.5, label='2Sig')
plt.plot(bins_mid, bias_2sig_u, color='tab:blue', linestyle='dashed', alpha=0.5)
plt.ylabel('Change in %s Area [PE]'%(s1s2))
else:
plt.scatter(simu[coord], bias/simu[s1s2+'_area']*100, s=0.5, alpha=0.2, color='k')
plt.plot(bins_mid, np.array(bias_med)/np.array(simu[s1s2+'_area'][np.array(simu[coord]>=bins[0])]),
color='tab:blue', label='Median')
plt.plot(bins_mid, np.array(bias_1sig_l)/np.array(simu[s1s2+'_area'][np.array(simu[coord]>=bins[0])]),
color='tab:blue', linestyle='dashed', label='1Sig')
plt.plot(bins_mid, np.array(bias_1sig_u)/np.array(simu[s1s2+'_area'][np.array(simu[coord]>=bins[0])]),
color='tab:blue', linestyle='dashed')
plt.plot(bins_mid, np.array(bias_2sig_l)/np.array(simu[s1s2+'_area'][np.array(simu[coord]>=bins[0])]),
color='tab:blue', linestyle='dashed', alpha=0.5, label='2Sig')
plt.plot(bins_mid, np.array(bias_2sig_u)/np.array(simu[s1s2+'_area'][np.array(simu[coord]>=bins[0])]),
color='tab:blue', linestyle='dashed', alpha=0.5)
plt.ylabel('Change in %s Area [%%]'%(s1s2))
plt.xlabel(coord+units_dict[coord])
plt.xlim(bins[0], bins[-1])
Expand Down

0 comments on commit dee118a

Please sign in to comment.