Files
bo-ptycho/notebooks/convergence.ipynb
T

228 KiB

In [1]:
import numpy as np
import matplotlib.pyplot as plt
In [42]:
train_x = np.load("../results/260805-si/Si8V1_2/train_x.npy").T
train_y = np.load("../results/260805-si/Si8V1_2/train_y.npy").T
In [45]:
xparams = [
    'defocus [A]',
    'layers',
    'thickness [A]'
]

sort_index = np.argsort(train_y)

x = train_x[:,sort_index]
y = train_y[sort_index]

EPSILON = 1e-5 # choose best according to plot

y_scaled = np.log(-y + y[-1] + EPSILON)

fig, ax = plt.subplots(1, 2, figsize=(7,3))
ax[0].plot(y, 'k')
ax[1].plot(y_scaled, 'k')
plt.show()
In [52]:
cut = 45 # set to -1 to get all points

fig, axs = plt.subplots(1, len(x), figsize=(3*len(x)+0.5, 3.5), sharey=True)

for i, axi in enumerate(axs):
    axi.scatter(x[i][cut:], -y[cut:], c=y_scaled[cut:], cmap='coolwarm')
    axi.set_xlabel(xparams[i])

axs[0].set_ylabel('$- \\log (\ \\mathtt{fourier\_error}\ )$')

plt.tight_layout()
plt.show()
In [53]:

fig, axs = plt.subplots(len(x), len(x), figsize=(3*len(x)+0.5, 3*len(x)+0.5))

for i, axi in enumerate(axs):
    for j, axij in enumerate(axi):
        axij.scatter(
            x[i], x[j],
            c = y_scaled, # color
            cmap = 'coolwarm',
            s = 20, # size
            alpha = 0 if i == j else 1 # make diagonal transparent
            )
        if i == len(x)-1:
            axij.set_xlabel(xparams[j])
        else:
            axij.set_xticks([])
        if j == 0:
            axij.set_ylabel(xparams[i])
        else:
            axij.set_yticks([])

plt.tight_layout()
plt.show()
In [ ]: