{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<div style=\"text-align: center\"><h2><font color=\"sky_blue\">G2Net Gravitational Wave Detection</font></h2></div>","metadata":{"execution":{"iopub.status.busy":"2021-07-01T18:34:33.135690Z","iopub.execute_input":"2021-07-01T18:34:33.136037Z","iopub.status.idle":"2021-07-01T18:34:33.143946Z","shell.execute_reply.started":"2021-07-01T18:34:33.136008Z","shell.execute_reply":"2021-07-01T18:34:33.141983Z"}}},{"cell_type":"markdown","source":"![](https://www.nasa.gov/sites/default/files/thumbnails/image/smbhb_rotate_banner.gif)\nSimulation of Spiraling Supermassive Blackholes. Source - [NASA](https://www.nasa.gov/feature/goddard/2018/new-simulation-sheds-light-on-spiraling-supermassive-black-holes)","metadata":{}},{"cell_type":"markdown","source":"## Table of Content\n1. [Resources](#Resources)\n1. [Metadata](#Metadata)\n1. [Visualize Waves](#Visualize-Waves)\n\n","metadata":{"execution":{"iopub.status.busy":"2021-07-01T18:44:53.268894Z","iopub.execute_input":"2021-07-01T18:44:53.269242Z","iopub.status.idle":"2021-07-01T18:44:53.274463Z","shell.execute_reply.started":"2021-07-01T18:44:53.269213Z","shell.execute_reply":"2021-07-01T18:44:53.273317Z"}}},{"cell_type":"markdown","source":"## Resources\n<a id='Resources'></a>\n- Huge collection of ML + G-Waves [link](https://iphysresearch.github.io/Survey4GWML/)\n- CNN for simulated G-Wave detection - [link](https://arxiv.org/pdf/2011.04418.pdf)","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport typing\nimport os\nimport glob\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport pandas as pd\nfrom tqdm import tqdm","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:59:45.271693Z","iopub.execute_input":"2021-07-01T20:59:45.272055Z","iopub.status.idle":"2021-07-01T20:59:45.277185Z","shell.execute_reply.started":"2021-07-01T20:59:45.272025Z","shell.execute_reply":"2021-07-01T20:59:45.275982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Metadata\n<a id='Metadata'></a>","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:28:51.136195Z","iopub.execute_input":"2021-07-01T20:28:51.136555Z","iopub.status.idle":"2021-07-01T20:28:51.140870Z","shell.execute_reply.started":"2021-07-01T20:28:51.136525Z","shell.execute_reply":"2021-07-01T20:28:51.139273Z"}}},{"cell_type":"code","source":"root = \"/kaggle/input/g2net-gravitational-wave-detection/\"\n\ntrain_df = pd.read_csv(\"/kaggle/input/g2net-mapping-id-to-file-path/training_labels_with_paths.csv\")\n# train_df = pd.read_csv(root+\"training_labels.csv\")\n# train_df[\"path\"] = None\n\n# for path in tqdm(glob.glob(root+\"train/**/*.npy\", recursive=True)):\n#     name = path.split(\"/\")[-1].split(\".\")[0]\n#     train_df.loc[train_df.id == name, \"path\"] = path\n    \ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:21:27.456555Z","iopub.execute_input":"2021-07-01T21:21:27.456986Z","iopub.status.idle":"2021-07-01T21:21:28.752293Z","shell.execute_reply.started":"2021-07-01T21:21:27.456950Z","shell.execute_reply":"2021-07-01T21:21:28.751224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Visualize Waves\n<a id='Visualize Waves'></a>","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:31:15.956651Z","iopub.execute_input":"2021-07-01T20:31:15.957025Z","iopub.status.idle":"2021-07-01T20:31:15.962923Z","shell.execute_reply.started":"2021-07-01T20:31:15.956994Z","shell.execute_reply":"2021-07-01T20:31:15.961157Z"}}},{"cell_type":"code","source":"def plot_waves(sample: np.ndarray) -> None:\n    # sns.set(style=\"ticks\", context=\"notebook\", palette=\"pastel\")\n    plt.style.use(\"seaborn-muted\")\n    _ = plt.plot(sample[0])\n    _ = plt.plot(sample[1])\n    _ = plt.plot(sample[2])","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:09:11.655153Z","iopub.execute_input":"2021-07-01T20:09:11.655626Z","iopub.status.idle":"2021-07-01T20:09:11.667750Z","shell.execute_reply.started":"2021-07-01T20:09:11.655585Z","shell.execute_reply":"2021-07-01T20:09:11.666471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pos_df = train_df[train_df.target==1].iloc[0]\nneg_df = train_df[train_df.target==0].iloc[0]\n\npos_wav = np.load(pos_df.filepath)\nplot_waves(pos_wav)\nplt.show()\nneg_wav = np.load(neg_df.filepath)\nplot_waves(neg_wav)","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:34:16.294921Z","iopub.execute_input":"2021-07-01T21:34:16.295323Z","iopub.status.idle":"2021-07-01T21:34:16.679727Z","shell.execute_reply.started":"2021-07-01T21:34:16.295291Z","shell.execute_reply":"2021-07-01T21:34:16.678790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<div class=\"alert alert-block alert-info\">\n<b>Note:</b>  Work in Progress\n</div>","metadata":{"execution":{"iopub.status.busy":"2021-07-01T18:32:03.067871Z","iopub.execute_input":"2021-07-01T18:32:03.068247Z","iopub.status.idle":"2021-07-01T18:32:03.076871Z","shell.execute_reply.started":"2021-07-01T18:32:03.068216Z","shell.execute_reply":"2021-07-01T18:32:03.074948Z"}}}]}