Last active
July 27, 2022 23:44
-
-
Save juanchiem/46f3a047b2bb13287f182b58ad4c4c35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# devtools::install_github('byzheng/weaana') | |
library(weaana) | |
file <- system.file("extdata/WeatherRecordsDemo1.met", package = "weaana") | |
# Read weather file - met file | |
met <- readWeatherRecords(file) | |
x_temp <- c(0, 26, 34) | |
y_temp <- c(0, 26, 0) | |
res <- thermalTime(met, x_temp, y_temp) | |
head(res) | |
# Get records in data.frame | |
records <- getWeatherRecords(met) | |
# Define of growth stages | |
# S0: From start of year to emergence | |
# S1: From emergence to flowering time - 300Cd | |
# S2: From flowering time - 300Cd to flowering time + 100Cd | |
# S3: From flowering time + 100 Cd to flowering time + 600Cd | |
# S4: From flowering + 600Cd to maturity | |
head(records) | |
res1 <- climate_by_stages( | |
climates = records, | |
sowing = as.Date("1981-05-01"), | |
emergence = rep(10, 10), | |
heading = NULL, | |
flowering = runif(10) * 20 + 50, | |
maturity = runif(10) * 20 + 100, | |
latitude = -27) |> | |
mutate_at(vars(stage), as.numeric) | |
head(res1) | |
View(res1) | |
res1 <- within(res1, crop <- cumsum(stage == 0)) | |
res1 |> select(crop, everything()) | |
res1 |> | |
ggplot()+ | |
aes(x=stage, y=sum.rain, col=factor(crop), group=factor(crop))+ | |
geom_point() + | |
geom_line() | |
# Climate variables | |
# stage: defination of stages | |
# n: Number of days in each stage | |
# avgt: average temperature (C) | |
# sum.tt: total thermal time (Cd) with base temperature 0C | |
# avg.mint: average minimum temperature | |
# avg.maxt: average maximum temperature | |
# sum.rain: total rainfall | |
# avg.evap: average evapration | |
# avg.radn average radiation | |
# hot.days: number of hot days (daily maximum temperature is more than 30C) | |
# very.hot.days: number of very hot days (daily maximum temperature is more than 35C) | |
# frost.days: number of frost days (daily minimum temperature is less than 0C) | |
# hot.sum: total thermal time above 30C of hot days (daily maximum temperature is more than 30C) | |
# very.hot.sum: total thermal time above 35C of very hot days (daily maximum temperature is more than 35C) | |
# frost.sum: total thermal time below 0C of frost days (daily minimum temperature is less than 0C) | |
# vpd: vapour-pressure deficit | |
# te: transpiration efficiency | |
# bio.radn: bio.radn | |
# bio.water: bio.water | |
# bio.tt: bio.tt | |
# ptq: photothermal quotient | |
# avt.diffuse.radn: average diffuse radiation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment