{"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":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\n#import numpy as np # linear algebra\n#import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\n#import os\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n    #for filename in filenames:\n        #print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-24T09:37:31.147313Z","iopub.execute_input":"2022-12-24T09:37:31.148613Z","iopub.status.idle":"2022-12-24T09:37:31.153214Z","shell.execute_reply.started":"2022-12-24T09:37:31.148567Z","shell.execute_reply":"2022-12-24T09:37:31.152209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport h5py\ntdf=h5py.File('../input/g2net-detecting-continuous-gravitational-waves/train/004f23b2d.hdf5','r')","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.279978Z","iopub.execute_input":"2022-12-24T09:33:30.280454Z","iopub.status.idle":"2022-12-24T09:33:30.467564Z","shell.execute_reply.started":"2022-12-24T09:33:30.280392Z","shell.execute_reply":"2022-12-24T09:33:30.466544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"list(tdf.keys())","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.469391Z","iopub.execute_input":"2022-12-24T09:33:30.469866Z","iopub.status.idle":"2022-12-24T09:33:30.483141Z","shell.execute_reply.started":"2022-12-24T09:33:30.469813Z","shell.execute_reply":"2022-12-24T09:33:30.481826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"particular=tdf['004f23b2d']\nparticular.keys()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.486407Z","iopub.execute_input":"2022-12-24T09:33:30.486874Z","iopub.status.idle":"2022-12-24T09:33:30.498074Z","shell.execute_reply.started":"2022-12-24T09:33:30.486829Z","shell.execute_reply":"2022-12-24T09:33:30.496907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h1=particular['H1']\nh1.keys()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.499453Z","iopub.execute_input":"2022-12-24T09:33:30.500491Z","iopub.status.idle":"2022-12-24T09:33:30.511188Z","shell.execute_reply.started":"2022-12-24T09:33:30.500422Z","shell.execute_reply":"2022-12-24T09:33:30.510007Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sft=h1['SFTs']\nsft_val=list(sft)*360\ndf=pd.DataFrame({\"sfts\":sft_val})\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.51277Z","iopub.execute_input":"2022-12-24T09:33:30.513142Z","iopub.status.idle":"2022-12-24T09:33:30.7612Z","shell.execute_reply.started":"2022-12-24T09:33:30.513106Z","shell.execute_reply":"2022-12-24T09:33:30.760049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"freq=particular['frequency_Hz']\nfreq_val=list(freq)*360","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.762705Z","iopub.execute_input":"2022-12-24T09:33:30.763852Z","iopub.status.idle":"2022-12-24T09:33:30.773213Z","shell.execute_reply.started":"2022-12-24T09:33:30.763802Z","shell.execute_reply":"2022-12-24T09:33:30.771818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dff=pd.DataFrame({\"frequencies\":freq_val})\ndff.describe()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.77469Z","iopub.execute_input":"2022-12-24T09:33:30.775069Z","iopub.status.idle":"2022-12-24T09:33:30.841435Z","shell.execute_reply.started":"2022-12-24T09:33:30.775026Z","shell.execute_reply":"2022-12-24T09:33:30.840126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"l1=particular['L1']\nl1.keys()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.843229Z","iopub.execute_input":"2022-12-24T09:33:30.843696Z","iopub.status.idle":"2022-12-24T09:33:30.851411Z","shell.execute_reply.started":"2022-12-24T09:33:30.843657Z","shell.execute_reply":"2022-12-24T09:33:30.850104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nh1ts=h1['timestamps_GPS']\nt_val=list(h1ts)*360\ndft=pd.DataFrame({\"timestamps\":t_val})\nh1tf=np.array(t_val).view(np.float32)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:30.856769Z","iopub.execute_input":"2022-12-24T09:33:30.857831Z","iopub.status.idle":"2022-12-24T09:33:31.600457Z","shell.execute_reply.started":"2022-12-24T09:33:30.857782Z","shell.execute_reply":"2022-12-24T09:33:31.599317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nfsft=np.array(sft_val).view(np.float32)\nfsftd=fsft.reshape(-1)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:31.601797Z","iopub.execute_input":"2022-12-24T09:33:31.602153Z","iopub.status.idle":"2022-12-24T09:33:33.628629Z","shell.execute_reply.started":"2022-12-24T09:33:31.60212Z","shell.execute_reply":"2022-12-24T09:33:33.627315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n=len(h1tf)\nplt.plot(h1tf[n-100:n],fsftd[n-100:n])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:33.630312Z","iopub.execute_input":"2022-12-24T09:33:33.63106Z","iopub.status.idle":"2022-12-24T09:33:33.914523Z","shell.execute_reply.started":"2022-12-24T09:33:33.631009Z","shell.execute_reply":"2022-12-24T09:33:33.913312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(fsftd[0:n])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:33.915934Z","iopub.execute_input":"2022-12-24T09:33:33.916389Z","iopub.status.idle":"2022-12-24T09:33:35.017392Z","shell.execute_reply.started":"2022-12-24T09:33:33.91634Z","shell.execute_reply":"2022-12-24T09:33:35.016238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nf=len(freq_val)\nplt.plot(freq_val[0:100],fsftd[0:100])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:35.018913Z","iopub.execute_input":"2022-12-24T09:33:35.01958Z","iopub.status.idle":"2022-12-24T09:33:35.178117Z","shell.execute_reply.started":"2022-12-24T09:33:35.019535Z","shell.execute_reply":"2022-12-24T09:33:35.176765Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdfn=h5py.File('../input/g2net-detecting-continuous-gravitational-waves/train/01bcf6533.hdf5','r')","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:35.180103Z","iopub.execute_input":"2022-12-24T09:33:35.180592Z","iopub.status.idle":"2022-12-24T09:33:35.193171Z","shell.execute_reply.started":"2022-12-24T09:33:35.180545Z","shell.execute_reply":"2022-12-24T09:33:35.19186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"particularn=tdfn['01bcf6533']\nh1n=particularn['H1']\nsftn=h1n['SFTs']\nsftn_val=list(sftn)*360\nh1tsn=h1n['timestamps_GPS']\nt_valn=list(h1tsn)*360\nh1tfn=np.array(t_valn).view(np.float32)\nfsftn=np.array(sftn_val).view(np.float32)\nfsftdn=fsftn.reshape(-1)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:35.195226Z","iopub.execute_input":"2022-12-24T09:33:35.196021Z","iopub.status.idle":"2022-12-24T09:33:37.433486Z","shell.execute_reply.started":"2022-12-24T09:33:35.195971Z","shell.execute_reply":"2022-12-24T09:33:37.432204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"freqn=particularn['frequency_Hz']\nfreqn_val=list(freqn)*360","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:37.435044Z","iopub.execute_input":"2022-12-24T09:33:37.435533Z","iopub.status.idle":"2022-12-24T09:33:37.445645Z","shell.execute_reply.started":"2022-12-24T09:33:37.435497Z","shell.execute_reply":"2022-12-24T09:33:37.444513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n1=len(h1tfn)\nplt.plot(h1tfn[n1-100:n1],fsftdn[n1-100:n1])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:37.446996Z","iopub.execute_input":"2022-12-24T09:33:37.447406Z","iopub.status.idle":"2022-12-24T09:33:37.647965Z","shell.execute_reply.started":"2022-12-24T09:33:37.447347Z","shell.execute_reply":"2022-12-24T09:33:37.646734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(fsftdn[0:n1])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:37.649518Z","iopub.execute_input":"2022-12-24T09:33:37.65075Z","iopub.status.idle":"2022-12-24T09:33:38.835052Z","shell.execute_reply.started":"2022-12-24T09:33:37.650684Z","shell.execute_reply":"2022-12-24T09:33:38.833803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(freq_val,fsftdn[0:nf])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:38.836875Z","iopub.execute_input":"2022-12-24T09:33:38.837886Z","iopub.status.idle":"2022-12-24T09:33:40.705906Z","shell.execute_reply.started":"2022-12-24T09:33:38.837829Z","shell.execute_reply":"2022-12-24T09:33:40.704808Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"m=np.mean(fsftd)\nm","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:40.707129Z","iopub.execute_input":"2022-12-24T09:33:40.707463Z","iopub.status.idle":"2022-12-24T09:33:41.222223Z","shell.execute_reply.started":"2022-12-24T09:33:40.707432Z","shell.execute_reply":"2022-12-24T09:33:41.221111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"v=np.var(fsftd)\nv","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:41.223506Z","iopub.execute_input":"2022-12-24T09:33:41.223822Z","iopub.status.idle":"2022-12-24T09:33:52.209569Z","shell.execute_reply.started":"2022-12-24T09:33:41.223792Z","shell.execute_reply":"2022-12-24T09:33:52.208272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mn=np.mean(fsftdn)\nmn","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:52.210853Z","iopub.execute_input":"2022-12-24T09:33:52.211208Z","iopub.status.idle":"2022-12-24T09:33:52.717726Z","shell.execute_reply.started":"2022-12-24T09:33:52.211168Z","shell.execute_reply":"2022-12-24T09:33:52.716692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vn=np.var(fsftdn)\nvn","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:33:52.718927Z","iopub.execute_input":"2022-12-24T09:33:52.719304Z","iopub.status.idle":"2022-12-24T09:34:03.07486Z","shell.execute_reply.started":"2022-12-24T09:33:52.71927Z","shell.execute_reply":"2022-12-24T09:34:03.073597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(h1tf[0:20],freq_val[0:20])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.076341Z","iopub.execute_input":"2022-12-24T09:34:03.077208Z","iopub.status.idle":"2022-12-24T09:34:03.250722Z","shell.execute_reply.started":"2022-12-24T09:34:03.077149Z","shell.execute_reply":"2022-12-24T09:34:03.249456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(h1tfn[0:20],freqn_val[0:20])","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.252199Z","iopub.execute_input":"2022-12-24T09:34:03.252711Z","iopub.status.idle":"2022-12-24T09:34:03.419974Z","shell.execute_reply.started":"2022-12-24T09:34:03.252677Z","shell.execute_reply":"2022-12-24T09:34:03.418999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"td=h5py.File('/kaggle/input/g2net-detecting-continuous-gravitational-waves/train/00a6db666.hdf5','r')","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.421075Z","iopub.execute_input":"2022-12-24T09:34:03.42177Z","iopub.status.idle":"2022-12-24T09:34:03.43534Z","shell.execute_reply.started":"2022-12-24T09:34:03.421733Z","shell.execute_reply":"2022-12-24T09:34:03.434192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fetchsig=td['00a6db666']\nh12=fetchsig['H1']\nl12=fetchsig['L1']\nsfth1=h12['SFTs']\nsfth1_val=list(sfth1)*360\nsftl1=l12['SFTs']\nsftl1_val=list(sftl1)*360","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.442237Z","iopub.execute_input":"2022-12-24T09:34:03.443402Z","iopub.status.idle":"2022-12-24T09:34:03.93219Z","shell.execute_reply.started":"2022-12-24T09:34:03.443331Z","shell.execute_reply":"2022-12-24T09:34:03.931013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"h1tsn","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.933606Z","iopub.execute_input":"2022-12-24T09:34:03.934518Z","iopub.status.idle":"2022-12-24T09:34:03.943208Z","shell.execute_reply.started":"2022-12-24T09:34:03.934481Z","shell.execute_reply":"2022-12-24T09:34:03.94208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def signaltonoise(a, axis=0, ddof=0):\n    a = np.asanyarray(a)\n    m = a.mean(axis)\n    sd = a.std(axis=axis, ddof=ddof)\n    return np.where(sd == 0, 0, m/sd)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.944651Z","iopub.execute_input":"2022-12-24T09:34:03.946009Z","iopub.status.idle":"2022-12-24T09:34:03.953801Z","shell.execute_reply.started":"2022-12-24T09:34:03.945962Z","shell.execute_reply":"2022-12-24T09:34:03.952856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"snr1=signaltonoise(fsft,axis=0,ddof=0)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:03.954857Z","iopub.execute_input":"2022-12-24T09:34:03.955783Z","iopub.status.idle":"2022-12-24T09:34:14.923492Z","shell.execute_reply.started":"2022-12-24T09:34:03.955747Z","shell.execute_reply":"2022-12-24T09:34:14.922124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"snr=signaltonoise(fsftn,axis=0,ddof=0)","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:14.92487Z","iopub.execute_input":"2022-12-24T09:34:14.925327Z","iopub.status.idle":"2022-12-24T09:34:26.356745Z","shell.execute_reply.started":"2022-12-24T09:34:14.925293Z","shell.execute_reply":"2022-12-24T09:34:26.355422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ta=list(h1tsn)*4512","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:26.358564Z","iopub.execute_input":"2022-12-24T09:34:26.35947Z","iopub.status.idle":"2022-12-24T09:34:26.547825Z","shell.execute_reply.started":"2022-12-24T09:34:26.359421Z","shell.execute_reply":"2022-12-24T09:34:26.54663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ta1=list(h1ts)*4546","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:26.549264Z","iopub.execute_input":"2022-12-24T09:34:26.550052Z","iopub.status.idle":"2022-12-24T09:34:26.743386Z","shell.execute_reply.started":"2022-12-24T09:34:26.550004Z","shell.execute_reply":"2022-12-24T09:34:26.74197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tc=np.corrcoef(snr,snr1[0:len(snr)])\ntc","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:50:45.314548Z","iopub.execute_input":"2022-12-24T09:50:45.314975Z","iopub.status.idle":"2022-12-24T09:50:45.324054Z","shell.execute_reply.started":"2022-12-24T09:50:45.31494Z","shell.execute_reply":"2022-12-24T09:50:45.322695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install gwpy","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:26.755394Z","iopub.execute_input":"2022-12-24T09:34:26.756534Z","iopub.status.idle":"2022-12-24T09:34:50.443768Z","shell.execute_reply.started":"2022-12-24T09:34:26.756489Z","shell.execute_reply":"2022-12-24T09:34:50.44252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from gwpy.timeseries import TimeSeries\nfrom gwpy.plot import Plot\nt=TimeSeries(fsftdn[0:n1])\nplot=Plot(t)\nplot.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-24T09:34:50.445842Z","iopub.execute_input":"2022-12-24T09:34:50.446212Z","iopub.status.idle":"2022-12-24T09:34:59.095629Z","shell.execute_reply.started":"2022-12-24T09:34:50.446174Z","shell.execute_reply":"2022-12-24T09:34:59.094712Z"},"trusted":true},"execution_count":null,"outputs":[]}]}