import math


def to_window_length_for_2min_cadence(length_day):
    """Helper for LightCurve.flatten().
    Return a `window_length` for the given number of days, assuming the data has 2-minute cadence."""
    res = math.floor(720 * length_day)
    if res % 2 == 0:
        res += 1  # savgol_filter window length must be odd number
    return res