DC2_cat_name = 'cosmoDC2_v1.1.4_small' #richness and mass cuts #min_halo_mass = 5.0e13 #Msun min_halo_mass = 1.0e12 #gc and gc_truth: catalog objects / others are just tables truth_data, gc_truth = DC2_cat_open(DC2_cat_name, min_halo_mass, cluster_only=True) #halo table halo_data = truth_data[truth_data['is_central']==True] print("Number of elements in the truth catalog = ", len(truth_data)) print("Number of halos in the truth catalog = ", len(halo_data)) print("Truth catalog sky area = ", gc_truth.sky_area, "deg2") from clevar.catalog import ClCatalog from clevar.match import ProximityMatch c1 = ClCatalog('Cat1', ra=wazp_data['ra'], dec=wazp_data['dec'], z=wazp_data['redshift']) c2 = ClCatalog('Cat2', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass=halo_data['halo_mass']) #test #c2 = ClCatalog('Cat2', id=input2['ID'], ra=input2['RA'], dec=input2['DEC'], z=input2['Z'], mass=input2['MASS']) #print(c1) #print(c2) from clevar.match import ProximityMatch mt = ProximityMatch() from clevar.cosmology import AstroPyCosmology mt_config1 = {'delta_z':.05, 'match_radius': '1 mpc', 'cosmo':AstroPyCosmology()} mt_config2 = {'delta_z':.05, 'match_radius': '1 mpc',
print("Number of WaZP clusters cat_2 = ", len(wazp_data_2)) print("Number of WaZP cluster members cat_2 = ", len(wazp_members_data_2)) print("Number of WaZP clusters cat_3 = ", len(wazp_data_3)) print("Number of WaZP cluster members cat_3 = ", len(wazp_members_data_3)) #print("Number of Redmapper clusters = ", len(cluster_data)) #print("Number of Redmapper cluster members = ", len(member_data)) #print("Number of halos in the truth catalog = ", len(halo_data)) #print("Number of elements in the truth catalog = ", len(truth_data)) sys.exit() from clevar.catalog import ClCatalog from clevar.match import ProximityMatch c1 = ClCatalog('i_band', ra=wazp_data_1['ra'], dec=wazp_data_1['dec'], z=wazp_data_1['redshift'], mass=wazp_data_1['NGALS']) c2 = ClCatalog('z_band', ra=wazp_data_2['ra'], dec=wazp_data_2['dec'], z=wazp_data_2['redshift'], mass=wazp_data_2['NGALS']) c3 = ClCatalog('DR3', ra=wazp_data_3['ra'], dec=wazp_data_3['dec'], z=wazp_data_3['redshift'], mass=wazp_data_3['NGALS']) #c3 = ClCatalog('RM', ra=cluster_data['ra'], dec=cluster_data['dec'], z=cluster_data['redshift'], mass = cluster_data['richness']) #c4 = ClCatalog('Halos', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass = halo_data['halo_mass'])
# filters=['is_central==False', 'halo_mass > 10**13'])) # + ']')halo_mass > ' + str(min_halo_mass) '+']))# 'halo_id==127200143167'])) #print("Number of elements in the truth catalog = ", len(galaxy_data_all)) print("Number of halos in the truth catalog = ", len(halo_data)) #print("Truth catalog sky area = ", gc_truth.sky_area, "deg2") #print(halo_data) #print(galaxy_data_all) #matching from clevar.catalog import ClCatalog #c1 = ClCatalog('Cat1', ra=wazp_data['ra'], dec=wazp_data['dec'], z=wazp_data['redshift'], mass = wazp_data['NGALS'], id=wazp_data['ID']) #c1 = c1_raw[c1_raw.data['z']<0.7] c1 = ClCatalog('Cat1', ra=cluster_data['ra'], dec=cluster_data['dec'], z=cluster_data['redshift'], mass=cluster_data['richness'], id=cluster_data['cluster_id']) #c2 = ClCatalog('Cat2', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass=halo_data['halo_mass'], ngals_i = halo_data['NGALS_i'], ngals_z = halo_data['NGALS_z']) c2 = ClCatalog('Cat2', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass=halo_data['halo_mass'], id=halo_data['halo_id']) #print(c1) #print(c2) #create clevar member catalogs from clevar.catalog import MemCatalog #m1 = MemCatalog('Mem1', id=wazp_members_data['ID_g'], id_cluster=wazp_members_data['ID_CLUSTER'], ra=wazp_members_data['ra'], dec=wazp_members_data['dec'], pmem=wazp_members_data['PMEM'])
#mask = truth_data['is_central']==True #mask = np.logical_and(truth_data['is_central']==True,truth_data['halo_id']==127200143167) #halo_data = truth_data[mask] #halo members #galaxy_data_all = Table(gc_truth.get_quantities(['ra','dec', 'halo_mass', 'halo_id', 'redshift', 'mag_g', 'mag_i', 'mag_r', 'mag_z', 'mag_y', 'baseDC2/is_on_red_sequence_gr', 'baseDC2/is_on_red_sequence_ri', 'is_central', 'hostHaloMass'],#, 'baseDC2/sod_halo_mass'], # filters=['halo_mass > 10**13', 'mag_i<30', 'is_central==False']))# 'halo_id==127200143167'])) #print("Number of elements in the truth catalog = ", len(galaxy_data_all)) print("Number of halos in the truth catalog = ", len(halo_data)) #print("Truth catalog sky area = ", gc_truth.sky_area, "deg2") #matching from clevar.catalog import ClCatalog from clevar.match import ProximityMatch c1 = ClCatalog('Cat1', ra=wazp_data['ra'], dec=wazp_data['dec'], z=wazp_data['redshift'], mass = wazp_data['NGALS']) #c1 = c1_raw[c1_raw.data['z']<0.7] c1 = ClCatalog('Cat1', ra=cluster_data['ra'], dec=cluster_data['dec'], z=cluster_data['redshift'], mass = cluster_data['richness']) #c2 = ClCatalog('Cat2', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass=halo_data['halo_mass'], ngals_i = halo_data['NGALS_i'], ngals_z = halo_data['NGALS_z']) c2 = ClCatalog('Cat2', ra=halo_data['ra'], dec=halo_data['dec'], z=halo_data['redshift'], mass=halo_data['halo_mass']) #test #c2 = ClCatalog('Cat2', id=input2['ID'], ra=input2['RA'], dec=input2['DEC'], z=input2['Z'], mass=input2['MASS']) #print(c1) #print(c2) #save c1 and c2 #wazp #c1.data['ra', 'dec', 'z', 'mass'].write('matching/' + outpath_matching + '/wazp.fits', overwrite=True) #c2.data['ra', 'dec', 'z', 'mass'].write('matching/' + outpath_matching + '/halos.fits', overwrite=True) #c1.data['ra', 'dec', 'z', 'mass'].write('matching/' + outpath_matching + '/redmapper.fits') #redmapper c1.data['ra', 'dec', 'z', 'mass'].write('matching/' + outpath_matching + '/redmapper.fits', overwrite=True)
algo = 'redMapper' outpath = "/sps/lsst/users/tguillem/DESC/desc_may_2021/desc-data-portal/notebooks/dc2/plots/" + matching_folder if os.path.exists(outpath): shutil.rmtree(outpath) os.makedirs(outpath) #load c1 and c2 #redmapper cat_wazp = Table.read(matching_folder + 'redmapper.fits') print('OK') print(cat_wazp) #c1 = ClCatalog.read(matching_folder + 'wazp.fits', 'wazp', ra='ra', dec='dec', z='z', mass = 'mass') #c1 = ClCatalog.read(matching_folder + 'redmapper.fits', 'Cat1', ra='ra', dec='dec', z='z', mass = 'mass') #c1 = ClCatalog.read(matching_folder + 'redmapper.fits', 'Cat1', z='z', mass = 'mass') c1 = ClCatalog.read_full(matching_folder + 'redmapper.fits') #wazp #c1 = ClCatalog.read('matching/6688/wazp.fits', 'wazp', ra='ra', dec='dec', z='z', mass = 'mass') #c2 = ClCatalog.read(matching_folder + 'halos.fits', 'halos', ra='ra', dec='dec', z='z', mass = 'mass') #c2 = ClCatalog.read(matching_folder + 'redmapper.fits', 'redmapper', ra='ra', dec='dec', z='z', mass = 'mass') c2 = ClCatalog.read_full(matching_folder + 'halos.fits') print(c1) print(c2) mt = ProximityMatch() mt.load_matches(c1, c2, out_dir=matching_folder) #now restrict to matched pairs from clevar.match import get_matched_pairs mt1, mt2 = get_matched_pairs(c1, c2, 'cross') plt.figure()