Example #1
0
def add_z_cl(ax, fields, completeness):
    # fix the path to get the results
    import sys
    sys.path.append('../results/')
    from get_results import loadClusters

    # confirmed clusters
    high_conf = [
        'PSZ1_G206.45+13.89', 'PSZ1_G224.82+13.62', 'PSZ2_G029.66-47.63',
        'PSZ2_G043.44-41.27', 'PSZ2_G096.43-20.89', 'PSZ2_G120.76+44.14',
        'PSZ2_G125.55+32.72', 'PSZ2_G137.24+53.93', 'PSZ2_G305.76+44.79',
        'PSZ2_G107.83-45.45', 'PSZ2_G098.38+77.22', 'PSZ1_G084.62-15.86',
        'PSZ2_G106.11+24.11', 'PSZ2_G173.76+22.92', 'PSZ2_G191.82-26.64'
    ]

    # get the density for the confirmed fields.
    depth = [completeness[fields.index(hc)] for hc in numpy.sort(high_conf)]

    # the confirmed = True gets the 15 confirmed clusters
    results = loadClusters(round=3, confirmed=True)

    # sort the results
    results.sort_values('Cluster', inplace=True)

    ax.scatter(results['z_cl_boada'],
               depth,
               s=150,
               marker='*',
               color='#e24a33')

    return ax
from astropy.table import Table
from get_results import loadClusters
from astLib import astCoords
from numpy import nan
import pandas as pd
''' This creates a simple latex table with the results using the columns
specified below. A few things will need to be done by hand after this is
created. The corrected errors to redshifts, and corrected Ngals will need
to be manually added by looking at the results images. The cluster finder
doesn't save those columns by default.

'''

# the confirmed = True gets the 12 confirmed clusters
results = loadClusters(round=2)

# load the master spreadsheet
t_ss = Table.read('../catalogs/PSZ2_unconfirmed_catalog - current.csv')
df_ss = t_ss.to_pandas()

observed = df_ss.loc[df_ss['MOSAIC Imaging'].notnull()]

confirmed = observed.merge(results,
                           left_on='Name',
                           right_on='Cluster',
                           how='left')

# load the PSZ1 catalog
t_1 = Table.read('../catalogs/PSZ1v2.1.fits')
df1 = t_1.to_pandas()
            # just in case there are no elements in the bin
            to_delete.append(len(df) + 1 + len(to_delete))

    # add x values
    bins = np.delete(bins, to_delete)
    df['x'] = bins

    return df


# read all of the data
ps1 = Table.read('../catalogs/PSZ1v2.1.fits')
ps2 = Table.read('../catalogs/PSZ2v1.fits')
Bpaper = Table.read('../papers/1803.05764/Barrena_tbl3.csv')
# the confirmed = True gets the 12 confirmed clusters
results = loadClusters(round=2, confirmed=True)

# convert to pandas
df1 = ps1.to_pandas()
df2 = ps2.to_pandas()
df_paper = Bpaper.to_pandas()

# clean up strings -- not required
df1 = df1.applymap(lambda x: x.decode() if isinstance(x, bytes) else x)
df2 = df2.applymap(lambda x: x.decode() if isinstance(x, bytes) else x)

# clean up underscores in bpaper and results
df_paper['Planck Name'] = df_paper['Planck Name'].str.replace('_', ' ')
results['Cluster'] = results['Cluster'].str.replace('_', ' ')
# drop empty values
df_paper.dropna(subset=['Planck Name', 'z_cl'], inplace=True)
Example #4
0
def find_nearest(array, value):
    ''' returns the index and value of the nearest value in an array. '''
    idx = (abs(array - value)).argmin()
    return idx, array[idx]


# get the models for BC03
tau = [1, 1.25, 1.5, 1.75, 2]
models = [setup_models(5, t) for t in tau]

# make some colored lines for the plots
cm_subset = linspace(0.2, 0.8, len(tau))
colors = [cm.bone(x) for x in cm_subset]

