moved notebooks to sandbox

This commit is contained in:
2026-08-16 02:51:23 +09:00
parent 8e8136d562
commit 93f69ceb06
2 changed files with 0 additions and 281 deletions
-154
View File
@@ -1,154 +0,0 @@
{
"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
}
-127
View File
@@ -1,127 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 17,
"id": "5c8aa3fd",
"metadata": {},
"outputs": [],
"source": [
"from scipy.io import loadmat as scipy_loadmat\n",
"from mat73 import loadmat as mat73_loadmat\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1d3c8601",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/home/swim/bo-ptycho/notebooks'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%pwd"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4a419040",
"metadata": {},
"outputs": [],
"source": [
"f = \"/home/swim/Si_project/Si8V2_full/roi1_Ndp256/MLs_L1_p1_g64_Ndp192_pc1_noModel_Ns23_dz14.6087_reg0.2/Niter1000.mat\""
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "405b77b4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['__header__', '__version__', '__globals__', 'outputs', 'probe', 'object', 'p', '__function_workspace__'])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"contents = scipy_loadmat(f)\n",
"contents.keys()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "8a7b58b2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"mappingproxy({'object_ROI': (dtype('O'), 0),\n",
" 'binning': (dtype('O'), 8),\n",
" 'detector': (dtype('O'), 16),\n",
" 'dx_spec': (dtype('O'), 24),\n",
" 'lambda': (dtype('O'), 32),\n",
" 'multi_slice_param': (dtype('O'), 40),\n",
" 'obj_init_param': (dtype('O'), 48),\n",
" 'init_probe_file': (dtype('O'), 56),\n",
" 'normalize_init_probe': (dtype('O'), 64)})"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"contents['p'].dtype.fields"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8870f98",
"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
}