Learn R Programming

PWFSLSmoke (version 1.0.20)

timeInfo: Get Time Related Information

Description

Calculate the local time at the target location, sunrise, sunset and solar noon times, and create several temporal masks.

If the timezone is provided it will be used. Otherwise, the MazamaSpatialUtils package will be used to determine the timezone from longitude and latitude.

The returned dataframe will have as many rows as the length of the incoming UTC time vector and will contain the following columns:

  • localTime -- local clock time

  • sunrise -- time of sunrise on each localTime day

  • sunset -- time of sunset on each localTime day

  • solarnoon -- time of solar noon on each localTime day

  • day -- logical mask = TRUE between sunrise and sunset

  • morning -- logical mask = TRUE between sunrise and solarnoon

  • afternoon -- logical mask = TRUE between solarnoon and sunset

  • night -- logical mask = opposite of day

Usage

timeInfo(time, longitude = NULL, latitude = NULL, timezone = NULL)

Arguments

time

POSIXct vector with specified timezone

longitude

longitude of the location of interest

latitude

latitude of the location of interest

timezone

Olson timezone at the location of interest

Value

A dataframe with times and masks.

Examples

Run this code
# NOT RUN {
carmel <- monitor_subset(Carmel_Valley, tlim=c(20160801,20160810))

# Create timeInfo object for this monitor
ti <- timeInfo(carmel$data$datetime,
               carmel$meta$longitude,
               carmel$meta$latitude,
               carmel$meta$timezone)

# Subset the data based on day/night masks
data_day <- carmel$data[ti$day,]
data_night <- carmel$data[ti$night,]

# Build two monitor objects
carmel_day <- list(meta=carmel$meta, data=data_day)
carmel_night <- list(meta=carmel$meta, data=data_night)

# Plot them
monitorPlot_timeseries(carmel_day, shadedNight=TRUE, pch=8, col='goldenrod')
monitorPlot_timeseries(carmel_night, pch=16, col='darkblue', add=TRUE)
# }

Run the code above in your browser using DataLab