Example #1
0
    def plot_mass_step(self,sn_name,HOST_pkl):
        
        HOST=cPickle.load(open(HOST_pkl))
        mb=self.HF.y_corrected+5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)-5.
        data= mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5.
        error= N.sqrt(self.HF.y_error_corrected**2+self.Y_err**2)

        Masse=N.zeros(len(data))
        Masse_minus=N.zeros(len(data))
        Masse_plus=N.zeros(len(data))
        Filtre_M=N.array([True]*len(data))

        for i in range(len(sn_name)):
            sn=sn_name[i]
            if sn in HOST.keys() :
                Masse[i]=HOST[sn]['mchost.mass']
                Masse_minus[i]=HOST[sn]['mchost.mass_m.err']
                Masse_plus[i]=HOST[sn]['mchost.mass_p.err']

                if HOST[sn]['mchost.mass']==0:
                    Filtre_M[i]=False
            else :
                Filtre_M[i]=False


        MASS_SUP=(Masse[Filtre_M]>10)
        Xmass_SUP=N.linspace(10,14,10)
        Xmass_low=N.linspace(6,10,10)
        Masse_err=[Masse_minus[Filtre_M],Masse_plus[Filtre_M]]
        
        M_SI_SUP=N.average(data[Filtre_M][MASS_SUP],weights=1./error[Filtre_M][MASS_SUP]**2)
        wRMS_sup=H.comp_rms(data[Filtre_M][MASS_SUP]-M_SI_SUP, 10, err=False, variance=error[Filtre_M][MASS_SUP]**2)
        M_SI_SUP=N.average(data[Filtre_M][MASS_SUP],weights=1./(error[Filtre_M][MASS_SUP]**2+wRMS_sup**2))
        M_SI_SUP_err=N.sqrt((1./N.sum(1./(error[Filtre_M][MASS_SUP]**2+wRMS_sup**2))))
        
        M_SI_low=N.average(data[Filtre_M][~MASS_SUP],weights=1./error[Filtre_M][~MASS_SUP]**2)
        wRMS_low=H.comp_rms(data[Filtre_M][~MASS_SUP]-M_SI_low, 10, err=False, variance=error[Filtre_M][~MASS_SUP]**2)
        M_SI_low=N.average(data[Filtre_M][~MASS_SUP],weights=1./(error[Filtre_M][~MASS_SUP]**2+wRMS_low**2))
        M_SI_low_err=N.sqrt((1./N.sum(1./(error[Filtre_M][~MASS_SUP]**2+wRMS_low**2))))

        print M_SI_SUP-M_SI_low, ' +/- ', N.sqrt(M_SI_SUP_err**2+M_SI_low_err**2)
        pull=abs(M_SI_SUP-M_SI_low)/N.sqrt(M_SI_SUP_err**2+M_SI_low_err**2)
        X_SI=N.linspace(min(data)-N.std(data),max(data)+N.std(data),100)
        P.figure()

        P.text(11,0.4,'$\sigma=%.3f$'%(pull),fontsize=14)
        P.scatter(Masse[Filtre_M],data[Filtre_M],c='b')
        P.errorbar(Masse[Filtre_M],data[Filtre_M],linestyle='', yerr=error[Filtre_M],xerr=Masse_err,ecolor='grey',alpha=0.9,marker='.',zorder=0)
        P.plot(10*N.ones(2),[-0.6,0.6],'k-.',linewidth=2)
        P.plot(Xmass_low,N.ones(len(Xmass_low))*M_SI_low,'b')
        P.fill_between(Xmass_low,N.ones(len(Xmass_low))*M_SI_low-M_SI_low_err,N.ones(len(Xmass_low))*M_SI_low+M_SI_low_err,color='b',alpha=0.5)
        P.plot(Xmass_SUP,N.ones(len(Xmass_SUP))*M_SI_SUP,'b')
        P.fill_between(Xmass_SUP,N.ones(len(Xmass_SUP))*M_SI_SUP-M_SI_SUP_err,N.ones(len(Xmass_SUP))*M_SI_SUP+M_SI_SUP_err,color='b',alpha=0.5)

        P.ylim(min(data)-N.std(data),max(data)+2*N.std(data))
        P.xlabel('$\log(M/M_{\odot})$',fontsize=16)
        P.xlim(7,12)
        P.ylabel(r'$\mu-\mu_{\Lambda CDM}$',fontsize=15)
        P.ylim(-0.6,0.6)
Example #2
0
    def Make_hubble_diagram(self):

        self.HF=Multi.Multilinearfit(self.data,self.Y,yerr=self.Y_err,xerr=None,covx=self.data_cov)
        
        self.HF.Multilinearfit(adddisp=True)
        self.HF.comp_stat()
        mb=self.Y+5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)-5.
        self.residuals=mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5.
