View source: R/compute_field_photoperiod.R
compute_field_photoperiod | R Documentation |
This function computes photoperiod as an environmental field across an spatial mesh.
compute_field_photoperiod( date, nodexy, interval = c("dawn", "dusk"), units = "hours" )
date |
A vector of dates (see |
nodexy |
A dataframe containing decimal coordinates (in latitude/longitude) at which photoperiod is calculated. The dataframe should have two columns: 'x' and 'y'. See |
interval |
A character vector with two elements which define the specific sunrise and sunset phases (in that order) between which photoperiod is calculated. This is passed to the |
units |
A character input which defines the units of the time difference. This is passed to |
At specified locations (taken from nodexy
) and on specified dates (taken from date
), photoperiod is calculated as the number of time units (e.g. hours) between two discrete sunlight times (e.g. dawn and dusk), defined by the user and calculated by getSunlightTimes
. For very long sequences of dates/locations, the function may take several minutes.
Unlike other compute_field_*()
functions, photoperiod is only defined on each day (not for each hour of the day). Therefore, rather than returning an array, the function returns a dataframe with the date ('date'), the location ('lat' and 'lon'), the times of the user-specified interval (e.g., 'dawn' and 'dusk') and the photoperiod ('photoperiod') in user-specified units. The dataframe is ordered by date.
Edward Lavender
#### Example (1): Compute photoperiod as the number of hours between dawn and dusk: field_photoperiod <- compute_field_photoperiod(date = as.Date(c("2016-03-01", "2016-03-02")), nodexy = dat_nodexy, interval = c("dawn", "dusk"), units = "hours") utils::head(field_photoperiod) #### Example (2): Compute photoperiod as the number of days between dawn and dusk field_photoperiod <- compute_field_photoperiod(date = as.Date(c("2016-03-01", "2016-03-02")), nodexy = dat_nodexy, interval = c("dawn", "dusk"), units = "days") utils::head(field_photoperiod) #### Example (3): Compute photoperiod as the number of days between sunrise and sunset: field_photoperiod <- compute_field_photoperiod(date = as.Date(c("2016-03-01", "2016-03-02")), nodexy = dat_nodexy, interval = c("sunrise", "sunset"), units = "days") utils::head(field_photoperiod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.