Learn R Programming

embryogrowth (version 5.1)

temperature.periodic: Estimate temperatures in periodic timeseries based on anchored minimum and maximum

Description

Estimate temperatures in periodic timeseries based on anchored minimum and maximum. The data.frame minmax can be generated manually. It should have two columns, one time and one temperature with all the successive minimum and maximum temperatures.

Usage

temperature.periodic(minmax, time = NULL, replicates = 100)

Arguments

minmax
A data.frame returned by minmax.periodic
time
The time at which produced the estimate
replicates
Number of replicates to estimate sd

Value

  • A data.frame with a column time and a column temperature

Details

temperature.periodic estimate temperatures in periodic timeseries based on anchored minimum and maximum

Examples

Run this code
# Generate a timeserie of time
time.obs <- NULL
for (i in 0:9) time.obs <- c(time.obs, c(0, 6, 12, 18)+i*24)
# For these time, generate a timeseries of temperatures
temp.obs <- rep(NA, length(time.obs))
temp.obs[3+(0:9)*4] <- rnorm(10, 25, 3)
temp.obs[1+(0:9)*4] <- rnorm(10, 10, 3)
for (i in 1:(length(time.obs)-1))
  if (is.na(temp.obs[i]))
  temp.obs[i] <- mean(c(temp.obs[i-1], temp.obs[i+1]))
  if (is.na(temp.obs[length(time.obs)]))
  temp.obs[length(time.obs)] <- temp.obs[length(time.obs)-1]/2

# Search for the minimum and maximum values
r <- minmax.periodic(time.minmax.daily=c(Min=2, Max=15),
time.obs=time.obs, temp.obs=temp.obs, period=24)

# Estimate all the temperatures for these values
t <- temperature.periodic(minmax=r)

plot_errbar(x=t[,"time"], y=t[,"temperature"],
errbar.y=ifelse(is.na(t[,"sd"]), 0, 2*t[,"sd"]),
type="l", las=1, bty="n", errbar.y.polygon = TRUE,
xlab="hours", ylab="Temperatures", ylim=c(0, 35),
errbar.y.polygon.list = list(col="grey"))

plot_add(x=t[,"time"], y=t[,"temperature"], type="l")

Run the code above in your browser using DataLab