results = loadClusters()

users = ['boada', 'felipe', 'doze']

for user in users:
    r_user = results[~results['Confidence_{}'.format(user)].isnull()]

    # now we loop over all of the results
    for i, (indx, c) in enumerate(r_user.Cluster.iteritems()):
        print(user, '--', c)
        bcg = r_user.iloc[i]['BCG_{}'.format(user)]
        bcg = int(bcg)
        # load the member data
        try:
            members = loadMembers(user, c)
        except FileNotFoundError:
Example #5
0
def main(round=3):
    ''' This creates a simple latex table with the results using the columns
    specified below. A few things will need to be done by hand after this is
    created. The corrected errors to redshifts, and corrected Ngals will need
    to be manually added by looking at the results images. The cluster finder
    doesn't save those columns by default.

    '''

    # the confirmed = True gets the 12 confirmed clusters
    results = loadClusters(round=round, confirmed=True)

    # load the master spreadsheet
    t_ss = Table.read('../catalogs/PSZ2_unconfirmed_catalog - current.csv')
    df_ss = t_ss.to_pandas()

    observed = df_ss.loc[~df_ss['MOSAIC Imaging'].isnull()]

    confirmed = observed.merge(results, left_on='Name', right_on='Cluster',
                               how='left')

    # load the PSZ1 catalog
    t_1 = Table.read('../catalogs/PSZ1v2.1.fits')
    df1 = t_1.to_pandas()

    # now we add all of the extra info
    # Berrena paper
    Bpaper = Table.read('../papers/1803.05764/Barrena_tbl3.csv')
    df_paper = Bpaper.to_pandas()

    complete = confirmed.merge(df_paper, left_on='Name', right_on='Planck Name',
                               how='left')

    # tack on the PSZ1 catalog
    complete = complete.merge(df1, left_on='PSZ1 Indx', right_on='INDEX',
                              how='left')

    # combine some columns to get extra info
    complete['z_extern'] = complete['PSZ1 Redshift'].fillna(complete['z_cl'])
    complete['S/N'] = complete['SNR_PSZ2'].fillna(complete['SNR_PSZ1'])

    # get the columns we want
    cols = ['Name', 'PSZ1 Indx', 'PSZ2 Indx', 'S/N', 'RA_SEX', 'DEC_SEX',
            'dist_BCG', 'z_cl_boada', 'z_clerr_boada', 'Ngal_c_boada', 'Cmag_i',
            'z_extern', 'REDSHIFT_SOURCE', 'BCG_boada']

    c = complete.loc[:, cols]

    c.loc[:, ('RA_SEX', 'DEC_SEX')] = nan

    c.loc[(~c['z_extern'].isnull()) & (c['REDSHIFT_SOURCE'] == -1.0),
          'REDSHIFT_SOURCE'] = 99

    # let's the the RA/DEC of our BCGs
    m = c.loc[c['BCG_boada'].notnull()]

    for i, row in m.iterrows():
        mems = loadMembers('boada', row['Name'], round=round)
        try:
            ra = mems.loc[mems['ID'] == row['BCG_boada'], 'RA'].values[0]
        except IndexError:
            continue
        dec = mems.loc[mems['ID'] == row['BCG_boada'], 'DEC'].values[0]
        # convert to sexigesimal
        ra_sex = astCoords.decimal2hms(ra, ':')
        dec_sex = astCoords.decimal2dms(dec, ':')

        # compute the distance to the PSZ position
        psz_ra = complete.iloc[i]['RA_x']
        psz_dec = complete.iloc[i]['DEC_x']

        m.loc[i, 'dist_BCG'] = astCoords.calcAngSepDeg(psz_ra,
                                                       psz_dec, ra, dec) * 60

        # write it back into the main frame
        m.loc[i, 'RA_SEX'] = ra_sex
        m.loc[i, 'DEC_SEX'] = dec_sex

    return m