Commit 73667f60 authored by NUNEZ Arturo's avatar NUNEZ Arturo
Browse files

Automatic commit mardi 30 janvier 2018, 16:30:01 (UTC+0100)

parent 28d529c4
This diff is collapsed.
This diff is collapsed.
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 1
}
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 1
}
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib notebook\n",
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from scipy.stats import rv_continuous\n",
"from scipy.special import gamma\n",
"import numpy as np\n",
"import emcee\n",
"from mpl_toolkits.axes_grid1 import make_axes_locatable\n",
"from numpy import exp, sqrt\n",
"from scipy.integrate import quad, dblquad, simps\n",
"from scipy.stats import rv_continuous\n",
"from scipy.special import gamma\n",
"from scipy.interpolate import interp1d\n",
"from scipy.integrate import quad\n",
"import scipy.optimize as optimize\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"from sklearn.neighbors import KDTree\n",
"import sys\n",
"import lmfit\n",
"from py_unsio import *\n",
"import pymc\n",
"import os\n",
"from pymodelfit import FunctionModel1DAuto\n",
"import wkbl\n",
"from mpl_toolkits.mplot3d import axes3d\n",
"from matplotlib import cm\n",
"import wkbl.astro.nbody_essentials as nbe\n",
"import cfalcon\n",
"CF =cfalcon.CFalcon()\n",
"import iminuit\n",
"from iminuit import Minuit, describe, Struct\n",
"import probfit\n",
"import warnings\n",
"from matplotlib.colors import LogNorm\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"loading Dark matter..\n",
"centering\n",
"done r200 = 227.9296875\n"
]
}
],
"source": [
"path = \"/data/OWN/DMO/mochima2_Z5/output_00041\"\n",
"#path = \"/media/arturo/ARTUROTECA/OUTPUTS/HaloB/output_00417\"\n",
"myDMO = wkbl.Galaxy_Hound(path)\n",
"print \"centering\"\n",
"zoom_reg = np.where(myDMO.dm.mass == myDMO.dm.mass.min())\n",
"nucenter = nbe.real_center(myDMO.dm.pos3d[zoom_reg], myDMO.dm.mass[zoom_reg])\n",
"myDMO.center_shift(nucenter)\n",
"myDMO.r_virial(600)\n",
"print \"done r200 = {0}\".format(myDMO.r200)\n",
"myDMO.redefine(1)\n",
"myGkm = 6.673e-11*(1e-3**3)*myDMO.p.msuntokg#km^ 3 Msun^-1 s^-2"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ok,myDMO.dm.rho,_= CF.getDensity(np.array(myDMO.dm.pos3d.reshape(len(myDMO.dm.pos3d)*3),dtype=np.float32), myDMO.dm.mass)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# $2E_{kin}$"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2E_kin = 3.0329e+16 m_sun kms² s⁻²\n"
]
}
],
"source": [
"K = np.sum(myDMO.dm.mass*(myDMO.dm.v)**2)\n",
"print \"2E_kin = {0:1.4e} m_sun kms² s⁻²\".format(K)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# $E_{pot}$"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(array([], dtype=int64),)\n",
"first simplification from Shapiro2004\n",
" E_pot = -3.9727e+16 m_sun km² s⁻²\n"
]
}
],
"source": [
"r_sorted = np.argsort(myDMO.dm.r)\n",
"M_i = np.cumsum(myDMO.dm.mass[r_sorted]) - myDMO.dm.mass[r_sorted]\n",
"m_i = myDMO.dm.mass[r_sorted]\n",
"r_i = myDMO.dm.r[r_sorted]*(1e-2*myDMO.p.pctocm)# in km\n",
"U = np.sum(-myG*M_i*m_i/r_i)\n",
"fi = np.where(r_i<0.19)\n",
"print fi\n",
"print \"first simplification from Shapiro2004\\n E_pot = {0:1.4e} m_sun km² s⁻²\".format(U)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.53758186497e-39\n"
]
}
],
"source": [
"print myGkpc"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.53758186497e-39\n"
]
}
],
"source": [
"print myGkpc"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"myGkm = 6.673e-11*(1e-3**3)*myDMO.p.msuntokg#km^ 3 Msun^-1 s^-2\n",
"myGkpc = myGkm / myDMO.p.kpctokm**3 #kpc^ 3 Msun^-1 s^-2"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pos = np.array(myDMO.dm.pos3d.reshape(len(myDMO.dm.pos3d)*3),dtype=np.float32)\n",
"ok, acc, Phy = CF.getGravity(pos,myDMO.dm.mass,0.090,G=myGkpc)"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-359909900000.0"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.sum(Phy*myDMO.p.kpctokm**2)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-3.7791042e-22"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.sum(Phy)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3.086e+16"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"myDMO.p.kpctokm"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3.08567758e+16"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment