예제 #1
0
def plotGraph():
    fig = plt.figure()
    xlabel(r'$r\quad[\mathrm{pc}]$')
    if prof == 'M':
        ylabel(r'$M\quad[\mathrm{M}_{\odot}]$') #[10^5 M_{\odot}]')
    elif prof == 'rho':
        ylabel(r'$\rho\quad[\mathrm{M}_{\odot}/\mathrm{pc}^3]$') #[10^5 M_{\odot}]')
    elif prof=='beta':
        ylabel(r'$\beta_'+str(pop)+'$') #[10^5 M_{\odot}]')
    elif prof == 'nu':
        ylabel(r'$\nu_'+str(pop)+'$')
    elif prof == 'sig':
        ylabel(r'$\sigma_'+str(pop)+'$')
        
    fill_between(radsc, M95lo*Msc, M95hi*Msc, color='black',alpha=0.2,lw=1)
    fill_between(radsc, M68lo*Msc, M68hi*Msc, color='black',alpha=0.4,lw=1)
    plot(radsc,Mmedi*Msc,'r',lw=1)
    
    r1, r2 = halflightradii(gp.case)
    if prof == 'dens' or prof == 'M' or prof=='delta1' or prof=='nu1' or prof=='sig1':
        axvline(x=r1, visible=True)
    if prof == 'dens' or prof == 'M' or prof=='delta2':
        axvline(x=r2, visible=True)
    
    # theoretical model
    if prof == 'M':
        plot(radsc,Msc*Mwalkertot(radsc),'--',color='black',lw=1)
    elif prof == 'rho':
        plot(radsc,Msc*rhowalktot_3D(radsc),'--',color='black',lw=1) # 7 co
        # plot lowest profile as well
        # plot(radsc,Msc*profs[0],'.',color='orange',lw=1)
    elif prof == 'beta':
        plot(radsc,betawalker(radsc)[pop],color='black')
    elif prof == 'sig':
        rad, dummy, dummy, sig1, sigerr1 = gh.readcol5(gp.files.sigfiles[pop])
        rad *= gp.Rscale[pop]
        sigdat *= gp.maxvlos[pop]
        sigerr *= gp.maxvlos[pop]
        # plot(rad, sigdat, '--', color='b', lw=2)
        # plot(rad, sigdat-sigerr, '--', color='b', lw=1)
        # plot(rad, sigdat+sigerr, '--', color='b', lw=1)
        fill_between(rad, sigdat-sigerr, sigdat+sigerr, color='blue', alpha=0.3,lw=0)
    elif prof == 'nu':
        rad, dummy, dummy, nudat, nuerr = gh.readcol5(gp.files.nufiles[pop])
        rad *= gp.Rscale[pop]
        nudat *=gp.Nu0pc[pop]
        nuerr *=gp.Nu0pc[pop]
        fill_between(rad, nudat-nuerr, nudat+nuerr, color='blue', alpha=0.3,lw=0)


    if prof!='beta' and prof != 'sig':
        yscale('log')
    if prof == 'nu':
        yscale('log')
    if prof == "M" or prof == 'rho' or prof == 'nr':
        xscale('log')
        xlim([100.,1200.]);  ylim([0.005,1.5])
    if prof == 'beta':
        xlim([100.,1200.]);  ylim([-0.15,0.9])
    return fig
예제 #2
0
def plotGraph():
    fig = figure()
    xlabel(r'$r\quad[\mathrm{pc}]$')
    if prof == 'M':
        ylabel(r'$M\quad[\mathrm{M}_{\odot}]$') #[10^5 M_{\odot}]')
    elif prof == 'rho':
        ylabel(r'$\rho\quad[\mathrm{M}_{\odot}/\mathrm{pc}^3]$') #[10^5 M_{\odot}]')
    elif prof=='delta1' or prof == 'delta2':
        ylabel(r'$\beta$') #[10^5 M_{\odot}]')
    elif prof == 'nu1':
        ylabel(r'$\nu_1$')
    elif prof == 'sig1':
        ylabel(r'$\sigma_1$')
        
    fill_between(radsc, M95lo*Msc, M95hi*Msc, color='black',alpha=0.2,lw=1)
    fill_between(radsc, M68lo*Msc, M68hi*Msc, color='black',alpha=0.4,lw=1)
    plot(radsc,Mmedi*Msc,'r',lw=1)
    
    r1 = halflightradius(gp.case)
    if prof == 'rho' or prof == 'M' or prof=='beta1' or prof=='nu1' or prof=='sig1':
        axvline(x=r1, visible=True)
    
    # theoretical model
    if prof == 'M':
        plot(radsc,Msc*Mwalkertot(radsc),'--',color='black',lw=1)
    elif prof == 'rho':
        plot(radsc,Msc*rhogaiatot_3D(radsc),'--',color='black',lw=1) # 7 co
        # plot lowest profile as well
        # plot(radsc,Msc*profs[0],'.',color='orange',lw=1)
    elif prof == 'beta1':
        plot(radsc, betagaia(radsc), color='black')
    elif prof == 'sig1':
        rad, dummy, dummy, sig1, sigerr1 = gh.readcol5(gp.files.sigfiles[1])
        rad *= gp.Rscale[1]
        sig1*=gp.maxvlos[1]
        sigerr1*=gp.maxvlos[1]
        # plot(rad, sig1, '--', color='b', lw=2)
        # plot(rad, sig1-sigerr1, '--', color='b', lw=1)
        # plot(rad, sig1+sigerr1, '--', color='b', lw=1)
        fill_between(rad, sig1-sigerr1, sig1+sigerr1, color='blue', alpha=0.3,lw=0)
    elif prof == 'nu1':
        rad, dummy, dummy, nu1, nuerr1 = gh.readcol5(gp.files.nufiles[1])
        rad *= gp.Rscale[1]
        # TODO: missing factor 10 somewhere..
        pdb.set_trace()
        nu1 *= gp.Nu0pc[1];   nuerr1 *= gp.Nu0pc[1]
        fill_between(rad, nu1-nuerr1, nu1+nuerr1, color='blue', alpha=0.3,lw=0)

    if prof!='delta1' and prof!='delta2' and prof != 'sig1' and prof != 'nu1':
        # xscale('log')
        yscale('log')
    if prof == 'nu1':
        yscale('log')
    if prof == "M" or prof == 'rho':
        xscale('log')
        #xlim([100.,1200.]);  ylim([0.005,1.5])
    # if prof == 'delta1':
    #     xlim([100.,1200.]);  ylim([-0.15,0.9])

    return fig
예제 #3
0
파일: gl_data.py 프로젝트: sofiasi/darcoda
    def read_nu(self):
        for pop in np.arange(gp.pops+1):
            Nux, binmin, binmax, Nudat, Nuerr = \
                    gh.readcol5(gp.files.nufiles[pop]) # component 1
            # 3*[rscale], [Nu0], [Nu0]
            Nuerr *= gp.nuerrcorr # [rho0]
            # switch to Munit (msun) and pc here
            Nux    = Nux[:]    * gp.Rscale[pop]  # [pc]
            Nudat  = Nudat[:]  * gp.Nu0pc[pop] # [Msun/pc^2]
            Nuerr  = Nuerr[:]  * gp.Nu0pc[pop] # [Msun/pc^2]
            self.rbin = Nux                            # [pc]
            self.binmin = binmin; self.binmax = binmax    # 2*[pc]
            gp.xipol = self.rbin                          # [pc]
            maxr = max(self.rbin)
            gp.xepol = np.hstack([self.rbin, 2*maxr, 4*maxr, 8*maxr])
            
            # deproject, # takes [pc], 2* [munit/pc^2], gives [pc], 2* [munit/pc^3],
            # already normalized to same total mass
            if gp.geom=='sphere':
                dummy, nudat, nuerr = Rho_NORM_rho(self.rbin, Nudat, Nuerr)
            else:
                Nudat, Nuerr = Nudat, Nuerr

            self.Nudat.append(Nudat) # [Msun/pc^2]
            self.Nuerr.append(Nuerr) # [Msun/pc^2]
            self.nudat.append(nudat) # [Msun/pc^3]
            self.nuerr.append(nuerr) # [Msun/pc^3]
        return
