<jupyter_start><jupyter_text>Plotting angular distributions for U-238<jupyter_code>import sandy
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("whitegrid")
tape = sandy.get_endf6_file("jeff_33", "xs", 922380)
lpc = sandy.Lpc.from_endf6(tape)  # legendre polynomial coefficients<jupyter_output><empty_output><jupyter_text>Available MT numbers<jupyter_code>lpc.data.index.get_level_values("MT").unique()<jupyter_output><empty_output><jupyter_text>Tabulated energies (linear interpolation is assumed)<jupyter_code>lpc.data.index.get_level_values("E").unique()<jupyter_output><empty_output><jupyter_text>Plot for MT=2<jupyter_code># keep only coefficients for first 6 polynomials
data = lpc.data.stack().rename("VAL").reset_index().query("MT==2 & P<=6")
data["P"] = data["P"].astype("category")

fig, ax = plt.subplots(figsize=(7, 4), dpi=100)
sns.lineplot(ax=ax, data=data, x="E", y="VAL", hue="P")
ax.set_xlim([1e1, 2e7])
ax.set_xlabel("neutron energy / $MeV$")
ax.set_ylabel("polynomial coefficient")
ax.set_xscale("log")
fig.tight_layout()<jupyter_output><empty_output><jupyter_text>Convert polynomial coefficients to tabulated angular distribution<jupyter_code>cosines = np.linspace(-1, 1, 101)
tpd = lpc.filter_by("MT", 2).to_tpd(cosines=cosines)
data = tpd.data.stack().rename("VAL").reset_index()

fig, ax = plt.subplots(figsize=(7, 4), dpi=100)
sns.lineplot(ax=ax, data=data, x="COSINE", y="VAL", hue="E")
ax.legend(title="neutron energy / $MeV$", ncol=2)
ax.set_xlim([-1, 1])
ax.set_xlabel("scattering cosine")
ax.set_ylabel("tabulated angular distribution")
ax.set_yscale("log")
fig.tight_layout()<jupyter_output><empty_output><jupyter_text>Plot for MT=51<jupyter_code>cosines = np.linspace(-1, 1, 101)
tpd = lpc.filter_by("MT", 51).to_tpd(cosines=cosines)
data = tpd.data.stack().rename("VAL").reset_index()

fig, ax = plt.subplots(figsize=(7, 4), dpi=100)
sns.lineplot(ax=ax, data=data, x="COSINE", y="VAL", hue="E")
ax.legend(title="neutron energy / $MeV$", ncol=2)
ax.set_xlim([-1, 1])
ax.set_xlabel("scattering cosine")
ax.set_ylabel("tabulated angular distribution")
ax.set_yscale("log")
fig.tight_layout()<jupyter_output><empty_output><jupyter_text>Plot for MT=90<jupyter_code>cosines = np.linspace(-1, 1, 101)
tpd = lpc.filter_by("MT", 90).to_tpd(cosines=cosines)
data = tpd.data.stack().rename("VAL").reset_index()

fig, ax = plt.subplots(figsize=(7, 4), dpi=100)
sns.lineplot(ax=ax, data=data, x="COSINE", y="VAL", hue="E")
ax.legend(title="neutron energy / $MeV$", ncol=2)
ax.set_xlim([-1, 1])
ax.set_xlabel("scattering cosine")
ax.set_ylabel("tabulated angular distribution")
ax.set_yscale("log")
fig.tight_layout()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup