From f9f8eb7aa302a7c82604d978891e77a39db0c628 Mon Sep 17 00:00:00 2001 From: NUNEZ Arturo Date: Tue, 14 Aug 2018 16:30:01 +0200 Subject: [PATCH] =?UTF-8?q?Automatic=20commit=20mardi=2014=20ao=C3=BBt=202?= =?UTF-8?q?018,=2016:30:01=20(UTC+0200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LAM2LUPM/Mochima_2_2LUPM_HR.ipynb | 3241 ++--------------- .../ALLPLOTS/AllPlots_Mochima_SF0.ipynb | 29 +- Simulations/Virial_Q_SHAPIRO.ipynb | 42 +- 3 files changed, 408 insertions(+), 2904 deletions(-) diff --git a/LAM2LUPM/Mochima_2_2LUPM_HR.ipynb b/LAM2LUPM/Mochima_2_2LUPM_HR.ipynb index 04eb45e..9d59357 100644 --- a/LAM2LUPM/Mochima_2_2LUPM_HR.ipynb +++ b/LAM2LUPM/Mochima_2_2LUPM_HR.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "collapsed": false }, @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "collapsed": false }, @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "collapsed": true }, @@ -137,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -148,7 +148,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "collapsed": true }, @@ -175,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "collapsed": false }, @@ -184,8 +184,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "2.2105422228126743\n", - "0.2 2.2105422228126743\n" + "2.2127749336898894\n", + "0.2 2.2127749336898894\n" ] } ], @@ -266,7 +266,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -342,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "collapsed": false }, @@ -362,12 +362,12 @@ "\n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", @@ -416,7 +416,7 @@ "\n", "
FCN = 12.7894584948TOTAL NCALL = 268NCALLS = 268FCN = 16.8412611722TOTAL NCALL = 247NCALLS = 247
EDM = 2.19669886347e-05EDM = 4.53971357878e-05GOAL EDM = 1e-05\n", " UP = 1.0
\n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -430,8 +430,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -442,8 +442,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -466,8 +466,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -478,8 +478,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -489,20 +489,20 @@ " \n", "
++NameValueParab Error
1po6.963040.4419897.443320.453937002.0
2r_s13.78627.744437.689544.56616001.0
4be2.720910.2509512.561880.182718002.5
5ga1.065990.134210.8404090.203063000.5
\n", " \n", - "
\n",
+       "            
\n",
        "            \n",
        "            
\n", @@ -525,7 +525,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 12.79, chi_bin = 0.56\n" + "chi_rho = 16.84, chi_bin = 0.82\n" ] } ], @@ -545,7 +545,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "collapsed": false }, @@ -565,12 +565,12 @@ "\n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", @@ -619,7 +619,7 @@ "\n", "
FCN = 0.493107374192TOTAL NCALL = 356NCALLS = 356FCN = 0.517897199617TOTAL NCALL = 299NCALLS = 299
EDM = 7.91506714308e-05EDM = 0.000150399937567GOAL EDM = 1e-05\n", " UP = 1.0
\n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -633,8 +633,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -645,8 +645,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -669,8 +669,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -681,8 +681,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -692,20 +692,20 @@ " \n", "
++NameValueParab Error
1po6.614171.510236.730081.72817004.0
2r_s21.582821.736419.066320.0535001.0
4be2.899280.6995172.868310.679008002.5
5ga1.163040.7671631.114270.784379000.5
\n", " \n", - "
\n",
+       "            
\n",
        "            \n",
        "            