예제 #4
0
파일: gl_data.py 프로젝트: sofiasi/darcoda
 def read_kappa(self):
     for pop in np.arange(gp.pops+1):
         Dummy, Dummy, Dummy, kapdat, kaperr = gh.readcol5(gp.files.kappafiles[pop])
         # 3*[Rscale], [1], [1]
         kaperr /= gp.kaperrcorr # [1]
         self.kapdat.append(kapdat) # [1]
         self.kaperr.append(kaperr) # [1]
     return
예제 #5
0
파일: gl_data.py 프로젝트: sofiasi/darcoda
 def read_sigma(self):
     for pop in np.arange(gp.pops+1):
         # print(gp.files.sigfiles[pop])
         Dummy, Dummy, Dummy, sigdat, sigerr = gh.readcol5(gp.files.sigfiles[pop])
         # 3*[Rscale], [maxvlos], [maxvlos]
         sigerr /= gp.sigerrcorr     # [maxvlos]
         # change to km/s here
         self.sigdat.append(sigdat[:] * gp.maxvlos[pop]) # [km/s]
         self.sigerr.append(sigerr[:] * gp.maxvlos[pop]) # [km/s]
     return
예제 #6
0
def run(basename, prof):
    read_scale()

    # read in half light radius, Nu0[munit/Rscale^2], Nu0[munit/pc^2], munit
    print(gp.files.get_scale_file(0))
    A = np.loadtxt(gp.files.get_scale_file(0), unpack=False, skiprows=1)
    gp.rstarhalf = A[0] # halflight radius (all tracer part.s), stored first ("0")
    # read in radial bins
    radii, binmin, binmax, nudat1, nuerr1 = gh.readcol5(gp.files.nufiles[0])
    gp.xipol = radii*gp.rstarhalf       # [pc]
    maxr = max(radii)
    radii = np.hstack([radii, 2*maxr, 4*maxr, 8*maxr])
    gp.xepol = radii*gp.rstarhalf
    
    models = read_models()
    
    # use physical representation for profiles
    profs = []
    for i in range(len(models)):
        M = models[i]
        tmp_rho = M[0:gp.nepol]
        off = gp.nipol
        tmp_nu = M[off:off+gp.nepol]
        off += gp.nipol
        tmp_beta = M[off:off+gp.nbeta]
        # TODO: include handling of N populations

        try:
            tmp_prof = physical(gp.xepol, prof, pop, tmp_rho, tmp_nu, tmp_beta)
            profs.append(tmp_prof)
        except Exception as detail:
            print('handling error in profile', detail)
            continue

    sortedprofs = gh.sort_profiles_binwise(np.array(profs).transpose())

    Mmin, M95lo, M68lo, Mmedi, \
      M68hi, M95hi, Mmax = gh.get_median_1_2_sig(sortedprofs)

    # plot ranges
    if prof=='rho' or prof=='nu':
        gpl.startlog(); gpl.xscale('log')
    else:
        gpl.start()
    plot_labels(prof, pop)
            
    if prof=='nr':
        gpl.xscale('log')
        # gpl.xlim([0.,2.*gp.xipol[-1]])
        gp.xipol = np.hstack([gp.xipol[0]/2., gp.xipol, gp.rinfty*gp.xipol[-1]])
    if prof=='nu' or prof=='sig':
        plot_data(gp.xipol, prof, pop)
    plot_analytic(gp.xepol, prof, pop)

    radfill = gp.xepol
    if prof == 'sig':
        radfill = gp.xipol
    fill_nice(radfill, M95lo, M68lo, Mmedi, M68hi, M95hi)

    gpl.savefig(basename+'/prof_'+prof+'_'+str(pop)+'.png')
    gpl.ion(); gpl.show(); gpl.ioff()
    return