Remove twilights that form subsequent outliers in length of day or night.
daylengthfilter.RdThis function performs the following steps:
Separate rows of day (type=1)/night(type=2), and calculate length of each day or night
Fill short time gaps with baytrends::fillMissing().
Fill large time gaps assuming polar night or midnight sun: Add 23.5 hrs day/0.5hrs night (midnight sun) or 0.5 hrs day/23.5 hrs night (polar night) for dates without twilights, assuming summer or winter solstice if otherwise quite long (>16hrs) or quite short day (<8hrs) in that period of the year.
Calculate different length in day/night between consecutive dates.
Initial filtering: Endpoints are filtered by comparing day/night lengths to a 20-day mean, to accommodate the often poor data quality due to shading from nest attendance at start and end of logging periods
Main filtering: daily day/night lengths compared to loess predictions of day/night length based on 5 day running means.
Twilights that results in lengths being more than 6hrs, but less than 48 hour different from the previous date removed.
At last, repeat all above steps, but now filter twilights that results in lengths being more than 3hrs, but less than 48 hour different from the previous date removed.