Esempio n. 1
0
def getDAMICy(file='data/DAMIC_siyield_allerr.txt'):
    #units of E should be eV

    #get the data
    damic_data = dp.getXYdata_wXYerr(file)
    #print(damic_data.keys())

    #convert to numpy arrays
    damic_data['xx'] = np.asarray(damic_data['xx']) * 1000  #make units eV
    damic_data['yy'] = np.asarray(damic_data['yy']) * 1000  #make units eV
    damic_data['ex'] = np.asarray(damic_data['ex']) * 1000  #make units eV
    damic_data['ey'] = np.asarray(damic_data['ey']) * 1000  #make units eV

    #get the yield stuff
    damic_data['yy_yield'] = damic_data['yy'] / damic_data['xx']
    damic_data['ey_yield'] = damic_data['yy_yield'] * np.sqrt((damic_data['ey']/damic_data['yy'])**2 + \
                                       (damic_data['ex']/damic_data['xx'])**2)

    #spline fit
    damic_y = inter.UnivariateSpline(damic_data['xx'],
                                     damic_data['yy_yield'],
                                     s=1.5)

    return damic_y
Esempio n. 2
0
import sys 
#sys.path.append('../python/')
import NGC5533_functions as nf
import noordermeer as noord               # Traced data of Galaxy NGC 5533
import numpy as np
import matplotlib.pyplot as plt
import lmfit as lm
import dataPython as dp
import scipy.interpolate as inter

################################
##### Measured data points #####
################################

data = dp.getXYdata_wXYerr('../data/100kpc_data.txt')
#data = dp.getXYdata_wXYerr('../galactic-spin-binder/NGC_5533/data/final/100kpc_data.txt')
r_dat = np.asarray(data['xx'])
v_dat = np.asarray(data['yy'])
v_err0 = np.asarray(data['ex'])
v_err1 = np.asarray(data['ey'])

###########################################
###### Uncertainty Band and Weights #######
###########################################

# Uncertainty band, using Noordermeer's function with a guessed delta_i
delta_i = 3     # guessed value
v_i = (v_dat / np.tan(52*(np.pi/180)) * delta_i *(np.pi/180))

# Traced uncertainty band
Esempio n. 3
0
import numpy as np
import sys
sys.path.append('../../python/')
import dataPython as dp
import scipy.integrate as si

##############################
### Import data/text files ###
##############################

# Note: there's no need to import the radius for each component as everything has the same r array
# (the r array of the raw data)

# Datapoints:
data = dp.getXYdata_wXYerr('../testing/7814/ngc7814data')
radius = np.asarray(data['xx'])
v_dat = np.asarray(data['yy'])
v_err1 = np.asarray(data['ey'])

# Disk:
disk_data = dp.getXYZdata('../testing/7814/7814reallydisk.dat')
disk = np.asarray(disk_data['zz'])

# Bulge:
bulge_data = dp.getXYZdata('../testing/7814/7814reallybulge.dat')
bulge = np.asarray(bulge_data['zz'])

