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

Environmental analysis of crop trials - Van Etten

Embed Size (px)

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.

Citation preview

Page 1: Environmental analysis of crop trials - Van Etten

Environmental analysis of crop trialsusing weather data

Jacob van Etten

Page 2: Environmental analysis of crop trials - Van Etten

weatherData

This package helps us to:

1. Get data from weather stations

2. Interpolate weather data for any location

Page 3: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

Get additional packages

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

library(maps)

library(vegan)

library(reshape)

Page 5: Environmental analysis of crop trials - Van Etten

Get the script

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

http://goo.gl/Y6h7m

Page 6: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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)

Page 15: Environmental analysis of crop trials - Van Etten

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)

Page 16: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

RDA

rda2005 <- rda(tr2005, env2005)

summary(rda2005)

plot(rda2005)

Page 20: Environmental analysis of crop trials - Van Etten

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: Environmental analysis of crop trials - Van Etten

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.