예제 #1
0
파일: CatPrep.py 프로젝트: nkern/C4
def select_func(params):
	''' Takes cluster catalogue and makes cleaning selection cuts based on redshift, N200, Nspec, cluster pairs etc. '''

	print '...beginning clean selection cuts'	

	# Load Halo Catalgoue
	halos = fits.open(data_loc+'/halos.fits')[1].data

	if params['data_loc'][-2:] == 'TH':		# TRUTH
		cut = np.where(	
				(halos['Z_BCG']>0.03)&
				(halos['Z_BCG']<0.12)&
				(halos['n10virm19']>5)
			)[0]

	if params['data_loc'][-2:] == 'IC':		# TRUTH_CAUSTIC
		cut = np.where(	
				(halos['miller_N200']>5)&
				(np.isnan(halos['miller_N200'])==False)&
				(halos['Z_AVG']>0.03)&
				(halos['Z_AVG']<0.12)&
				(halos['Nspec']>5)&
				(halos['pair_avg']!=True)&
				(halos['cata_fail']!=True)
			)[0]

	elif params['data_loc'][-2:] == 'C4':		# TRUTH_CAUSTIC_C4
		cut = np.where(	
				(halos['miller_N200']>5)&
				(np.isnan(halos['miller_N200'])==False)&
				(halos['Z_AVG']>0.03)&
				(halos['Z_AVG']<0.12)&
				(halos['Nspec']>5)&
				(halos['pair_avg']!=True)&
				(halos['cata_fail']!=True)
			)[0]

	elif params['data_loc'][-2:] == '12':		# DR12
		cut = np.where(	
				(halos['miller_N200']>=5)&
				(np.isnan(halos['miller_N200'])==False)&
				(halos['Z_AVG']>0.03)&
				(halos['Z_AVG']<0.12)&
				(halos['Nspec']>5)&
				(halos['pair_avg']!=True)&
				(halos['cata_fail']!=True)
			)[0]

	print '...size before cuts = '+str(len(halos))+', size after = '+str(len(cut))
	
	new_halos = halos[cut]
	keys = new_halos.names
	dic = dict(map(lambda x: (x,new_halos[x]),keys))
	fits_table(dic,keys,data_loc+'/cut_halos.fits',clobber=True)
예제 #2
0
def select_func(params):
    ''' Takes cluster catalogue and makes cleaning selection cuts based on redshift, N200, Nspec, cluster pairs etc. '''

    print '...beginning clean selection cuts'

    # Load Halo Catalgoue
    halos = fits.open(data_loc + '/halos.fits')[1].data

    if params['data_loc'][-2:] == 'TH':  # TRUTH
        cut = np.where((halos['Z_BCG'] > 0.03) & (halos['Z_BCG'] < 0.12)
                       & (halos['n10virm19'] > 5))[0]

    if params['data_loc'][-2:] == 'IC':  # TRUTH_CAUSTIC
        cut = np.where((halos['miller_N200'] > 5)
                       & (np.isnan(halos['miller_N200']) == False)
                       & (halos['Z_AVG'] > 0.03) & (halos['Z_AVG'] < 0.12)
                       & (halos['Nspec'] > 5) & (halos['pair_avg'] != True)
                       & (halos['cata_fail'] != True))[0]

    elif params['data_loc'][-2:] == 'C4':  # TRUTH_CAUSTIC_C4
        cut = np.where((halos['miller_N200'] > 5)
                       & (np.isnan(halos['miller_N200']) == False)
                       & (halos['Z_AVG'] > 0.03) & (halos['Z_AVG'] < 0.12)
                       & (halos['Nspec'] > 5) & (halos['pair_avg'] != True)
                       & (halos['cata_fail'] != True))[0]

    elif params['data_loc'][-2:] == '12':  # DR12
        cut = np.where((halos['miller_N200'] >= 5)
                       & (np.isnan(halos['miller_N200']) == False)
                       & (halos['Z_AVG'] > 0.03) & (halos['Z_AVG'] < 0.12)
                       & (halos['Nspec'] > 5) & (halos['pair_avg'] != True)
                       & (halos['cata_fail'] != True))[0]

    print '...size before cuts = ' + str(len(halos)) + ', size after = ' + str(
        len(cut))

    new_halos = halos[cut]
    keys = new_halos.names
    dic = dict(map(lambda x: (x, new_halos[x]), keys))
    fits_table(dic, keys, data_loc + '/cut_halos.fits', clobber=True)
