Learn R Programming

bioRad (version 0.5.1)

check_night: Check if it is night at a given time and place

Description

Checks if it is night (TRUE/FALSE) for a combination of latitude, longitude, date and sun elevation. When used on a bioRad object (pvol, vp, vpts) this information is extracted from the bioRad object directly.

Usage

check_night(x, ..., elev = -0.268)

# S3 method for default check_night(x, lon, lat, ..., tz = "UTC", elev = -0.268)

# S3 method for vp check_night(x, ..., elev = -0.268)

# S3 method for list check_night(x, ..., elev = -0.268)

# S3 method for vpts check_night(x, ..., elev = -0.268)

# S3 method for pvol check_night(x, ..., elev = -0.268)

Arguments

x

pvol, vp or vpts, or a date inheriting from class POSIXct or a string interpretable by as.POSIXct.

...

optional lat,lon arguments.

elev

numeric. Sun elevation in degrees.

lon

numeric. Longitude in decimal degrees.

lat

numeric. Latitude in decimal degrees.

tz

character. Time zone. Ignored when date already has an associated time zone

Value

TRUE when night, FALSE when day, NA if unknown (either datetime or geographic location missing). For vpts a vector of TRUE/FALSE values is returned.

Details

The angular diameter of the sun is about 0.536 degrees, therefore the moment of sunrise/sunset corresponds to half that elevation at -0.268 degrees.

check_night() evaluates to FALSE when the sun has a higher elevation than parameter elev, otherwise TRUE.

Approximate astronomical formula are used, therefore the day/night transition may be off by a few minutes.

Examples

Run this code
# NOT RUN {
# check if it is night at UTC midnight in the Netherlands on January 1st:
check_night("2016-01-01 00:00", 5, 53)

# check on bioRad objects directly:
check_night(example_vp)

check_night(example_vpts)
# }

Run the code above in your browser using DataLab