Example #3
0
    def plot_result_before(self,SALT=True):
        
        P.figure(figsize=(9,9))
        mb=self.Y+5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)-5.

        gs = gridspec.GridSpec(2, 1,height_ratios=[3,1])
        #P.subplots_adjust(hspace=0.001)
        P.subplots_adjust(left=0.09, bottom=0.07, right=0.99, top=0.95,hspace=0.001)

        P.subplot(gs[0])

        wwRMS,wwRMS_ERR=H.comp_rms(mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5., 10, err=True, variance=self.Y_err**2)

        P.scatter(self.z,mb-self.HF.M0,label='wRMS = %.3f$ \pm$ %.3f'%((wwRMS,wwRMS_ERR)))
        P.errorbar(self.z,mb-self.HF.M0 , xerr=None ,
                   yerr=N.sqrt(self.HF.y_error_corrected**2+self.Y_err**2),linestyle='',alpha=0.5,marker='.',zorder=0)
        P.plot(N.linspace(0.001,0.11,10),5.*N.log(d_l(N.linspace(0.001,0.11,10),SNLS=True))/N.log(10.)-5.)
        P.xlim(0.01,0.11)
        P.ylim(32.2,39)
        if SALT:
            P.ylabel(r'$\mu=m_B^*-M_0$',fontsize=20) 
            P.title('Hubble diagram (%i supernovae)'%(len(self.z)))
        else:
            P.ylabel(r'$\mu=m_B^*-M_0$',fontsize=20)
            P.title('SUGAR Hubble diagram (%i supernovae)'%(len(self.z)))
            
        P.semilogx()
        P.xticks([2500.,9500.],['toto','pouet'])
        P.xlim(0.01,0.11)
        P.legend(loc=4)

        P.subplot(gs[1])

        P.scatter(self.z,mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5.)
        P.errorbar(self.z,mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5., xerr=None ,
                   yerr=N.sqrt(self.HF.y_error_corrected**2+self.Y_err**2),linestyle='',alpha=0.5,marker='.',zorder=0)
        P.plot(N.linspace(0.001,0.11,10),N.zeros(10))
        P.xlim(0.01,0.11)
        P.ylim(-1,1)
        P.ylabel(r'$\mu-\mu_{\Lambda CDM}$',fontsize=20)
        P.semilogx()
        P.xlabel('z',fontsize=20)
Example #4
0
    def plot_result_after(self,SALT=True):
        
        P.figure(figsize=(9,9))
        mb=self.HF.y_corrected+5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)-5.

        gs = gridspec.GridSpec(2, 1,height_ratios=[3,1])
        P.subplots_adjust(left=0.09, bottom=0.07, right=0.99, top=0.95,hspace=0.001)
        P.subplot(gs[0])

        #P.scatter(self.z,mb-self.HF.M0,c='b',label='wRMS = %.3f $\pm$ %.3f,   $\sigma_{int}$=%.3f'%((self.HF.WRMS,self.HF.WRMS_err,self.HF.disp)))
        P.scatter(self.z,mb-self.HF.M0,c='b',label='wRMS = %.3f $\pm$ %.3f'%((self.HF.WRMS,self.HF.WRMS_err)))
        P.errorbar(self.z,mb-self.HF.M0 , xerr=None ,
                   yerr=N.sqrt(self.HF.y_error_corrected**2+self.Y_err**2),linestyle='',alpha=0.5,marker='.',zorder=0)
        P.plot(N.linspace(0.001,0.11,10),5.*N.log(d_l(N.linspace(0.001,0.11,10),SNLS=True))/N.log(10.)-5.)
        P.xlim(0.01,0.11)
        P.ylim(32.2,39)
        if SALT:
            P.ylabel(r'$\mu=m_B^*-M_0+\alpha x_1 -\beta c$',fontsize=20) 
            P.title('SALT2 Hubble diagram (%i supernovae)'%(len(self.z)))
        else:
            P.ylabel(r'$\mu=m_B^*-M_0-\sum_i^{n=3}a_i q_i -b A_V$',fontsize=20)
            P.title('SUGAR Hubble diagram (%i supernovae)'%(len(self.z)))
            
        P.semilogx()
        P.xticks([2500.,9500.],['toto','pouet'])
        P.xlim(0.01,0.11)
        P.legend(loc=4)

        P.subplot(gs[1])
        self.residuals=mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5.
        P.scatter(self.z,mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5.,c='b')
        P.errorbar(self.z,mb-self.HF.M0-5.*N.log(d_l(self.z,SNLS=True))/N.log(10.)+5., xerr=None ,
                   yerr=N.sqrt(self.HF.y_error_corrected**2+self.Y_err**2),linestyle='',alpha=0.5,marker='.',zorder=0)
        P.plot(N.linspace(0.001,0.11,10),N.zeros(10))

        P.xlim(0.01,0.11)
        P.ylim(-1,1)
        P.ylabel(r'$\mu-\mu_{\Lambda CDM}$',fontsize=20)
        P.semilogx()
        P.xlabel('z',fontsize=20)
Example #5
0
    def load_photometry_and_data(self,Filter='B'):

        self.Photometry=N.zeros(len(self.sn_name))
        self.Photometry_err=N.zeros(len(self.sn_name))
        self.data=N.zeros((len(self.sn_name),2))
        self.Cov_data=N.zeros((len(self.sn_name),2,2))
        self.z=N.zeros(len(self.sn_name))
        self.z_err=N.zeros(len(self.sn_name))
        self.DayMax=N.zeros(len(self.sn_name))

        for i,sn in enumerate(self.sn_name):
            self.z[i]=self.dic[sn]['host.zcmb']
            self.Photometry[i]=self.dic[sn]['salt2.RestFrameMag_0_'+Filter]-5.*N.log(d_l(self.z[i],SNLS=True))/N.log(10.)+5.
            self.Photometry_err[i]=N.sqrt(self.dic[sn]['salt2.RestFrameMag_0_'+Filter+'.err']**2+0.03**2)
            self.data[i,0]=self.dic[sn]['salt2.X1']
            self.data[i,1]=self.dic[sn]['salt2.Color']
            self.Cov_data[i,0,0]=self.dic[sn]['salt2.X1.err']**2
            self.Cov_data[i,1,1]=self.dic[sn]['salt2.Color.err']**2
            self.Cov_data[i,0,1]=self.dic[sn]['salt2.CovColorX1']
            self.Cov_data[i,1,0]=self.dic[sn]['salt2.CovColorX1']
            self.z_err[i]=self.dic[sn]['host.zhelio.err']
            self.DayMax[i]=self.dic[sn]['salt2.DayMax']