<jupyter_start><jupyter_text>V928 Tau - Period Analysis This notebook contains all the steps necessary to check the ground-based survey data for additional eclipses or signs there of (with the same shape as the eclipse detected by K2). The work is quite extensive and intensive as we attempt period folding on ~10 years of photometric data from eight ground-based survey telescopes (ASAS, ASAS-SN, ATLAS, CRTS, KELT, PTF, SWASP, ZTF) and four teams of amateurs (<NAME>, <NAME>, <NAME> and the AstroLab Iris team) along with the K2 data.<jupyter_code>import os
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
from Code import period_analysis as pa
from Code import ground_variation as gv

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Load the Data First we load all the photometric data, and then remove the stellar variation model from the data.<jupyter_code># load the data
times, mags, errors, telescopes = gv.load_survey_data('data/photometry/all_data.txt')

# plot it
gv.plot_all(times, mags, errors, telescopes)
# stellar variation model

# get k2_time0
for i, tel in enumerate(telescopes):
    if 'K2' in tel:
        k2_ind = i
k2_time0 = times[k2_ind][0]

# remove stellar variations from data
pb_sv = np.load('models/best_fits/stellar_variation.npy')
mags_corr = []
for time, mag in zip(times, mags):
    stellar_var = gv.ground_stellar_variation_model(pb_sv, time, k2_time0)
    mags_corr.append(mag - stellar_var)<jupyter_output><empty_output><jupyter_text>Period Folding $-$ Preparation Here we do the actual period folding and do some of the preparations necessary for it, like extracting K2 data from the rest, running a trial and then doing the period folding and making and saving the plots to be explored by hand.  Extract K2 data and limits<jupyter_code># separate k2 from ground based data
ground_times = []
ground_mags = []
ground_errors = []
ground_tels = []
for time, mag, error, telescope in zip(times, mags_corr, errors, telescopes):
    if 'K2' in telescope:
        k2_time = time
        k2_mag = mag
        k2_error = error
    else:
        ground_times.append(time)
        ground_mags.append(mag)
        ground_errors.append(error)
        ground_tels.append(telescope)

# get the eclipse
k2l = 681
k2u = 710
k2te = k2_time[k2l:k2u]
k2me = k2_mag[k2l:k2u]
k2ee = k2_error[k2l:k2u]

fig = plt.figure(figsize=(16, 6))
plt.errorbar(k2_time, k2_mag, yerr=k2_error, fmt='o', color='k', label='full data')
plt.errorbar(k2te, k2me, yerr=k2ee, fmt='o', color='r', label='in eclipse')
plt.legend()
plt.title('K2 Light Curve')
plt.xlabel('Julian Date')
plt.ylabel('$\Delta$ Magnitude [mag]')
plt.gca().invert_yaxis()
plt.xlim(2457834, 2457836)
plt.show()<jupyter_output><empty_output><jupyter_text>Test This is just to ensure everything is working and give a feel for what the goal is of the period folding.<jupyter_code># do a test
period = 201.19805
k2l = 681
k2u = 710
good_pct = 90
sigma = 1
plot_data, total, percentage, chi2s, tot_chi2 = pa.prepare_data(period, k2_time, k2_mag, k2_error, ground_times, ground_mags, ground_errors, k2l, k2u, sigma)
title_str = 'Period = %.2f days ($\chi^2$ = %.2f)\n%i points $\\rightarrow$ %i within %.1f $\sigma$ (%.2f%%)'
title = ''#title_str % (period, tot_chi2, total, percentage*total/100, sigma, percentage)
pa.plot_folded_eclipse(*plot_data, ground_tels, title=title, ylim1=(-0.15,0.45),ylim2=(-0.25,0.25))<jupyter_output><empty_output><jupyter_text>Period Folding $-$ Performing Here we commit to the actual period folding itself. We know from the orbital analysis notebook that the period is limited between 66 days and $\sim$1200 days, so we choose this range, and choose a fine grid to test whether or not the period folding fulfills certain requirements.- percentage of good points > outlier acceptance    - good points lie within x times the error bar    - outlier acceptance percentage is an input value- we require there to be some data folded in    - the number can be tuned<jupyter_code># folding periods in days
Pmin = 66    # min
Pmax = 1200  # max
dP   = 0.002 # step size

# combine
P = np.arange(Pmin, Pmax + dP, dP)
# combining standard parameters
k2_params = (k2_time, k2_mag, k2_error)
ground_params = (ground_times, ground_mags, ground_errors, ground_tels)
# plot parameters
xlim   = None
ylim1  = (-0.15, 0.45)
ylim2  = (-0.25, 0.25)
k2_ind = 12
show   = False

# combine
plot_params = (xlim, ylim1, ylim2, k2_ind, show)
# defining parameters
k2_tl      = 681
k2_tu      = 710
good_pct   = 90
min_points = 5<jupyter_output><empty_output><jupyter_text>Unbinned Photometry sigma = 2.0, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
plot_selection_20 = (k2_tl, k2_tu, 2.0, good_pct, min_points)
full_params_20 = (*k2_params, *ground_params, *plot_selection_20, *plot_params)

# folding and extracting
p_s20 = pa.fold_all(P, *full_params_20)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.5, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
plot_selection_15 = (k2_tl, k2_tu, 1.5, good_pct, min_points)
full_params_15 = (*k2_params, *ground_params, *plot_selection_15, *plot_params)

# folding and extracting
p_s15 = pa.fold_all(p_s20, *full_params_15)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.0, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
plot_selection_10 = (k2_tl, k2_tu, 1.0, good_pct, min_points)
full_params_10 = (*k2_params, *ground_params, *plot_selection_10, *plot_params)

# folding
p_s10 = pa.fold_all(P, *full_params_10)<jupyter_output>text file exists -- done<jupyter_text>Binned Photometry (0.1 day = 2.4 hours) Here we explore the period folding, but also add the fact that the data is binned (0.1 day bins). We bin each telescope (except K2) and then repeat the process above.<jupyter_code>binsize = 0.1
sr_01b = 'plots/period_folding/sigma=%.1f_bs=0.10/'

# set-up lists
binned_times  = []
binned_mags   = []
binned_errors = []

for time, mag, error in zip(ground_times, ground_mags, ground_errors):
    # calculate
    binned_time, binned_mag, binned_error = gv.bin_telescope(time, mag, error, binsize)
    # append
    binned_times.append(binned_time)
    binned_mags.append(binned_mag)
    binned_errors.append(binned_error)

binned_params = (binned_times, binned_mags, binned_errors, ground_tels)<jupyter_output><empty_output><jupyter_text>sigma = 3.0, good_percentage = 90 % and min_points = 5.<jupyter_code>plot_selection_30 = (k2_tl, k2_tu, 3.0, good_pct, min_points)

# combine
full_params_30b = (*k2_params, *binned_params, *plot_selection_30, *plot_params)

# fold and extract
p_s30b = pa.fold_all(P, *full_params_30b, saveroot=sr_01b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 2.0, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
full_params_20b = (*k2_params, *binned_params, *plot_selection_20, *plot_params)

# fold and extract
p_s20b = pa.fold_all(p_s30b, *full_params_20b, saveroot=sr_01b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.5, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
full_params_15b = (*k2_params, *binned_params, *plot_selection_15, *plot_params)

# fold and extract
p_s15b = pa.fold_all(p_s20b, *full_params_15b, saveroot=sr_01b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.0, good_percentage = 90 % and min_points = 5.<jupyter_code># combine
full_params_10b = (*k2_params, *binned_params, *plot_selection_10, *plot_params)

# fold and extract
p_s10b = pa.fold_all(p_s15b, *full_params_10b, saveroot=sr_01b)<jupyter_output>text file exists -- done<jupyter_text>Binned Photometry (0.05 day $\sim$ 1 hours) Here we explore the period folding, but also add the fact that the data is binned (0.05 day bins). We bin each telescope (except K2) and then repeat the process above.<jupyter_code>binsize = 0.05
sr_005b = 'plots/period_folding/sigma=%.1f_bs=0.05/'

# set-up lists
binned_times  = []
binned_mags   = []
binned_errors = []

for time, mag, error in zip(ground_times, ground_mags, ground_errors):
    # calculate
    binned_time, binned_mag, binned_error = gv.bin_telescope(time, mag, error, binsize)
    # append
    binned_times.append(binned_time)
    binned_mags.append(binned_mag)
    binned_errors.append(binned_error)

binned_params = (binned_times, binned_mags, binned_errors, ground_tels)<jupyter_output><empty_output><jupyter_text>sigma = 3.0, good_percentage = 90 % and min_points = 5.<jupyter_code># fold and extract
p_s30b2 = pa.fold_all(P, *full_params_30b, saveroot=sr_005b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 2.0, good_percentage = 90 % and min_points = 5.<jupyter_code># fold and extract
p_s20b2 = pa.fold_all(p_s30b2, *full_params_20b, saveroot=sr_005b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.5, good_percentage = 90 % and min_points = 5.<jupyter_code># fold and extract
p_s15b2 = pa.fold_all(p_s20b2, *full_params_15b, saveroot=sr_005b)<jupyter_output>text file exists -- done<jupyter_text>sigma = 1.0, good_percentage = 90 % and min_points = 5.<jupyter_code># fold
p_s10b2 = pa.fold_all(p_s15b2, *full_params_10b, saveroot=sr_005b)<jupyter_output>text file exists -- done<jupyter_text>Interesting Periods These were discovered by looking through all the plots produced above and then selected by <NAME> and <NAME> (by eye).<jupyter_code>P_int = np.array([[178.050, 201.198, 204.166], [341.792, 343.766, 685.192]])
# plot parameters
grid = (8, 3)

fig = plt.figure(figsize=(16, 10))
for i in range(2):
    for j in range(3):
        pos_phot = (i * 4, j)
        pos_res  = (i * 4 + 1, j)
        ax_phot = plt.subplot2grid(grid, pos_phot, colspan=1, rowspan=3)
        ax_res  = plt.subplot2grid(grid, pos_res, colspan=1, rowspan=1)
        if j == 0:
            ax_phot.<jupyter_output>687.532
{'fraction_non_alphanumeric': 0.10773452586644984, 'fraction_numerical': 0.04675271877223295, 'mean_word_length': 5.142322097378277, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '19', 'dir': 'jupyter-structured-clean-dedup', 'id': '184958', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 3977, 'n_tokens_neox': 3654, 'n_words': 973, 'path': 'period_analysis.ipynb', 'repo_name': 'dmvandam/V928tau', 'size': '9886'}