예제 #3
0
파일: CatPrep.py 프로젝트: nkern/C4
def cluster_rich(data_loc,halo_file,chris_data_root,chris_data_file,newfilename,write_data=True,clobber=True):
	""" Calculate a Cluster's richness via Miller N200 and Kern N200
		data_loc : e.g. MassRich/TRUTH_CAUSTIC
		halo_file : e.g. halos.fits
		chris_data_root : e.g. /nfs/christoq_ls/C4/sdssdr12
		chris_data_file : e.g. DR12_GalaxyPhotoData_wabs_wedges.fits or m19.1_allgals_wsdss_specerrs_abs.fits
 """

	# Run through Kern richness estimator, mainly to get cluster pairs

        root = '/nfs/christoq_ls/nkern'

        C4 = CFOUR({'H0':70,'chris_data_root':chris_data_root})
	C = Caustic()
	H0 = 70.0
	c = 2.99792e5
	Cosmo = cosmo.LambdaCDM(H0,0.3,0.7)
	keys = ['C','H0','c','Cosmo','C4']
	varib = ez.create(keys,locals())
	R = RICHNESS(varib)

        # Load Halos
        halos = fits.open(data_loc+'/'+halo_file)[1].data
        HaloID = halos['orig_order']
        RA = halos['ra_avg']
        DEC = halos['dec_avg']
        Z = halos['z_avg']
        RVIR = halos['RVIR']

	# Load Galaxy Data
	gals = fits.open(chris_data_root+'/'+chris_data_file)[1].data
	# Change gals keys according to SDSSDR12 galaxy file
	if data_loc[-4:] != 'DR12':
		gals = dict(map(lambda x: (x,gals[x]),gals.names))
		gals['objid'] = gals.pop('GAL_HALOID')
		gals['ra'] = gals.pop('GAL_RA')
		gals['dec'] = gals.pop('GAL_DEC')
		gals['z'] = gals.pop('GAL_Z_APP')
		gals['u_mag'] = gals.pop('GAL_SDSS_U')
		gals['g_mag'] = gals.pop('GAL_SDSS_G')
		gals['r_mag'] = gals.pop('GAL_SDSS_R')
		gals['i_mag'] = gals.pop('GAL_SDSS_I')
		gals['z_mag'] = gals.pop('GAL_SDSS_Z')
		gals['r_absmag'] = gals.pop('R_ABSMAG')

	# Derive Gal Cut Out Parameters
	arcs = np.array(Cosmo.arcsec_per_kpc_proper(Z))*15000. / 3600.    # 15 Mpc in degrees

	# Kern richness arrays
	kern_N200 = []
	HVD = []
	pair_avg = []
	Nspec = []
	kern_obs_tot = []
	kern_obs_back = []		# obs_back is number of non-member galaxies in central aperture around cluster (aka. already scaled to inner aperture)

	# Miller Richness Arrays
	new = fits.open(chris_data_root+'/richness_cr200_bcg/new.fits')[0].data
	newb = fits.open(chris_data_root+'/richness_cr200_bcg/newb.fits')[0].data
	newb *= 0.2
	miller_N200 = []
	miller_obs_tot = []
	miller_obs_back = []
	colfac = 9
	bakfac = 1
	mag3 = 4
	v = 2
	radfac = 1

	# Loop over clusters
	print ''
	print '-'*40
	print '...calculating cluster richnesses'
	for i in range(len(HaloID)):

		if i % 100 == 0: print '...working on cluster '+str(i)+' out of '+str(len(HaloID))
		# Define Cluster parameters
		clus_ra = RA[i]
		clus_dec = DEC[i]
		clus_z = Z[i]
		clus_rvir = RVIR[i]
		haloid = HaloID[i]

		if np.isnan(clus_ra) == True or np.isnan(clus_dec) == True or np.isnan(clus_z) == True:
			richness.append(0)
			HVD.append(0)
			pair_avg.append(False)
			Nspec.append(0)
			continue

		# 15 Mpc in degrees of declination and degrees of RA
		d_dec = arcs[i]
		d_ra = d_dec/np.cos(clus_dec*np.pi/180)
		d_z = 0.04

		# Cut Out Galaxy Data Around Cluster
		cut = np.where( (np.abs(gals['ra']-clus_ra)<d_ra) & (np.abs(gals['dec']-clus_dec)<d_dec) & (np.abs(gals['z']-clus_z) < d_z))[0]
		gal_ra = gals['ra'][cut];gal_dec = gals['dec'][cut];gal_z=gals['z'][cut];gal_gmags=gals['g_mag'][cut];gal_rmags=gals['r_mag'][cut];gal_imags=gals['i_mag'][cut];gal_absr=gals['r_absmag'][cut]

		# Run Kern Richness Estimator
		rich = R.richness_est(gal_ra,gal_dec,gal_z,np.zeros(len(gal_z)),gal_gmags,gal_rmags,gal_imags,gal_absr,haloid,clus_ra,clus_dec,clus_z,clus_rvir=clus_rvir,spec_list=None,use_specs=False,use_bcg=False,fit_rs=False,fixed_vdisp=False,fixed_aperture=False,plot_sky=False,plot_gr=False,plot_phase=False,find_pairs=True)

		kern_N200.append(rich)
		HVD.append(R.vel_disp)
		pair_avg.append(R.pair)
		Nspec.append(R.Nspec)
		kern_obs_tot.append(R.obs_tot)
		kern_obs_back.append(R.obs_back_scaled)

		# Append Miller Richness Values
		k = halos['orig_order'][i]
		miller_N200.append(new[k,colfac,mag3,v,radfac] - newb[k,bakfac,mag3,v,radfac])
		miller_obs_tot.append(new[k,colfac,mag3,v,radfac])
		miller_obs_back.append(newb[k,bakfac,mag3,v,radfac])


	kern_N200 = np.array(kern_N200)
	HVD = np.array(HVD)
	pair_avg = np.array(pair_avg)
	Nspec = np.array(Nspec)
	kern_obs_tot = np.array(kern_obs_tot)
	kern_obs_back = np.array(kern_obs_back)

	miller_N200 = np.array(miller_N200)
	miller_obs_tot = np.array(miller_obs_tot)
	miller_obs_back = np.array(miller_obs_back)

	print '...finished calculating richnesses'
	## Write Data Out
	if write_data == True:
		print '...writing out halos.fits file'

		# Dictionary of new columns
		new_keys = ['kern_N200','HVD','pair_avg','Nspec','kern_obs_tot','kern_obs_back','miller_N200','miller_obs_tot','miller_obs_back']
		new_dic = ez.create(new_keys,locals())

		# Original fits record file
		orig_table = halos

		# Write out own fits file
		keys = ['HaloID','RVIR'] + new_keys
		dic = ez.create(keys,locals())
		fits_table(dic,keys,data_loc+'/richnesses.fits',clobber=True)

		# Append new columns
		fits_append(orig_table,new_dic,new_keys,filename=data_loc+'/'+newfilename,clobber=clobber)
		print '-'*40
		print ''
