|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "e7a1fc45", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import math\n", |
| 11 | + "import numpy as np\n", |
| 12 | + "import matplotlib.pyplot as plt\n", |
| 13 | + "import pygrc as gr" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "code", |
| 18 | + "execution_count": null, |
| 19 | + "id": "7e27a301", |
| 20 | + "metadata": {}, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "df = gr.Reader.read(filepath=\"/home/amdesai/Physics/data/NGC5055_rotmod.dat\")\n", |
| 24 | + "gr.Plot().overlap(df,\"Rad\",[\"Vobs\",\"Vgas\",\"Vbul\",\"Vdisk\"],\"observed velocity\")\n", |
| 25 | + "df" |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + "cell_type": "code", |
| 30 | + "execution_count": null, |
| 31 | + "id": "642a96a4", |
| 32 | + "metadata": {}, |
| 33 | + "outputs": [], |
| 34 | + "source": [ |
| 35 | + "# some example functions based on Galaxies 2018, 6(3), 70; https://doi.org/10.3390/galaxies6030070\n", |
| 36 | + "\n", |
| 37 | + "def mass(r, M0, R0):\n", |
| 38 | + " return M0*(1- (1+(r/R0))*np.exp(-r/R0))\n", |
| 39 | + "\n", |
| 40 | + "def mond(r, M0, rc, R0,b, beta):\n", |
| 41 | + " a = 1.2e-10\n", |
| 42 | + " G = 4.300e-6 #parsecs \n", |
| 43 | + " m = mass(r,M0, R0)\n", |
| 44 | + " f = (G*m/r)*(1 + b*(1+(r/rc)))#*10e-3\n", |
| 45 | + " return np.sqrt(f)*10e-3\n", |
| 46 | + "\n", |
| 47 | + "def newton(r, M0, rc, R0,beta):\n", |
| 48 | + " a = 1.2e-10\n", |
| 49 | + " G = 4.30e-6 #parsecs \n", |
| 50 | + " m = mass(r,M0, R0)\n", |
| 51 | + " f = G*m/r\n", |
| 52 | + " #f = (G*m/r)*(1/np.sqrt(2)) * np.sqrt(1 + np.sqrt(1 + (r**4) * (2*a/(G*m))**2))\n", |
| 53 | + " return np.sqrt(f)*10e-3\n" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "code", |
| 58 | + "execution_count": null, |
| 59 | + "id": "6df730b3", |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [], |
| 62 | + "source": [ |
| 63 | + "r = np.linspace(1e-5,df['Rad'].max(),2000)\n", |
| 64 | + "\n", |
| 65 | + "m_1=gr.Fit(df['Rad'],df['Vobs'],1.,1.,3,.35,1.)\n", |
| 66 | + "\n", |
| 67 | + "m_2=gr.Fit(df['Rad'],df['Vobs'],1.,1.,3,1.)" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "code", |
| 72 | + "execution_count": null, |
| 73 | + "id": "0deaae95", |
| 74 | + "metadata": {}, |
| 75 | + "outputs": [], |
| 76 | + "source": [ |
| 77 | + "m1= m_1.fit_lsq(mond, [(1.,1e17),(1.,10.),(2.,5.),(0.1,2),(0.1,2)],df['errV'],[False,False,True,True,True])\n", |
| 78 | + "m1" |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "code", |
| 83 | + "execution_count": null, |
| 84 | + "id": "64e5e876", |
| 85 | + "metadata": {}, |
| 86 | + "outputs": [], |
| 87 | + "source": [ |
| 88 | + "m2 = m_2.fit_lsq(newton, [(1.,1e16),(1.,10.),(1,10),(0.1,2)],df['errV'],[False,True,True,True])\n", |
| 89 | + "m2" |
| 90 | + ] |
| 91 | + }, |
| 92 | + { |
| 93 | + "cell_type": "code", |
| 94 | + "execution_count": null, |
| 95 | + "id": "efb56302", |
| 96 | + "metadata": {}, |
| 97 | + "outputs": [], |
| 98 | + "source": [ |
| 99 | + "m_2.get_profile(m2,'M0')\n", |
| 100 | + "m_1.draw_contours(m1,['M0','rc'])" |
| 101 | + ] |
| 102 | + }, |
| 103 | + { |
| 104 | + "cell_type": "code", |
| 105 | + "execution_count": null, |
| 106 | + "id": "98ed80d2", |
| 107 | + "metadata": {}, |
| 108 | + "outputs": [], |
| 109 | + "source": [ |
| 110 | + "fig, ax =plt.subplots()\n", |
| 111 | + "gr.Plot().plot_grc(df,m1,mond,'MOND','NGC',ax)\n", |
| 112 | + "gr.Plot().plot_grc(df,m2,newton,'Newton','NGC',ax)\n", |
| 113 | + "plt.savefig('1.pdf')" |
| 114 | + ] |
| 115 | + } |
| 116 | + ], |
| 117 | + "metadata": { |
| 118 | + "kernelspec": { |
| 119 | + "display_name": "Python 3 (ipykernel)", |
| 120 | + "language": "python", |
| 121 | + "name": "python3" |
| 122 | + }, |
| 123 | + "language_info": { |
| 124 | + "codemirror_mode": { |
| 125 | + "name": "ipython", |
| 126 | + "version": 3 |
| 127 | + }, |
| 128 | + "file_extension": ".py", |
| 129 | + "mimetype": "text/x-python", |
| 130 | + "name": "python", |
| 131 | + "nbconvert_exporter": "python", |
| 132 | + "pygments_lexer": "ipython3", |
| 133 | + "version": "3.10.6" |
| 134 | + } |
| 135 | + }, |
| 136 | + "nbformat": 4, |
| 137 | + "nbformat_minor": 5 |
| 138 | +} |
0 commit comments