Project

General

Profile

« Previous | Next » 

Revision d5665aab

Added by Benoit Parmentier about 12 years ago

Methods comp part7-task#491- residuals analyses using SNOTEL data, initial commit

View differences:

climate/research/oregon/interpolation/methods_comparison_assessment_part7.R
1
#####################################  METHODS COMPARISON part 7 ##########################################
2
#################################### Spatial Analysis: validation CAI-fusion  ############################################
3
#This script utilizes the R ojbects created during the interpolation phase.                       #
4
#We use the SNOTEL dataset and the 
5
#This scripts focuses on a detailed studay of differences in the predictions of CAI_kr and FUsion_Kr                              #
6
#AUTHOR: Benoit Parmentier                                                                        #
7
#DATE: 12/03/2012                                                                                 #
8
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#491 --                                  #
9
###################################################################################################
10

  
11
###Loading R library and packages                                                      
12
library(gtools)                                        # loading some useful tools such as mixedsort
13
library(mgcv)                                           # GAM package by Wood 2006 (version 2012)
14
library(sp)                                             # Spatial pacakge with class definition by Bivand et al. 2008
15
library(spdep)                                          # Spatial package with methods and spatial stat. by Bivand et al. 2012
16
library(rgdal)                                          # GDAL wrapper for R, spatial utilities (Keitt et al. 2012)
17
library(gstat)                                          # Kriging and co-kriging by Pebesma et al. 2004
18
library(automap)                                        # Automated Kriging based on gstat module by Hiemstra et al. 2008
19
library(spgwr)
20
library(gpclib)
21
library(maptools)
22
library(graphics)
23
library(parallel)                            # Urbanek S. and Ripley B., package for multi cores & parralel processing
24
library(raster)
25
library(rasterVis)
26
library(plotrix)   #Draw circle on graph
27
library(reshape)
28
library(RCurl)
29
######### Functions used in the script
30
#loading R objects that might have similar names
31

  
32
out_prefix<-"_method_comp7_12042012_"
33
dates_input<-c("20100103","20100901")
34
i=2
35
##### LOAD USEFUL DATA
36

  
37
#obj_list<-"list_obj_08262012.txt"                                  #Results of fusion from the run on ATLAS
38
path_wd<-"/home/parmentier/Data/IPLANT_project/methods_interpolation_comparison_10242012" #Jupiter LOCATION on Atlas for kriging                              #Jupiter Location on XANDERS
39
#path<-"/Users/benoitparmentier/Dropbox/Data/NCEAS/Oregon_covariates/"            #Local dropbox folder on Benoit's laptop
40
setwd(path_wd) 
41
path_data_cai<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_10242012_CAI"  #Change to constant
42
path_data_fus<-"/home/parmentier/Data/IPLANT_project/data_Oregon_stations_10242012_GAM"
43
#list files that contain model objects and ratingin-testing information for CAI and Fusion
44
obj_mod_fus_name<-"results_mod_obj__365d_GAM_fusion_const_all_lstd_11022012.RData"
45
obj_mod_cai_name<-"results_mod_obj__365d_GAM_CAI2_const_all_10312012.RData"
46

  
47
gam_fus<-load_obj(file.path(path_data_fus,obj_mod_fus_name))
48
gam_cai<-load_obj(file.path(path_data_cai,obj_mod_cai_name))  #This contains all the info
49
sampling_date_list<-gam_fus$sampling_obj$sampling_dat$date
50

  
51
### Projection for the current region
52
proj_str="+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m +no_defs";
53
#User defined output prefix
54

  
55
#CRS<-proj4string(ghcn)                       #Storing projection information (ellipsoid, datum,etc.)
56
lines<-read.table(paste(path,"/",inlistf,sep=""), sep="")                      #Column 1 contains the names of raster files
57
inlistvar<-lines[,1]
58
inlistvar<-paste(path,"/",as.character(inlistvar),sep="")
59
covar_names<-as.character(lines[,2])                                         #Column two contains short names for covaraites
60

  
61
s_raster<- stack(inlistvar)                                                  #Creating a stack of raster images from the list of variables.
62
layerNames(s_raster)<-covar_names                                            #Assigning names to the raster layers
63
projection(s_raster)<-proj_str
64

  
65

  
66
########## Load Snotel data 
67
infile_snotname<-"snot_OR_2010_sp2_methods_11012012_.shp" #load Snotel data
68
snot_OR_2010_sp<-readOGR(".",sub(".shp","",infile_snotname))
69
snot_OR_2010_sp$date<-as.character(snot_OR_2010_sp$date)
70
tmp_date<-snot_OR_2010_sp$date[1]
71
#date<-strptime(dates[i], "%Y%m%d")   # interpolation date being processed
72

  
73
#change format of dates...
74
#date_test<-strptime(tmp_date, "%e%m%y")   # interpolation date being processed
75
#date_test<-strptime(tmp_date, "%D")   # interpolation date being processed
76
#month<-strftime(date, "%m")          # current month of the date being processed
77
#LST_month<-paste("mm_",month,sep="") # name of LST month to be matched
78

  
79

  
80
#Load GHCN data used in modeling: training and validation site
81

  
82
### load specific date...and plot: make a function to extract the diff and prediction...
83
rast_diff_fc<-rast_fus_pred-rast_cai_pred
84
layerNames(rast_diff)<-paste("diff",date_selected,sep="_")
85

  
86

  
87
####COMPARE WITH LOCATION OF GHCN and SNOTEL NETWORK
88

  
89
X11(width=12,height=12)
90
plot(rast_diff_fc)
91
plot(snot_OR_2010_sp,pch=2,col="red",add=T)
92
plot(data_stat,add=T) #This is the GHCN network
93
legend("bottom",legend=c("SNOTEL", "GHCN"), 
94
       cex=0.8, col=c("red","black"),
95
       pch=c(2,1))
