In [1]:
from scipy.optimize import curve_fit
import astropy.io.ascii as ascii
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
In [2]:
tab1=ascii.read("Table1.csv")
tab2=ascii.read("Table2.csv")
tab3=ascii.read("Table3.csv")
In [3]:
tab1
Out[3]:
In [4]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['rvel'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
plt.plot(tab1['radius'],tab1['Theoryval'],'-')
plt.plot(tab1['radius'],tab1['Ydiffval'],'--')
plt.title('Gas Dominated Dwarf (NGC 3741)')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf.pdf')
plt.savefig('gasdwarf.jpeg')
In [5]:
def line(x, a):
return a * x
In [6]:
popt, pcov = curve_fit(line, tab1['radius'], tab1['Ydiffval'])
In [7]:
popt
Out[7]:
In [8]:
pcov
Out[8]:
In [10]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf_fit_omega.pdf')
plt.savefig('gasdwarf_fit_omega.jpeg')
In [11]:
tab2
Out[11]:
In [12]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Rvelocity'],yerr=tab2['Velerr'],fmt='o',capsize=3)
plt.plot(tab2['Radius'],tab2['Theory'],'-')
plt.plot(tab2['Radius'],tab2['Veldiff'],'--')
plt.title('Disk-Dominated Spiral (NGC6503)')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral.pdf')
plt.savefig('diskspiral.jpeg')
In [13]:
popt2, pcov2 = curve_fit(line, tab2['Radius'], tab2['Veldiff'])
In [15]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt2), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral_fit_omega.pdf')
plt.savefig('diskspiral_fit_omega.jpeg')
In [16]:
print popt2
print pcov2
In [17]:
tab3
Out[17]:
In [18]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['rvel'],yerr=tab3['velerr'],fmt='o',capsize=3)
plt.plot(tab3['radius'],tab3['Rtheory'],'-')
plt.plot(tab3['radius'],tab3['veldiff'],'--')
plt.title('Bulge-Dominated Spiral (NGC7814)')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral.pdf')
plt.savefig('bulgespiral.jpeg')
In [19]:
popt3, pcov3 = curve_fit(line, tab3['radius'], tab3['veldiff'])
In [20]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt3), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral_fit_omega.pdf')
plt.savefig('bulgespiral_fit_omega.jpeg')
In [21]:
print popt3
print pcov3
In [91]:
popt, pcov = curve_fit(line, tab1['radius'][2:], tab1['Ydiffval'][2:])
In [90]:
tab1['radius'][2:]
Out[90]:
In [93]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt[0], popt[1]), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Diff between theory & observed (in km/s/Mpc)')
plt.savefig('gasdwarf_diff_fit.pdf')
plt.savefig('gasdwarf_diff_fit.jpeg')
In [95]:
popt2, pcov2 = curve_fit(line, tab2['Radius'][4:], tab2['Veldiff'][4:])
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt2[0], popt2[1]), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Diff between theory & observed (in km/s/Mpc)')
plt.savefig('diskspiral_diff_fit.pdf')
plt.savefig('diskspiral_diff_fit.jpeg')
In [96]:
popt3, pcov3 = curve_fit(line, tab3['radius'][2:], tab3['veldiff'][2:])
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, line(xfine, popt3[0], popt3[1]), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Diff between theory & observed (in km/s/Mpc)')
plt.savefig('bulgespiral_diff_fit.pdf')
plt.savefig('bulgespiral_diff_fit.jpeg')
In [22]:
def linexp(x, a, b):
return a * x * np.exp(b*x)
In [23]:
popt, pcov = curve_fit(linexp, tab1['radius'], tab1['Ydiffval'])
In [24]:
print popt
In [26]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, linexp(xfine, popt[0], popt[1]), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf_fit_omega_exp.pdf')
plt.savefig('gasdwarf_fit_omega_exp.jpeg')
In [29]:
popt2, pcov2 = curve_fit(linexp, tab2['Radius'], tab2['Veldiff'])
In [30]:
print popt2
print pcov2
In [32]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, linexp(xfine, popt2[0], popt2[1]), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral_fit_omega_exp.pdf')
plt.savefig('diskspiral_fit_omega_exp.jpeg')
In [33]:
popt3, pcov3 = curve_fit(linexp, tab3['radius'], tab3['veldiff'])
In [34]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, linexp(xfine, popt3[0], popt3[1]), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral_fit_omega_exp.pdf')
plt.savefig('bulgespiral_fit_omega_exp.jpeg')
In [36]:
print popt3
print pcov3
In [45]:
def linexp1(x, a, b):
return a * np.exp(b*x)
In [46]:
popt, pcov = curve_fit(linexp1, tab1['radius'], tab1['Ydiffval'])
In [47]:
print popt
print pcov
In [48]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, linexp1(xfine, popt[0], popt[1]), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf_fit_omega_exp1.pdf')
plt.savefig('gasdwarf_fit_omega_exp1.jpeg')
In [49]:
popt2, pcov2 = curve_fit(linexp1, tab2['Radius'], tab2['Veldiff'])
In [50]:
print popt2
print pcov2
In [51]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, linexp1(xfine, popt2[0], popt2[1]), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral_fit_omega_exp1.pdf')
plt.savefig('diskspiral_fit_omega_exp1.jpeg')
In [52]:
popt3, pcov3 = curve_fit(linexp1, tab3['radius'], tab3['veldiff'])
In [53]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, linexp1(xfine, popt3[0], popt3[1]), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral_fit_omega_exp1.pdf')
plt.savefig('bulgespiral_fit_omega_exp1.jpeg')
In [ ]:
In [54]:
def linexp2(x, a, b):
return a * np.exp(b/x)
In [55]:
popt, pcov = curve_fit(linexp2, tab1['radius'], tab1['Ydiffval'])
In [56]:
print popt
print pcov
In [57]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, linexp2(xfine, popt[0], popt[1]), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf_fit_omega_exp2.pdf')
plt.savefig('gasdwarf_fit_omega_exp2.jpeg')
In [58]:
popt2, pcov2 = curve_fit(linexp2, tab2['Radius'], tab2['Veldiff'])
In [59]:
print popt2
print pcov2
In [60]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, linexp2(xfine, popt2[0], popt2[1]), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral_fit_omega_exp2.pdf')
plt.savefig('diskspiral_fit_omega_exp2.jpeg')
In [61]:
popt3, pcov3 = curve_fit(linexp2, tab3['radius'], tab3['veldiff'])
In [62]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, linexp2(xfine, popt3[0], popt3[1]), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral_fit_omega_exp2.pdf')
plt.savefig('bulgespiral_fit_omega_exp2.jpeg')
In [ ]:
In [63]:
def linexp3(x, a, b):
return a *x* np.exp(b/x)
In [64]:
popt, pcov = curve_fit(linexp3, tab1['radius'], tab1['Ydiffval'])
In [65]:
print popt
print pcov
In [66]:
plt.figure()
plt.errorbar(tab1['radius'],tab1['Ydiffval'],yerr=tab1['rvelerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 7.5, 100) # define values to plot the function for
plt.plot(xfine, linexp3(xfine, popt[0], popt[1]), 'r-')
plt.title('Gas Dominated Dwarf best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('gasdwarf_fit_omega_exp3.pdf')
plt.savefig('gasdwarf_fit_omega_exp3.jpeg')
In [69]:
popt2, pcov2 = curve_fit(linexp3, tab2['Radius'], tab2['Veldiff'])
In [70]:
print popt2
print pcov2
In [71]:
plt.figure()
plt.errorbar(tab2['Radius'],tab2['Veldiff'],yerr=tab2['Velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 25, 100) # define values to plot the function for
plt.plot(xfine, linexp3(xfine, popt2[0], popt2[1]), 'r-')
plt.title('Disk-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('diskspiral_fit_omega_exp3.pdf')
plt.savefig('diskspiral_fit_omega_exp3.jpeg')
In [73]:
popt3, pcov3 = curve_fit(linexp3, tab3['radius'], tab3['veldiff'])
In [74]:
plt.figure()
plt.errorbar(tab3['radius'],tab3['veldiff'],yerr=tab3['velerr'],fmt='o',capsize=3)
xfine = np.linspace(0., 20, 100) # define values to plot the function for
plt.plot(xfine, linexp3(xfine, popt3[0], popt3[1]), 'r-')
plt.title('Bulge-dominated Spiral best fit')
plt.xlabel('Radius(in kpc)')
plt.ylabel('Rotational velocity (in km/s/Mpc)')
plt.savefig('bulgespiral_fit_omega_exp3.pdf')
plt.savefig('bulgespiral_fit_omega_exp3.jpeg')
In [ ]: