knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.align = "center", fig.asp = 0.618, fig.width = 5, out.width = "70%", fig.retina = 3 )
library(tidyverse) library(cropsyst)
The constructor function cs_setup()
is used to initialize an empty cropsyst model object to which additional model parameters can be added using the following functions:
cs_add_weather()
cs_add_soil()
cs_add_canopy_cover()
cs_add_crop()
cs_add_irrigation()
(optional)Daily weather data is required and shouild be inlcuded as a data frame and follow the naming format below.
Input weather data should be at a continuous daily time scale and contain the following columns
An example dataset cs_weather
is provided with cropsyst and is shown below:
head(cs_weather)
Soil data should contain the following columns
An example dataset cs_soil
is provided with cropsyst and is shown below:
head(cs_soil)
An example dataset cs_canopy_cover
is provided with cropsyst and is shown below:
head(cs_canopy_cover)
Cropsyst simulations are able to use 3 irrigation scenarios
An example dataset cs_irrigation
is provided with cropsyst and is shown below:
head(cs_irrigation)
cs_input <- cs_setup() %>% cs_add_weather(weather = cs_weather, latitude = 35.2, elevation = 1170, screening_height = 2) %>% cs_add_soil(soil = cs_soil, thickness_evaporative_layer = 0.005) %>% cs_add_canopy_cover(cs_canopy_cover) %>% cs_add_irrigation(cs_irrigation, irrigated_fraction = 0.0001) %>% cs_add_crop(planting_date = ydoy(2016, 131), season_end_date = ydoy(2016, 131+156-1), midseason_et_crop_coef = 1.15, tree_fruit = FALSE, fruit_harvest_date = ydoy(2016, 131+153), max_crop_height = 2, max_root_depth = 2, perrenial = FALSE, max_water_uptake = 14, transpiration_use_eff = 7, C3 = FALSE)
cs_out <- cs_input %>% cs_run()
The model output maintains the form of the model input with weather, irr_soil, and non_irr_soil as data frames and params as a list of model input parameters.
names(cs_out)
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = potential_crop_et))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = et_crop_coef))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = -root_depth, color = "Root Depth")) + geom_line(aes(x = dap, y = crop_height, color = "Crop Height")) + labs(x = "Days after planting", y = "Height (m)")
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = potential_biomass_prod, color = "potential")) + geom_line(aes(x = dap, y = biomass_production, color = "actual")) cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = cum_biomass_production))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = attainable_transpiration, color = "Attainable")) + geom_line(aes(x = dap, y = potential_transpiration, color = "Potential")) + geom_line(aes(x = dap, y = actual_transpiration, color = "Actual"))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = attainable_soil_water_evaporation, color = "Attainable")) + geom_line(aes(x = dap, y = irr_zone_soil_water_evap, color = "Irrigated")) + geom_line(aes(x = dap, y = non_irr_zone_soil_water_evap, color = "Non-Irrigated"))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = leaf_water_potential))
cs_out$weather %>% ggplot() + geom_line(aes(x = dap, y = actual_evapotranspiration))
s
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.