-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d1afb
commit 01fced8
Showing
4 changed files
with
240 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e375f8cb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pygrc as gr\n", | ||
"import math\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8332c16c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"galaxy = [\n", | ||
"\"NGC4217\",\n", | ||
"\"NGC5055\",\n", | ||
"\"NGC5585\",\n", | ||
"\"NGC6015\",\n", | ||
"\"NGC6503\",\n", | ||
"\"NGC7331\",\n", | ||
"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a81f659b", | ||
"metadata": { | ||
"scrolled": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"df_all = []\n", | ||
"for g in galaxy:\n", | ||
" df = gr.Reader.read(filepath=\"../notebooks/data/\"+g+\"_rotmod.dat\")\n", | ||
" df_all.append(df)\n", | ||
" gr.Plot().overlap(df,\"Rad\",[\"Vobs\",\"Vgas\",\"Vbul\",\"Vdisk\"],\"Distance (kpc)\",\"Velocity\",g)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "149622af", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"r = np.linspace(0.01,50,2000)\n", | ||
"def mass(r, M0, R0):\n", | ||
"#def mass(r, M0, rc, R0,beta):\n", | ||
" #return M0*(np.sqrt(R0/rc)*(r/(r+rc)))**(3*beta)\n", | ||
" return M0*(1- (1+(r/R0))*np.exp(-r/R0))\n", | ||
"\n", | ||
"def mond(r, M0, rc, R0,b, beta):\n", | ||
" a = 1.2e-10\n", | ||
" G = 4.300e-6 #parsecs \n", | ||
" m = mass(r,M0, R0)\n", | ||
" f = (G*m/r)*(1 + b*(1+(r/rc)))#*10e-3\n", | ||
" return np.sqrt(f)*10e-3\n", | ||
"\n", | ||
"def newton(r, M0, rc, R0,beta):\n", | ||
" a = 1.2e-10\n", | ||
" G = 4.30e-6 #parsecs \n", | ||
" m = mass(r,M0, R0)\n", | ||
" f = G*m/r\n", | ||
" #f = (G*m/r)*(1/np.sqrt(2)) * np.sqrt(1 + np.sqrt(1 + (r**4) * (2*a/(G*m))**2))\n", | ||
" return np.sqrt(f)*10e-3" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9ad18e72", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for df in df_all:\n", | ||
" print(df['Rad'].max())\n", | ||
" print(df['Rad'].min())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d49750d3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m_mond=[]\n", | ||
"m_newton=[]\n", | ||
"\n", | ||
"for df in df_all:\n", | ||
" m_mond.append(gr.Fit(df['Rad'],df['Vobs'],1.,1.,3,.35,1.))\n", | ||
" m_newton.append(gr.Fit(df['Rad'],df['Vobs'],1.,1.,3,1.))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7e2450de", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fit_mond = [0]*len(m_mond)\n", | ||
"fit_newton = [0]*len(m_newton)\n", | ||
"for i in range(len(m_mond)):\n", | ||
" fit_mond[i] = m_mond[i].fit_lsq(mond, [(1.,1e14),(1.,10.),(2.,5.),(0.1,2),(0.1,2)],df_all[i]['errV'],[False,False,True,True,True])\n", | ||
" fit_newton[i] = m_newton[i].fit_lsq(newton, [(1.,1e14),(1.,10.),(1,10),(0.1,2)],df_all[i]['errV'],[False,True,True,True])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f770703a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"for i in range(len(m_mond)):\n", | ||
" fig, ax =plt.subplots()\n", | ||
" gr.Plot().plot_grc(df_all[i],fit_mond[i],mond,'MOND',galaxy[i],ax)\n", | ||
" gr.Plot().plot_grc(df_all[i],fit_newton[i],newton,'Newton',galaxy[i],ax)\n", | ||
" plt.savefig(galaxy[i]+'_rad_vars_fit.pdf')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b4339cbf", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fit_mond[1].draw_mnprofile('M0', band=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d4aa72f7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fit_mond[4].draw_mncontour('rc', 'M0',cl=[.67,.9,.95])" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.10.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setuptools.setup( | ||
name="pygrc", | ||
version="0.2.0", | ||
version="0.3.0", | ||
description= "A package to read SPARC data for Galactic Rotation Curves", | ||
author="Aman Desai", | ||
author_email="[email protected]", | ||
|