def mcquillan_rapid_rotator_bins(): '''Plot the rapid rotator bins in the full McQuillan sample.''' mcq = cache.mcquillan_corrected_splitter() ebs = cache.eb_splitter_with_DSEP() dwarfs = mcq.subsample(["Dwarfs", "Right Statistics Teff"]) eb_dwarfs = ebs.subsample(["Dwarfs", "Right Statistics Teff"]) periodbins = np.flipud(np.array([1.5, 7, 10])) f, axes = plt.subplots(1, 2, figsize=(24, 12), sharex=True, sharey=True) cons_limit = -0.3 mcq_period_indices = np.digitize(dwarfs["Prot"], periodbins) eb_period_indices = np.digitize(eb_dwarfs["period"], periodbins) Protstr = r"$P_{\mathrm{rot}}$" titles = [ "{1} > {0:g} day".format(periodbins[0], Protstr), "{0:g} day < {2} <= {1:g} day".format(periodbins[2], periodbins[1], Protstr) ] eblabel = "EB" rotlabel = "McQuillan" for i, title, ax in zip(range(0, 4, 2), titles, np.ravel(axes)): mcq_periodbin = dwarfs[mcq_period_indices == i] eb_periodbin = eb_dwarfs[eb_period_indices == i] hr.absmag_teff_plot(mcq_periodbin["SDSS-Teff"], mcq_periodbin["Corrected K Excess"], marker=".", color=bc.black, ls="", axis=ax, zorder=1, label=rotlabel) hr.absmag_teff_plot(eb_periodbin["SDSS-Teff"], eb_periodbin["Corrected K Excess"], marker="*", color=bc.pink, ls="", ms=24, axis=ax, zorder=2, label=eblabel) eblabel = rotlabel = "" ax.set_ylabel("") ax.set_xlabel("") ax.set_title(title) ax.plot([4000, 5250], [cons_limit, cons_limit], marker="", ls="--", color=bc.violet, lw=6, zorder=3) ax.plot([3500, 6500], [-0.0, -0.0], 'k-', lw=2, zorder=4) axes[0].set_ylabel("Corrected $M_{Ks}$ Excess") axes[0].set_xlabel("$T_{\mathrm{eff}}$ (K)") axes[1].set_xlabel("$T_{\mathrm{eff}}$ (K)") axes[0].set_xlim(5250, 4000) axes[0].set_ylim(0.3, -1.25) axes[0].legend(loc="upper right")
def binary_fractions_with_period(): '''Measure the binary fraction with period.''' mcq = cache.mcquillan_corrected_splitter() nomcq = cache.mcquillan_nondetections_corrected_splitter() ebs = cache.eb_splitter_with_DSEP() mcq_dwarfs = mcq.subsample(["Dwarfs", "Right Statistics Teff"]) nomcq_dwarfs = nomcq.subsample(["Dwarfs", "Right Statistics Teff"]) generic_columns = ["Corrected K Excess"] dwarfs = vstack( [mcq_dwarfs[generic_columns], nomcq_dwarfs[generic_columns]]) dwarf_ebs = ebs.subsample(["Dwarfs", "Right Statistics Teff"]) f, ax2 = plt.subplots(1, 1, dpi=dpi, figsize=figsize) cons_limit = -0.3 # Create the histograms period_bins, dp = np.linspace(1.5, 21.5, 20 + 1, retstep=True, endpoint=True) # These are for the conservative sample. singles03 = mcq_dwarfs["Prot"][ mcq_dwarfs["Corrected K Excess"] >= cons_limit] binaries03 = mcq_dwarfs["Prot"][ mcq_dwarfs["Corrected K Excess"] < cons_limit] single_ebs03 = dwarf_ebs["period"][ dwarf_ebs["Corrected K Excess"] >= cons_limit] binary_ebs03 = dwarf_ebs["period"][ dwarf_ebs["Corrected K Excess"] < cons_limit] binary_rot_hist03, _ = np.histogram(binaries03, bins=period_bins) binary_eb_hist03, _ = np.histogram(binary_ebs03, bins=period_bins) single_rot_hist03, _ = np.histogram(singles03, bins=period_bins) single_eb_hist03, _ = np.histogram(single_ebs03, bins=period_bins) full_rot_hist, _ = np.histogram(mcq_dwarfs["Prot"], bins=period_bins) full_eb_hist, _ = np.histogram(dwarf_ebs["period"], bins=period_bins) # The total number of binaries and singles in the full sample. summed_binaries03 = ( np.count_nonzero(mcq_dwarfs["Corrected K Excess"] < cons_limit) + np.count_nonzero(dwarf_ebs["Corrected K Excess"] < cons_limit) + np.count_nonzero(nomcq_dwarfs["Corrected K Excess"] < cons_limit)) summed_singles03 = ( np.count_nonzero(mcq_dwarfs["Corrected K Excess"] >= cons_limit) + np.count_nonzero(dwarf_ebs["Corrected K Excess"] >= cons_limit) + np.count_nonzero(nomcq_dwarfs["Corrected K Excess"] >= cons_limit)) # The binary fraction for the full sample fullsamp_frac03 = (summed_binaries03 / (len(mcq_dwarfs) + len(dwarf_ebs) + len(nomcq_dwarfs))) # Sum up the binaries, single, and total histograms total_binaries03 = binary_rot_hist03 + binary_eb_hist03 total_singles03 = single_rot_hist03 + single_eb_hist03 total = full_rot_hist + full_eb_hist # Measure the binary fraction frac03 = total_binaries03 / total frac_uppers03 = au.binomial_upper(total_binaries03, total) - frac03 frac_lowers03 = frac03 - au.binomial_lower(total_binaries03, total) period_mids = (period_bins[1:] + period_bins[:-1]) / 2 ax2.step(period_bins, np.append(frac03, [0]), where="post", color=bc.black, ls="-", label="", lw=3) ax2.errorbar(period_bins[:-1] + dp / 2, frac03, yerr=[frac_lowers03, frac_uppers03], color=bc.black, ls="", marker="") ax2.plot([1, 50], [fullsamp_frac03, fullsamp_frac03], ls=":", marker="", color=bc.black, lw=3) ax2.set_xlabel("Rotation Period (day)") ax2.set_ylabel("Photometric Binary Function") ax2.set_xlim(1.5, 21.5) ax2.set_ylim(0, 1) ax2.set_title(r"$\Delta {0} < {1:g}$ mag".format(MKstr.strip("$"), cons_limit))
def distribution_singles_binaries(): '''Plot the distribution of singles and binaries.''' mcq = cache.mcquillan_corrected_splitter() nomcq = cache.mcquillan_nondetections_corrected_splitter() ebs = cache.eb_splitter_with_DSEP() mcq_dwarfs = mcq.subsample(["Dwarfs", "Right Statistics Teff"]) nomcq_dwarfs = nomcq.subsample(["Dwarfs", "Right Statistics Teff"]) generic_columns = ["Corrected K Excess"] dwarfs = vstack( [mcq_dwarfs[generic_columns], nomcq_dwarfs[generic_columns]]) dwarf_ebs = ebs.subsample(["Dwarfs", "Right Statistics Teff"]) f, ax = plt.subplots(1, 1, dpi=dpi, figsize=figsize, sharex=True) cons_limit = -0.3 # Create the histograms period_bins, dp = np.linspace(1.5, 21.5, 20 + 1, retstep=True, endpoint=True) # These are for the conservative sample. singles03 = mcq_dwarfs["Prot"][ mcq_dwarfs["Corrected K Excess"] >= cons_limit] binaries03 = mcq_dwarfs["Prot"][ mcq_dwarfs["Corrected K Excess"] < cons_limit] single_ebs03 = dwarf_ebs["period"][ dwarf_ebs["Corrected K Excess"] >= cons_limit] binary_ebs03 = dwarf_ebs["period"][ dwarf_ebs["Corrected K Excess"] < cons_limit] binary_rot_hist03, _ = np.histogram(binaries03, bins=period_bins) binary_eb_hist03, _ = np.histogram(binary_ebs03, bins=period_bins) single_rot_hist03, _ = np.histogram(singles03, bins=period_bins) single_eb_hist03, _ = np.histogram(single_ebs03, bins=period_bins) full_rot_hist, _ = np.histogram(mcq_dwarfs["Prot"], bins=period_bins) full_eb_hist, _ = np.histogram(dwarf_ebs["period"], bins=period_bins) # The total number of binaries and singles in the full sample. summed_binaries03 = ( np.count_nonzero(mcq_dwarfs["Corrected K Excess"] < cons_limit) + np.count_nonzero(dwarf_ebs["Corrected K Excess"] < cons_limit) + np.count_nonzero(nomcq_dwarfs["Corrected K Excess"] < cons_limit)) summed_singles03 = ( np.count_nonzero(mcq_dwarfs["Corrected K Excess"] >= cons_limit) + np.count_nonzero(dwarf_ebs["Corrected K Excess"] >= cons_limit) + np.count_nonzero(nomcq_dwarfs["Corrected K Excess"] >= cons_limit)) # The binary fraction for the full sample fullsamp_frac03 = (summed_binaries03 / (len(mcq_dwarfs) + len(dwarf_ebs) + len(nomcq_dwarfs))) # Sum up the binaries, single, and total histograms total_binaries03 = binary_rot_hist03 + binary_eb_hist03 total_singles03 = single_rot_hist03 + single_eb_hist03 total = full_rot_hist + full_eb_hist # Measure the binary fraction frac03 = total_binaries03 / total frac_uppers03 = au.binomial_upper(total_binaries03, total) - frac03 frac_lowers03 = frac03 - au.binomial_lower(total_binaries03, total) normalized_binaries03 = total_binaries03 / summed_binaries03 normalized_binaries_upper03 = ( (au.poisson_upper(total_binaries03, 1) - total_binaries03) / summed_binaries03) normalized_binaries_lower03 = ( (total_binaries03 - au.poisson_lower(total_binaries03, 1)) / summed_binaries03) normalized_singles03 = total_singles03 / summed_singles03 normalized_singles_upper03 = ( (au.poisson_upper(total_singles03, 1) - total_singles03) / summed_singles03) normalized_singles_lower03 = ( (total_singles03 - au.poisson_lower(total_singles03, 1)) / summed_singles03) ax.step(period_bins, np.append(normalized_binaries03, [0]), where="post", color=bc.algae, ls="-", label="Photometric Binaries") ax.step(period_bins, np.append(normalized_singles03, [0]), where="post", color=bc.purple, linestyle="--", label="Photometric Singles") ax.errorbar( period_bins[:-1] + dp / 2 - dp / 10, normalized_binaries03, yerr=[normalized_binaries_lower03, normalized_binaries_upper03], color=bc.algae, ls="", marker="") ax.errorbar(period_bins[:-1] + dp / 2 + dp / 10, normalized_singles03, yerr=[normalized_singles_lower03, normalized_singles_upper03], color=bc.purple, ls="", marker="") ax.set_xlabel("Rotation Period (day)") ax.set_ylabel("Normalized Period Distribution") ax.set_ylim(0, 0.035) ax.legend(loc="lower right")