Environmental analysis of crop trials - Van Etten

Post on 07-Jul-2015

629 views 0 download

description

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.

transcript

Environmental analysis of crop trialsusing weather data

Jacob van Etten

weatherData

This package helps us to:

1. Get data from weather stations

2. Interpolate weather data for any location

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

Get additional packages

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

library(maps)

library(vegan)

library(reshape)

Get the script

http://dl.dropbox.com/u/18619554/maizeCA.R

http://goo.gl/Y6h7m

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.

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)

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.

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)

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"))

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)

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.

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)

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

per

atu

re (

°C)

Derive ecophysiological vars

?thermalStressDailyRun 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)

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)

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")]

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]

RDA

rda2005 <- rda(tr2005, env2005)

summary(rda2005)

plot(rda2005)

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)

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.