{"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":"!cp ../input/scintillation-detector-signal-types/*.{txt,py} .\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\nfrom tqdm import tqdm\n\nfrom scipy.signal import argrelextrema\nfrom sklearn.neighbors import KernelDensity\nfrom utils import get_signals, invert, exp_fit, get_signal, get_PSD, inv_x, normalize","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-25T03:30:26.626491Z","iopub.execute_input":"2022-07-25T03:30:26.626986Z","iopub.status.idle":"2022-07-25T03:30:27.680501Z","shell.execute_reply.started":"2022-07-25T03:30:26.626941Z","shell.execute_reply":"2022-07-25T03:30:27.679099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data_full = pd.read_csv('Run200_Wave_0_1.txt', sep=' ', header=None, skipinitialspace=True)\ndata = data_full.drop([0, 1, 2, 3, 504], axis=1)\ndata.columns = list(range(500))\ndata = 2**14 - data - 1560\ndata.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:30.170960Z","iopub.execute_input":"2022-07-25T03:30:30.171367Z","iopub.status.idle":"2022-07-25T03:30:32.302860Z","shell.execute_reply.started":"2022-07-25T03:30:30.171332Z","shell.execute_reply":"2022-07-25T03:30:32.301498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"N, Cr, Cs = range(105,111), range(160,200), slice(160,200)\nd = data.loc[N,Cr]\nprint(d.shape)\ndt = data.T[N][Cs]\nprint(dt.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:33.553129Z","iopub.execute_input":"2022-07-25T03:30:33.553516Z","iopub.status.idle":"2022-07-25T03:30:33.569050Z","shell.execute_reply.started":"2022-07-25T03:30:33.553484Z","shell.execute_reply":"2022-07-25T03:30:33.567745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"roll = 3\nc = d.rolling(roll,axis=1).median()\nc","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:34.917636Z","iopub.execute_input":"2022-07-25T03:30:34.918019Z","iopub.status.idle":"2022-07-25T03:30:34.961527Z","shell.execute_reply.started":"2022-07-25T03:30:34.917989Z","shell.execute_reply":"2022-07-25T03:30:34.960395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ct = dt.rolling(roll).median()\nct","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:36.354055Z","iopub.execute_input":"2022-07-25T03:30:36.354867Z","iopub.status.idle":"2022-07-25T03:30:36.394625Z","shell.execute_reply.started":"2022-07-25T03:30:36.354810Z","shell.execute_reply":"2022-07-25T03:30:36.393454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p = ct.plot(title='Signal', figsize=(20,10))\np.set_xlabel('time, ns')\np.set_ylabel('bit ADC');","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:39.164872Z","iopub.execute_input":"2022-07-25T03:30:39.165695Z","iopub.status.idle":"2022-07-25T03:30:39.474765Z","shell.execute_reply.started":"2022-07-25T03:30:39.165647Z","shell.execute_reply":"2022-07-25T03:30:39.473470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20,10))\nplt.xlabel('time, ns')\nplt.ylabel('bit ADC')\nfor i in c.index:\n  plt.plot(c.loc[i])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:30:41.548838Z","iopub.execute_input":"2022-07-25T03:30:41.549224Z","iopub.status.idle":"2022-07-25T03:30:41.792962Z","shell.execute_reply.started":"2022-07-25T03:30:41.549193Z","shell.execute_reply":"2022-07-25T03:30:41.791744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p = c.T.plot(title='Signal', figsize=(20,10))\np.set_xlabel('time, ns')\np.set_ylabel('bit ADC');","metadata":{"execution":{"iopub.status.busy":"2022-07-25T03:33:14.044060Z","iopub.execute_input":"2022-07-25T03:33:14.044502Z","iopub.status.idle":"2022-07-25T03:33:14.332944Z","shell.execute_reply.started":"2022-07-25T03:33:14.044471Z","shell.execute_reply":"2022-07-25T03:33:14.331752Z"},"trusted":true},"execution_count":null,"outputs":[]}]}