Analysis crop trials using climate data

21
Environmental analysis of crop trials using weather data Jacob van Etten Alberto Labarga

Transcript of Analysis crop trials using climate data

Page 1: Analysis crop trials using climate data

Environmental analysis of crop trials using weather data

Jacob van Etten Alberto Labarga

Page 2: Analysis crop trials using climate data

weatherData

This package helps us to: 1. Get data from weather stations 2. Interpolate weather data for any location

Page 3: Analysis crop trials using climate data

Get the packages

install.packages("weatherData", repos="http://R-Forge.R-project.org") library(weatherData) install.packages(“cropData", repos="http://R- Forge.R-project.org") library(cropData) OR: http://dl.dropbox.com/u/18619554/cropData_1.0.zip http://dl.dropbox.com/u/18619554/weatherData_1.0.zip

Page 4: Analysis crop trials using climate data

Get additional packages

install.packages(c(“maps”, “vegan”, “reshape”)) library(maps) library(vegan) library(reshape)

Page 5: Analysis crop trials using climate data

Get the script

http://dl.dropbox.com/u/18619554/maizeCA.R http://goo.gl/Y6h7m

Page 6: Analysis crop trials using climate data

Get the data

We will use the Global Summary of Day (GSOD) data of NCDC. ftp://ftp.ncdc.noaa.gov/pub/data/gsod/ Downloading takes a lot of time. However, we can selectively download part of the data, in an automatic way. We will show how to do it with a toy example. Then we will use data from disk to continue.

Page 7: Analysis crop trials using climate data

Selecting stations first

Select stations within a geographic extent data(stations) locsExtent <-c(0,20,40,60) stationsSelected <- stationsExtent(locsExtent, stations) Show on a map plot(stationsSelected[c("LON","LAT")], pch=3, cex=.5) library(maps) map("world",add=TRUE, interior=F)

Page 8: Analysis crop trials using climate data

Download the data Make a working directory first. setwd(“yourFolder”) Now download the files to this working directory. downloadGSOD(2010, 2010, stations = stationsSelected, silent = FALSE, tries = 2, overwrite = FALSE) After a few downloads, kill the process by pressing “Esc”. Inspect what you have in “yourFolder” and delete the downloaded files.

Page 9: Analysis crop trials using climate data

Read the data into R

Copy the data we have provided you into “yourFolder”. The following lines will make a table and remove missing observations. weather <- makeTableGSOD() weather <- na.omit(weather) fix(weather)

Page 10: Analysis crop trials using climate data

Getting some trial data

The idea is to link weather data to crop trial data. We get some trial data that was incorporated in the package. trial <- read.csv(system.file("external/trialsCA.csv", package="cropData")) locs <- read.csv(system.file("external/locationsCA.csv", package="cropData"))

Page 11: Analysis crop trials using climate data

Make a quick map

stationsSelected <- stationsExtent(c(-110,-60,5,25), stations) plot(stationsSelected[c("LON","LAT")], pch=3, cex=.5) points(locs[c("LON","LAT")], pch=15) map("world",add=TRUE, interior=F)

Page 12: Analysis crop trials using climate data

Interpolation

We have already seen interpolation at work. Now we use interpolation to estimate weather variables for the trial locations. The function interpolateDailyWeather() automatically interpolates the weather surface for each day and extracts the values for each trial location.

Page 13: Analysis crop trials using climate data

Interpolate

Interpolate weather for the years 2003, 2004 and 2005. ipW2003 <- interpolateDailyWeather( tableGSOD = weatherCA, locations = locs[c("ID", "LON", "LAT", "ALT")], startDate="2003-5-15", endDate="2003-9-25", stations = stationsSelected) Repeat for the other years and then combine: ipW <- rbind(ipW2003,ipW2004,ipW2005)

Page 14: Analysis crop trials using climate data

Duration of T > 30 °C = 4.8 h

Maximum is assumed to be 2 h after solar noon.

Minimum is assumed to be at sunrise.

Thermal stress

Time

Tem

pera

ture

(°C)

Page 15: Analysis crop trials using climate data

Derive ecophysiological vars

?thermalStressDaily Run the example to see how this works. Then: TEMPSTRESS30 <- thermalStressSeasonal(30, ipW, trial, locs) PREC <- precipitationSeasonal(ipW, trial) RADIATION <- radiationSeasonal(ipW, trial, locs) trial <- cbind(trial, TEMPSTRESS30, PREC, RADIATION)

Page 16: Analysis crop trials using climate data

Do RDA on residuals

Instead of a normal PCA, we constrain the axes of the PCA with linear combinations of the ecophysiological variables. This type of constrained PCA is called redundancy analysis (RDA)

Page 17: Analysis crop trials using climate data

Do ANOVA

m <- lm(Yield ~ Variety + Location + Plant.m2, data=tr2005) G + GxE are left over, the rest is filtered out tr2005$Yield <- residuals(m) tr2005 <- tr2005[,c("Variety","Location","Yield")]

Page 18: Analysis crop trials using climate data

Make table ready for RDA

tr2005 <- melt(tr2005) tr2005 <- acast(tr2005, Location ~ Variety) env2005 <- trial[trial$Year == 2005, c("Location", "TEMPSTRESS30", "PRECSUM", "PRECCV", "RADIATION")] env2005 <- unique(env2005) rownames(env2005) <- env2005$Location env2005 <- env2005[,-1]

Page 19: Analysis crop trials using climate data

RDA

rda2005 <- rda(tr2005, env2005) summary(rda2005) plot(rda2005)

Page 20: Analysis crop trials using climate data

Putting GxE on map

It is possible to use the resulting RDA model to predict for any locations. The steps would be: 1. Interpolate weather variables for new

location 2. Derive ecophysiological variables 3. Predict yield value for this new location

(not taking into account additive environmental effect)

Page 21: Analysis crop trials using climate data

Final remarks

Trial data are often noisy – extracting the signal from the data is the objective Many environmental variables are difficult to measure, but can be taken to be “random” in the analysis Many statistical tools exist to link weather data to crop trial data.