예제 #4
0
파일: CatPrep.py 프로젝트: nkern/C4
def clus_avg(data_loc,halo_file,chris_data_root,newfilename,write_data=True,clobber=True):

	C4 = CFOUR({'H0':70,'chris_data_root':chris_data_root})
	C = Caustic()

	# Load Halos
        halos = fits.open(data_loc+'/'+halo_file)[1].data
        HaloID = halos['orig_order']
        RA = halos['ra_bcg']
        DEC = halos['dec_bcg']
        Z = halos['z_biwt']
        RVIR = halos['RVIR']
        SINGLE = halos['single']
        SUB = halos['sub']
        NC4 = halos['nc4']

	RA_AVG,DEC_AVG,Z_AVG = [],[],[]

	# Loop Over Halos
	print ''
	print '-'*40
	print '...running average cluster center code'
	for i in range(len(halos)):
		if i % 100 == 0: print '...working on cluster '+str(i)+' out of '+str(len(halos))
		try:
			# Assign Halo Properties
			clus_ra = RA[i]
			clus_dec = DEC[i]
			clus_z = Z[i]

			# Load Galaxies
			galdata = C4.load_chris_gals(HaloID[i])
			gal_ra,gal_dec,gal_z,gal_gmags,gal_rmags,gal_imags = galdata

			# Take Iterative Average, four times
			# vlim = 1500, rlim = 1.5
			clus_ra,clus_dec,clus_z = proj_avg(clus_ra,clus_dec,clus_z,gal_ra,gal_dec,gal_z,1500,1.5,C)
			# vlim = 1000, rlim = 1.5
			clus_ra,clus_dec,clus_z = proj_avg(clus_ra,clus_dec,clus_z,gal_ra,gal_dec,gal_z,1000,1.5,C)
			# vlim = 1500, rlim = 1.5
			clus_ra,clus_dec,clus_z = proj_avg(clus_ra,clus_dec,clus_z,gal_ra,gal_dec,gal_z,1000,1.5,C)
			# vlim = 2000, rlim = 1.5
			clus_ra,clus_dec,clus_z = proj_avg(clus_ra,clus_dec,clus_z,gal_ra,gal_dec,gal_z,2000,1.5,C)

		except:
			print i
			clus_ra,clus_dec,clus_z = 0, 0, 0

		RA_AVG.append(clus_ra)
		DEC_AVG.append(clus_dec)
		Z_AVG.append(clus_z)

	RA_AVG,DEC_AVG,Z_AVG = np.array(RA_AVG),np.array(DEC_AVG),np.array(Z_AVG)

	print '...finished average cluster-center calculations'

	## Write Data Out
	if write_data == True:
		print '...writing out cluster catalgoue with average centers included'
		# Dictionary of new columns
		new_keys = ['RA_AVG','DEC_AVG','Z_AVG']
		new_dic = ez.create(new_keys,locals())

		# Original fits record file
		orig_table = halos

		# Write own fits file
		keys = ['HaloID','RA','DEC','Z','RVIR','RA_AVG','DEC_AVG','Z_AVG']
		dic = ez.create(keys,locals())
		fits_table(dic,keys,data_loc+'/avg_centers.fits',clobber=True)

		# Append new columns
		fits_append(orig_table,new_dic,new_keys,filename=data_loc+'/'+newfilename,clobber=clobber)
		print '-'*40
		print ''
