Learn R Programming

GeoLight (version 2.0.0)

lightFilter: Filter to remove noise in light intensity measurements during the night

Description

The filter identifies and removes light intensities oczillating around the baseline or few light intensities resulting in a short light peak during the night. Such noise during the night will increase the calculated twilight events using the function twilightCalc and therewith the manual work to remove these false twilight events.

Usage

lightFilter(light, baseline = NULL, iter = 2)

Arguments

light
numerical value of the light intensity (usually arbitrary units).
baseline
the light intensity baseline (no light). If Default, it will be calculated as the most frequent value below the mean light intensities.
iter
a numerical value, specifying how many iterations should be computed (see details).

Value

numerical vector with the new light levels. Same length as the initial light vector.

Details

The filter searches for light levels above the baseline and compares the prior and posterior levels. If these values are below the threshold the particular light level will be reduced to the baseline. A few (usually two) iterations might be enough to remove most noise during the night (however, not if such noise occurs at the begining or at the end were not enough prior or posterior values are available).

Examples

Run this code
night <- rep(0,50); night[runif(4,0,50)] <- 10; night[runif(4,0,50)] <- -5
nightday <- c(night,rep(30,50))
plot(nightday,type="l",ylim=c(-5,30),ylab="light level",xlab="time (time)")
light2 <- lightFilter(nightday, baseline=0, iter=4)
lines(light2,col="red")
legend("bottomright",c("before","after"),lty=c(1,1),col=c("black","red"),bty="n")

Run the code above in your browser using DataLab