Period matching#
For a list of times t0s, nighshift can help find the optimal period matching these events
Data simulation#
We simulate a list of times and only pick few of them to represent a sparse observation of a certain event (such as an exoplanet transit)
import numpy as np
true_period = 1.23400
np.random.seed(42)
t0s = np.random.choice(np.arange(50)*true_period, size=6)
print(t0s)
[46.892 34.552 17.276 51.828 8.638 24.68 ]
Finding optimal period#
We can then try to match these events with a range of periods
from nightshift import period_match
periods = np.linspace(0.2, 5, 1000000)
match, best = period_match(t0s, periods)
And plot the results
import matplotlib.pyplot as plt
plt.subplot(111, xlabel="periods", ylabel="match")
plt.axvline(true_period, c="k", alpha=0.3, label="true_period")
plt.plot(periods, match)
plt.legend()
print(f"true: {true_period:.4f}\nfound: {best:.4f}")
true: 1.2340
found: 1.2340