#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)
c2.data['ra', 'dec', 'z', 'mass'].write('matching/' + outpath_matching + '/halos.fits', overwrite=True)
#sys.exit()

###load clevar-saved catalogs
#binning
zbins = np.linspace(0, 2, 11)
mbins = np.logspace(13, 14, 5)
already_matched = False
if already_matched:
     mt = ProximityMatch()
     #mt.load_matches(c1, c2, out_dir='matching/band_i/')
     mt.load_matches(c1, c2, out_dir='matching/band_i/13.0_5/')
     mp = MatchedPairs(c1, c2, 'cross')
     #print(c1)
     #for element in c1:
     #     print(element['mt_cross'])
     #galaxy_data_all = Table(c1['mass'],c1['mt_cross'])
     #c1_matched = Table(c1['mass'], filters=[c1.data['mt_cross']==7334])
     #print(c2)
     ###halo mass - richness plot
     #plt.figure()
     #scatter
     #ax = scaling.mass(c1, c2, 'cross', log_mass=True, xlabel='NGALS', ylabel='halo_mass')
     #ax.set_xlim([10, 300])
     #ax.set_ylim([2.0e13, 2.0e15])
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',
              'cosmo':AstroPyCosmology()}
mt.prep_cat_for_match(c1, **mt_config1)
mt.prep_cat_for_match(c2, **mt_config2)

mt.multiple(c1, c2)
mt.multiple(c2, c1)

mt.unique(c1, c2, preference='angular_proximity')
Example #3
0
#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()
plt.scatter(mt1['mass'],
            mt2['mass'],
            marker='.',
            color='blue',
            s=10,
            alpha=0.3,
            label='clusters')
#plt.scatter(np.log(mt1['mass']), np.log(mt2['mass']), marker='.',color = 'blue', s=10, alpha=0.3, label='clusters')