Example #1
0
def main_deprecated():

    df = _get_cks_data()
    sel = _apply_cks_IV_metallicity_study_filters(df)
    p17_df = df[sel]

    vot = parse('../data/McQuillan_2014_ApJS_211_24_table1.vot')
    m14 = vot.get_first_table()
    m14_df = m14.to_table().to_pandas()

    p17_df['id_kic'] = p17_df['id_kic'].astype(str)
    m14_df['KIC'] = m14_df['KIC'].astype(str)

    # # no matches. wat.
    # mdf = p17_df.merge(m14_df, how='inner', left_on='id_kic', right_on='KIC')

    q = NasaExoplanetArchive.query_criteria(table='koi',
                                            select='kepoi_name,ra,dec',
                                            order='kepoi_name')
    q_df = q.to_pandas()

    mdf0 = p17_df.merge(q_df,
                        how='inner',
                        left_on='id_koicand',
                        right_on='kepoi_name').drop_duplicates('id_koicand',
                                                               keep='first')

    assert len(mdf0) == len(p17_df)

    c_p17 = SkyCoord(ra=nparr(mdf0.ra) * u.deg, dec=nparr(mdf0.dec) * u.deg)
    c_m14 = SkyCoord(ra=nparr(m14_df._RA) * u.deg,
                     dec=nparr(m14_df._DE) * u.deg)

    idx_m14, idx_p17, d2d, _ = c_p17.search_around_sky(c_m14, 1 * u.arcsec)
Example #2
0
def main():

    df = _get_cks_data()
    sel = _apply_cks_IV_metallicity_study_filters(df)
    p17_df = df[sel]

    vot = parse('../data/McQuillan_2013_ApJ_775L.vot')
    m13 = vot.get_first_table()
    m13_df = m13.to_table().to_pandas()

    p17_df['id_kic'] = p17_df['id_kic'].astype(str)
    m13_df['KIC'] = m13_df['KIC'].astype(str)

    mdf = p17_df.merge(m13_df, how='inner', left_on='id_kic', right_on='KIC')

    for scale in ['linear', 'log']:
        f, ax = plt.subplots()
        ax.scatter(mdf.giso_prad, mdf.Prot, s=2, c='k')
        ax.set_xlabel('CKS Planet Size [R$_\oplus$]')
        ax.set_ylabel('M13 Rotation Period [day]')
        ax.set_xscale(scale)
        ax.set_yscale(scale)
        format_ax(ax)
        outpath = f'../results/cks_rotation_period/cks_rp_vs_mcquillan_prot_{scale}.png'
        f.savefig(outpath, dpi=300, bbox_inches='tight')

    plt.close('all')
    f, ax = plt.subplots()
    ax.scatter(mdf.koi_period, mdf.Prot, s=2, c='k')
    ax.set_xlabel('KOI Period [day]')
    ax.set_ylabel('M13 Rotation Period [day]')
    ax.set_xscale('log')
    ax.set_yscale('log')
    format_ax(ax)
    outpath = '../results/cks_rotation_period/koi_period_vs_mcquillan_prot.png'
    f.savefig(outpath, dpi=300, bbox_inches='tight')

    plt.close('all')
    f, ax = plt.subplots()
    ax.scatter(mdf.koi_period, mdf.giso_prad, s=2, c='k')
    ax.set_xlabel('KOI Period [day]')
    ax.set_ylabel('CKS Planet Size [R$_\oplus$]')
    ax.set_xscale('log')
    ax.set_yscale('log')
    format_ax(ax)
    outpath = '../results/cks_rotation_period/koi_period_vs_giso_prad_M13_match.png'
    f.savefig(outpath, dpi=300, bbox_inches='tight')
