def plot_periods(ssm_file, mbls_file, rrlyrae): ids = list(rrlyrae.ids) sesar_periods = np.array([rrlyrae.get_metadata(lcid)['P'] for lcid in ids]) ssm_periods = gather_results(ssm_file, ids) mbls_periods = gather_results(mbls_file, ids) fig, ax = plt.subplots(1, 2, figsize=(10, 4), sharex=True, sharey=True) fig.subplots_adjust(left=0.07, right=0.95, wspace=0.1, bottom=0.15, top=0.9) colors = seaborn.color_palette() plot_period_comparison(ax[0], ssm_periods, sesar_periods, color=colors[0]) plot_period_comparison(ax[1], mbls_periods, sesar_periods, color=colors[1]) ax[0].set_xlabel('supersmoother period (days)') ax[0].set_ylabel('Sesar 2010 period (days)') ax[1].set_xlabel('multiband period (days)') ax[0].set_title("SuperSmoother (g-band)", y=1.04) ax[1].set_title("Shared-phase Multiband", y=1.04) return fig, ax
def plot_LSST_sims(outfile, pointing_indices, ndays, gmags, template_indices): results_multi = 'resultsLSST.npy' results_ssm = 'resultsLSST_ssm_{0}.npy' # Get measured periods Pobs_multi = gather_results(results_multi, pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) Pobs_multi[np.isnan(Pobs_multi)] = 0 Pobs_ssm = np.array([gather_results(results_ssm.format(band), pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) for band in 'ugriz']) Pobs_ssm = Pobs_ssm[:, :, :, :, :, 0].transpose(1, 2, 3, 4, 0) Pobs_ssm[np.isnan(Pobs_ssm)] = 0 # Get true periods rrlyrae = fetch_rrlyrae() Ptrue = np.reshape([rrlyrae.get_metadata(rrlyrae.ids[i])['P'] for i in template_indices.ravel()], template_indices.shape) # Check for matches dphimax = 0.37 matches_multi = olusei_period_criterion(Pobs_multi, Ptrue.reshape(Ptrue.shape + (1,)), ndays.reshape(ndays.shape + (1,)), dphimax=dphimax) results_multi = np.any(matches_multi, -1).mean(-1).mean(-1) matches_ssm = olusei_period_criterion(Pobs_ssm, Ptrue.reshape(Ptrue.shape + (1,)), ndays.reshape(ndays.shape + (1,)), dphimax=dphimax) results_ssm = np.any(matches_ssm, -1).mean(-1).mean(-1) fig, ax = plt.subplots() for t, frac_multi, frac_ssm in reversed(list(zip(ndays.ravel(), results_multi.T, results_ssm.T))): line = ax.plot(gmags.ravel(), frac_multi, label='{0:.1f} years'.format(t / 365)) ax.fill_between(gmags.ravel(), frac_ssm, frac_multi, edgecolor='none', facecolor=line[0].get_color(), alpha=0.3) ax.legend(loc='lower left') ax.set(xlabel='g-band magnitude', ylabel='Fraction of Periods among Top-5', title='Multiband Improvement over SuperSmoother for LSST', xlim=(20, 24.5), ylim=(0, 1))
def period_recovery(band): outfile = 'resultsLSST_ssm_{0}.npy'.format(band) results = gather_results(outfile, pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) best_results = results[:, :, :, :, 0] recovery = period_criterion(best_results, Ptrue, ndays) print(band, recovery.sum() / recovery.size) return recovery
def plot_LSST_sims(outfile, pointing_indices, ndays, gmags, template_indices): results_multi = 'resultsLSST.npy' results_ssm = 'resultsLSST_ssm_{0}.npy' # Get measured periods Pobs_multi = gather_results(results_multi, pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) Pobs_multi[np.isnan(Pobs_multi)] = 0 Pobs_ssm = np.array([ gather_results(results_ssm.format(band), pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) for band in 'ugriz' ]) Pobs_ssm = Pobs_ssm[:, :, :, :, :, 0].transpose(1, 2, 3, 4, 0) Pobs_ssm[np.isnan(Pobs_ssm)] = 0 # Get true periods rrlyrae = fetch_rrlyrae() Ptrue = np.reshape([ rrlyrae.get_metadata(rrlyrae.ids[i])['P'] for i in template_indices.ravel() ], template_indices.shape) # Check for matches dphimax = 0.37 matches_multi = olusei_period_criterion(Pobs_multi, Ptrue.reshape(Ptrue.shape + (1, )), ndays.reshape(ndays.shape + (1, )), dphimax=dphimax) results_multi = np.any(matches_multi, -1).mean(-1).mean(-1) matches_ssm = olusei_period_criterion(Pobs_ssm, Ptrue.reshape(Ptrue.shape + (1, )), ndays.reshape(ndays.shape + (1, )), dphimax=dphimax) results_ssm = np.any(matches_ssm, -1).mean(-1).mean(-1) fig, ax = plt.subplots() for t, frac_multi, frac_ssm in reversed( list(zip(ndays.ravel(), results_multi.T, results_ssm.T))): line = ax.plot(gmags.ravel(), frac_multi, label='{0:.1f} years'.format(t / 365)) ax.fill_between(gmags.ravel(), frac_ssm, frac_multi, edgecolor='none', facecolor=line[0].get_color(), alpha=0.3) ax.legend(loc='lower left') ax.set(xlabel='g-band magnitude', ylabel='Fraction of Periods among Top-5', title='Multiband Improvement over SuperSmoother for LSST', xlim=(20, 24.5), ylim=(0, 1))
factor = dphimax / Tdays return abs(Pobs - Ptrue) <= (Ptrue**2) * factor template_indices = np.arange(2 * 23).reshape(2, 23).T pointing_indices = np.arange(1, 24)[:, None] ndays = np.array([180, 365, 2 * 365, 5 * 365])[:, None, None] gmags = np.array([20, 21, 22, 23, 24.5])[:, None, None, None] results_multi = 'LSSTsims/resultsLSST.npy' results_ssm = 'LSSTsims/resultsLSST_ssm_{0}.npy' # Get measured periods Pobs_multi = gather_results(results_multi, pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) Pobs_multi[np.isnan(Pobs_multi)] = 0 Pobs_ssm = np.array([ gather_results(results_ssm.format(band), pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices) for band in 'ugriz' ]) Pobs_ssm = Pobs_ssm[:, :, :, :, :, 0].transpose(1, 2, 3, 4, 0) Pobs_ssm[np.isnan(Pobs_ssm)] = 0 # Get true periods
def olusei_period_criterion(Pobs, Ptrue, Tdays, dphimax=0.037): factor = dphimax / Tdays return abs(Pobs - Ptrue) <= (Ptrue ** 2) * factor template_indices = np.arange(2 * 23).reshape(2, 23).T pointing_indices = np.arange(1, 24)[:, None] ndays = np.array([180, 365, 2 * 365, 5 * 365])[:, None, None] gmags = np.array([20, 21, 22, 23, 24.5])[:, None, None, None] results_multi = "LSSTsims/resultsLSST.npy" results_ssm = "LSSTsims/resultsLSST_ssm_{0}.npy" # Get measured periods Pobs_multi = gather_results( results_multi, pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices ) Pobs_multi[np.isnan(Pobs_multi)] = 0 Pobs_ssm = np.array( [ gather_results( results_ssm.format(band), pointing_indices=pointing_indices, ndays=ndays, gmags=gmags, template_indices=template_indices, ) for band in "ugriz" ] )