예제 #5
0
파일: CatPrep.py 프로젝트: nkern/C4
## Truth Table (M-R for Henriques using 3D members and True Mass) ##
if panel1 == True:
	# Constants
	chris_data_root = '/nfs/christoq_ls/MILLENNIUM/Henriques/TRUTH'
	data_loc = 'MassRich/TRUTH'

	# Load Data
	truth = fits.open(chris_data_root+'/c4_cluster_truth_revH100_rev5.fits')[1].data
	truth['m200mean']*=1e10
	truth['m200crit']*=1e10

	# Write out halos.fits file
	if init_cats == True:
		keys = truth.names
		dic = dict(map(lambda x: (x,truth[x]),keys))
		fits_table(dic,keys,data_loc+'/truth.fits',clobber=True)

	params = {'data_loc':data_loc}
	
	## Perform clean selection function cuts ##
	if sel_func == True:
		select_func(params)
	
	Rich = truth['n10virm19']
	Mass = truth['m200crit']

	rich_low,rich_high,rich_step = 3.3,4.8,0.3
	richbins = np.arange(rich_low,rich_high,rich_step)
	mass_low,mass_high,mass_step = 14.25,15.15,0.2
	massbins = np.arange(mass_low,mass_high,mass_step)
예제 #6
0
def cluster_rich(data_loc,
                 halo_file,
                 chris_data_root,
                 chris_data_file,
                 newfilename,
                 write_data=True,
                 clobber=True):
    """ Calculate a Cluster's richness via Miller N200 and Kern N200
		data_loc : e.g. MassRich/TRUTH_CAUSTIC
		halo_file : e.g. halos.fits
		chris_data_root : e.g. /nfs/christoq_ls/C4/sdssdr12
		chris_data_file : e.g. DR12_GalaxyPhotoData_wabs_wedges.fits or m19.1_allgals_wsdss_specerrs_abs.fits
 """

    # Run through Kern richness estimator, mainly to get cluster pairs

    root = '/nfs/christoq_ls/nkern'

    C4 = CFOUR({'H0': 70, 'chris_data_root': chris_data_root})
    C = Caustic()
    H0 = 70.0
    c = 2.99792e5
    Cosmo = cosmo.LambdaCDM(H0, 0.3, 0.7)
    keys = ['C', 'H0', 'c', 'Cosmo', 'C4']
    varib = ez.create(keys, locals())
    R = RICHNESS(varib)

    # Load Halos
    halos = fits.open(data_loc + '/' + halo_file)[1].data
    HaloID = halos['orig_order']
    RA = halos['ra_avg']
    DEC = halos['dec_avg']
    Z = halos['z_avg']
    RVIR = halos['RVIR']

    # Load Galaxy Data
    gals = fits.open(chris_data_root + '/' + chris_data_file)[1].data
    # Change gals keys according to SDSSDR12 galaxy file
    if data_loc[-4:] != 'DR12':
        gals = dict(map(lambda x: (x, gals[x]), gals.names))
        gals['objid'] = gals.pop('GAL_HALOID')
        gals['ra'] = gals.pop('GAL_RA')
        gals['dec'] = gals.pop('GAL_DEC')
        gals['z'] = gals.pop('GAL_Z_APP')
        gals['u_mag'] = gals.pop('GAL_SDSS_U')
        gals['g_mag'] = gals.pop('GAL_SDSS_G')
        gals['r_mag'] = gals.pop('GAL_SDSS_R')
        gals['i_mag'] = gals.pop('GAL_SDSS_I')
        gals['z_mag'] = gals.pop('GAL_SDSS_Z')
        gals['r_absmag'] = gals.pop('R_ABSMAG')

    # Derive Gal Cut Out Parameters
    arcs = np.array(
        Cosmo.arcsec_per_kpc_proper(Z)) * 15000. / 3600.  # 15 Mpc in degrees

    # Kern richness arrays
    kern_N200 = []
    HVD = []
    pair_avg = []
    Nspec = []
    kern_obs_tot = []
    kern_obs_back = [
    ]  # obs_back is number of non-member galaxies in central aperture around cluster (aka. already scaled to inner aperture)

    # Miller Richness Arrays
    new = fits.open(chris_data_root + '/richness_cr200_bcg/new.fits')[0].data
    newb = fits.open(chris_data_root + '/richness_cr200_bcg/newb.fits')[0].data
    newb *= 0.2
    miller_N200 = []
    miller_obs_tot = []
    miller_obs_back = []
    colfac = 9
    bakfac = 1
    mag3 = 4
    v = 2
    radfac = 1

    # Loop over clusters
    print ''
    print '-' * 40
    print '...calculating cluster richnesses'
    for i in range(len(HaloID)):

        if i % 100 == 0:
            print '...working on cluster ' + str(i) + ' out of ' + str(
                len(HaloID))
        # Define Cluster parameters
        clus_ra = RA[i]
        clus_dec = DEC[i]
        clus_z = Z[i]
        clus_rvir = RVIR[i]
        haloid = HaloID[i]

        if np.isnan(clus_ra) == True or np.isnan(clus_dec) == True or np.isnan(
                clus_z) == True:
            richness.append(0)
            HVD.append(0)
            pair_avg.append(False)
            Nspec.append(0)
            continue

        # 15 Mpc in degrees of declination and degrees of RA
        d_dec = arcs[i]
        d_ra = d_dec / np.cos(clus_dec * np.pi / 180)
        d_z = 0.04

        # Cut Out Galaxy Data Around Cluster
        cut = np.where((np.abs(gals['ra'] - clus_ra) < d_ra)
                       & (np.abs(gals['dec'] - clus_dec) < d_dec)
                       & (np.abs(gals['z'] - clus_z) < d_z))[0]
        gal_ra = gals['ra'][cut]
        gal_dec = gals['dec'][cut]
        gal_z = gals['z'][cut]
        gal_gmags = gals['g_mag'][cut]
        gal_rmags = gals['r_mag'][cut]
        gal_imags = gals['i_mag'][cut]
        gal_absr = gals['r_absmag'][cut]

        # Run Kern Richness Estimator
        rich = R.richness_est(gal_ra,
                              gal_dec,
                              gal_z,
                              np.zeros(len(gal_z)),
                              gal_gmags,
                              gal_rmags,
                              gal_imags,
                              gal_absr,
                              haloid,
                              clus_ra,
                              clus_dec,
                              clus_z,
                              clus_rvir=clus_rvir,
                              spec_list=None,
                              use_specs=False,
                              use_bcg=False,
                              fit_rs=False,
                              fixed_vdisp=False,
                              fixed_aperture=False,
                              plot_sky=False,
                              plot_gr=False,
                              plot_phase=False,
                              find_pairs=True)

        kern_N200.append(rich)
        HVD.append(R.vel_disp)
        pair_avg.append(R.pair)
        Nspec.append(R.Nspec)
        kern_obs_tot.append(R.obs_tot)
        kern_obs_back.append(R.obs_back_scaled)

        # Append Miller Richness Values
        k = halos['orig_order'][i]
        miller_N200.append(new[k, colfac, mag3, v, radfac] -
                           newb[k, bakfac, mag3, v, radfac])
        miller_obs_tot.append(new[k, colfac, mag3, v, radfac])
        miller_obs_back.append(newb[k, bakfac, mag3, v, radfac])

    kern_N200 = np.array(kern_N200)
    HVD = np.array(HVD)
    pair_avg = np.array(pair_avg)
    Nspec = np.array(Nspec)
    kern_obs_tot = np.array(kern_obs_tot)
    kern_obs_back = np.array(kern_obs_back)

    miller_N200 = np.array(miller_N200)
    miller_obs_tot = np.array(miller_obs_tot)
    miller_obs_back = np.array(miller_obs_back)

    print '...finished calculating richnesses'
    ## Write Data Out
    if write_data == True:
        print '...writing out halos.fits file'

        # Dictionary of new columns
        new_keys = [
            'kern_N200', 'HVD', 'pair_avg', 'Nspec', 'kern_obs_tot',
            'kern_obs_back', 'miller_N200', 'miller_obs_tot', 'miller_obs_back'
        ]
        new_dic = ez.create(new_keys, locals())

        # Original fits record file
        orig_table = halos

        # Write out own fits file
        keys = ['HaloID', 'RVIR'] + new_keys
        dic = ez.create(keys, locals())
        fits_table(dic, keys, data_loc + '/richnesses.fits', clobber=True)

        # Append new columns
        fits_append(orig_table,
                    new_dic,
                    new_keys,
                    filename=data_loc + '/' + newfilename,
                    clobber=clobber)
        print '-' * 40
        print ''
