def disp(fitres, idsurv, cut=3): headn = linef.linef(fitres, 'zCMB') #ids,mures = np.loadtxt(fitres, usecols=(3,41), unpack=True, dtype='string', skiprows=45) data1 = np.genfromtxt(fitres, skip_header=headn, names=True, comments='#') zCMB = data1['zCMB'].astype(float) MU = data1['MU'].astype(float) MU_MODEL = data1['MUMODEL'].astype(float) mures = MU - MU_MODEL mures = mures.astype(float) #print mures #if ((idsurv=='15')|(idsurv=='1')|(idsurv=='4')): # xx=(ids==idsurv) #if ((idsurv!='15')&(idsurv!='1')&(idsurv!='4')): # xx=((ids!='15')&(ids!='1')&(ids!='4')) if (idsurv == 99): xx = (np.absolute(mures) > (-1000)) #print xx #print mures[xx] mures = mures[zCMB < cut] #print idsurv, 1.48*np.median(np.absolute(mures[xx])), len(mures[xx]) #return 1.48*np.median(np.absolute(mures[xx])) return np.sqrt(np.mean(np.square(mures)))
rede1 = [] rede2 = [] for num in range(0, len(red2) - 1): red = np.append(red, (red2[num] + red2[num + 1]) / 2.0) rede1 = np.append( rede1, np.absolute((red2[num] + red2[num + 1]) / 2.0 - red2[num])) rede2 = np.append( rede2, np.absolute((red2[num] + red2[num + 1]) / 2.0 - red2[num + 1])) #xerr=[rede1,rede2] print len(rede1) print rede1 print rede2 print red #stop num = linef.linef('../DATA/SALT2mu/SALT2mu_fitoptg0bin.M0DIF', 'VARNAME') z1, mures, murese = np.loadtxt('../DATA/SALT2mu/SALT2mu_fitoptg0bin.M0DIF', usecols=(4, 5, 6), unpack=True, dtype='string', skiprows=num + 1) z1 = z1.astype(float) mures = mures.astype(float) murese = murese.astype(float) muresebin = murese print z1, red #stop red = z1 for x in range(0, 10):
for xl in range(0, 2): singx = sing1 for ii in range(0, 2): betas = 3.1 #print '../SIMS//PS1_GRIDu_sys/DS_smear'+scat[xl]+'_PS1_GRIDs-0'+str(i)+'/FITOPT000.FITRES' if (xl > 0): sing1 = sing2 betas = 3.8 singx = sing2 #a = plt.axes([0.0, -.03, .08, .03]) #simalpha,simbeta,z,simx11,simc1,simmb,mb,x11,c1,simdlmag,pke,fitprob,mbe,x11e,c1e = np.loadtxt(sing1[ii]+'/FITOPT000.FITRES', usecols=(42,43,6,40,41,45,23,19,21,38,18,32,24,20,22), unpack=True, dtype='string', skiprows=12) if (os.path.isfile(singx[ii] + '/FITOPT000.FITRES') == False): os.system('gunzip ' + singx[ii] + '/FITOPT000.FITRES.gz') headn = linef.linef(singx[ii] + '/FITOPT000.FITRES', 'zCMB') data1 = np.genfromtxt(singx[ii] + '/FITOPT000.FITRES', skip_header=headn, names=True, comments='#') cid = np.genfromtxt(singx[ii] + '/FITOPT000.FITRES', skip_header=headn, usecols=(1), comments='#', dtype='str')[1:] z = data1['zCMB'].astype(float) SNRMAX11 = data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float) c1 = data1['c'].astype(float) NDOF1 = data1['NDOF'].astype(float) fitprob = data1['FITPROB'].astype(float)
plotsetup.halfpaperfig() cosmo = FlatLambdaCDM(H0=70, Om0=0.3) gs1 = gridspec.GridSpec(2, 1) gs1.update(hspace=0.04,bottom=0.13,top=0.92) ax2= plt.subplot(gs1[1]) ax1= plt.subplot(gs1[0]) ax=[ax1,ax2] pos=[] for i in range(1,2999): pos.append(i/1000.0) headn=linef.linef('../DATA/SALT2mu/SALT2mu_fitoptg0.fitres','zCMB') data1=np.genfromtxt('../DATA/SALT2mu/SALT2mu_fitoptg0.fitres',skip_header=headn,names=True,comments='#') cid=np.genfromtxt('../DATA/SALT2mu/SALT2mu_fitoptg0.fitres',skip_header=headn,usecols=(1),comments='#',dtype='str')[1:] z1 = data1['zCMB'].astype(float) mu1=data1['MU'].astype(float) mu1e = data1['MUERR'].astype(float) idsurvey=data1['IDSURVEY'].astype(float) x=cosmo.luminosity_distance(pos).value y=5.0*(np.log10(x))+25.0
return [(x[3]), x[5]] def prec(x): return '(' + "%.3f" % float(x[0]) + '\pm' + "%.3f" % float(x[1]) + ')' cosmo = FlatLambdaCDM(H0=70, Om0=0.3) #SALT2mu/SALT2mu_fitoptgb0.fitres # -0.081421771 0.081707301 0.031227249 0.054284053 # -0.081480861 0.076136832 0.025882917 0.045994964 #../DATA/SALT2mu/SALT2mu_fitoptgm0.fitres #list1, idsurvey,z1, mass1,x11,c1,mu1, mu1e = np.loadtxt('../DATA/SALT2mu_fitopt.fitres', usecols=(0,3, 7,13,18,20,37,39), unpack=True, dtype='string', skiprows=12) headn = linef.linef( '../DATA/SALT2mu_SNLS+SDSS+LOWZ+PS1_Scolnic2+HST/DS17/SALT2mu_FITOPT000_MUOPT000.FITRES', 'zCMB') data1 = np.genfromtxt( '../DATA/SALT2mu_SNLS+SDSS+LOWZ+PS1_Scolnic2+HST/DS17/SALT2mu_FITOPT000_MUOPT000.FITRES', skip_header=headn, names=True, comments='#') list1 = np.genfromtxt( '../DATA/SALT2mu_SNLS+SDSS+LOWZ+PS1_Scolnic2+HST/DS17/SALT2mu_FITOPT000_MUOPT000.FITRES', skip_header=headn, usecols=(1), comments='#', dtype='str')[1:] z1 = data1['zCMB'].astype(float) SNRMAX11 = data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float)
gs1.update(bottom=0.5, top=0.95, hspace=0.0) ax1 = plt.subplot(gs1[0]) ax2 = plt.subplot(gs1[1]) gs1 = gridspec.GridSpec(1, 1) gs1.update(bottom=0.1, top=0.36, hspace=0.0) ax3 = plt.subplot(gs1[0]) #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('wc0a.fitres', delimiter=' ', usecols=(0,3, 6,17,19,35,37), unpack=True, dtype='string', skiprows=12) #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('wc0a.fitres', delimiter=' ', usecols=(0,3, 6,16,17,31,33), unpack=True, dtype='string', skiprows=12) #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('wc0a.fitres', usecols=(0,3, 7,17,19,34,35), unpack=True, dtype='string', skiprows=12) #list1, idsurvey,z1, mass1,x11,c1,mu1, mu1e,mures1 = np.loadtxt('../DATA/SALT2mu_fitopt.fitres', usecols=(0,3, 7,13,20,22,37,39,41), unpack=True, dtype='string', skiprows=12) name1 = '../DATA/SALT2mu/SALT2mu_fitoptg0.fitres' name1 = '../DATA/SALT2mu_SNLS+SDSS+LOWZ+PS1_Scolnic2+HST/DS17/SALT2mu_FITOPT000_MUOPT000.FITRES' headn = linef.linef(name1, 'zCMB') header1 = headn data1 = np.genfromtxt(name1, skip_header=header1, names=True, comments='#') cid1 = np.genfromtxt(name1, skip_header=header1, usecols=(1), comments='#', dtype='str')[1:] z1 = data1['zHD'].astype(float) SNRMAX11 = data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float) c1 = data1['c'].astype(float) mb1 = data1['mB'].astype(float) NDOF1 = data1['NDOF'].astype(float) #TGAPMAX2=data1['TGAPMAX'].astype(float) FITPROB1 = data1['FITPROB'].astype(float)
] #names1[1]='/project/rkessler/djones/NN_forDan/empiricalsim/biascor/SIMGEN_LOWZ/SIMGEN_LOWZ/SIMGEN_LOWZ_G10/FITOPT000.FITRES' #/project/rkessler/djones/NN_forDan/empiricalsim/biascor/SIMGEN_LOWZ/SIMGEN_LOWZ/SIMGEN_LOWZ_G10/FITOPT000.FITRES files = [ 'ps1', 'lowz', 'sdss', 'snls', 'hst', 'csp', 'cfa1', 'cfa2', 'cfa3', 'cfa3k', 'cfa41', 'cfa42' ] header1d = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] header1s = [5, 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6] zm1 = [0, 0, 0.05, 0.1, 0.8, 0, 0, 0, 0, 0, 0, 0] zm2 = [0.69, 0.065, 0.49, 0.99, 2.29, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09] zt = [0.2, 0.02, 0.1, 0.3, 0.5, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02] for ii in range(0, 2): print named[0] if (ii != 40): headn = linef.linef(named[0], 'zCMB') print headn #stop data1 = np.genfromtxt(named[0], skip_header=headn, names=True, comments='#') cid = np.genfromtxt(named[0], skip_header=headn, usecols=(1), comments='#', dtype='str')[1:] #if (ii==4): # print 'ok' # data1=np.genfromtxt('/project/rkessler/dscolnic/HST_analysis/CANDELS/CANDELs/FITOPT000.FITRES',skip_header=10,names=True,comments='#') # cid=np.genfromtxt('/project/rkessler/dscolnic/HST_analysis/CANDELS/CANDELs/FITOPT000.FITRES',skip_header=10,usecols=(1),comments='#',dtype='str')[1:]
for i in range(0, 4): if (i == 0): name1 = '../SIMS/PS1_SINGLEu2/DS_smearG10_PS1_GRIDu_single/FITOPT000.FITRES' betas = 3.1 if (i == 1): name1 = '../SIMS/PS1_SINGLEu2/DS_smearC11_PS1_GRIDu_single/FITOPT000.FITRES' betas = 3.8 if (i == 2): name1 = '../SIMS/PS1_SINGLEu2/DS_smearG10_PS1_GRIDu_sysing/FITOPT000.FITRES' betas = 3.1 if (i == 3): name1 = '../SIMS/PS1_SINGLEu2/DS_smearC11_PS1_GRIDu_sysing/FITOPT000.FITRES' betas = 3.8 header1 = 5 header1 = linef.linef(name1, 'zCMB') data1 = np.genfromtxt(name1, skip_header=header1, names=True, comments='#') cid1 = np.genfromtxt(name1, skip_header=header1, usecols=(1), comments='#', dtype='str')[1:] z1 = data1['zCMB'].astype(float) SNRMAX11 = data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float) c1 = data1['c'].astype(float) mb1 = data1['mB'].astype(float) NDOF1 = data1['NDOF'].astype(float) #TGAPMAX2=data1['TGAPMAX'].astype(float) FITPROB1 = data1['FITPROB'].astype(float) PKMJD1 = data1['PKMJD'].astype(float)
from astropy import cosmology as cosmo import wmom import matplotlib import plotsetup from matplotlib import gridspec import matplotlib.ticker as ticker import linef plotsetup.halfpaperfig() #list1, idsurvey,z1, mass1,x11,c1,mu1, mu1e = np.loadtxt('wc0a.fitres', usecols=(0,3, 6,10,17,19,34,35), unpack=True, dtype='string', skiprows=12) #VARNAMES: CID CIDint IDSURVEY TYPE FIELD CUTFLAG_SNANA zCMB zCMBERR zHD zHDERR VPEC VPEC_ERR HOST_LOGMASS HOST_LOGMASS_ERR SNRMAX1 SNRMAX2 SNRMAX3 PKMJD PKMJDERR x1 x1ERR c cERR mB mBERR x0 x0ERR \ # COV_x1_c COV_x1_x0 COV_c_x0 NDOF FITCHI2 FITPROB RA DECL TGAPMAX MU MUMODEL MUERR MUERR_RAW MURES MUPULL ERRCODE biasCor_mu biasCorErr_mu biasCor_mB biasCor_x1 biasCor_c biasScale_muCOV IDSAM#PLE name1 = '../DATA/SALT2mu/SALT2mu_fitoptg0.fitres' header1 = linef.linef(name1, 'zCMB') data1 = np.genfromtxt(name1, skip_header=header1, names=True, comments='#') cid1 = np.genfromtxt(name1, skip_header=header1, usecols=(1), comments='#', dtype='str')[1:] z1 = data1['zCMB'].astype(float) SNRMAX11 = data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float) c1 = data1['c'].astype(float) mb1 = data1['mB'].astype(float) NDOF1 = data1['NDOF'].astype(float) #TGAPMAX2=data1['TGAPMAX'].astype(float) FITPROB1 = data1['FITPROB'].astype(float) PKMJD1 = data1['PKMJD'].astype(float)
import linef from matplotlib import gridspec import matplotlib.ticker as ticker plotsetup.halfpaperfig() xcid, xred, xtype, xfield,xmjd = np.loadtxt('PS1_Noah2.txt', delimiter=' ', usecols=(0, 1,2,3,4), unpack=True, dtype='string', skiprows=2) print 'mjd', xred #stop #xred=xred[0] xmjd = xmjd.astype(int) xred = xred.astype(float) print 'xr', xred #stop #list1, idsurvey, z1,x11,c1,mb1,mu1, mu1e = np.loadtxt('PS1_Scolnic/NewDan100f/FITOPT000+SALT2mu.FITRES', usecols=(1, 2,6,17,19,21,36,37), unpack=True, dtype='string', skiprows=15) headn=linef.linef("../DATA/sntable_dump_SNANA.fitres",'z') data1=np.genfromtxt("../DATA/sntable_dump_SNANA.fitres",skip_header=headn,names=True,comments='#') cid=np.genfromtxt("../DATA/sntable_dump_SNANA.fitres",skip_header=headn,usecols=(1),comments='#',dtype='str')[1:] z1 = data1['z'].astype(float) #SNRMAX11=data1['SNRMAX1'].astype(float) #x11 = data1['x1'].astype(float) #c1 = data1['c'].astype(float) #NDOF1=data1['NDOF'].astype(float) #TGAPMAX1=data1['TGAPMAX'].astype(float) #FITPROB=data1['FITPROB'].astype(float) PKMJD=data1['PKMJDINI'].astype(float) RA=data1['RA'].astype(float) DECL=data1['DECL'].astype(float) idsurvey=data1['IDSURVEY'].astype(float) headn=linef.linef("../DATA/SALT2mu/SALT2mu_fitoptg0.fitres",'zCMB') data1=np.genfromtxt("../DATA/SALT2mu/SALT2mu_fitoptg0.fitres",skip_header=headn,names=True,comments='#')
#if (num<0): return r"$\bar{\mathrm{c}}=\textrm{--}$"+"{:10.2f}".format(np.absolute(num)) if (num<0): return r"$\bar{\mathrm{c}}=\textrm{--}$"+"{:10.2f}".format(np.absolute(num)) def fformx(num): if (num>0): return r"$\bar{\mathrm{x_1}}=$"+"{:10.2f}".format(num) if (num<0): return r"$\bar{\mathrm{x_1}}=\textrm{--}$"+"{:10.2f}".format(np.absolute(num)) #candels_hubble_62a.fitres #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('candels_hubble_0a.fitres', delimiter=' ', usecols=(0, 2,5,16,18,31,33), unpack=True, dtype='string', skiprows=2) #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('candels_hubble_0a.fitres', delimiter=' ', usecols=(0,3, 6,17,19,35,37), unpack=True, dtype='string', skiprows=2) #list1, idsurvey, z1,x11,c1,mu1, mu1e = np.loadtxt('wc0a.fitres', delimiter=' ', usecols=(0,3, 6,17,19,31,33), unpack=True, dtype='string', skiprows=12) list1, idsurvey, z1,mass,x11,c1,mb1,mu1, mu1e,mures = np.loadtxt('../DATA/SALT2mu/SALT2mu_fitoptg0.fitres', usecols=(1,3, 7,13,20,22,24,37,39,41), unpack=True, dtype='string', skiprows=15) name1='../DATA/SALT2mu/SALT2mu_fitoptg0.fitres' header1=linef.linef('../DATA/SALT2mu/SALT2mu_fitoptg0.fitres','zCMB') data1=np.genfromtxt(name1,skip_header=header1,names=True,comments='#') cid1=np.genfromtxt(name1,skip_header=header1,usecols=(1),comments='#',dtype='str')[1:] z1 = data1['zCMB'].astype(float) SNRMAX11=data1['SNRMAX1'].astype(float) x11 = data1['x1'].astype(float) c1 = data1['c'].astype(float) mb1= data1['mB'].astype(float) NDOF1=data1['NDOF'].astype(float) #TGAPMAX2=data1['TGAPMAX'].astype(float) FITPROB1=data1['FITPROB'].astype(float) PKMJD1=data1['PKMJD'].astype(float) #RA2=data1['RA'].astype(float) #DEC2=data1['DECL'].astype(float) idsurvey1=data1['IDSURVEY'].astype(float) NDOF1=data1['NDOF'].astype(float)
import plotsetup from matplotlib import gridspec import matplotlib.ticker as ticker plotsetup.halfpaperfig() #malmquist_tree12z.txt #Restetal.fitres #SALT2mu_PS1.M0DIF #SALT2mu_PS1_conv.M0DIF #SALT2mu_Rest_pre.M0DIF #SALT2mu/SALT2mu_fitoptgs_ps1 #SALT2mu/SALT2mu_fitoptgos_ps1 headn = linef.linef('../DATA/SALT2mu/SALT2mu_fitoptgos_ps1.M0DIF', 'VARN') z1, muerr1, mures1 = np.loadtxt('../DATA/SALT2mu/SALT2mu_fitoptgos2_ps1.M0DIF', usecols=(4, 6, 5), unpack=True, dtype='string', skiprows=headn + 1) z1b, muerr1b, mures1b = np.loadtxt( '../DATA/SALT2mu/SALT2mu_fitoptgs2_ps1.M0DIF', usecols=(4, 6, 5), unpack=True, dtype='string', skiprows=headn + 1) headn = linef.linef('SALT2mu/SALT2mu_Rest_pre.M0DIF', 'VARN') z2, muerr2, mures2 = np.loadtxt('SALT2mu/SALT2mu_Rest_pre.M0DIF', usecols=(2, 4, 3),
z=[] err=[] err2=[] cntr=[] offset=[] offsetp=[] cntrlines=open('allcntr.dat','r').readlines() for x in cntrlines: cntr=np.append(cntr,x[68:74]) offset=np.append(offset,float(x[131:137])) file1='../DATA/DS17_PS1_Scolnic2/PS1_Spec_DS17/FITOPT000.FITRES' if (os.path.isfile(file1)==False): os.system('gunzip '+file1+'.gz') #name1,z1,SNRMAX11,x11,c1 ,NDOF1 ,TGAPMAX1 = np.loadtxt('../DATA/DS16_PS1_Scolnic2/NewDan101f_DS16/FITOPT000.FITRES', usecols=(1,7,12,17,19,28,33), unpack=True, dtype='string', skiprows=16) import linef headn=linef.linef(file1,'zCMB') data1=np.genfromtxt(file1,skip_header=headn,names=True,comments='#') name1=np.genfromtxt(file1,skip_header=headn,usecols=(1),comments='#',dtype='str')[1:] z1 = data1['zCMB'].astype(float) z=[] err2=[] print 'cntr', cntr for i in range(0,len(name1)): xxc=(name1[i]==cntr) print 'xxc', xxc if (len(cntr[xxc])>0): z=np.append(z,float(z1[i])) offsetp=np.append(offsetp,float(offset[xxc][0])) print 'z', len(z)