{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "65e78297", "metadata": {}, "outputs": [], "source": [ "import os\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "id": "90917d29", "metadata": {}, "outputs": [], "source": [ "result_dir = \"../results/260812-Si/Si2V1_2\"\n", "train_x = np.load(os.path.join(result_dir, 'train_x.npy')).T\n", "train_y = np.load(os.path.join(result_dir, 'train_y.npy')).T\n" ] }, { "cell_type": "code", "execution_count": null, "id": "05c0f656", "metadata": {}, "outputs": [], "source": [ "train_x.shape" ] }, { "cell_type": "code", "execution_count": null, "id": "47b5dd69", "metadata": {}, "outputs": [], "source": [ "xparams = [\n", " 'defocus [A]',\n", " 'layers',\n", " 'thickness [A]'\n", "]\n", "\n", "sort_index = np.argsort(train_y)\n", "\n", "x = train_x[:,sort_index]\n", "y = train_y[sort_index]\n", "\n", "EPSILON = 1e-3 # choose best according to plot\n", "\n", "train_y_scaled = np.log(-train_y + y[-1] + EPSILON)\n", "y_scaled = np.log(-y + y[-1] + EPSILON)\n", "\n", "fig, ax = plt.subplots(1, 2, figsize=(7,3))\n", "ax[0].plot(y, 'k')\n", "ax[1].plot(y_scaled, 'k')\n", "plt.show()\n", "\n", "fig, ax = plt.subplots(1, 2, figsize=(7,3))\n", "ax[0].plot(train_y, 'k')\n", "ax[1].plot(train_y_scaled, 'k')\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "4990770c", "metadata": {}, "outputs": [], "source": [ "cut = 0 # set to -1 to get all points\n", "\n", "fig, axs = plt.subplots(1, len(x), figsize=(3*len(x)+0.5, 3.5), sharey=True)\n", "\n", "for i, axi in enumerate(axs):\n", " axi.scatter(x[i][cut:], y_scaled[cut:], c=y_scaled[cut:], cmap='coolwarm')\n", " axi.set_xlabel(xparams[i])\n", "\n", "axs[0].set_ylabel('$- \\\\log (\\ \\\\mathtt{fourier\\_error}\\ )$')\n", "\n", "plt.tight_layout()\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "a2694f3c", "metadata": {}, "outputs": [], "source": [ "\n", "fig, axs = plt.subplots(len(x), len(x), figsize=(3*len(x)+0.5, 3*len(x)+0.5))\n", "\n", "for i, axi in enumerate(axs):\n", " for j, axij in enumerate(axi):\n", " axij.scatter(\n", " x[j], x[i],\n", " c = y_scaled, # color\n", " cmap = 'coolwarm',\n", " s = 20, # size\n", " alpha = 0 if i == j else 1 # make diagonal transparent\n", " )\n", " if i == len(x)-1:\n", " axij.set_xlabel(xparams[j])\n", " else:\n", " axij.set_xticks([])\n", " if j == 0:\n", " axij.set_ylabel(xparams[i])\n", " else:\n", " axij.set_yticks([])\n", "\n", "plt.tight_layout()\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "295ca65c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "lemon", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.12" } }, "nbformat": 4, "nbformat_minor": 5 }