fig, ax = plt.subplots(
3, 1, figsize=(8, 5), sharex=True, gridspec_kw={"height_ratios": [5, 0.75, 1.5]}
)
fig.subplots_adjust(hspace=0)
ls = []
n, bins, patches = ax[0].hist(
speed,
bins=50,
color="black",
range=(0, 2000),
histtype="step",
label="Solar CMEs",
linewidth=2,
)
ls.append(patches[0])
# Inoue 2023 H-alpha flares
l1 = ax[1].scatter(
[990], [0.2], marker="o", color="black", s=20, label="Inoue+23 1-comp"
)
ax[1].errorbar([990], [0.2], xerr=[[130], [130]], fmt="none", color="black", capsize=3)
l2 = ax[1].scatter(
[1690], [-0.2], marker="o", color="red", s=20, label="Inoue+23 2-comp"
)
ax[1].errorbar([1690], [-0.2], xerr=[[100], [100]], fmt="none", color="red", capsize=3)
ax[1].scatter([760], [-0.2], marker="o", color="red", s=20)
ax[1].errorbar([760], [-0.2], xerr=[[90], [90]], fmt="none", color="red", capsize=3)
ls.append(l1)
ls.append(l2)
for i, epoch in enumerate(epochs):
sampler = emcee.backends.HDFBackend(
data_path + epochs[i] + "_" + target + "_velocity_chain.h5"
)
samples = sampler.get_chain(flat=True)
samples[:, 0] = (
d * np.tan(samples[:, 0] * mas) / (24 * 60 * 60) / 1e3
) # mas/day -> km/s
samples[:, 2] = (
d * np.tan(samples[:, 2] * mas) / (24 * 60 * 60) / 1e3
) # mas/day -> km/s
epoch_speed = np.sqrt(samples[:, 0] ** 2 + samples[:, 2] ** 2)
lower, mid, upper = np.percentile(epoch_speed, [16, 50, 84])
ln = ax[2].scatter(
[mid],
[-(i - 3) / 4],
marker="s",
color=cm[i],
s=20,
label="%s (%.1f)" % (epoch, mean_mjd[i]),
)
ax[2].errorbar(
[mid],
[-(i - 3) / 4],
xerr=[[mid - lower], [upper - mid]],
fmt="none",
color=cm[i],
capsize=3,
)
ax[2].errorbar(
[lower],
[-(i - 3) / 4],
xerr=[[mid - lower], [0]],
color=cm[i],
capsize=3,
marker="",
alpha=0.5,
)
ax[2].errorbar(
[upper],
[-(i - 3) / 4],
xerr=[[0], [upper - mid]],
color=cm[i],
capsize=3,
marker="",
alpha=0.5,
)
ls.append(ln)
ax[0].yaxis.set_major_formatter(mpl.ticker.FormatStrFormatter("%3.0f"))
ax[0].tick_params(labelsize=10, labelrotation=45)
ax[0].set_ylabel("Number of Events", fontsize=12)
ax[2].xaxis.set_major_formatter(mpl.ticker.FormatStrFormatter("%3.0f"))
ax[2].tick_params(labelsize=10)
ax[2].set_xlabel("Projected Linear Speed (km/s)", fontsize=12)
ax[0].set_xlim(0, 2000)
ax[0].set_ylim(0, 4000)
ax[1].set_ylim(-1, 1)
ax[2].set_ylim(-1, 1)
ax[1].set_yticks([])
ax[2].set_yticks([])
ax[0].legend(ls, [l.get_label() for l in ls], loc="upper right", fontsize=9)
fig.set_dpi(300)
plt.savefig(fig_path + "velocity_comparison.pdf", bbox_inches="tight")
plt.show()