<jupyter_start><jupyter_text>Figure that illustrates the training data in comparison to NSA<jupyter_code>import numpy as np 
from sedflow import obs as Obs
from sedflow import train as Train
from IPython.display import IFrame
# --- plotting --- 
import corner as DFM
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.use('PDF')
mpl.rcParams['text.usetex'] = True
mpl.rcParams['font.family'] = 'serif'
mpl.rcParams['axes.linewidth'] = 1.5
mpl.rcParams['axes.xmargin'] = 1
mpl.rcParams['xtick.labelsize'] = 'x-large'
mpl.rcParams['xtick.major.size'] = 5
mpl.rcParams['xtick.major.width'] = 1.5
mpl.rcParams['ytick.labelsize'] = 'x-large'
mpl.rcParams['ytick.major.size'] = 5
mpl.rcParams['ytick.major.width'] = 1.5
mpl.rcParams['legend.frameon'] = False<jupyter_output><empty_output><jupyter_text>read in training data<jupyter_code># x = theta_sps
# y = [u, g, r, i, z, sigma_u, sigma_g, sigma_r, sigma_i, sigma_z, z]
x_train, y_train = Train.load_data('train', version=1, sample='flow', params='thetas_sps')
train_data = np.vstack([x_train[:,0], x_train[:,1], y_train[:,-1], y_train[:,1], y_train[:,2], y_train[:,7]]).T<jupyter_output><empty_output><jupyter_text>read in NSA data<jupyter_code>nsa, _ = Obs.NSA()
flux_nsa = nsa['NMGY'][:,2:]
ivar_nsa = nsa['NMGY_IVAR'][:,2:]

zred_nsa = nsa['Z']

mags_nsa = Train.flux2mag(flux_nsa)
sigs_nsa = Train.sigma_flux2mag(ivar_nsa**-0.5, flux_nsa)
i_nsa = 25
obs_data = np.vstack([np.ones(len(mags_nsa)), np.ones(len(mags_nsa)), zred_nsa, mags_nsa[:,1], mags_nsa[:,2], sigs_nsa[:,2]]).T
ranges = [(8., 12.5), (0., 1.), (0., 0.06), (10., 22), (10., 22), (0.018, 0.025)]
fig = DFM.corner(train_data[::100], 
                 labels=[r'$\log M_*$', r'$\beta_1$', r'($z$) redshift', r'$g$', r'$r$', r'$\sigma_r$'], 
                 label_kwargs={'fontsize': 25}, 
                 hist_kwargs={'density': True},
                 range=ranges, 
                 hist2d_kwargs={'levels': [0.68, 0.95]})
DFM.overplot_lines(fig, [None, None, zred_nsa[i_nsa], mags_nsa[i_nsa,1], mags_nsa[i_nsa,2], sigs_nsa[i_nsa,2]], color='C3')
ndim = int(np.sqrt(len(fig.axes)))
axes = np.array(fig.axes).reshape((ndim, ndim))

# Loop over the diagonal
for i in range(ndim):
    if i > 1: 
        ax = axes[i, i]
        h = ax.hist(obs_data[:,i], color='C0', density=True, range=ranges[i], histtype='stepfilled', alpha=0.5, bins=20)
        ax.set_ylim(0., 1.1*h[0].max())

# Loop over the histograms
for yi in range(ndim):
    for xi in range(yi):
        if xi > 1 and yi > 1: 
            ax = axes[yi, xi]
            ax.scatter(obs_data[:,xi], obs_data[:,yi], color='C0', s=1, rasterized=True)
            #ax.scatter(obs_data[igals,xi], obs_data[igals,yi], color='C1', s=3, rasterized=True)
            #DFM.hist2d(data_set[:,xi], data_set[:,yi], color='C0', 
            #           range=[ranges[xi], ranges[yi]], 
            #           levels=[0.68, 0.95, 0.99], 
            #           plot_datapoints=False, 
            #           plot_density=False, 
            #           ax=ax)


ax = axes[2, ndim-2]
ax.fill_between([], [], [], color='k', label='Training Set')
ax.fill_between([], [], [], color='C0', label='NSA Catalog')
ax.legend(handletextpad=0.2, markerscale=10, fontsize=25)
fig.savefig('paper/figs/training.pdf', bbox_inches='tight')
IFrame("paper/figs/training.pdf", width=600, height=600)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19520851818988466, 'fraction_numerical': 0.033126293995859216, 'mean_word_length': 3.838340486409156, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '113789', 'license': 'MIT', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1362, 'n_words': 248, 'path': 'docs/nb/training_data.ipynb', 'repo_name': 'changhoonhahn/SEDflow', 'size': '3381'}