{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2018-12-21T07:58:17.675598Z", "start_time": "2018-12-21T07:58:17.606705Z" } }, "outputs": [], "source": [ "%reload_ext autoreload\n", "%autoreload 2\n", "import warnings\n", "warnings.filterwarnings(\"ignore\",category =RuntimeWarning)\n", "import numpy as np\n", "import de2 as de\n", "import multiprocessing as mp\n", "import makeqx as mkq\n", "import oldqx as oqx\n", "\n", "\n", "def rndtop5(x):\n", " return np.round(x*2.0)/2\n", "\n", "def tmm_wrapper2(arg):\n", " args, kwargs = arg\n", " return oqx.tmm_eval_wsweep(*args, **kwargs)\n", "\n", "def arc_par(pop, **kwargs):\n", " jobs = []\n", " pool=mp.Pool(90)\n", " for indiv in pop:\n", " #indiv = indiv.reshape((int(indiv.size/2), 2))\n", " #indiv[:,1] = mkq.digitize_qx(indiv[:,1], dlevels=2)\n", " indiv = rndtop5(indiv)\n", " #indiv = indiv.flatten()\n", " jobs.append((indiv, 0))\n", " arg = [(j, kwargs) for j in jobs]\n", " answ = np.array(pool.map(tmm_wrapper2, arg))\n", " pool.close()\n", " return answ\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "start_time": "2018-12-21T07:55:40.495Z" } }, "outputs": [], "source": [ "dataset_size = 100000\n", "\n", "# parameters of the dataset\n", "num_layers = 16\n", "num_lpoints = 256\n", "lam_min = 300\n", "lam_max = 1200\n", "d_min = 0\n", "d_max = 200\n", "\n", "dataset_X = np.random.uniform(0,1,num_layers*dataset_size).astype(float).reshape(dataset_size, num_layers)\n", "lams = np.linspace(lam_min, lam_max, num_lpoints, endpoint=True)\n", "dataset_Y = np.zeros((dataset_size,num_lpoints))\n", "\n", "dataset_Y = arc_par(dataset_X, lam_low=lam_min, lam_high=lam_max, lam_pts = num_lpoints)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2018-12-21T07:58:56.988277Z", "start_time": "2018-12-21T07:58:56.966718Z" } }, "outputs": [ { "data": { "text/plain": [ "(10, 256)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import h5py\n", "h5f = h5py.File('./datasets/s16_siti.h5', 'w')\n", "h5f.create_dataset('sizes', data=dataset_X)\n", "h5f.create_dataset('spectrum', data=dataset_Y)\n", "h5f.close()" ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "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.7.0" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }