{"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":"## G2Net\n\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-05T03:16:30.041771Z","iopub.execute_input":"2022-10-05T03:16:30.042312Z","iopub.status.idle":"2022-10-05T03:16:38.105701Z","shell.execute_reply.started":"2022-10-05T03:16:30.04224Z","shell.execute_reply":"2022-10-05T03:16:38.105003Z"}}},{"cell_type":"code","source":"!pip install pyfstat","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-10-05T07:50:37.53317Z","iopub.execute_input":"2022-10-05T07:50:37.533686Z","iopub.status.idle":"2022-10-05T07:51:28.090296Z","shell.execute_reply.started":"2022-10-05T07:50:37.533588Z","shell.execute_reply":"2022-10-05T07:51:28.088752Z"},"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pyfstat\nimport h5py \nimport pandas as pd\nimport numpy as np\nimport gc\nimport sys\nimport os\nimport copy\nfrom datetime import datetime\n\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:51.854058Z","iopub.execute_input":"2022-10-05T07:58:51.854555Z","iopub.status.idle":"2022-10-05T07:58:55.355581Z","shell.execute_reply.started":"2022-10-05T07:58:51.854493Z","shell.execute_reply":"2022-10-05T07:58:55.354266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_file = r'/kaggle/input/g2net-detecting-continuous-gravitational-waves/train_labels.csv'\ntrain_folder = r'/kaggle/input/g2net-detecting-continuous-gravitational-waves/train'\ntest_folder = r'/kaggle/input/g2net-detecting-continuous-gravitational-waves/test'","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:55.358104Z","iopub.execute_input":"2022-10-05T07:58:55.359038Z","iopub.status.idle":"2022-10-05T07:58:55.364533Z","shell.execute_reply.started":"2022-10-05T07:58:55.358952Z","shell.execute_reply":"2022-10-05T07:58:55.363067Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Target analysis\n\nThe target file `train_labels.csv` contains 603 rows.\n\n| field  |description   |\n| ------------ | ------------ |\n| id  |  unique id for each sample. each id corresponds to a file name in `\\train` folder |\n| target  |  1: data contains the presence of a gravitational wave. <br>0: data does not contain the presence of a gravitational wave.<br> -1: Physicists are currently unable to determine the status of these files. |\n\n","metadata":{}},{"cell_type":"code","source":"df_target = pd.read_csv(target_file)\n\ndf_target.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:55.365844Z","iopub.execute_input":"2022-10-05T07:58:55.366182Z","iopub.status.idle":"2022-10-05T07:58:55.405927Z","shell.execute_reply.started":"2022-10-05T07:58:55.366151Z","shell.execute_reply":"2022-10-05T07:58:55.404717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_target['target'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:55.921969Z","iopub.execute_input":"2022-10-05T07:58:55.922418Z","iopub.status.idle":"2022-10-05T07:58:55.938317Z","shell.execute_reply.started":"2022-10-05T07:58:55.92238Z","shell.execute_reply":"2022-10-05T07:58:55.937172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Train file","metadata":{}},{"cell_type":"code","source":"pos_sample = '001121a05'\nneg_sample = '01bcf6533'","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:57.070067Z","iopub.execute_input":"2022-10-05T07:58:57.070465Z","iopub.status.idle":"2022-10-05T07:58:57.075499Z","shell.execute_reply.started":"2022-10-05T07:58:57.070434Z","shell.execute_reply":"2022-10-05T07:58:57.074086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f = h5py.File(f'{train_folder}/{pos_sample}.hdf5', 'r')","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:57.824062Z","iopub.execute_input":"2022-10-05T07:58:57.824461Z","iopub.status.idle":"2022-10-05T07:58:57.839045Z","shell.execute_reply.started":"2022-10-05T07:58:57.824429Z","shell.execute_reply":"2022-10-05T07:58:57.837971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"f.keys()","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:58.319109Z","iopub.execute_input":"2022-10-05T07:58:58.319524Z","iopub.status.idle":"2022-10-05T07:58:58.332121Z","shell.execute_reply.started":"2022-10-05T07:58:58.319487Z","shell.execute_reply":"2022-10-05T07:58:58.330651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#<KeysViewHDF5 ['H1', 'L1', 'frequency_Hz']>\n#<KeysViewHDF5 ['SFTs', 'timestamps_GPS']>\nh1 = f[pos_sample]['H1']['SFTs'][:, :]\nh1_time = f[pos_sample]['H1']['timestamps_GPS'][:]\nl1 = f[pos_sample]['L1']['SFTs'][:, :]\nl1_time = f[pos_sample]['L1']['timestamps_GPS'][:]\nfreq = f[pos_sample]['frequency_Hz'][:]","metadata":{"execution":{"iopub.status.busy":"2022-10-05T07:58:59.601056Z","iopub.execute_input":"2022-10-05T07:58:59.601456Z","iopub.status.idle":"2022-10-05T07:59:00.310602Z","shell.execute_reply.started":"2022-10-05T07:58:59.601425Z","shell.execute_reply":"2022-10-05T07:59:00.309598Z"},"trusted":true},"execution_count":null,"outputs":[]}]}