예제 #7
0
def clus_avg(data_loc,
             halo_file,
             chris_data_root,
             newfilename,
             write_data=True,
             clobber=True):

    C4 = CFOUR({'H0': 70, 'chris_data_root': chris_data_root})
    C = Caustic()

    # Load Halos
    halos = fits.open(data_loc + '/' + halo_file)[1].data
    HaloID = halos['orig_order']
    RA = halos['ra_bcg']
    DEC = halos['dec_bcg']
    Z = halos['z_biwt']
    RVIR = halos['RVIR']
    SINGLE = halos['single']
    SUB = halos['sub']
    NC4 = halos['nc4']

    RA_AVG, DEC_AVG, Z_AVG = [], [], []

    # Loop Over Halos
    print ''
    print '-' * 40
    print '...running average cluster center code'
    for i in range(len(halos)):
        if i % 100 == 0:
            print '...working on cluster ' + str(i) + ' out of ' + str(
                len(halos))
        try:
            # Assign Halo Properties
            clus_ra = RA[i]
            clus_dec = DEC[i]
            clus_z = Z[i]

            # Load Galaxies
            galdata = C4.load_chris_gals(HaloID[i])
            gal_ra, gal_dec, gal_z, gal_gmags, gal_rmags, gal_imags = galdata

            # Take Iterative Average, four times
            # vlim = 1500, rlim = 1.5
            clus_ra, clus_dec, clus_z = proj_avg(clus_ra, clus_dec, clus_z,
                                                 gal_ra, gal_dec, gal_z, 1500,
                                                 1.5, C)
            # vlim = 1000, rlim = 1.5
            clus_ra, clus_dec, clus_z = proj_avg(clus_ra, clus_dec, clus_z,
                                                 gal_ra, gal_dec, gal_z, 1000,
                                                 1.5, C)
            # vlim = 1500, rlim = 1.5
            clus_ra, clus_dec, clus_z = proj_avg(clus_ra, clus_dec, clus_z,
                                                 gal_ra, gal_dec, gal_z, 1000,
                                                 1.5, C)
            # vlim = 2000, rlim = 1.5
            clus_ra, clus_dec, clus_z = proj_avg(clus_ra, clus_dec, clus_z,
                                                 gal_ra, gal_dec, gal_z, 2000,
                                                 1.5, C)

        except:
            print i
            clus_ra, clus_dec, clus_z = 0, 0, 0

        RA_AVG.append(clus_ra)
        DEC_AVG.append(clus_dec)
        Z_AVG.append(clus_z)

    RA_AVG, DEC_AVG, Z_AVG = np.array(RA_AVG), np.array(DEC_AVG), np.array(
        Z_AVG)

    print '...finished average cluster-center calculations'

    ## Write Data Out
    if write_data == True:
        print '...writing out cluster catalgoue with average centers included'
        # Dictionary of new columns
        new_keys = ['RA_AVG', 'DEC_AVG', 'Z_AVG']
        new_dic = ez.create(new_keys, locals())

        # Original fits record file
        orig_table = halos

        # Write own fits file
        keys = [
            'HaloID', 'RA', 'DEC', 'Z', 'RVIR', 'RA_AVG', 'DEC_AVG', 'Z_AVG'
        ]
        dic = ez.create(keys, locals())
        fits_table(dic, keys, data_loc + '/avg_centers.fits', clobber=True)

        # Append new columns
        fits_append(orig_table,
                    new_dic,
                    new_keys,
                    filename=data_loc + '/' + newfilename,
                    clobber=clobber)
        print '-' * 40
        print ''
예제 #8
0
if panel1 == True:
    # Constants
    chris_data_root = '/nfs/christoq_ls/MILLENNIUM/Henriques/TRUTH'
    data_loc = 'MassRich/TRUTH'

    # Load Data
    truth = fits.open(chris_data_root +
                      '/c4_cluster_truth_revH100_rev5.fits')[1].data
    truth['m200mean'] *= 1e10
    truth['m200crit'] *= 1e10

    # Write out halos.fits file
    if init_cats == True:
        keys = truth.names
        dic = dict(map(lambda x: (x, truth[x]), keys))
        fits_table(dic, keys, data_loc + '/truth.fits', clobber=True)

    params = {'data_loc': data_loc}

    ## Perform clean selection function cuts ##
    if sel_func == True:
        select_func(params)

    Rich = truth['n10virm19']
    Mass = truth['m200crit']

    rich_low, rich_high, rich_step = 3.3, 4.8, 0.3
    richbins = np.arange(rich_low, rich_high, rich_step)
    mass_low, mass_high, mass_step = 14.25, 15.15, 0.2
    massbins = np.arange(mass_low, mass_high, mass_step)