Environmental analysis of crop trialsusing weather data<br />Jacob van Etten<br />
weatherData<br />This package helps us to:<br />1. Get data from weather stations<br />2. Interpolate weather data for any...
Get the packages<br />install.packages("weatherData", repos="http://R-Forge.R-project.org")<br />library(weatherData)<br /...
Get additional packages<br />install.packages(c(“maps”, “vegan”, “reshape”))<br />library(maps)<br />library(vegan)<br />l...
Get the script<br />http://dl.dropbox.com/u/18619554/maizeCA.R<br />http://goo.gl/Y6h7m<br />
Get the data<br />We will use the Global Summary of Day (GSOD) data of NCDC.<br />ftp://ftp.ncdc.noaa.gov/pub/data/gsod/<b...
Selecting stations first<br />Select stations within a geographic extent<br />data(stations)<br />locsExtent <-c(0,20,40,6...
Download the data<br />Make a working directory first.<br />setwd(“yourFolder”)<br />Now download the files to this workin...
Read the data into R<br />Copy the data we have provided you into “yourFolder”.<br />The following lines will make a table...
Getting some trial data<br />The idea is to link weather data to crop trial data.<br />We get some trial data that was inc...
Make a quick map<br />stationsSelected <- stationsExtent(c(-110,-60,5,25), stations)<br />plot(stationsSelected[c("LON","L...
Interpolation<br />We have already seen interpolation at work.<br />Now we use interpolation to estimate weather variables...
Interpolate<br />Interpolate weather for the years 2003, 2004 and 2005.<br />ipW2003 <- interpolateDailyWeather(<br />tabl...
Duration of T > 30 °C =<br />4.8 h<br />Minimum is assumed to be at sunrise.<br />Maximum is assumed to be 2 h after solar...
Derive ecophysiologicalvars<br />?thermalStressDaily<br />Run the example to see how this works.<br />Then:<br />TEMPSTRES...
Do RDA on residuals<br />Instead of a normal PCA, we constrain the axes of the PCA with linear combinations of the ecophys...
Do ANOVA<br />m <-  lm(Yield ~ Variety + Location + Plant.m2, data=tr2005) <br />G + GxE are left over, the rest is filter...
Make table ready for RDA<br />tr2005 <- melt(tr2005)<br />tr2005 <- acast(tr2005, Location ~ Variety)<br />env2005 <- tria...
RDA<br />rda2005 <- rda(tr2005, env2005)<br />summary(rda2005)<br />plot(rda2005)<br />
Putting GxE on map<br />It is possible to use the resulting RDA model to predict for any locations.<br />The steps would b...
Final remarks<br />Trial data are often noisy – extracting the signal from the data is the objective<br />Many environment...
Upcoming SlideShare
Loading in …5
×

Environmental analysis of crop trials - Van Etten

660
-1

Published on

Presentation by Jacob van Etten.

CCAFS workshop titled "Using Climate Scenarios and Analogues for Designing Adaptation Strategies in Agriculture," 19-23 September in Kathmandu, Nepal.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
660
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Environmental analysis of crop trials - Van Etten

  1. 1. Environmental analysis of crop trialsusing weather data<br />Jacob van Etten<br />
  2. 2. weatherData<br />This package helps us to:<br />1. Get data from weather stations<br />2. Interpolate weather data for any location<br />
  3. 3. Get the packages<br />install.packages("weatherData", repos="http://R-Forge.R-project.org")<br />library(weatherData)<br />install.packages(“cropData", repos="http://R-<br />Forge.R-project.org")<br />library(cropData)<br />OR:<br />http://dl.dropbox.com/u/18619554/cropData_1.0.zip<br />http://dl.dropbox.com/u/18619554/weatherData_1.0.zip<br />
  4. 4. Get additional packages<br />install.packages(c(“maps”, “vegan”, “reshape”))<br />library(maps)<br />library(vegan)<br />library(reshape)<br />
  5. 5. Get the script<br />http://dl.dropbox.com/u/18619554/maizeCA.R<br />http://goo.gl/Y6h7m<br />
  6. 6. Get the data<br />We will use the Global Summary of Day (GSOD) data of NCDC.<br />ftp://ftp.ncdc.noaa.gov/pub/data/gsod/<br />Downloading takes a lot of time.<br />However, we can selectively download part of the data, in an automatic way.<br />We will show how to do it with a toy example.<br />Then we will use data from disk to continue.<br />
  7. 7. Selecting stations first<br />Select stations within a geographic extent<br />data(stations)<br />locsExtent <-c(0,20,40,60)<br />stationsSelected <- stationsExtent(locsExtent, stations)<br />Show on a map<br />plot(stationsSelected[c("LON","LAT")], pch=3, cex=.5)<br />library(maps)<br />map("world",add=TRUE, interior=F)<br />
  8. 8. Download the data<br />Make a working directory first.<br />setwd(“yourFolder”)<br />Now download the files to this working directory.<br />downloadGSOD(2010, 2010, stations = stationsSelected, silent = FALSE, tries = 2, overwrite = FALSE) <br />After a few downloads, kill the process by pressing “Esc”.<br />Inspect what you have in “yourFolder” and delete the downloaded files.<br />
  9. 9. Read the data into R<br />Copy the data we have provided you into “yourFolder”.<br />The following lines will make a table and remove missing observations.<br />weather <- makeTableGSOD() <br />weather <- na.omit(weather)<br />fix(weather)<br />
  10. 10. Getting some trial data<br />The idea is to link weather data to crop trial data.<br />We get some trial data that was incorporated in the package.<br />trial <- read.csv(system.file("external/trialsCA.csv", package="cropData"))<br />locs <- read.csv(system.file("external/locationsCA.csv", package="cropData"))<br />
  11. 11. Make a quick map<br />stationsSelected <- stationsExtent(c(-110,-60,5,25), stations)<br />plot(stationsSelected[c("LON","LAT")], pch=3, cex=.5)<br />points(locs[c("LON","LAT")], pch=15)<br />map("world",add=TRUE, interior=F)<br />
  12. 12. Interpolation<br />We have already seen interpolation at work.<br />Now we use interpolation to estimate weather variables for the trial locations.<br />The function interpolateDailyWeather() automatically interpolates the weather surface for each day and extracts the values for each trial location.<br />
  13. 13. Interpolate<br />Interpolate weather for the years 2003, 2004 and 2005.<br />ipW2003 <- interpolateDailyWeather(<br />tableGSOD = weatherCA, <br />locations = locs[c("ID", "LON", "LAT", "ALT")], <br />startDate="2003-5-15", <br />endDate="2003-9-25", <br />stations = stationsSelected)<br />Repeat for the other years and then combine:<br />ipW <- rbind(ipW2003,ipW2004,ipW2005)<br />
  14. 14. Duration of T > 30 °C =<br />4.8 h<br />Minimum is assumed to be at sunrise.<br />Maximum is assumed to be 2 h after solar noon.<br />Thermal stress<br />Temperature (°C)<br />Time<br />
  15. 15. Derive ecophysiologicalvars<br />?thermalStressDaily<br />Run the example to see how this works.<br />Then:<br />TEMPSTRESS30 <- thermalStressSeasonal(30, ipW, trial, locs)<br />PREC <- precipitationSeasonal(ipW, trial)<br />RADIATION <- radiationSeasonal(ipW, trial, locs)<br />trial <- cbind(trial, TEMPSTRESS30, PREC, RADIATION)<br />
  16. 16. Do RDA on residuals<br />Instead of a normal PCA, we constrain the axes of the PCA with linear combinations of the ecophysiological variables.<br />This type of constrained PCA is called redundancy analysis (RDA)<br />
  17. 17. Do ANOVA<br />m <- lm(Yield ~ Variety + Location + Plant.m2, data=tr2005) <br />G + GxE are left over, the rest is filtered out<br />tr2005$Yield <- residuals(m)<br />tr2005 <- tr2005[,c("Variety","Location","Yield")]<br />
  18. 18. Make table ready for RDA<br />tr2005 <- melt(tr2005)<br />tr2005 <- acast(tr2005, Location ~ Variety)<br />env2005 <- trial[trial$Year == 2005, c("Location", "TEMPSTRESS30", "PRECSUM", "PRECCV", "RADIATION")]<br />env2005 <- unique(env2005)<br />rownames(env2005) <- env2005$Location<br />env2005 <- env2005[,-1]<br />
  19. 19. RDA<br />rda2005 <- rda(tr2005, env2005)<br />summary(rda2005)<br />plot(rda2005)<br />
  20. 20. Putting GxE on map<br />It is possible to use the resulting RDA model to predict for any locations.<br />The steps would be:<br />Interpolate weather variables for new location<br />Derive ecophysiological variables<br />Predict yield value for this new location (not taking into account additive environmental effect)<br />
  21. 21. Final remarks<br />Trial data are often noisy – extracting the signal from the data is the objective<br />Many environmental variables are difficult to measure, but can be taken to be “random” in the analysis<br />Many statistical tools exist to link weather data to crop trial data. <br />

×