| Title: | Unified Access to the APSIMWISE Ecosystem |
|---|---|
| Description: | Provides a unified interface to R packages supporting the Agricultural Production Systems sIMulator (APSIM), crop modelling, weather analysis, and agricultural decision support. It simplifies installation and loading of related packages and provides consistent user-facing functions across multiple crop types. |
| Authors: | Bangyou Zheng [aut, cre] |
| Maintainer: | Bangyou Zheng <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-13 23:39:43 UTC |
| Source: | https://github.com/cran/apsimwise |
Returns the options manager associated with a crop. The returned object can be used to inspect and modify crop-specific parameters such as thermal time and vernalisation responses.
crop(name)crop(name)
name |
Character string specifying the crop name.
Supported crops include (case-insensitive):
|
An options manager object created by
optree::create_options_manager().
# Get the lentil options manager l <- crop("lentil") # View all options l$get() # Retrieve thermal time parameters l$get("phenology.thermal_time") # Modify an option l$set( "phenology.thermal_time" = list( x = c(0, 25, 35), y = c(0, 25, 0) ) )# Get the lentil options manager l <- crop("lentil") # View all options l$get() # Retrieve thermal time parameters l$get("phenology.thermal_time") # Modify an option l$set( "phenology.thermal_time" = list( x = c(0, 25, 35), y = c(0, 25, 0) ) )
Calculate thermal time for a crop
thermal_time(..., crop)thermal_time(..., crop)
... |
Arguments passed to the selected crop's thermal time function. |
crop |
The crop model to use. Supported crops are |
A vector of thermal time values for the specified crop.
library(apsimwise) # Example weather data mint <- c(0, 10) maxt <- c(30, 40) date <- as.Date(c("2024-01-01", "2024-01-02")) # Use default lupin parameters thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin" ) # Modify the global lupin thermal time response for all following calculations crop("lupin")$set( "phenology.thermal_time" = list( x = c(0, 25, 35), y = c(0, 25, 0) ) ) thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin" ) # Then the parameters can be reset crop("lupin")$reset() # Override thermal time parameters for a single call thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin", x_temp = c(0, 25, 35), y_temp = c(0, 25, 0) ) # Calculate thermal time from a weather file met_file <- system.file("extdata/ppd_72150.met", package = "tidyweather") # Read weather records records <- read_weather(met_file) # Calculate thermal time for lupin using tidyverse ways library(dplyr) records |> mutate( tt = thermal_time( mint = mint, maxt = maxt, date = date, latitude = latitude[1], crop = "lupin" ) ) |> select(name, date, mint, maxt, tt) # Calculate thermal time for lupin grouped by year and site if there are multiple sites # Create some fake data for a second site records2 <- records |> mutate( name = "site2", mint = mint + 1, maxt = maxt + 1, latitude = latitude - 10 ) |> bind_rows(records) # Calculate thermal time for lupin grouped by site records2 |> group_by(name) |> mutate( tt = thermal_time( mint = mint, maxt = maxt, date = date, latitude = latitude[1], crop = "lupin" ) ) |> select(name, date, mint, maxt, tt)library(apsimwise) # Example weather data mint <- c(0, 10) maxt <- c(30, 40) date <- as.Date(c("2024-01-01", "2024-01-02")) # Use default lupin parameters thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin" ) # Modify the global lupin thermal time response for all following calculations crop("lupin")$set( "phenology.thermal_time" = list( x = c(0, 25, 35), y = c(0, 25, 0) ) ) thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin" ) # Then the parameters can be reset crop("lupin")$reset() # Override thermal time parameters for a single call thermal_time( mint, maxt, date = date, lat = -27, crop = "lupin", x_temp = c(0, 25, 35), y_temp = c(0, 25, 0) ) # Calculate thermal time from a weather file met_file <- system.file("extdata/ppd_72150.met", package = "tidyweather") # Read weather records records <- read_weather(met_file) # Calculate thermal time for lupin using tidyverse ways library(dplyr) records |> mutate( tt = thermal_time( mint = mint, maxt = maxt, date = date, latitude = latitude[1], crop = "lupin" ) ) |> select(name, date, mint, maxt, tt) # Calculate thermal time for lupin grouped by year and site if there are multiple sites # Create some fake data for a second site records2 <- records |> mutate( name = "site2", mint = mint + 1, maxt = maxt + 1, latitude = latitude - 10 ) |> bind_rows(records) # Calculate thermal time for lupin grouped by site records2 |> group_by(name) |> mutate( tt = thermal_time( mint = mint, maxt = maxt, date = date, latitude = latitude[1], crop = "lupin" ) ) |> select(name, date, mint, maxt, tt)
Calculate vernalisation days for a crop
vernalisation_days(..., crop)vernalisation_days(..., crop)
... |
Arguments passed to the selected crop's vernalisation days function. |
crop |
The crop model to use. Supported crops are |
A vector of vernalisation days for the specified crop.
mint <- c(0, 10) maxt <- c(30, 40) vernalisation_days(mint, maxt, crop = "lupin")mint <- c(0, 10) maxt <- c(30, 40) vernalisation_days(mint, maxt, crop = "lupin")