<commit_before>{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%pylab osx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Populating the interactive namespace from numpy and matplotlib\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import Quaternions\n",
      "import matplotlib.pyplot as plt\n",
      "from mpl_toolkits.mplot3d import Axes3D"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Load data from files"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Omega_NR = loadtxt('//Users/boyle/Research/Current/PrecessingPNComparison/BoyleNotes/OmegaVector.dat')\n",
      "t_NR = Omega_NR[:,0]\n",
      "Omega_NR = Omega_NR[:,1:]\n",
      "OmegaHat_NR = array([o/norm(o) for o in Omega_NR])\n",
      "\n",
      "Command=\"\"\"\n",
      "t_T1 = Data_T1[:,0]\n",
      "R_T1 = array([Quaternions.Quaternion(R) for R in Data_T1[:,8:12]])\n",
      "Omega_T1 = array([v**3*(R*Quaternions.zHat*R.conjugate()).vec() for v,R in zip(Data_T1[:,1],R_T1)])\n",
      "OmegaHat_T1 = array([(R*Quaternions.zHat*R.conjugate()).vec() for R in R_T1])\n",
      "chi1_T1 = array(Data_T1[:,2:5])\n",
      "chi1Hat_T1 = array([v/norm(v) for v in chi1_T1])\n",
      "chi2_T1 = array(Data_T1[:,5:8])\n",
      "chi2Hat_T1 = array([v/norm(v) for v in chi2_T1])\n",
      "\"\"\"\n",
      "\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"Data_{0}{1} = loadtxt('EvolvePN_{0}_3p5PN{1}.dat')\"\"\".format(Tn,Q))\n",
      "        exec(Command.replace('T1',Tn+Q))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 12
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot the angular velocities"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "ax.plot(OmegaHat_NR[:,0], OmegaHat_NR[:,1], OmegaHat_NR[:,2])\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"ax.plot(OmegaHat_T1[:,0], OmegaHat_T1[:,1], OmegaHat_T1[:,2])\"\"\".replace('T1', Tn+Q))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\Omega}$');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 14
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot $\\chi_1$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "for Tn in ['T1', 'T4', 'T5']:\n",
      "    exec(\"\"\"ax.plot(chi1Hat_T1[:,0], chi1Hat_T1[:,1], chi1Hat_T1[:,2])\"\"\".replace('T1', Tn))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\chi}_1$');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot $\\chi_2$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "for Tn in ['T1', 'T4', 'T5']:\n",
      "    exec(\"\"\"ax.plot(chi2Hat_T1[:,0], chi2Hat_T1[:,1], chi2Hat_T1[:,2])\"\"\".replace('T1', Tn))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\chi}_2$');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}<commit_msg>Look at output from C++ evolutions<commit_after>{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%pylab osx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Populating the interactive namespace from numpy and matplotlib\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import h5py\n",
      "import matplotlib.pyplot as plt\n",
      "from mpl_toolkits.mplot3d import Axes3D\n",
      "import Quaternions\n",
      "import GWFrames"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 18
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Load data from files"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "NRDir = '/Users/boyle/Research/Data/SimulationAnnex/Catalog/SKS/'+\\\n",
      "            'd10.0_q6.00_sA_0.739_0.190_-0.495_sB_-0.190_0.051_-0.227/Lev3/'\n",
      "\n",
      "f = h5py.File(NRDir+'Horizons.h5', 'r')\n",
      "t_NR = f['AhA.dir/chiInertial.dat'][:,0]\n",
      "chi1_NR = f['AhA.dir/chiInertial.dat'][:,1:]\n",
      "x1 = f['AhA.dir/CoordCenterInertial.dat'][:,1:]\n",
      "m1 = f['AhA.dir/ChristodoulouMass.dat'][0,1]\n",
      "chi2_NR = f['AhB.dir/chiInertial.dat'][:,1:]\n",
      "x2 = f['AhB.dir/CoordCenterInertial.dat'][:,1:]\n",
      "m2 = f['AhB.dir/ChristodoulouMass.dat'][0,1]\n",
      "f.close()\n",
      "\n",
      "t_relaxed = ! awk {'\"/^relaxed-measurement-time/ {print \\$3}\"'} {NRDir}/metadata.txt\n",
      "t_relaxed = float(t_relaxed[0])\n",
      "i_relaxed = abs(t_NR-t_relaxed).argmin()\n",
      "\n",
      "def norm(v) :\n",
      "    return sqrt(v[0]**2+v[1]**2+v[2]**2)\n",
      "n = array([(xa-xb)/norm(xa-xb) for xa,xb in zip(x1,x2)])\n",
      "ndot = empty((len(x1[:,0]), 3))\n",
      "ndot[:,0] = array(GWFrames.ScalarDerivative(GWFrames.vectord(n[:,0]), GWFrames.vectord(t_NR)))\n",
      "ndot[:,1] = array(GWFrames.ScalarDerivative(GWFrames.vectord(n[:,1]), GWFrames.vectord(t_NR)))\n",
      "ndot[:,2] = array(GWFrames.ScalarDerivative(GWFrames.vectord(n[:,2]), GWFrames.vectord(t_NR)))\n",
      "Omega_NR = array([cross(N,Ndot) for N,Ndot in zip(n,ndot)])\n",
      "OmegaHat_NR = array([o/norm(o) for o in Omega_NR])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 20
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Command=\"\"\"\n",
      "t_T1 = Data_T1[:,0]\n",
      "R_T1 = array([Quaternions.Quaternion(R) for R in Data_T1[:,8:12]])\n",
      "Omega_T1 = array([(v**3*R*Quaternions.zHat*R.conjugate()).vec() for v,R in zip(Data_T1[:,1],R_T1)])\n",
      "OmegaHat_T1 = array([(R*Quaternions.zHat*R.conjugate()).vec() for R in R_T1])\n",
      "chi1_T1 = array(Data_T1[:,2:5])\n",
      "chi1Hat_T1 = array([v/norm(v) for v in chi1_T1])\n",
      "chi2_T1 = array(Data_T1[:,5:8])\n",
      "chi2Hat_T1 = array([v/norm(v) for v in chi2_T1])\n",
      "\"\"\"\n",
      "\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"Data_{0}{1} = loadtxt('EvolvePN_{0}_3p5PN{1}.dat')\"\"\".format(Tn,Q))\n",
      "        exec(Command.replace('T1',Tn+Q))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 33
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot the angular velocities"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "ax.plot(OmegaHat_NR[:,0], OmegaHat_NR[:,1], OmegaHat_NR[:,2])\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"ax.plot(OmegaHat_T1[:,0], OmegaHat_T1[:,1], OmegaHat_T1[:,2])\"\"\".replace('T1', Tn+Q))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\Omega}$');\n",
      "savefig('OmegaHat.pdf');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 83
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "ax.plot(Omega_NR[:,0], Omega_NR[:,1], Omega_NR[:,2])\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"ax.plot(Omega_T1[:,0], Omega_T1[:,1], Omega_T1[:,2])\"\"\".replace('T1', Tn+Q))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\vec{\\Omega}$');\n",
      "savefig('Omega.pdf')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 84
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "figure()\n",
      "plot(t_NR, [norm(o) for o in Omega_NR], label='NR');\n",
      "for Q in ['', '_Q']:\n",
      "    for Tn in ['T1', 'T4', 'T5']:\n",
      "        exec(\"\"\"plot(t_T1-t_T1[0], [norm(o) for o in Omega_T1], label='T1')\"\"\".replace('T1', Tn+Q))\n",
      "legend(loc='upper left');\n",
      "ylabel(r'$\\Omega$');\n",
      "xlabel(r'$t/M$');\n",
      "xlim(xmin=-20);\n",
      "ylim((0.,0.3));\n",
      "savefig('OmegaMag.pdf');\n",
      "ylim((0.025,0.075));\n",
      "savefig('OmegaMag_Zoomed.pdf');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 98
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot $\\chi_1$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "for Tn in ['T1', 'T4', 'T5']:\n",
      "    exec(\"\"\"ax.plot(chi1Hat_T1[:,0], chi1Hat_T1[:,1], chi1Hat_T1[:,2])\"\"\".replace('T1', Tn))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\chi}_1$');\n",
      "savefig('chi1Hat.pdf');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 86
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Plot $\\chi_2$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fig = plt.figure()\n",
      "ax = fig.add_subplot(111, projection='3d')\n",
      "for Tn in ['T1', 'T4', 'T5']:\n",
      "    exec(\"\"\"ax.plot(chi2Hat_T1[:,0], chi2Hat_T1[:,1], chi2Hat_T1[:,2])\"\"\".replace('T1', Tn))\n",
      "tight_layout(pad=0.1);\n",
      "title(r'$\\hat{\\chi}_2$');\n",
      "savefig('chi2Hat.pdf');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 87
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.2563588850174216, 'fraction_numerical': 0.03083623693379791, 'mean_word_length': 2.3153335258446432, 'pattern_counts': {'":': 161, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5364325', 'n_tokens_mistral': 4918, 'n_tokens_neox': 4813, 'n_words': 683}