96
title(paste("SNOTEL and GHCN networks on ", date_selected, sep=""))
97
savePlot(paste("fig1a_map_SNOT_GHCN_network_diff_bckgd",date_selected,out_prefix,".png", sep=""), type="png")
98

  
99
plot(ELEV_SRTM)
100
plot(snot_OR_2010_sp,pch=2,col="red",add=T)
101
plot(data_stat,add=T)
102
legend("bottom",legend=c("SNOTEL", "GHCN"), 
103
       cex=0.8, col=c("red","black"),
104
       pch=c(2,1))
105
title(paste("SNOTEL and GHCN networks on ", date_selected, sep=""))
106
savePlot(paste("fig1b_map_SNOT_GHCN_network_elev_bckgd",date_selected,out_prefix,".png", sep=""), type="png")
107

  
108
## Select date from SNOT
109
#not_selected<-subset(snot_OR_2010_sp, date=="90110" )
110

  
111
dates<-c("20100103","20100901")
112
dates_snot<-c("10310","90110")
113
i=2
114

  
115
for(i in 1:length(dates)){
116
  
117
  date_selected<-dates[i]
118
  date_selected_snot<-as.integer(dates_snot[i])  #Change format of date at a later stage...
119
  snot_selected <-snot_OR_2010_sp[snot_OR_2010_sp$date==date_selected_snot,]
120
  #snot_selected<-na.omit(as.data.frame(snot_OR_2010_sp[snot_OR_2010_sp$date==90110,]))
121
  
122
  LC_stack<-stack(LC1,LC2,LC3,LC4,LC6,LC7)
123
  rast_pred3<-stack(rast_diff_fc,rast_pred2,LC_stack)
124
  layerNames(rast_pred3)<-c("diff_fc","fus","CAI","ELEV_SRTM","LC1","LC2","LC3","LC4","LC6","LC7")   #extract amount of veg...
125
  
126
  #extract info
127
  extract_snot<-extract(rast_pred3,snot_selected)  #
128
  snot_data_selected<-cbind(as.data.frame(snot_selected),extract_snot)
129
  snot_data_selected$res_f<-snot_data_selected$fus-snot_data_selected$tmax
130
  snot_data_selected$res_c<-snot_data_selected$CAI-snot_data_selected$tmax
131
  snot_data_selected<-(na.omit(as.data.frame(snot_data_selected)))
132
  
133
  #Plot predicted vs observed
134
  y_range<-range(c(data_vf$pred_mod7,snot_data_selected$fus),na.rm=T)
135
  x_range<-range(c(data_vf$dailyTmax,snot_data_selected$tmax),na.rm=T)
136
  plot(data_vf$pred_mod7,data_vf$dailyTmax, ylab="Observed daily tmax (C)", xlab="Predicted daily tmax (C)", 
137
       ylim=y_range,xlim=x_range)
138
  text(data_vf$pred_mod7,data_vf$dailyTmax,labels=data_vf$idx,pos=3)
139
  abline(0,1) #takes intercept at 0 and slope as 1 so display 1:1 ine
140
  grid(lwd=0.5,col="black")
141
  points(snot_data_selected$fus,snot_data_selected$tmax,pch=2,co="red")
142
  title(paste("Testing stations tmax fusion vs daily tmax",date_selected,sep=" "))
143
  savePlot(paste("fig2_testing_scatterplot_pred_fus_observed_SNOT_GHCN_",date_selected,out_prefix,".png", sep=""), type="png")
144
  
145
  ###### CAI
146
  y_range<-range(c(data_vc$pred_mod9,snot_data_selected$CAI),na.rm=T)
147
  x_range<-range(c(data_vc$dailyTmax,snot_data_selected$tmax),na.rm=T)
148
  plot(data_vc$pred_mod9,data_vc$dailyTmax, ylab="Observed daily tmax (C)", xlab="Predicted daily tmax (C)", 
149
       ylim=y_range,xlim=x_range)
150
  text(data_vc$pred_mod9,data_vc$dailyTmax,labels=data_vf$idx,pos=3)
151
  abline(0,1) #takes intercept at 0 and slope as 1 so display 1:1 ine
152
  grid(lwd=0.5,col="black")
153
  points(snot_data_selected$CAI,snot_data_selected$tmax,pch=2,co="red")
154
  title(paste("Testing stations tmax CAI vs daily tmax",date_selected,sep=" "))
155
  savePlot(paste("fig3_testing_scatterplot_pred_CAI_observed_SNOT_GHCN_",date_selected,out_prefix,".png", sep=""), type="png")
156
  
157
  ##### ELEV CAI
158
  y_range<-range(c(data_vc$dailyTmax,snot_data_selected$tmax),na.rm=T)
159
  y_range<-range(c(data_vc$pred_mod9,snot_data_selected$CAI),na.rm=T)
160
  x_range<-range(c(data_vc$ELEV_SRTM,snot_data_selected$ELEV_SRTM),na.rm=T)
161
  
162
  plot(data_vc$ELEV_SRTM,data_vc$pred_mod9,ylab="Observed daily tmax (C)", xlab="Predicted daily tmax (C)", 
163
       ylim=y_range,xlim=x_range)
164
  text(data_vc$ELEV_SRTM,data_vc$pred_mod9,labels=data_vc$idx,pos=3)
165
  abline(0,1) #takes intercept at 0 and slope as 1 so display 1:1 ine
166
  grid(lwd=0.5, col="black")
167
  points(snot_data_selected$ELEV_SRTM,snot_data_selected$CAI,pch=2,co="red")
168
  title(paste("Testing stations tmax CAI vs daily tmax",date_selected,sep=" "))
169
  savePlot(paste("fig4_testing_scatterplot_pred_CAI_observed_SNOT_GHCN_",date_selected,out_prefix,".png", sep=""), type="png")
170
  
171
  ##### ELEV CAI
172
  y_range<-range(c(data_vc$dailyTmax,snot_data_selected$tmax),na.rm=T)
173
  #y_range<-range(c(data_vc$pred_mod9,snot_data_selected$CAI),na.rm=T)
174
  x_range<-range(c(data_vc$ELEV_SRTM,snot_data_selected$ELEV_SRTM),na.rm=T)
175
  
176
  plot(data_vc$ELEV_SRTM,data_vc$dailyTmax,ylab="Observed daily tmax (C)", xlab="Elevation (m)", 
177
       ylim=y_range,xlim=x_range)
178
  text(data_vc$ELEV_SRTM,data_vc$dailyTmax,labels=data_vc$idx,pos=3)
179
  abline(0,1) #takes intercept at 0 and slope as 1 so display 1:1 ine
180
  grid(lwd=0.5, col="black")
181
  points(snot_data_selected$ELEV_SRTM,snot_data_selected$tmax,pch=2,co="red")
182
  title(paste("Testing stations tmax CAI vs daily tmax",date_selected,sep=" "))
183
  savePlot(paste("fig4_testing_scatterplot_pred_CAI_observed_SNOT_GHCN_",date_selected,out_prefix,".png", sep=""), type="png")
184
  
185
  brks<-seq(0,100,10)
186
  lab_brks<-seq(1,10,1)
187
  lc1_rcstat<-cut(snot_data_selected$LC1,breaks=brks,labels=lab_brks,right=F)
188
  snot_data_selected$LC1_rec<-lc1_rcstat
189
  lc_rcstat<-cut(snot_data_selected$LC3,breaks=brks,labels=lab_brks,right=F)
190
  snot_data_selected$LC3_rec<-lc_rcstat
191
  lc_rcstat<-cut(snot_data_selected$LC2,breaks=brks,labels=lab_brks,right=F)
192
  snot_data_selected$LC2_rec<-lc_rcstat
193
  lc_rcstat<-cut(snot_data_selected$LC4,breaks=brks,labels=lab_brks,right=F)
194
  snot_data_selected$LC4_rec<-lc_rcstat
195
  lc_rcstat<-cut(snot_data_selected$LC6,breaks=brks,labels=lab_brks,right=F)
196
  snot_data_selected$LC6_rec<-lc_rcstat
197
  lc_rcstat<-cut(snot_data_selected$LC7,breaks=brks,labels=lab_brks,right=F)
198
  snot_data_selected$LC7_rec<-lc_rcstat
199
  
200
  tmp<-aggregate(diff_fc~LC1_rec,data=snot_data_selected,FUN=mean)
201
  plot(tmp, type="l")
202
  tmp<-aggregate(diff_fc~LC2_rec,data=snot_data_selected,FUN=mean)
203
  plot(tmp)
204
  tmp<-aggregate(diff_fc~LC3_rec,data=snot_data_selected,FUN=mean)
205
  plot(tmp)
206
  tmp<-aggregate(diff_fc~LC4_rec,data=snot_data_selected,FUN=mean)
207
  plot(tmp)
208
  tmp<-aggregate(diff_fc~LC6_rec,data=snot_data_selected,FUN=mean)
209
  plot(tmp)
210
  plot(snot_data_selected$LC2_rec,snot_data_selected$diff_fc)
211
  table(snot_data_selected$LC7_rec)
212
  scatterplot(diff_fc~LC1|LC1_rec)
213
  mod_diff_fc_LC2<-lm(diff_fc~LC_rec,data=snot_data_selected)
214
  lc_melt<-melt(snot_data_selected[c("diff_fc","LC1_rec","LC2_rec","LC3_rec","LC4_rec","LC6_rec")],
215
                measure=c("diff_fc"), 
216
                id=c("LC1_rec","LC2_rec","LC3_rec","LC4_rec","LC6_rec"),
217
                na.rm=F)
218
  lc_cast<-cast(lc_melt,value~variable,mean)
219
  tabf_resmod9_locs<-as.data.frame(tabf_cast[,,1])
220
  
221
  ### PLOT LAND COVER
222
  X11()
223
  plot(zones_stat$zones,zones_stat$LC1_forest,type="b",ylim=c(-4.5,4.5),
224
       ylab="difference between CAI and fusion",xlab="land cover percent class/10")
225
  lines(lab_brks,snot_data_selected,col="red",type="b")
226
  lines(zones_stat$zones,zones_stat[,4],col="blue",type="b")
227
  lines(zones_stat$zones,zones_stat[,5],col="darkgreen",type="b")
228
  lines(zones_stat$zones,zones_stat[,6],col="purple",type="b")
229
  legend("topleft",legend=c("LC1_forest", "LC2_shrub", "LC3_grass", "LC4_crop", "LC6_urban"), 
230
         cex=1.2, col=c("black","red","blue","darkgreen","purple"),
231
         lty=1)
232
  title(paste("Prediction tmax difference and land cover ",sep=""))
233
  
234
  savePlot(paste("fig6_diff_prediction_tmax_difference_land cover",date_selected,out_prefix,".png", sep=""), type="png")
235
  dev.off()
236
  snot_data_selected$LC2_rec<-lc2_rcstat
237
  
238
  ############ ACCURACY METRICS AND RESIDUALS ####
239
  #snot_data_selected<-
240
  calc_accuracy_metrics<-function(x,y){
241
    residuals<-x-y
242
    mae<-mean(abs(residuals),na.rm=T)
243
    rmse<-sqrt(mean((residuals)^2,na.rm=T))
244
    me<-mean(residuals,na.rm=T)
245
    #r2<-cor(x,y,na.rm=T)
246
    metrics_dat<-list(mae,rmse,me)
247
    names(metrics_dat)<-c("mae","rmse","me")
248
    return(metrics_dat)
249
  }
250
  
251
  #change to tmax when fixed problem...
252
  ac_metrics_fus<-calc_accuracy_metrics(snot_data_selected$tmax,snot_data_selected$fus) 
253
  ac_metrics_cai<-calc_accuracy_metrics(snot_data_selected$tmax,snot_data_selected$CAI) 
254
  
255
  #print(ac_metrics_fus,ac_metrics_cai)
256
  ac_metrics_fus
257
  ac_metrics_cai
258
  
259
  plot(snot_data_selected$E_SRTM,snot_data_selected$diff_fc)
260
  
261
  #DO MAE IN TERM OF ELEVATION CLASSES and LAND COVER CLASSES as well as diff...
262
  #DO diff IN TERM OF ELEVATION CLASSES as well as diff..
263
  
264
  brks<-c(0,500,1000,1500,2000,2500,4000)
265
  lab_brks<-1:6
266
  elev_rcstat<-cut(snot_data_selected$ELEV_SRTM,breaks=brks,labels=lab_brks,right=F)
267
  snot_data_selected$elev_rec<-elev_rcstat
268
  y_range<-range(c(snot_data_selected$diff_fc))
269
  x_range<-range(c(elev_rcstat))
270
  plot(elev_rcstat,snot_data_selected$diff_fc, ylab="diff_fc", xlab="ELEV_SRTM (m) ", 
271
       ylim=y_range, xlim=x_range)
272
  #text(elev_rcstat,diff_cf,labels=data_vf$idx,pos=3)
273
  grid(lwd=0.5,col="black")
274
  title(paste("SNOT stations diff f vs Elevation",date_selected,sep=" "))
275
  
276
  brks<-c(0,500,1000,1500,2000,2500,4000)
277
  lab_brks<-1:6
278
  elev_rcstat<-cut(snot_data_selected$E_SRTM,breaks=brks,labels=lab_brks,right=F)
279
  
280
  y_range<-range(c(snot_data_selected$res_f),na.rm=T)
281
  x_range<-range(c(elev_rcstat))
282
  plot(elev_rcstat,snot_data_selected$res_f, ylab="res_f", xlab="ELEV_SRTM (m) ", 
283
       ylim=y_range, xlim=x_range)
284
  #text(elev_rcstat,diff_cf,labels=data_vf$idx,pos=3)
285
  grid(lwd=0.5,col="black")
286
  title(paste("SNOT stations residuals fusion vs Elevation",date_selected,sep=" "))
287
  
288
  brks<-c(0,500,1000,1500,2000,2500,4000)
289
  lab_brks<-1:6
290
  elev_rcstat<-cut(snot_data_selected$ELEV_SRTM,breaks=brks,labels=lab_brks,right=F)
291
  snot_data_selected$elev_rec<-elev_rcstat
292
  y_range<-range(c(snot_data_selected$res_c),na.rm=T)
293
  x_range<-range(c(elev_rcstat))
294
  plot(elev_rcstat,snot_data_selected$res_c, ylab="res_c", xlab="ELEV_SRTM (m) ", 
295
       ylim=y_range, xlim=x_range)
296
  #text(elev_rcstat,diff_cf,labels=data_vf$idx,pos=3)
297
  grid(lwd=0.5,col="black")
298
  title(paste("SNOT stations residuals CAI vs Elevation",date_selected,sep=" "))
299
  
300
  #ADD BOTH
301
  plot(elev_rcstat,snot_data_selected$res_c, ylab="res_c", xlab="ELEV_SRTM (m) ", 
302
       ylim=y_range, xlim=x_range)
303
  
304
  #CORRELATION BETWEEN RESIDUALS FUS and CAI
305
  
306
  y_range<-range(c(snot_data_selected$res_f,snot_data_selected$res_c),na.rm=T)
307
  x_range<-range(c(snot_data_selected$res_c,snot_data_selected$res_f),na.rm=T)
308
  plot(snot_data_selected$res_f,snot_data_selected$res_c, ylab="res_c", xlab="res_f ", 
309
       ylim=y_range, xlim=x_range)
310
  abline(0,1)
311
  #
312
  
313
  #CORRELATION BETWEEN PREDICTION FUS and CAI
314
  
315
  y_range<-range(c(snot_data_selected$fus),na.rm=T)
316
  x_range<-range(c(snot_data_selected$CAI),na.rm=T)
317
  plot(snot_data_selected$fus,snot_data_selected$CAI, ylab="CAI", xlab="FUS", 
318
       ylim=y_range, xlim=x_range)
319
  ####
320
  mae<-function(residuals){
321
    mean(abs(residuals),na.rm=T)
322
  }
323
  
324
  mean_diff_fc<-aggregate(diff_fc~elev_rec,data=snot_data_selected,mean)
325
  mean_mae_c<-aggregate(res_c~elev_rec,data=snot_data_selected,mae)
326
  mean_mae_f<-aggregate(res_c~elev_rec,data=snot_data_selected,mae)
327
  plot(mean_fus,type="o")
328
  plot(as.integer(as.character(mean_fus$elev_rec)),mean_fus$diff_fc,type="b")
329
  plot(as.integer(as.character(mean_fus$elev_rec)),mean_fus$diff_fc,type="b")
330
  hist(snot_data_selected$E_SRTM)
331
  hist(data_vf$ELEV_SRTM)
332
  
333
  diffelev_mod<-lm(diff_fc~elev_rec,data=snot_data_selected)
334
  summary(diffelev_mod)
335
  diffelev_mod<-lm(res_c~elev_rec,data=snot_data_selected)
336
  summary(diffelev_mod)
337
  diffelev_mod$fit
338
  table(snot_data_selected$elev_rec) #Number of observation per class
339
  max(snot_data_selected$E_STRM)
340
  
341
  avl<-c(0,10,1,10,20,2,20,30,3,30,40,4,40,50,5,50,60,6,60,70,7,70,80,8,80,90,9,90,100,10)#Note that category 1 does not include 0!!
342
  rclmat<-matrix(avl,ncol=3,byrow=TRUE)
343
  
344
  
345
  #### DO THIS FOR IMAGE STACK...DIFF and LAND COVER...
346
  dat_stack<-stack(rast_diff,rast_fus_pred,rast_cai_pred, ELEV_SRTM)
347
  dat_analysis<-as(dat_stack,"SpatialGridDataFrame")
348
  names(dat_analysis)<-c("diff_fc","pred_fus","pred_cai","E_SRTM")
349
  brks<-c(0,500,1000,1500,2000,2500,4000)
350
  lab_brks<-1:6
351
  elev_rcstat<-cut(dat_analysis$E_SRTM,breaks=brks,labels=lab_brks,right=F)
352
  dat_analysis$elev_rec<-elev_rcstat
353
  
354
  spplot(dat_analysis,"elev_rec")
355
  spplot(dat_analysis,"diff_fc")
356
  mean_diff_fc<-aggregate(diff_fc~elev_rec,data=dat_analysis,mean)
357
  table(dat_analysis$elev_rec) #Number of observation per class
358
  
359
  diffelev_mod<-lm(diff_fc~elev_rec,data=dat_analysis)
360
  summary(diffelev_mod)
361
  mean_rec6_val<-0.65993+(-8.56327)
362
  mean_diff_fc
363
  
364
  brks<-c(0,500,1000,1500,2000,2500,4000)
365
  lab_brks<-1:6
366
  elev_rcstat<-cut(data_vf$ELEV_SRTM,breaks=brks,labels=lab_brks,right=F)
367
  y_range<-range(c(diff_fc))
368
  x_range<-range(c(elev_rcstat))
369
  plot(elev_rcstat,diff_fc, ylab="diff_cf", xlab="ELEV_SRTM (m) ", 
370
       ylim=y_range, xlim=x_range)
371
  text(elev_rcstat,diff_cf,labels=data_vf$idx,pos=3)
372
  grid(lwd=0.5,col="black")
373
  title(paste("Testing stations residuals fusion vs Elevation",date_selected,sep=" "))
374
  
375
  # Combine both training and testing
376
  pred_fus<-c(data_vf$pred_mod7,data_sf$pred_mod7)
377
  pred_cai<-c(data_vc$pred_mod9,data_sc$pred_mod9)
378
  elev_station<-c(data_vf$ELEV_SRTM,data_sf$ELEV_SRTM)
379
  diff_fc<-pred_fus-pred_cai
380
  
381
  elev_rcstat<-cut(elev_station,breaks=brks,labels=lab_brks,right=F)
382
  y_range<-range(diff_fc)
383
  x_range<-range(elev_station)
384
  plot(elev_station,diff_fc, ylab="diff_fc", xlab="ELEV_SRTM (m) ", 
385
       ylim=y_range, xlim=x_range)
386
  text(elev_rcstat,diff_fc,labels=data_vf$idx,pos=3)
387
  grid(lwd=0.5,col="black")
388
  title(paste("Testing stations residuals fusion vs Elevation",date_selected,sep=" "))
389
  
390
  #USING BOTH validation and training
391
} 

Also available in: Unified diff