<jupyter_start><jupyter_text>This notebook reproduces the Lomb periodogram for paper A possible dynamically Cold Classical contact binary: (126719) 2002 CC249, Thirouin & Sheppard<jupyter_code>%matplotlib inline 
%run functions.py

def plotMagDeltas(observations):
    xs = [pd.to_datetime(d) for d in observations.when]

    plt.rcParams['figure.figsize'] = (15, 5);
    plt.scatter(xs, observations.magDelta);
    plt.xlim(xs[0], xs[len(xs) - 1]);
    plt.gca().invert_yaxis();
    


data = pd.read_csv('Thirouin et al.csv')

def timeFromJD(t):
    return Time(t, format='jd')

data['time'] = data.JD.apply(timeFromJD)
data['when'] = data.apply(lambda row: row.time.datetime.strftime('%Y-%b-%d %H:%M:%S'), axis=1)
data['timestamp'] = data.apply(lambda row: row.time.jd, axis=1)

plotMagDeltas(data)
from astropy.stats import LombScargle
import astropy.units as u

def naiveLombScargle(observations):
    a = observations.timestamp.values
    startTimestamp = a[0] #datetime.fromtimestamp(a[0])
    #a = [((datetime.fromtimestamp(x)-startTimestamp).total_seconds() / 3600) for x in a]
    a = a - a[0]
    #a = a * u.hour
    #a = a * u.day
    b = observations.magDelta.values
    freq, power = LombScargle(a, b).autopower(nyquist_factor=100)

    plt.rcParams['figure.figsize'] = (15, 5);
    plt.figure();
    plt.plot(1/freq, power);
    plt.xlim(0,2);

    best_frequency = freq[np.argmax(power)]

    print('Best frequency (cycles per day) = ', best_frequency)
    print('Best period (hours) = ', (1/best_frequency) * 24)
    
    #t_fit = np.linspace(0*u.hour,1000*u.hour)
    #y_fit = LombScargle(a, b).model(t_fit, best_frequency)
    
    #plt.plot(y_fit);
relevantObservations = data
#relevantObservations = data.loc[data['when'] > '2016']

naiveLombScargle(relevantObservations)<jupyter_output>Best frequency (cycles per day) =  4.04275207269
Best period (hours) =  5.93655004524
{'fraction_non_alphanumeric': 0.15108293713681986, 'fraction_numerical': 0.03803486529318542, 'mean_word_length': 4.30532212885154, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '128255', 'license': 'Unlicense', 'n_tokens_mistral': 763, 'n_tokens_neox': 692, 'n_words': 142, 'path': 'Thirouin et al.ipynb', 'repo_name': 'sharponlooker/A2017U1', 'size': '1893'}