<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Sampling Data"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "from scipy.constants import c\n",
    "import pymwm\n",
    "params = {'core': {'shape': 'cylinder', 'size': 0.15,\n",
    "                   'fill': {'RI': 1.333}},\n",
    "          'clad': {'book': 'Au', 'page': 'Stewart-DLF'},\n",
    "          'bounds': {'wl_max': 1.2, 'wl_min': 0.545,\n",
    "                     'wl_imag': 6.0},  # conditions for use\n",
    "          'modes': {'num_n': 6, 'num_m': 2, 'wl_min': 0.5, 'wl_max': 1.2,\n",
    "                    'wl_imag': 6.0}}  # sampling setting for database\n",
    "wg = pymwm.create(params)  # It takes hours for the first time"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "wg.alphas"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "{'h': [('E', 1, 1),\n",
       "  ('E', 1, 2),\n",
       "  ('E', 2, 1),\n",
       "  ('E', 3, 1),\n",
       "  ('E', 4, 1),\n",
       "  ('E', 5, 1),\n",
       "  ('M', 0, 1),\n",
       "  ('M', 1, 1)],\n",
       " 'v': [('E', 0, 1),\n",
       "  ('E', 1, 1),\n",
       "  ('E', 1, 2),\n",
       "  ('E', 2, 1),\n",
       "  ('E', 3, 1),\n",
       "  ('E', 4, 1),\n",
       "  ('E', 5, 1),\n",
       "  ('M', 1, 1)]}"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "betas, convs, samples = wg.betas_convs_samples(params)\n",
    "samples.plot_convs(convs, ('M', 3, 1))\n",
    "samples.plot_real_betas(betas, ('M', 3, 1))\n",
    "samples.plot_imag_betas(betas, ('M', 3, 1))\n"
   ],
   "outputs": [
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    },
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    },
    {
     "output_type": "display_data",
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWgAAAD7CAYAAABHYA6MAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAmjklEQVR4nO2dfbBtdXnfP999zr0gGCIEX5B7U3SCJpYxaIgxOjEGYYJIwaTjlLS0TNLmTmxekCZjZJipYzvt0MRpta2TzB00odXRUavRMSgi9ib1DzDgCwXRYJJGESKixVSMwD376R9r7XPWXme9/NZea++9zuH7YdacvX7r9/LsfS7PWfu7nuf5KSIwxhgzPibrNsAYY0w1dtDGGDNS7KCNMWak2EEbY8xIsYM2xpiRYgdtjDEjZRAHLekiSV+S9GVJb6i4Lkn/Ob9+p6QXDrGuMcbsZ3o7aEkbwNuAVwLPA35B0vNK3V4JnJ0fR4Df67uuMcbsdzYHmONFwJcj4i8BJL0HuAz4QqHPZcB/iywr5lZJT5F0RkQ80DTxxpNPjs1TTxvAxOHQmPJ6xmRLFQPapzWtu9S5S3N1eo8J8w1qQ8rchT6V81TNUR5TTpyrGaO56zF3bb7f/LW//bsHHoqIp1aZ97M/c3J881tbVZd2ccedj94UERclde7BEA76TOCrhfP7gJ9I6HMm0OigN089jTN/8+r5xoR/KI1OtG18y/XmuRv+F2sYt6i9C7/PmmsL//<KEY>",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "x, y = np.meshgrid(samples.ws, samples.wis, indexing='ij')\n",
    "ws = x + 1j * y\n",
    "es = np.array([samples.clad(w) for w in ws.ravel()]).reshape(ws.shape)\n",
    "vs = np.vectorize(samples.v)(betas[('M', 3, 1)] ** 2, ws, es)\n",
    "plt.pcolormesh(x, y, np.abs(vs.real) > np.abs(vs.imag), shading=\"auto\", rasterized=True)\n",
    "plt.colorbar()\n",
    "plt.show()\n"
   ],
   "outputs": [
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "9d79d0f0957b739e22ce83622b13faf5fa51320166aa3ff5bb1c643ddfc68e3b"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.11 64-bit ('pymwm': conda)"
  },
  "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.8.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
<commit_msg>Don't usr np.vectorize<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Sampling Data"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "from scipy.constants import c\n",
    "import pymwm\n",
    "params = {'core': {'shape': 'cylinder', 'size': 0.15,\n",
    "                   'fill': {'RI': 1.333}},\n",
    "          'clad': {'book': 'Au', 'page': 'Stewart-DLF'},\n",
    "          'bounds': {'wl_max': 1.2, 'wl_min': 0.545,\n",
    "                     'wl_imag': 6.0},  # conditions for use\n",
    "          'modes': {'num_n': 6, 'num_m': 2, 'wl_min': 0.5, 'wl_max': 1.2,\n",
    "                    'wl_imag': 6.0}}  # sampling setting for database\n",
    "wg = pymwm.create(params)  # It takes hours for the first time"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "wg.alphas"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "{'h': [('E', 1, 1),\n",
       "  ('E', 1, 2),\n",
       "  ('E', 2, 1),\n",
       "  ('E', 3, 1),\n",
       "  ('E', 4, 1),\n",
       "  ('M', 0, 1),\n",
       "  ('M', 1, 1)],\n",
       " 'v': [('E', 0, 1),\n",
       "  ('E', 1, 1),\n",
       "  ('E', 1, 2),\n",
       "  ('E', 2, 1),\n",
       "  ('E', 3, 1),\n",
       "  ('E', 4, 1),\n",
       "  ('M', 1, 1)]}"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "betas, convs, samples = wg.betas_convs_samples(params)\n",
    "samples.plot_convs(convs, ('M', 3, 1))\n",
    "samples.plot_real_betas(betas, ('M', 3, 1))\n",
    "samples.plot_imag_betas(betas, ('M', 3, 1))\n"
   ],
   "outputs": [
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>//<KEY>
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    },
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    },
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "x, y = np.meshgrid(samples.ws, samples.wis, indexing='ij')\n",
    "ws = x + 1j * y\n",
    "es = np.array([samples.clad(w) for w in ws.ravel()]).reshape(ws.shape)\n",
    "vs = samples.v(betas[('M', 3, 1)] ** 2, ws, es)\n",
    "plt.pcolormesh(x, y, np.abs(vs.real) > np.abs(vs.imag), shading=\"auto\", rasterized=True)\n",
    "plt.colorbar()\n",
    "plt.show()\n"
   ],
   "outputs": [
    {
     "output_type": "display_data",
     "data": {
      "image/png": "<KEY>",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "9d79d0f0957b739e22ce83622b13faf5fa51320166aa3ff5bb1c643ddfc68e3b"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.11 64-bit ('pymwm': conda)"
  },
  "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.8.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

{'fraction_non_alphanumeric': 0.22295156179266637, 'fraction_numerical': 0.04775916704391127, 'mean_word_length': 2.3460810299129116, 'pattern_counts': {'":': 152, '<': 20, '<?xml version=': 0, '>': 22, '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}}
{'dir': 'git-commits-cleaned', 'id': '5270134', 'n_tokens_mistral': 4148, 'n_tokens_neox': 3819, 'n_words': 604}