Example #3
0
def make_old_short_period_plots():

    # approach #1: just use Petigura+ 2018's filters
    # approach #2: just use Petigura+ 2018's filters, + filter on gaia
    # astrometric excess
    # approach #3: just use Petigura+ 2018's filters, + filter on gaia
    # astrometric excess, + a/Rstar<100 only, + only the innermost planets of
    # systems.
    do_approach1 = 0
    do_approach2 = 0
    do_approach3 = 1
    approaches = np.array([do_approach1, do_approach2,
                           do_approach3]).astype(bool)
    if not len(approaches[approaches]) == 1:
        raise AssertionError('only one approach allowed')

    make_all = 0
    if make_all:
        make_initial_plots = 1
        make_stacked_histogram_plots = 1
        make_sanity_check_scatters = 1
        make_hr_diagram = 1
        make_ks2sample_abyRstar = 1
        make_ks2sample_turnoff = 1
        make_turnoff_v_mainsequence_scatters = 1
    else:
        make_initial_plots = 1
        make_stacked_histogram_plots = 0
        make_sanity_check_scatters = 0
        make_hr_diagram = 0
        make_ks2sample_abyRstar = 0
        make_ks2sample_turnoff = 0
        make_turnoff_v_mainsequence_scatters = 0

    if do_approach1:
        df = _get_cks_data()
        sel = _apply_cks_IV_metallicity_study_filters(df)
        savdir = '../results/cks_age_plots_old_short_period_p18filters/'
        savdir_append = '_old_short_period_p18filters'

    if do_approach2:
        df = _get_cks_data(merge_vs_gaia=True)
        sel = _apply_cks_IV_filters_plus_gaia_astrom_excess(df)
        savdir = '../results/cks_age_plots_old_short_period/'
        savdir_append = '_old_short_period'

    if do_approach3:
        df = _get_cks_data(merge_vs_gaia=True)
        sel = _apply_cks_IV_filters_plus_gaia_astrom_excess(df)
        sel &= _take_innermost_filter(df)
        savdir = '../results/cks_age_plots_old_short_period_onlyinnermost/'
        savdir_append = '_old_short_period_onlyinnermost'

    # remake the plots that got us interested in this
    if make_initial_plots:
        for xparam in ['koi_period', 'koi_dor', 'cks_VII_dor']:
            for logy in [True, False]:
                for logx in [True, False]:
                    plot_wellmeasuredparam(df,
                                           sel,
                                           xparam,
                                           logx,
                                           logy,
                                           is_cks=True,
                                           savdir_append=savdir_append)
                    plot_wellmeasuredparam(df,
                                           sel,
                                           xparam,
                                           logx,
                                           logy,
                                           is_cks=True,
                                           savdir_append=savdir_append)

    if make_stacked_histogram_plots:
        make_stacked_histograms(df[sel],
                                logtime=False,
                                xparam='koi_dor',
                                savdir=savdir)
        make_stacked_histograms(df[sel],
                                logtime=False,
                                xparam='cks_VII_dor',
                                savdir=savdir)
        make_stacked_histograms(df[sel],
                                logtime=False,
                                xparam='period',
                                savdir=savdir)
        make_stacked_histograms(df[sel],
                                logtime=True,
                                xparam='koi_dor',
                                savdir=savdir)
        make_stacked_histograms(df[sel],
                                logtime=True,
                                xparam='cks_VII_dor',
                                savdir=savdir)
        make_stacked_histograms(df[sel],
                                logtime=True,
                                xparam='period',
                                savdir=savdir)
        make_quartile_scatter(df[sel], xparam='koi_period', savdir=savdir)
        make_quartile_scatter(df[sel], xparam='koi_dor', savdir=savdir)
        make_quartile_scatter(df[sel], xparam='cks_VII_dor', savdir=savdir)

    if make_sanity_check_scatters:
        # a few sanity checks
        plot_scatter(df,
                     sel,
                     'koi_period',
                     'cks_smet',
                     True,
                     False,
                     is_cks=True,
                     savdir=savdir,
                     ylim=[0.5, -0.5])
        plot_scatter(df,
                     sel,
                     'koi_dor',
                     'cks_smet',
                     True,
                     False,
                     is_cks=True,
                     savdir=savdir,
                     ylim=[0.5, -0.5])
        plot_scatter(df,
                     sel,
                     'cks_VII_dor',
                     'cks_smet',
                     True,
                     False,
                     is_cks=True,
                     savdir=savdir,
                     ylim=[0.5, -0.5])
        plot_scatter(df,
                     sel,
                     'cks_smet',
                     'giso_slogage',
                     False,
                     False,
                     is_cks=True,
                     savdir=savdir,
                     xlim=[0.5, -0.5])

    # do the rough calculation of "what %age of planets are at a/R<10 at
    # >10 Gyr, and below it?
    calculate_and_print_fractions(df, sel)

    # what is the a/Rstar<3, smet < -0.3 object?
    inds = (df['cks_smet'] < -0.3)
    inds &= (df['koi_dor'] < 3)
    print(df[inds])

    # what are the a/Rstar<3, age > 10Gyr objects?
    inds = (10**(df['giso_slogage']) > 12e9)
    inds &= (df['koi_dor'] < 4)
    print(df[inds])

    # what exactly is the difference between a 14 gyro and 10 gyro isochrone
    # age?
    if make_hr_diagram:
        plot_hr(df,
                sel,
                'giso_slogage',
                is_cks=True,
                savdir=savdir,
                yaxis='abskmag',
                xscale='log')
        plot_hr(df,
                sel,
                'giso_slogage',
                is_cks=True,
                savdir=savdir,
                yaxis='abskmag',
                xscale='linear')
        plot_hr(df,
                sel,
                'giso_slogage',
                is_cks=True,
                savdir=savdir,
                yaxis='logg',
                xscale='log')
        plot_hr(df,
                sel,
                'giso_slogage',
                is_cks=True,
                savdir=savdir,
                yaxis='logg',
                xscale='linear')
        plot_hr(df,
                sel,
                'giso_slogage',
                is_cks=True,
                savdir=savdir,
                yaxis='logg',
                savstr='turnoffcut',
                xscale='linear')

    # CDFs and two-sample KS to compare the a/Rstar distributions of old and
    # young planets. What is the p-value?
    if make_ks2sample_abyRstar:
        agecuts = [7e9, 8e9, 9e9, 10e9, 11e9, 12e9]
        for agecut in agecuts:
            plot_ks2sample_abyRstar_old_v_young(df[sel],
                                                agecut,
                                                savdir=savdir,
                                                abyRstar_str='koi_dor')
            plot_ks2sample_abyRstar_old_v_young(df[sel],
                                                agecut,
                                                savdir=savdir,
                                                abyRstar_str='cks_VII_dor')

    if make_ks2sample_turnoff:
        _, _ = (plot_ks2sample_abyRstar_turnoff_v_mainsequence(
            df[sel], savdir=savdir, abyRstar_str='koi_dor'))

        df_turnedoff, df_onMS = (
            plot_ks2sample_abyRstar_turnoff_v_mainsequence(
                df[sel], savdir=savdir, abyRstar_str='cks_VII_dor'))

    if make_turnoff_v_mainsequence_scatters and make_ks2sample_turnoff:

        turnoff_v_mainsequence_scatters(df_turnedoff,
                                        df_onMS,
                                        savdir=savdir,
                                        xparam='koi_period')
        turnoff_v_mainsequence_scatters(df_turnedoff,
                                        df_onMS,
                                        savdir=savdir,
                                        xparam='koi_dor')
        turnoff_v_mainsequence_scatters(df_turnedoff,
                                        df_onMS,
                                        savdir=savdir,
                                        xparam='cks_VII_dor')