# Gas:
gas_data = dp.getXYZdata('../testing/7814/7814gascomp.dat')
gas = np.asarray(gas_data['zz'])
Esempio n. 4
0
def f(arraysize, Mbh):

    #fractions: now changing the number of dots plottd within each bracket, which changes as the slider
    #variable ("arraysize") changes

    #and trim to the first x elements of the pre-caclated radius arrays for each bracket
    arraysize = int(arraysize)  #units: dot
    re = wi.rrr[:arraysize]
    anglee = wi.angle[:arraysize]

    #plot for each bracket, two equations for each bracket
    y = wi.c_y + re * np.sin(anglee)  #y coordinates
    x = wi.c_x + re * np.cos(anglee)  #x coordinates

    #below: changing the physical size of the plotted dots as the bh mass slider changes. the if else statement is fancy
    #but not necessary

    Mbh = 1.5 * Mbh  #judging by eye
    if .1 <= Mbh < 1:
        Mbh = Mbh**1.5
    elif 1 <= Mbh < 2:
        Mbh = Mbh**2
    else:
        Mbh = Mbh**3  #display size of each marker

    f, (ax1, ax2) = plt.subplots(1, 2, sharey=False)
    f.set_figheight(15)
    f.set_figwidth(35)

    # Define r, for some reason this isn't working in code7814.py, so put directly here:
    data = dp.getXYdata_wXYerr('../../testing/7814/ngc7814data')
    r = np.asarray(data['xx'])

    ax1.scatter(x, y, color="r", marker='o', s=Mbh)
    ax1.imshow(img)
    ax1.axis('off')
    ax2.plot(r, h(r, Mbh, arraysize), label=("halo"), color='green')
    ax2.errorbar(r, wi.v_dat, yerr=wi.v_err1, fmt='bo', label='Data')
    ax2.plot(r, wi.b, label=("Bulge"), color='orange')
    ax2.plot(r, wi.d, label=("Disk"), color='purple')
    ax2.plot(r, wi.g, label=("Gas"), color='blue')
    ax2.plot(r, t(r, Mbh, arraysize), label=("Total Curve"), color='red')
    ax2.set_xlim([wi.minkpc, 19])
    ax2.set_ylim([0, 400])
    ax2.set_title('NGC 7814', fontsize=40)
    ax2.set_ylabel('Velocity [km/s]', fontsize=30)
    ax2.set_xlabel('radius [kpc]', fontsize=30)
    ax2.legend(loc='upper right', prop={'size': 23}, ncol=3)

    residuals = wi.v_dat - t(wi.r, Mbh, arraysize)
    # Determining errors
    errors = wi.v_err1**2  #second term is inclination uncertainty
    # Chi squared
    chisquared = np.sum(residuals**2 / errors**2)
    #chisquared = stats.chisquare(v_dat,totalcurve(r,M,bpref,dpref,rc,rho00,gpref))
    reducedchisquared = chisquared * (1 / (len(wi.r) - 6))

    props = dict(boxstyle='round', facecolor='white', alpha=0.5)
    ax2.text(0.4,
             360,
             r"Reduced $\chi^2$:" + '\n' + "{:.2f}".format(reducedchisquared),
             bbox=props,
             size=30)
Esempio n. 5
0
import matplotlib.pyplot as plt
import scipy.optimize as opt
import lmfit as lm
import sys
sys.path.append('../python')
import dataPython as dp
import NGC5533_functions as nf


# In[2]:


#**********************importing text files******************************
#there's no need to import the radius for each component as everything has the same r array (the r array of the raw data)
#data:
data = dp.getXYdata_wXYerr('../testing/891/891_data')
r = np.asarray(data['xx'])
v_dat = np.asarray(data['yy'])
v_err1 = np.asarray(data['ey'])
#disk:
disk = dp.getXYdata('../testing/891/891_dtDisk.dat')
d = np.asarray(disk['yy'])
#bulge:
bulge = dp.getXYdata('../testing/891/891_dtBulge.dat')
b = np.asarray(bulge['yy'])
#gas:
gas = dp.getXYdata('../testing/891/891_dtGas.dat')
g = np.asarray(gas['yy'])

#***************************define total curve
#D=9.25 #disk M-L ratio provided in [1] 
Esempio n. 6
0
from ipywidgets import interactive, fixed, FloatSlider, HBox, Layout, Button, Label, Output, VBox

from IPython.display import display, clear_output
from IPython.display import Javascript

import scipy.stats as stats
import warnings
warnings.filterwarnings("ignore")  #ignore warnings

# In[2]:

#import data files:

#TRACING:**************************************
#data points:
data = dp.getXYdata_wXYerr('../NGC_5005/traced_data/ngc5005_data.txt')
r_dat = np.asarray(data['xx'])
v_dat = np.asarray(data['yy'])
v_err0 = np.asarray(data['ex'])
v_err1 = np.asarray(data['ey'])
#v_err1=v_err1[:len(v_err1)-1]
#r_dat=r_dat[:len(r_dat)-1]
#v_dat=v_dat[:len(v_dat)-1]

#gas rotmod:
gas_rdata = dp.getXYZdata('../testing/aygas.dat')  #rotmod_gas.dat
rgasr = gas_rdata['xx']
rgasv = gas_rdata['zz']
rgasv = np.asarray(rgasv)
rgasv_spline = inter.InterpolatedUnivariateSpline(rgasr, rgasv, k=5)
rgasv_fit = rgasv_spline(r_dat)