Ejemplo n.º 1
0
    def plot(self,var='kappa',output=None):

       plt.clf()

       # Panel 1: Galaxy positions:
       ax1 = plt.subplot(3,3,(1,4), aspect ='equal')
       self.plotFieldOfView('light',ax1)
       
       # Panel 2: Halo mass distributions:
       ax2 = plt.subplot(3,3,(2,5), aspect ='equal')
       self.plotFieldOfView('mass',ax2)

       # Panel 3: Kappa contributions:
       ax3 = plt.subplot(3,3,(3,6), aspect ='equal')
       self.plotFieldOfView(var,ax3)
       
       # Lower panel: View along redshift axis
       ax4 = plt.subplot(3,3,(7,9))
       self.plotLineOfSight(var,ax4)
       
       if output != None:
           pangloss.rm(output)
           plt.savefig(output,dpi=300)
       
       return None
Ejemplo n.º 2
0
    def plot(self, output=None):

        plt.clf()

        # Panel 1: Galaxy positions:
        ax1 = plt.subplot(3, 3, (1, 4), aspect="equal")
        self.plotFieldOfView("light", ax1)

        # Panel 2: Halo mass distributions:
        ax2 = plt.subplot(3, 3, (2, 5), aspect="equal")
        self.plotFieldOfView("mass", ax2)

        # Panel 3: Kappa contributions:
        ax3 = plt.subplot(3, 3, (3, 6), aspect="equal")
        self.plotFieldOfView("kappa", ax3)

        # Lower panel: View along redshift axis
        ax4 = plt.subplot(3, 3, (7, 9))
        self.plotLineOfSight("kappa", ax4)

        if output != None:
            pangloss.rm(output)
            plt.savefig(output, dpi=300)

        return None
Ejemplo n.º 3
0
    def plotContributions(self,quantity,output):
       
       plt.clf()
 
       # Point positions:
       zmax = self.zs+0.1
       z = numpy.linspace(0.0,zmax,100)
       # Plot the points:
       if quantity == 'mass':
           contr = numpy.zeros(len(z))
           for i in range(len(z)):
               galaxies = self.galaxies.where(self.galaxies.z <= z[i])
               size = galaxies.Mhalo_obs
               contr[i] = numpy.sum(size)
           plt.plot(z, contr)
           plt.title('Cumulative Sum of Halo Mass')
      
       elif quantity == 'kappa':
           contr = numpy.zeros(len(z))
           for i in range(len(z)):
               galaxies = self.galaxies.where(self.galaxies.z <= z[i])
               size = galaxies.kappa
               contr[i] = numpy.sum(size)           
           plt.plot(z, contr)
           plt.title(r'Cumulative Sum of $\kappa_h$')
       
       elif quantity == 'mu':
           contr = numpy.zeros(len(z))
           for i in range(len(z)):
               galaxies = self.galaxies.where(self.galaxies.z <= z[i])
               size = galaxies.mu
               contr[i] = numpy.sum(size)           
           plt.plot(z, contr)
           plt.title(r'Cumulative Sum of $\mu_h$')  

       elif quantity == 'stellarmass':
           contr = numpy.zeros(len(z))
           for i in range(len(z)):
               galaxies = self.galaxies.where(self.galaxies.z <= z[i])
               size = galaxies.Mstar_obs
               contr[i] = numpy.sum(size)           
           plt.plot(z, contr)
           plt.title('Cumulative Sum of Stellar Mass')

       else:
           raise "Lightcone plotting error: unknown quantity "+quantity

       # Axis limits:
       zmax = max(self.galaxies.z.max(),self.zs+0.1)
       
       # Labels:
       plt.xlabel('redshift z')

       if output != None:
           pangloss.rm(output)
           plt.savefig(output,dpi=300)

       return
Ejemplo n.º 4
0
    def plot(self,key1,key2=None,weight="weight",output=None,bins=None,title=None):

        import pylab as plt
        
        assert key1 in self.parameters, self.errmsg()
        if key2!=None:
            assert key2 in self.parameters, self.errmsg()
        if key2=="weight": 
            print "This code automatically uses the weights to form a histogram, you can state this explicitly using weightkey=weight if you have several weight columns"
            key2==None
        
        reformatnames={}
        
        reformatnames["mu"]="$\mu$"

        reformatnames["mu_cone"]="$\mu_{lc}$"
        reformatnames["kappa_cone"]="$\kappa_{lc}$"
        
        reformatnames["mu_tot"]="$\mu_{\mathrm{tot}}$"
        reformatnames["kappa_tot"]="$\kappa_{\mathrm{tot}}$"
        
        reformatnames["kappa_ext"]="$\kappa_{\mathrm{ext}}$"
        reformatnames["Kappah_median"]="$\widetilde{\kappa}_{\mathrm{halos}}$"

        key1name=key1[:]
        if key1name in reformatnames.keys():
            key1name = reformatnames[key1name]

        if key2 != None:
            key2name=key2[:]
            if key2name in reformatnames.keys():
                key2name = reformatnames[key2name]

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # 1D histogram:

        if key2 == None:

            par1 = self.getParameter(key1)
            
            # Check to see if samples are weighted:
            if weight!=None and weight in self.parameters: 
                weights = self.getParameter(weight)
                # print "pdf: plotting weighted histogram..."
            else: 
                weights = numpy.ones(len(par1))*1.0
                # print "pdf: plotting unweighted histogram..."
            weights /= numpy.sum(weights)

            if bins==None:
                nb=len(par1)*0.05
                if nb<20: nb=20
                bins=numpy.linspace(par1.min(),par1.max(),20)
            
            plt.figure()
            plt.hist(par1,weights=weights,bins=bins)
            plt.xlabel(key1name)
            plt.ylabel("P(%s|$\mathcal{D}$)"%key1name)
            if title != None: plt.title(title)

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # 2D scatter plot:

        elif key2 != None:
            
            assert weight==None, "I don't know about weighted 2D plots yet."
            
            # print "pdf: plotting a 2D scatter plot ..."

            plt.figure()
            plt.scatter(self.getParameter(key1),self.getParameter(key2),\
                            c='k',s=2, edgecolors=None)
            plt.xlabel(key1name)
            plt.ylabel(key2name)
            if title != None: plt.title(title)

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if output == None:
            plt.show(block=True)
        else:
            pangloss.rm(output)
            plt.savefig(output,dpi=300)
                
        return None
Ejemplo n.º 5
0
    def plot(self,
             key1,
             key2=None,
             weight="weight",
             output=None,
             bins=None,
             title=None):

        import pylab as plt

        assert key1 in self.parameters, self.errmsg()
        if key2 != None:
            assert key2 in self.parameters, self.errmsg()
        if key2 == "weight":
            print "This code automatically uses the weights to form a histogram, you can state this explicitly using weightkey=weight if you have several weight columns"
            key2 == None

        reformatnames = {}

        reformatnames["mu"] = "$\mu$"

        reformatnames["mu_cone"] = "$\mu_{lc}$"
        reformatnames["kappa_cone"] = "$\kappa_{lc}$"

        reformatnames["mu_tot"] = "$\mu_{\mathrm{tot}}$"
        reformatnames["kappa_tot"] = "$\kappa_{\mathrm{tot}}$"

        reformatnames["kappa_ext"] = "$\kappa_{\mathrm{ext}}$"
        reformatnames[
            "Kappah_median"] = "$\widetilde{\kappa}_{\mathrm{halos}}$"

        key1name = key1[:]
        if key1name in reformatnames.keys():
            key1name = reformatnames[key1name]

        if key2 != None:
            key2name = key2[:]
            if key2name in reformatnames.keys():
                key2name = reformatnames[key2name]

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # 1D histogram:

        if key2 == None:

            par1 = self.getParameter(key1)

            # Check to see if samples are weighted:
            if weight != None and weight in self.parameters:
                weights = self.getParameter(weight)
                # print "pdf: plotting weighted histogram..."
            else:
                weights = numpy.ones(len(par1)) * 1.0
                # print "pdf: plotting unweighted histogram..."
            weights /= numpy.sum(weights)

            if bins == None:
                nb = len(par1) * 0.05
                if nb < 20: nb = 20
                bins = numpy.linspace(par1.min(), par1.max(), 20)

            plt.figure()
            plt.hist(par1, weights=weights, bins=bins)
            plt.xlabel(key1name)
            plt.ylabel("P(%s|$\mathcal{D}$)" % key1name)
            if title != None: plt.title(title)

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # 2D scatter plot:

        elif key2 != None:

            assert weight == None, "I don't know about weighted 2D plots yet."

            # print "pdf: plotting a 2D scatter plot ..."

            plt.figure()
            plt.scatter(self.getParameter(key1),self.getParameter(key2),\
                            c='k',s=2, edgecolors=None)
            plt.xlabel(key1name)
            plt.ylabel(key2name)
            if title != None: plt.title(title)

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if output == None:
            plt.show(block=True)
        else:
            pangloss.rm(output)
            plt.savefig(output, dpi=300)

        return None