def onset_by_rain(date, df, window=5, rain_threshold=5):
    """
    Finds true storm onset by finding the first date around the landfall that rain exceeds a threshold

    Args:
        date: the date to look around
        df: df with a date and rain column
        window: number of days around date to find max (total window size is window*2)
        rain_threshold: mm of rain to consider a storm to have started

    Returns:
        a datetime object and the corresponding index

    """
    mask = df['Date'] == date
    storm_row = df[mask]
    storm_ind = int(storm_row.index[0])

    sub_df = df.iloc[(storm_ind - window):(storm_ind + window)]

    if sub_df.Rain.dropna().empty:  # if there's no rain data
        return date, storm_ind

    ind = sub_df.Rain.idxmax()
    val = df.Rain.iloc[ind]
    while val > rain_threshold:
        ind -= 1
        val = df.Rain.iloc[ind]

    # ind += 1
    return df['Date'].iloc[ind], ind