Example #4
0
rc('font', **{'family': 'serif', 'serif': ['Times New Roman']})
rc('text', usetex=True)

from astropy.table import Table
from astropy.io import ascii
from astropy.coordinates import SkyCoord
import astropy.units as u

df = pd.read_csv('../data/Winn_2017_ajaa93e3t1_ascii.txt', comment='#',
                 delimiter='\t')

df.rename(index=str, columns={'$v\sin i$':'vsini',
                              '${T}_{\mathrm{eff}}$':'Teff'}, inplace=True)

# ok. Winn's table only gives 54 stars, but his paper talks about 156. what's
# up? Ah -- these are all the stars with v > 4km/s, which were selected because
# of the large fractional uncertainties otherwise.

from cks_age_exploration import _get_cks_data
cks = _get_cks_data()

d = pd.merge(df, cks, how='left', left_on='KIC', right_on='id_kic')

# 84 planets orbiting the 54 stars.
# 3 of the planets have a/Rstar < 5
# 17 of them have a/Rstar < 10.

# NOTE: it's somewhat shocking that the state of the rotation period literature
# is that there are only 54 STARS with reliable Prot & vsini, with v > 4km/s.
# WTF...
Example #5
0
    print('saved %s' % savname)
    savname = (
        '../results/cks_age_plots_old_short_period/' +
        'hill_radius_pairs_vs_age_aByRstar_cut_{:d}.png'.format(aByRstar_cut))
    f.savefig(savname, bbox_inches='tight', dpi=350)
    print('saved %s' % savname)


if __name__ == '__main__':

    make_fig1_and_split = False
    make_fig6_weiss17 = False
    make_stackedhist_innermost = False
    make_scatter_p2byp1_vs_p1 = False

    df = _get_cks_data()
    sel = _apply_cks_VI_metallicity_study_filters(df)
    pairs = get_all_planet_pairs(df, sel)
    pairs = compute_pair_separations_hill_radii(pairs)
    systems = get_system_innermost_sma_by_Rstar(df, sel)

    if make_fig1_and_split:
        # How does the average number of transiting planets per stellar system
        # change with metallicity?
        make_weiss18_VI_fig1(df, sel)
        split_weiss18_fig1_high_low_met(df, sel)

    if make_fig6_weiss17:
        # Does average separation between planet pairs in multis (in units of
        # mutual hill radii increase for the oldest multis?
        make_weiss17_V_fig6(pairs)