{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "distance×amplitude=constant  \n",
    "To make distance of BBH waveform the same to Korean waveform,we can just adjust their amplitudes to be equal(assume other parameters' value are the same)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import h5py\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "f1 = h5py.File('data_0.h5py','r')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load the data of BBH waveform. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rand_pars\n",
      "snrs\n",
      "y_data_noisefree\n",
      "y_data_noisy\n"
     ]
    }
   ],
   "source": [
    "for name in f1:\n",
    "    print (name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "snrs = f1['snrs']\n",
    "y_data_noisy = f1['y_data_noisy']\n",
    "y_data_noisefree = f1['y_data_noisefree']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 256)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_data_noisy.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 256)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_data_noisefree.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.602239529718611"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "snrs[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.49054561144056547"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "snrs[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.6836938474967145"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "snrs[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f0f2dbdf908>]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 28532 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(len(y_data_noisefree[0])),y_data_noisefree[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f0f2d721c18>]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 29484 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(len(y_data_noisefree[1])),y_data_noisefree[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f0f2d699048>]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 27216 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(len(y_data_noisefree[2])),y_data_noisefree[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "amplitude_1 = 6*10**(-24)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load the data of Korean waveform "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "f2 = open(r'h_m16_L0.18_l2m2_r300.dat',encoding='utf-8')\n",
    "list = []\n",
    "for line in f2:\n",
    "    s = line.strip('\\n').split()\n",
    "    list.append(s)\n",
    "f2.close()\n",
    "\n",
    "korean_waveform=pd.DataFrame(list,columns=['time','h_plus','h_cross'])\n",
    "korean_waveform.set_index([\"time\"], inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>h_plus</th>\n",
       "      <th>h_cross</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0.00000000e+00</td>\n",
       "      <td>0.00000000e+00</td>\n",
       "      <td>0.00000000e+00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2.70000000e-01</td>\n",
       "      <td>7.17117383e-09</td>\n",
       "      <td>3.83995103e-09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5.40000000e-01</td>\n",
       "      <td>1.43390297e-08</td>\n",
       "      <td>7.66235268e-09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.10000000e-01</td>\n",
       "      <td>2.15035687e-08</td>\n",
       "      <td>1.14672111e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1.08000000e+00</td>\n",
       "      <td>2.86647920e-08</td>\n",
       "      <td>1.52545325e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.79120000e+02</td>\n",
       "      <td>-7.12781211e-10</td>\n",
       "      <td>1.54069207e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.79390000e+02</td>\n",
       "      <td>2.19315281e-09</td>\n",
       "      <td>2.58643234e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.79660000e+02</td>\n",
       "      <td>-1.88629275e-09</td>\n",
       "      <td>1.53031325e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.79930000e+02</td>\n",
       "      <td>6.22065814e-10</td>\n",
       "      <td>2.58521388e-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8.80200000e+02</td>\n",
       "      <td>-3.90166108e-09</td>\n",
       "      <td>1.54178013e-08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3261 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                         h_plus         h_cross\n",
       "time                                           \n",
       "0.00000000e+00   0.00000000e+00  0.00000000e+00\n",
       "2.70000000e-01   7.17117383e-09  3.83995103e-09\n",
       "5.40000000e-01   1.43390297e-08  7.66235268e-09\n",
       "8.10000000e-01   2.15035687e-08  1.14672111e-08\n",
       "1.08000000e+00   2.86647920e-08  1.52545325e-08\n",
       "...                         ...             ...\n",
       "8.79120000e+02  -7.12781211e-10  1.54069207e-08\n",
       "8.79390000e+02   2.19315281e-09  2.58643234e-08\n",
       "8.79660000e+02  -1.88629275e-09  1.53031325e-08\n",
       "8.79930000e+02   6.22065814e-10  2.58521388e-08\n",
       "8.80200000e+02  -3.90166108e-09  1.54178013e-08\n",
       "\n",
       "[3261 rows x 2 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "korean_waveform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "h_plus=korean_waveform['h_plus']\n",
    "h_cross=korean_waveform['h_cross']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f0f260d7978>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 16444 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "h_plus_n = h_plus.astype(float)\n",
    "h_plus_n.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f0f260469e8>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 19448 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "h_cross_n = h_cross.astype(float)\n",
    "h_cross_n.plot()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "h=F_plus×h_plus+F_cross×h_cross  \n",
    "Normally F_plus≈1, pick h_plus as h here."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "amplitude_2 = 2*10**(-4)"
   ]
  }
 ],
 "metadata": {
  "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.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
