Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette shows how to apply monthly changes into a weather file for climate scenarios.
library(weaana)
The daily weather records are stored in the apsim format.
file <- system.file("extdata/WeatherRecordsDemo1.met", package = "weaana") # Read weather file met <- readWeatherRecords(file) # Get records in data.frame records <- getWeatherRecords(met) # Calculate month from weather records month <- as.numeric(format(records$date, '%m'))
The monthly changes of future climate can be obtained from future climate scenarios.
set.seed(1) # maximum and minimum temperature changes are absolute values tasmax <- (runif(12) - 0.5) * 2 tasmin <- (runif(12) - 0.5) * 2 # rain changes are a ratio pr <- (runif(12) - 0.5) / 10
Add the monthly changes into weather records
new_maxt <- records$maxt + tasmax[month] new_mint <- records$mint + tasmin[month] new_rain <- records$rain * pr[month] changeWeatherRecords(met, maxt = new_maxt) changeWeatherRecords(met, mint = new_mint) changeWeatherRecords(met, rain = new_rain)
Finally the new met file is saved into a new file
writeWeatherRecords(met, "new-file.met")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.