# sunTime: Convert clock times to sun times In overlap: Estimates of Coefficient of Overlapping for Animal Activity Patterns

## Description

Converts a vector of clock times to "sun times", by mapping sunrise to π/2 and sunset to 3π/2. Sunrise and sunset times are determined based on the dates and locations provided. See Nouvellet et al (2012) for a discussion. Requires the maptools package.

## Usage

 `1` ```sunTime(clockTime, Dates, Coords) ```

## Arguments

 `clockTime` a vector of times of observations in radians, ie. scaled to [0, 2π]. `Dates` a POSIXct object with the dates of the observations; the time zone must be set to the time zone used for 'clockTime'. `Coords` a SpatialPoints object with the locations of the observations, or with a single point giving a approximate location for the study area; the coordinates must be geographical coordinates, eg, WGS84, with long before lat.

## Value

Returns a vector of "sun times" in radians, where π/2 corresponds to sunrise and 3π/2 to sunset.

Mike Meredith.

## References

Nouvellet et al (2012) Noisy clocks and silent sunrises: measurement methods of daily activity pattern. Journal of Zoology 286:179-184.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```# Check that sp and maptools packages are installed if(requireNamespace("sp") && requireNamespace("maptools")) { # Get example data: data(simCalls) str(simCalls) # Convert dates to a POSIXct object with the right time zone (GMT): Dates <- as.POSIXct(simCalls\$dates, tz="GMT") # Create a SpatialPoints object with the location coords <- matrix(c(-3, 56), nrow=1) Coords <- sp::SpatialPoints(coords, proj4string=sp::CRS("+proj=longlat +datum=WGS84")) st <- sunTime(simCalls\$time, Dates, Coords) par(mfrow=2:1) densityPlot(st, col='red', lwd=2, xaxt='n', main="Sun time") axis(1, at=c(0, 6, 12, 18, 24), labels=c("midnight", "sunrise", "noon", "sunset", "midnight")) densityPlot(simCalls\$time, lwd=2, main="Clock time") par(mfrow=c(1,1)) } ```

### Example output

```Loading required namespace: sp