View source: R/add_time_to_weather_data.R
| add_time_to_weather_data | R Documentation |
Ensure, if possible, that input data that varies over time has a "time"
component. See the documentation for time for more information
about this quantity.
It is rare for users to call this function directly because it is called
internally by run_biocro.
add_time_to_weather_data(drivers)
drivers |
A list or dataframe representing known system parameters that vary over time, such as weather data. |
If drivers has doy and hour columns, then it is assumed
to represent weather data, and will be modified as follows:
A new time column will be computed from doy and
hour.
The original doy and hour columns will be removed.
In this case, it is expected that the BioCro:format_time direct module
will be used to re-compute doy and hour from time.
If drivers does not have doy and hour columns, then
drivers will be returned as-is.
Preconditions:
If drivers is a list, the values should be vectors of equal
length.
If drivers already contains a time component, then it
shouldn't contain either a doy or an hour component
unless it contains both of them and the values are mutually
consistent.
Why is the 'BioCro:format_time' module necessary?
If values of doy and hour are supplied to run_biocro in
the drivers, undesired results may happen during interpolation. For example,
if two sequential rows have (time = 3599, doy = 150, hour = 23) and
(time = 3600, doy = 151, hour = 0), and the results are to be returned
at half-hour time intervals, then linear interpolation between these rows
would produce (time = 3599.5, doy = 150.5, hour = 11.5). Typically it
is expected that doy takes only integer values, so this may cause
issues. Using the BioCro:format_time module to calculate doy and
hour from time will ensure that the result includes
(time = 3599.5, doy = 150, hour = 23.5) instead.
# Add a time column to the buit-in 2002 weather data
new_weather <- add_time_to_weather_data(weather[['2002']])
# Compare column names
colnames(weather[['2002']])
colnames(new_weather)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.