\n", @@ -728,7 +728,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 13.47, chi_bin = 0.49\n" + "chi_rho = 19.96, chi_bin = 0.52\n" ] } ], @@ -747,7 +747,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": { "collapsed": false }, @@ -756,7 +756,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 56.08, chi_bin = 3.52\n" + "chi_rho = 62.61, chi_bin = 3.53\n" ] } ], @@ -769,7 +769,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": { "collapsed": false, "hide_input": false, @@ -1543,7 +1543,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -1657,7 +1657,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": { "collapsed": false, "hide_input": true @@ -1673,7 +1673,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": { "collapsed": false, "hide_input": true @@ -1685,7 +1685,7 @@ "'\\nbin_num = 512\\n\\npot_sph, bins_pot = np.histogram(r2,bins=bin_num,\\n weights=Phy)\\nn, _ = np.histogram(r2,bins=bin_num)\\n\\nbin_num = 512\\nbins_pot = np.linspace(0.,myDMO.dm.r.max(),512)\\npot_sph_vesc, bins_pot_vesc = np.histogram(r2[(r2\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m\"density\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcentro\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mmyhydro\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcenter_shift\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcentro\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mmyhydro\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mr_virial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m600\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2.5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/home/arturo/Documents/git/WKBL/wkbl/astro/galaxy_peeker.pyc\u001b[0m in \u001b[0;36mr_virial\u001b[0;34m(self, r_max, r_min, rotate, n, bins, quiet)\u001b[0m\n\u001b[1;32m 84\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mrotate\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;32mand\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 86\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrotate_galaxy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 87\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mredefine\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 88\u001b[0m \u001b[0mD\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatrix_T\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatrix_P\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtranspose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatrix_T\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/arturo/Documents/git/WKBL/wkbl/astro/galaxy_peeker.pyc\u001b[0m in \u001b[0;36mrotate_galaxy\u001b[0;34m(self, rmin, rmax)\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mst\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrotate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 134\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_gss\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 135\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrotate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 136\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 137\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/arturo/Documents/git/WKBL/wkbl/astro/_gas.pyc\u001b[0m in \u001b[0;36mrotate\u001b[0;34m(self, T)\u001b[0m\n\u001b[1;32m 76\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mrotate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0mpos\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 78\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpos3d\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnbe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatrix_vs_vector\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mpos\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 79\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvel3d\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnbe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatrix_vs_vector\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mT\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvel3d\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/arturo/Documents/git/WKBL/wkbl/astro/nbody_essentials.pyc\u001b[0m in \u001b[0;36mmatrix_vs_vector\u001b[0;34m(mat, vec)\u001b[0m\n\u001b[1;32m 140\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 141\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 142\u001b[0;31m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 143\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mmat\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mvec\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 144\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mMemoryError\u001b[0m: " + "density [20411.78905103 17272.12144131 17121.43958551]\n", + "| r_200 = 212.70\n", + "| Diagonal matrix computed \n", + "| | 18, 0, 0|\n", + "| D =| 0, 17, 0|\n", + "| | 0, 0, 2|\n", + "density [ 0.27599664 -0.1329309 -0.0808066 ]\n" ] } ], "source": [ "pathsim = \"/data/OWN/Mochima/HR/SF0/output_00400\"\n", "#path = \"/media/arturo/ARTUROTECA/OUTPUTS/HaloB/output_00417\"\n", - "myhydro = wkbl.Galaxy_Hound(pathsim)\n", + "myhydro = wkbl.Galaxy_Hound(pathsim,flush=True)\n", "#ok,rho,_= CF.getDensity(np.array(myhydro.st.pos3d.reshape(len(myhydro.st.pos3d)*3),dtype=np.float32), myhydro.st.mass)\n", "#centro_rho = myhydro.st.pos3d[np.where(rho == rho.max())][0]\n", "zoomreg= np.where(myhydro.dm.mass==myhydro.dm.mass.min())\n", "centro = nbe.real_center(myhydro.dm.pos3d[zoomreg], myhydro.dm.mass[zoomreg] )\n", "print \"density\",centro\n", "myhydro.center_shift(centro)\n", - "myhydro.r_virial(600,n=2.5)" + "myhydro.r_virial(600,n=2.5)\n", + "zoomreg= np.where(myhydro.dm.mass==myhydro.dm.mass.min())\n", + "centro = nbe.real_center(myhydro.dm.pos3d[zoomreg], myhydro.dm.mass[zoomreg] )\n", + "print \"density\",centro\n", + "myhydro.center_shift(centro)" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 15, "metadata": { "collapsed": true, - "hide_input": true + "hide_input": false }, "outputs": [], "source": [ @@ -1819,7 +1814,7 @@ { "cell_type": "markdown", "metadata": { - "hide_input": true + "hide_input": false }, "source": [ "## virial parameter q" @@ -1830,7 +1825,7 @@ "execution_count": 16, "metadata": { "collapsed": false, - "hide_input": true + "hide_input": false }, "outputs": [ { @@ -1877,7 +1872,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": { "collapsed": false, "hide_input": false @@ -1887,7 +1882,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "2.2550060904938984\n" + "0.8939467080317811\n" ] } ], @@ -1919,7 +1914,7 @@ "\n", "\n", "# R array logarithmic Bining\n", - "r_p = np.logspace(np.log10(2*hsml),np.log10(2.5*myhydro.r200),100)\n", + "r_p = np.logspace(np.log10(3*hsml),np.log10(2.5*myhydro.r200),100)\n", "# histogram of dm particles per logarithmic bin\n", "n_hydro,r = np.histogram(myhydro.dm.r,bins=r_p)\n", "# edges of bins\n", @@ -1947,7 +1942,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": { "collapsed": false, "hide_input": false @@ -1982,7 +1977,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": { "collapsed": false, "hide_input": false @@ -2003,12 +1998,12 @@ "\n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", @@ -2057,7 +2052,7 @@ "\n", "
FCN = 14.1662806004TOTAL NCALL = 684NCALLS = 684FCN = 7.09530054778TOTAL NCALL = 574NCALLS = 574
EDM = 4.639765605e-05EDM = 2.79440041562e-05GOAL EDM = 1e-05\n", " UP = 1.0
\n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -2071,8 +2066,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2083,8 +2078,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2095,8 +2090,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2107,8 +2102,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2119,8 +2114,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2130,20 +2125,20 @@ " \n", "
++NameValueParab Error
1po7.414290.1851967.071440.166558002.0
2r_s7.363961.114879.583992.21672001.0
3al1.768220.5732461.993410.866704000.5
4be2.63260.1650752.583560.212192002.0
5ga0.4684760.170571.042650.120675000.0
\n", " \n", - "
\n",
+       "            
\n",
        "            \n",
        "            
\n", @@ -2166,7 +2161,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 14.17, chi_bin = 0.41\n" + "chi_rho = 7.10, chi_bin = 0.45\n" ] } ], @@ -2185,7 +2180,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 20, "metadata": { "collapsed": false, "hide_input": true @@ -2206,12 +2201,12 @@ "\n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", @@ -2260,7 +2255,7 @@ "\n", "
FCN = 0.385115415196TOTAL NCALL = 253NCALLS = 253FCN = 0.34987154356TOTAL NCALL = 501NCALLS = 501
EDM = 1.94271942734e-06EDM = 0.000162791530443GOAL EDM = 1e-05\n", " UP = 1.0
\n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -2274,8 +2269,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2286,8 +2281,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2298,8 +2293,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2310,8 +2305,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2322,8 +2317,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2333,20 +2328,20 @@ " \n", "
++NameValueParab Error
1po7.462962.230866.917551.14044006.0
2r_s7.7246212.860612.197915.0956001.0
3al1.483021.751221.69251.85027000.5
4be2.715731.060712.711351.05816002.0
5ga0.4437740.9254561.113871.17697000.0
\n", " \n", - "
\n",
+       "            
\n",
        "            \n",
        "            
\n", @@ -2369,7 +2364,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 15.33, chi_bin = 0.39\n" + "chi_rho = 8.87, chi_bin = 0.35\n" ] } ], @@ -2388,7 +2383,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 21, "metadata": { "collapsed": false, "hide_input": true @@ -2398,7 +2393,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "chi_rho = 170.41, chi_bin = 2.93\n" + "chi_rho = 325.97, chi_bin = 8.80\n" ] } ], @@ -2411,11 +2406,11 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 22, "metadata": { "collapsed": false, "hide_input": false, - "scrolled": true + "scrolled": false }, "outputs": [ { @@ -3185,7 +3180,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -3327,6 +3322,25 @@ "metadata": { "collapsed": false }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "64\n" + ] + } + ], + "source": [ + "print len(myhydro.dm.mass[myhydro.dm.r<1*myhydro.gs.hsml.min()])" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3338,11 +3352,11 @@ "###################################################\n", "################## DM profile ####################\n", "fit results: \n", - "$\\rho_0$ = 7.414 $\\pm$ 0.185\n", - "$r_s$ = 7.364 $\\pm$ 1.115\n", - "$\\alpha$ = 1.768 $\\pm$ 0.573\n", - "$\\beta$ = 2.633 $\\pm$ 0.165\n", - "$\\gamma$ = 0.468 $\\pm$ 0.171\n", + "$\\rho_0$ = 7.071 $\\pm$ 0.167\n", + "$r_s$ = 9.584 $\\pm$ 2.217\n", + "$\\alpha$ = 1.993 $\\pm$ 0.867\n", + "$\\beta$ = 2.584 $\\pm$ 0.212\n", + "$\\gamma$ = 1.043 $\\pm$ 0.121\n", "\n" ] } @@ -3359,7 +3373,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 28, "metadata": { "collapsed": false }, @@ -3368,9 +3382,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "integrated mass fit = 8.170e+11\n", - "integrates rho fit = 8.193e+11\n", - "mass inside r200 = 8.214e+11\n" + "integrated mass fit = 8.282e+11\n", + "integrates rho fit = 8.178e+11\n", + "mass inside r200 = 8.163e+11\n" ] } ], @@ -3394,7 +3408,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 29, "metadata": { "collapsed": false }, @@ -3405,7 +3419,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 30, "metadata": { "collapsed": false }, @@ -3443,7 +3457,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 114, "metadata": { "collapsed": true }, @@ -3496,9 +3510,10 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 117, "metadata": { - "collapsed": false + "collapsed": false, + "scrolled": true }, "outputs": [ { @@ -4268,7 +4283,7 @@ { "data": { "text/html": [ - "" + "" ], "text/plain": [ "" @@ -4287,10 +4302,10 @@ "U= np.meshgrid(x, y)\n", "\n", "\n", - "\n", - "Z = stars(U[0],U[1],9.5, .25 , 1.6 ,2.1,.5,\n", - " 8, 0.5, 2.8,\n", - " 8, 1.3 ,5.1)\n", + "#stars(R,z,B_0,r0,al,r_cut,q,d_0,z_d,Rd,D_0,z_D,RD):\n", + "Z = stars(U[0],U[1],9.4, .7 , 2.6 ,2.1,.5,\n", + " 8, 0.2, 1.8,\n", + " 8, .6 ,4.1)\n", "\n", "\n", "\n", @@ -4317,7 +4332,7 @@ "\n", "\n", "#print \"fit : max = {0:.3e}, min = {1:.3e}\".format(Z.max(),Z.min())##print \"data : max = {0:.3e}, min = {1:.3e}\".format(dens_hist.max(),dens_hist.min())\n", - "ratio = ((Z/Z.max())-(dens_hist/dens_hist.max()))#/(dens_hist/dens_hist.max())\n", + "ratio = ((Z)-(dens_hist))#/(dens_hist/dens_hist.max())\n", "#ratio = np.abs(Z-dens_hist)/(dens_hist)\n", "\n", "ax2.set_title(\"Data\")\n", @@ -4353,9 +4368,9 @@ ], "source": [ "\"\"\"\n", - "Z = stars(U[0],U[1],9.5, .25 , 1.6 ,2.1,.5,\n", - " 8, 0.6, 3.1,\n", - " 8, 1.3 ,6.1)\n", + "Z = stars(U[0],U[1],9.4, .7 , 2.6 ,2.1,.5,\n", + " 8, 0.2, 1.8,\n", + " 8, .6 ,4.1)\n", "\n", "\"\"\"" ] @@ -4371,7 +4386,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 125, "metadata": { "collapsed": false, "scrolled": true @@ -4392,7 +4407,7 @@ "\n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4446,7 +4461,7 @@ "\n", "
FCN = 1.06730763019e+22FCN = 1.70870346445e+23TOTAL NCALL = 28NCALLS = 28
\n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4472,8 +4487,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -4484,11 +4499,11 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4496,11 +4511,11 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -4591,18 +4606,18 @@ " \n", "
++NameValueParab Error
2r00.41.129810.551.24000.01
3al2.63.775920.32.84898000.00.015.0
4r_cut1.000015.684251.14.71514001.00.59.0
\n", " \n", - "
\n",
+       "            
\n",
        "            \n",
        "            
\n", @@ -4897,9 +4912,9 @@ "source": [ "m1=Minuit(chi2_st, \n", " B_0=9.9, fix_B_0=True,#error_B_0=0.5, limit_B_0=(9,10),\n", - " r0=0.4, error_r0=0.1, limit_r0=(0.01,2),\n", - " al=2.6, error_al=0.1, limit_al=(0,5.),\n", - " r_cut=0.7, error_r_cut=0.1, limit_r_cut=(1,9.),\n", + " r0=0.55, error_r0=0.1, limit_r0=(0.01,2),\n", + " al=0.3, error_al=0.01, limit_al=(0.01,5.),\n", + " r_cut=1.1, error_r_cut=0.1, limit_r_cut=(0.5,9.),\n", " q=0.66, error_q=0.1, limit_q=(0,1.),\n", " d_0=8.7, fix_d_0=True,#error_d_0=0.5, limit_d_0=(7,10.5),\n", " z_d=1.025, error_z_d=0.2, limit_z_d=(0.,1.6),\n", @@ -4916,7 +4931,7 @@ "m2=Minuit(mass_check, \n", " B_0=m1.values['B_0'], fix_B_0=True,#error_B_0=m1.values['B_0']*err, limit_B_0=(m1.values['B_0']*low,m1.values['B_0']*upp),\n", " r0=m1.values['r0'], error_r0=m1.values['r0']*err, limit_r0=(m1.values['r0']*low,m1.values['r0']*upp),\n", - " al=m1.values['al'], error_al=m1.values['al']*err, limit_al=(m1.values['al']*low,m1.values['al']*upp),\n", + " al=m1.values['al'], error_al=m1.values['al']*err, limit_al=(0.1,m1.values['al']*upp),\n", " r_cut=m1.values['r_cut'], error_r_cut=m1.values['r_cut']*err, limit_r_cut=(m1.values['r_cut']*low,m1.values['r_cut']*upp),\n", " q=m1.values['q'], error_q=m1.values['q']*err, limit_q=(m1.values['q']*low,m1.values['q']*upp),\n", " d_0=m1.values['d_0'], fix_d_0=True,#error_d_0=m1.values['d_0']*err, limit_d_0=(m1.values['d_0']*low,m1.values['d_0']*upp),\n", @@ -4932,7 +4947,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 126, "metadata": { "collapsed": true }, @@ -4967,7 +4982,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "metadata": { "collapsed": false }, @@ -4980,158 +4995,11 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
FCN = 0.0384892569594TOTAL NCALL = 243NCALLS = 243
EDM = 0.000100844699412GOAL EDM = 1e-05\n", - " UP = 1.0
\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
ValidValid ParamAccurate CovarPosDefMade PosDef
TrueTrueTrueTrueFalse
Hesse FailHasCovAbove EDMReach calllim
FalseTrueFalseFalse
\n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
+NameValueParab ErrorMinos Error-Minos Error+Limit-Limit+FIXED
1B09.381221.36839007.010.7
2d07.384493.05691007.010.7
3D08.891740.437538007.010.7
\n", - " \n", - "
\n",
-       "            \n",
-       "            
\n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "def chimass(B0,d0,D0):\n", " c = np.log10(get_masses(r_masses,B0,d0,D0))-np.log10(data_mass)\n", @@ -5140,15 +5008,15 @@ "\n", "mmass=Minuit(chimass, \n", " B0=9.5, error_B0=0.5, limit_B0=(7,10.7),\n", - " d0=9.5, error_d0=0.5, limit_d0=(7,10.7),\n", - " D0=9.5, error_D0=0.5, limit_D0=(7,10.7))\n", + " d0=9.5, error_d0=0.5, limit_d0=(7,9.1),\n", + " D0=9.5, error_D0=0.5, limit_D0=(7,9.1))\n", "# print_level=0)\n", "mmass.migrad();" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": { "collapsed": false }, @@ -5159,2517 +5027,148 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": { "collapsed": false, "scrolled": false }, - "outputs": [ - { - "data": { - "application/javascript": [ - "/* Put everything inside the global mpl namespace */\n", - "window.mpl = {};\n", - "\n", - "mpl.get_websocket_type = function() {\n", - " if (typeof(WebSocket) !== 'undefined') {\n", - " return WebSocket;\n", - " } else if (typeof(MozWebSocket) !== 'undefined') {\n", - " return MozWebSocket;\n", - " } else {\n", - " alert('Your browser does not have WebSocket support.' +\n", - " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", - " 'Firefox 4 and 5 are also supported but you ' +\n", - " 'have to enable WebSockets in about:config.');\n", - " };\n", - "}\n", - "\n", - "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", - " this.id = figure_id;\n", - "\n", - " this.ws = websocket;\n", - "\n", - " this.supports_binary = (this.ws.binaryType != undefined);\n", - "\n", - " if (!this.supports_binary) {\n", - " var warnings = document.getElementById(\"mpl-warnings\");\n", - " if (warnings) {\n", - " warnings.style.display = 'block';\n", - " warnings.textContent = (\n", - " \"This browser does not support binary websocket messages. \" +\n", - " \"Performance may be slow.\");\n", - " }\n", - " }\n", - "\n", - " this.imageObj = new Image();\n", - "\n", - " this.context = undefined;\n", - " this.message = undefined;\n", - " this.canvas = undefined;\n", - " this.rubberband_canvas = undefined;\n", - " this.rubberband_context = undefined;\n", - " this.format_dropdown = undefined;\n", - "\n", - " this.image_mode = 'full';\n", - "\n", - " this.root = $('
');\n", - " this._root_extra_style(this.root)\n", - " this.root.attr('style', 'display: inline-block');\n", - "\n", - " $(parent_element).append(this.root);\n", - "\n", - " this._init_header(this);\n", - " this._init_canvas(this);\n", - " this._init_toolbar(this);\n", - "\n", - " var fig = this;\n", - "\n", - " this.waiting = false;\n", - "\n", - " this.ws.onopen = function () {\n", - " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", - " fig.send_message(\"send_image_mode\", {});\n", - " fig.send_message(\"refresh\", {});\n", - " }\n", - "\n", - " this.imageObj.onload = function() {\n", - " if (fig.image_mode == 'full') {\n", - " // Full images could contain transparency (where diff images\n", - " // almost always do), so we need to clear the canvas so that\n", - " // there is no ghosting.\n", - " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", - " }\n", - " fig.context.drawImage(fig.imageObj, 0, 0);\n", - " };\n", - "\n", - " this.imageObj.onunload = function() {\n", - " this.ws.close();\n", - " }\n", - "\n", - " this.ws.onmessage = this._make_on_message_function(this);\n", - "\n", - " this.ondownload = ondownload;\n", - "}\n", - "\n", - "mpl.figure.prototype._init_header = function() {\n", - " var titlebar = $(\n", - " '
');\n", - " var titletext = $(\n", - " '
');\n", - " titlebar.append(titletext)\n", - " this.root.append(titlebar);\n", - " this.header = titletext[0];\n", - "}\n", - "\n", - "\n", - "\n", - "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", - "\n", - "}\n", - "\n", - "\n", - "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", - "\n", - "}\n", - "\n", - "mpl.figure.prototype._init_canvas = function() {\n", - " var fig = this;\n", - "\n", - " var canvas_div = $('
');\n", - "\n", - " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", - "\n", - " function canvas_keyboard_event(event) {\n", - " return fig.key_event(event, event['data']);\n", - " }\n", - "\n", - " canvas_div.keydown('key_press', canvas_keyboard_event);\n", - " canvas_div.keyup('key_release', canvas_keyboard_event);\n", - " this.canvas_div = canvas_div\n", - " this._canvas_extra_style(canvas_div)\n", - " this.root.append(canvas_div);\n", - "\n", - " var canvas = $('');\n", - " canvas.addClass('mpl-canvas');\n", - " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", - "\n", - " this.canvas = canvas[0];\n", - " this.context = canvas[0].getContext(\"2d\");\n", - "\n", - " var rubberband = $('');\n", - " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", - "\n", - " var pass_mouse_events = true;\n", - "\n", - " canvas_div.resizable({\n", - " start: function(event, ui) {\n", - " pass_mouse_events = false;\n", - " },\n", - " resize: function(event, ui) {\n", - " fig.request_resize(ui.size.width, ui.size.height);\n", - " },\n", - " stop: function(event, ui) {\n", - " pass_mouse_events = true;\n", - " fig.request_resize(ui.size.width, ui.size.height);\n", - " },\n", - " });\n", - "\n", - " function mouse_event_fn(event) {\n", - " if (pass_mouse_events)\n", - " return fig.mouse_event(event, event['data']);\n", - " }\n", - "\n", - " rubberband.mousedown('button_press', mouse_event_fn);\n", - " rubberband.mouseup('button_release', mouse_event_fn);\n", - " // Throttle sequential mouse events to 1 every 20ms.\n", - " rubberband.mousemove('motion_notify', mouse_event_fn);\n", - "\n", - " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", - " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", - "\n", - " canvas_div.on(\"wheel\", function (event) {\n", - " event = event.originalEvent;\n", - " event['data'] = 'scroll'\n", - " if (event.deltaY < 0) {\n", - " event.step = 1;\n", - " } else {\n", - " event.step = -1;\n", - " }\n", - " mouse_event_fn(event);\n", - " });\n", - "\n", - " canvas_div.append(canvas);\n", - " canvas_div.append(rubberband);\n", - "\n", - " this.rubberband = rubberband;\n", - " this.rubberband_canvas = rubberband[0];\n", - " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", - " this.rubberband_context.strokeStyle = \"#000000\";\n", - "\n", - " this._resize_canvas = function(width, height) {\n", - " // Keep the size of the canvas, canvas container, and rubber band\n", - " // canvas in synch.\n", - " canvas_div.css('width', width)\n", - " canvas_div.css('height', height)\n", - "\n", - " canvas.attr('width', width);\n", - " canvas.attr('height', height);\n", - "\n", - " rubberband.attr('width', width);\n", - " rubberband.attr('height', height);\n", - " }\n", - "\n", - " // Set the figure to an initial 600x600px, this will subsequently be updated\n", - " // upon first draw.\n", - " this._resize_canvas(600, 600);\n", - "\n", - " // Disable right mouse context menu.\n", - " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", - " return false;\n", - " });\n", - "\n", - " function set_focus () {\n", - " canvas.focus();\n", - " canvas_div.focus();\n", - " }\n", - "\n", - " window.setTimeout(set_focus, 100);\n", - "}\n", - "\n", - "mpl.figure.prototype._init_toolbar = function() {\n", - " var fig = this;\n", - "\n", - " var nav_element = $('
')\n", - " nav_element.attr('style', 'width: 100%');\n", - " this.root.append(nav_element);\n", - "\n", - " // Define a callback function for later on.\n", - " function toolbar_event(event) {\n", - " return fig.toolbar_button_onclick(event['data']);\n", - " }\n", - " function toolbar_mouse_event(event) {\n", - " return fig.toolbar_button_onmouseover(event['data']);\n", - " }\n", - "\n", - " for(var toolbar_ind in mpl.toolbar_items) {\n", - " var name = mpl.toolbar_items[toolbar_ind][0];\n", - " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", - " var image = mpl.toolbar_items[toolbar_ind][2];\n", - " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", - "\n", - " if (!name) {\n", - " // put a spacer in here.\n", - " continue;\n", - " }\n", - " var button = $('');\n", - " button.click(method_name, toolbar_event);\n", - " button.mouseover(tooltip, toolbar_mouse_event);\n", - " nav_element.append(button);\n", - " }\n", - "\n", - " // Add the status bar.\n", - " var status_bar = $('');\n", - " nav_element.append(status_bar);\n", - " this.message = status_bar[0];\n", - "\n", - " // Add the close button to the window.\n", - " var buttongrp = $('
');\n", - " var button = $('');\n", - " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", - " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", - " buttongrp.append(button);\n", - " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", - " titlebar.prepend(buttongrp);\n", - "}\n", - "\n", - "mpl.figure.prototype._root_extra_style = function(el){\n", - " var fig = this\n", - " el.on(\"remove\", function(){\n", - "\tfig.close_ws(fig, {});\n", - " });\n", - "}\n", - "\n", - "mpl.figure.prototype._canvas_extra_style = function(el){\n", - " // this is important to make the div 'focusable\n", - " el.attr('tabindex', 0)\n", - " // reach out to IPython and tell the keyboard manager to turn it's self\n", - " // off when our div gets focus\n", - "\n", - " // location in version 3\n", - " if (IPython.notebook.keyboard_manager) {\n", - " IPython.notebook.keyboard_manager.register_events(el);\n", - " }\n", - " else {\n", - " // location in version 2\n", - " IPython.keyboard_manager.register_events(el);\n", - " }\n", - "\n", - "}\n", - "\n", - "mpl.figure.prototype._key_event_extra = function(event, name) {\n", - " var manager = IPython.notebook.keyboard_manager;\n", - " if (!manager)\n", - " manager = IPython.keyboard_manager;\n", - "\n", - " // Check for shift+enter\n", - " if (event.shiftKey && event.which == 13) {\n", - " this.canvas_div.blur();\n", - " event.shiftKey = false;\n", - " // Send a \"J\" for go to next cell\n", - " event.which = 74;\n", - " event.keyCode = 74;\n", - " manager.command_mode();\n", - " manager.handle_keydown(event);\n", - " }\n", - "}\n", - "\n", - "mpl.figure.prototype.handle_save = function(fig, msg) {\n", - " fig.ondownload(fig, null);\n", - "}\n", - "\n", - "\n", - "mpl.find_output_cell = function(html_output) {\n", - " // Return the cell and output element which can be found *uniquely* in the notebook.\n", - " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", - " // IPython event is triggered only after the cells have been serialised, which for\n", - " // our purposes (turning an active figure into a static one), is too late.\n", - " var cells = IPython.notebook.get_cells();\n", - " var ncells = cells.length;\n", - " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", - " data = data.data;\n", - " }\n", - " if (data['text/html'] == html_output) {\n", - " return [cell, data, j];\n", - " }\n", - " }\n", - " }\n", - " }\n", - "}\n", - "\n", - "// Register the function which deals with the matplotlib target/channel.\n", - "// The kernel may be null if the page has been refreshed.\n", - "if (IPython.notebook.kernel != null) {\n", - " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", - "}\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "