<jupyter_start><jupyter_text>Example: rspline, hspline, pspline We create synthetic test data:<jupyter_code>import numpy as np
from wotan import flatten

points = 1000
time = np.linspace(0, 30, points)
flux = 1 + ((np.sin(time) + time / 10 + time**1.5 / 100) / 1000)
noise = np.random.normal(0, 0.0001, points)
flux += noise
for i in range(points):
    if i % 75 == 0:
        flux[i:i+5] -= 0.0004  # Add some transits
        flux[i+50:i+52] += 0.0002  # and flares
flux[300:400] = np.nan  # and a gap<jupyter_output><empty_output><jupyter_text>Run wotan:<jupyter_code>flatten_lc1, trend_lc1 = flatten(
    time,                 # Array of time values
    flux,                 # Array of flux values
    method='rspline',
    window_length=0.5,    # The length of the filter window in units of ``time``
    break_tolerance=0.5,  # Split into segments at breaks longer than that
    return_trend=True,    # Return trend and flattened light curve
    )

flatten_lc2, trend_lc2 = flatten(
    time,                 # Array of time values
    flux,                 # Array of flux values
    method='hspline',
    window_length=0.5,    # The length of the filter window in units of ``time``
    break_tolerance=0.5,  # Split into segments at breaks longer than that
    return_trend=True,    # Return trend and flattened light curve
    )

flatten_lc3, trend_lc3 = flatten(
    time,                 # Array of time values
    flux,                 # Array of flux values
    method='pspline',
                          # No window length! It is automatically selected
    break_tolerance=0.5,  # Split into segments at breaks longer than that
    return_trend=True,    # Return trend and flattened light curve
    )<jupyter_output>Segment 1 of 2
Iteration: 1 Rejected outliers: 11
Iteration: 2 Rejected outliers: 6
Iteration: 3 Rejected outliers: 2
Iteration: 4 Rejected outliers: 0
Converged.
Segment 2 of 2
Iteration: 1 Rejected outliers: 21
Iteration: 2 Rejected outliers: 13
Iteration: 3 Rejected outliers: 4
Iteration: 4 Rejected outliers: 4
Iteration: 5 Rejected outliers: 0
Converged.
Segment 1 of 2
Iteration: 1 Rejected outliers: 6
Iteration: 2 Rejected outliers: 1
Iteration: 3 Rejected outliers: 1
Iteration: 4 Rejected outliers: 4
Iteration: 5 Rejected outliers: 4
Iteration: 6 Rejected outliers: 2
Iteration: 7 Rejected outliers: 2
Iteration: 8 Rejected outliers: 1
Iteration: 9 Rejected outliers: 2
Iteration: 10 Rejected outliers: 1
Segment 2 of 2
Iteration: 1 Rejected outliers: 23
Iteration: 2 Rejected outliers: 14
Iteration: 3 Rejected outliers: 4
Iteration: 4 Rejected outliers: 3
Iteration: 5 Rejected outliers: 1
Iteration: 6 Rejected outliers: 1
Iteration: 7 Rejected outliers: 2
Iteration: 8 Rejected outlie[...]<jupyter_text>Visualize the result:<jupyter_code>import matplotlib.pyplot as plt
from matplotlib import rcParams; rcParams["figure.dpi"] = 150

plt.scatter(time, flux, s=1, color='black')
plt.plot(time, trend_lc1, color='red', linewidth=1)
plt.plot(time, trend_lc2, color='blue', linewidth=1)
plt.plot(time, trend_lc3, color='orange', linewidth=1)
plt.show();
plt.close()

plt.scatter(time, flux, s=1, color='black')
plt.plot(time, trend_lc1, color='red', linewidth=1, label='rspline')
plt.plot(time, trend_lc2, color='blue', linewidth=1, label='hspline')
plt.plot(time, trend_lc3, color='orange', linewidth=1, label='pspline')
plt.xlim(5, 9)
plt.ylim(0.9995, 1.0022)
plt.legend()
plt.show();
plt.close()

plt.scatter(time, flatten_lc1, s=1, color='black');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10417258018734034, 'fraction_numerical': 0.046267385750780585, 'mean_word_length': 3.8944444444444444, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '587928', 'license': 'MIT', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1165, 'n_words': 388, 'path': 'examples/splines.ipynb', 'repo_name': 'danielrios12/Wotan---filtro-de-dados', 'size': '3523'}